babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377
  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. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. /**
  409. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. private static OperatorPriority;
  1197. private static Stack;
  1198. static postfixToInfix(postfix: string[]): string;
  1199. static infixToPostfix(infix: string): string[];
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1203. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1204. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1205. /** @hidden */
  1206. export class ShaderCodeTestNode extends ShaderCodeNode {
  1207. testExpression: ShaderDefineExpression;
  1208. isValid(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1214. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1226. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1237. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1238. /** @hidden */
  1239. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1240. leftOperand: ShaderDefineExpression;
  1241. rightOperand: ShaderDefineExpression;
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1248. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1249. /** @hidden */
  1250. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1251. define: string;
  1252. operand: string;
  1253. testValue: string;
  1254. constructor(define: string, operand: string, testValue: string);
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Offline/IOfflineProvider" {
  1261. /**
  1262. * Class used to enable access to offline support
  1263. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1264. */
  1265. export interface IOfflineProvider {
  1266. /**
  1267. * Gets a boolean indicating if scene must be saved in the database
  1268. */
  1269. enableSceneOffline: boolean;
  1270. /**
  1271. * Gets a boolean indicating if textures must be saved in the database
  1272. */
  1273. enableTexturesOffline: boolean;
  1274. /**
  1275. * Open the offline support and make it available
  1276. * @param successCallback defines the callback to call on success
  1277. * @param errorCallback defines the callback to call on error
  1278. */
  1279. open(successCallback: () => void, errorCallback: () => void): void;
  1280. /**
  1281. * Loads an image from the offline support
  1282. * @param url defines the url to load from
  1283. * @param image defines the target DOM image
  1284. */
  1285. loadImage(url: string, image: HTMLImageElement): void;
  1286. /**
  1287. * Loads a file from offline support
  1288. * @param url defines the URL to load from
  1289. * @param sceneLoaded defines a callback to call on success
  1290. * @param progressCallBack defines a callback to call when progress changed
  1291. * @param errorCallback defines a callback to call on error
  1292. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1293. */
  1294. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1295. }
  1296. }
  1297. declare module "babylonjs/Misc/filesInputStore" {
  1298. /**
  1299. * Class used to help managing file picking and drag'n'drop
  1300. * File Storage
  1301. */
  1302. export class FilesInputStore {
  1303. /**
  1304. * List of files ready to be loaded
  1305. */
  1306. static FilesToLoad: {
  1307. [key: string]: File;
  1308. };
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/retryStrategy" {
  1312. import { WebRequest } from "babylonjs/Misc/webRequest";
  1313. /**
  1314. * Class used to define a retry strategy when error happens while loading assets
  1315. */
  1316. export class RetryStrategy {
  1317. /**
  1318. * Function used to defines an exponential back off strategy
  1319. * @param maxRetries defines the maximum number of retries (3 by default)
  1320. * @param baseInterval defines the interval between retries
  1321. * @returns the strategy function to use
  1322. */
  1323. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/baseError" {
  1327. /**
  1328. * @ignore
  1329. * Application error to support additional information when loading a file
  1330. */
  1331. export abstract class BaseError extends Error {
  1332. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1333. }
  1334. }
  1335. declare module "babylonjs/Misc/fileTools" {
  1336. import { WebRequest } from "babylonjs/Misc/webRequest";
  1337. import { Nullable } from "babylonjs/types";
  1338. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1339. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1340. import { BaseError } from "babylonjs/Misc/baseError";
  1341. /** @ignore */
  1342. export class LoadFileError extends BaseError {
  1343. request?: WebRequest;
  1344. file?: File;
  1345. /**
  1346. * Creates a new LoadFileError
  1347. * @param message defines the message of the error
  1348. * @param request defines the optional web request
  1349. * @param file defines the optional file
  1350. */
  1351. constructor(message: string, object?: WebRequest | File);
  1352. }
  1353. /** @ignore */
  1354. export class RequestFileError extends BaseError {
  1355. request: WebRequest;
  1356. /**
  1357. * Creates a new LoadFileError
  1358. * @param message defines the message of the error
  1359. * @param request defines the optional web request
  1360. */
  1361. constructor(message: string, request: WebRequest);
  1362. }
  1363. /** @ignore */
  1364. export class ReadFileError extends BaseError {
  1365. file: File;
  1366. /**
  1367. * Creates a new ReadFileError
  1368. * @param message defines the message of the error
  1369. * @param file defines the optional file
  1370. */
  1371. constructor(message: string, file: File);
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export class FileTools {
  1377. /**
  1378. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1379. */
  1380. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1381. /**
  1382. * Gets or sets the base URL to use to load assets
  1383. */
  1384. static BaseUrl: string;
  1385. /**
  1386. * Default behaviour for cors in the application.
  1387. * It can be a string if the expected behavior is identical in the entire app.
  1388. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1389. */
  1390. static CorsBehavior: string | ((url: string | string[]) => string);
  1391. /**
  1392. * Gets or sets a function used to pre-process url before using them to load assets
  1393. */
  1394. static PreprocessUrl: (url: string) => string;
  1395. /**
  1396. * Removes unwanted characters from an url
  1397. * @param url defines the url to clean
  1398. * @returns the cleaned url
  1399. */
  1400. private static _CleanUrl;
  1401. /**
  1402. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1403. * @param url define the url we are trying
  1404. * @param element define the dom element where to configure the cors policy
  1405. */
  1406. static SetCorsBehavior(url: string | string[], element: {
  1407. crossOrigin: string | null;
  1408. }): void;
  1409. /**
  1410. * Loads an image as an HTMLImageElement.
  1411. * @param input url string, ArrayBuffer, or Blob to load
  1412. * @param onLoad callback called when the image successfully loads
  1413. * @param onError callback called when the image fails to load
  1414. * @param offlineProvider offline provider for caching
  1415. * @param mimeType optional mime type
  1416. * @returns the HTMLImageElement of the loaded image
  1417. */
  1418. 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>;
  1419. /**
  1420. * Reads a file from a File object
  1421. * @param file defines the file to load
  1422. * @param onSuccess defines the callback to call when data is loaded
  1423. * @param onProgress defines the callback to call during loading process
  1424. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1425. * @param onError defines the callback to call when an error occurs
  1426. * @returns a file request object
  1427. */
  1428. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1429. /**
  1430. * Loads a file from a url
  1431. * @param url url to load
  1432. * @param onSuccess callback called when the file successfully loads
  1433. * @param onProgress callback called while file is loading (if the server supports this mode)
  1434. * @param offlineProvider defines the offline provider for caching
  1435. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1436. * @param onError callback called when the file fails to load
  1437. * @returns a file request object
  1438. */
  1439. 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;
  1440. /**
  1441. * Loads a file
  1442. * @param url url to load
  1443. * @param onSuccess callback called when the file successfully loads
  1444. * @param onProgress callback called while file is loading (if the server supports this mode)
  1445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1446. * @param onError callback called when the file fails to load
  1447. * @param onOpened callback called when the web request is opened
  1448. * @returns a file request object
  1449. */
  1450. 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;
  1451. /**
  1452. * Checks if the loaded document was accessed via `file:`-Protocol.
  1453. * @returns boolean
  1454. */
  1455. static IsFileURL(): boolean;
  1456. }
  1457. }
  1458. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1459. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1460. import { WebRequest } from "babylonjs/Misc/webRequest";
  1461. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1462. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1463. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1464. /** @hidden */
  1465. export class ShaderProcessor {
  1466. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1467. private static _ProcessPrecision;
  1468. private static _ExtractOperation;
  1469. private static _BuildSubExpression;
  1470. private static _BuildExpression;
  1471. private static _MoveCursorWithinIf;
  1472. private static _MoveCursor;
  1473. private static _EvaluatePreProcessors;
  1474. private static _PreparePreProcessors;
  1475. private static _ProcessShaderConversion;
  1476. private static _ProcessIncludes;
  1477. /**
  1478. * Loads a file from a url
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param offlineProvider defines the offline provider for caching
  1483. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1484. * @param onError callback called when the file fails to load
  1485. * @returns a file request object
  1486. * @hidden
  1487. */
  1488. 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;
  1489. }
  1490. }
  1491. declare module "babylonjs/Maths/math.like" {
  1492. import { float, int, DeepImmutable } from "babylonjs/types";
  1493. /**
  1494. * @hidden
  1495. */
  1496. export interface IColor4Like {
  1497. r: float;
  1498. g: float;
  1499. b: float;
  1500. a: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IColor3Like {
  1506. r: float;
  1507. g: float;
  1508. b: float;
  1509. }
  1510. /**
  1511. * @hidden
  1512. */
  1513. export interface IVector4Like {
  1514. x: float;
  1515. y: float;
  1516. z: float;
  1517. w: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector3Like {
  1523. x: float;
  1524. y: float;
  1525. z: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IVector2Like {
  1531. x: float;
  1532. y: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IMatrixLike {
  1538. toArray(): DeepImmutable<Float32Array>;
  1539. updateFlag: int;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IViewportLike {
  1545. x: float;
  1546. y: float;
  1547. width: float;
  1548. height: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IPlaneLike {
  1554. normal: IVector3Like;
  1555. d: float;
  1556. normalize(): void;
  1557. }
  1558. }
  1559. declare module "babylonjs/Materials/iEffectFallbacks" {
  1560. import { Effect } from "babylonjs/Materials/effect";
  1561. /**
  1562. * Interface used to define common properties for effect fallbacks
  1563. */
  1564. export interface IEffectFallbacks {
  1565. /**
  1566. * Removes the defines that should be removed when falling back.
  1567. * @param currentDefines defines the current define statements for the shader.
  1568. * @param effect defines the current effect we try to compile
  1569. * @returns The resulting defines with defines of the current rank removed.
  1570. */
  1571. reduce(currentDefines: string, effect: Effect): string;
  1572. /**
  1573. * Removes the fallback from the bound mesh.
  1574. */
  1575. unBindMesh(): void;
  1576. /**
  1577. * Checks to see if more fallbacks are still availible.
  1578. */
  1579. hasMoreFallbacks: boolean;
  1580. }
  1581. }
  1582. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1583. /**
  1584. * Class used to evalaute queries containing `and` and `or` operators
  1585. */
  1586. export class AndOrNotEvaluator {
  1587. /**
  1588. * Evaluate a query
  1589. * @param query defines the query to evaluate
  1590. * @param evaluateCallback defines the callback used to filter result
  1591. * @returns true if the query matches
  1592. */
  1593. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1594. private static _HandleParenthesisContent;
  1595. private static _SimplifyNegation;
  1596. }
  1597. }
  1598. declare module "babylonjs/Misc/tags" {
  1599. /**
  1600. * Class used to store custom tags
  1601. */
  1602. export class Tags {
  1603. /**
  1604. * Adds support for tags on the given object
  1605. * @param obj defines the object to use
  1606. */
  1607. static EnableFor(obj: any): void;
  1608. /**
  1609. * Removes tags support
  1610. * @param obj defines the object to use
  1611. */
  1612. static DisableFor(obj: any): void;
  1613. /**
  1614. * Gets a boolean indicating if the given object has tags
  1615. * @param obj defines the object to use
  1616. * @returns a boolean
  1617. */
  1618. static HasTags(obj: any): boolean;
  1619. /**
  1620. * Gets the tags available on a given object
  1621. * @param obj defines the object to use
  1622. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1623. * @returns the tags
  1624. */
  1625. static GetTags(obj: any, asString?: boolean): any;
  1626. /**
  1627. * Adds tags to an object
  1628. * @param obj defines the object to use
  1629. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1630. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1631. */
  1632. static AddTagsTo(obj: any, tagsString: string): void;
  1633. /**
  1634. * @hidden
  1635. */
  1636. static _AddTagTo(obj: any, tag: string): void;
  1637. /**
  1638. * Removes specific tags from a specific object
  1639. * @param obj defines the object to use
  1640. * @param tagsString defines the tags to remove
  1641. */
  1642. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1643. /**
  1644. * @hidden
  1645. */
  1646. static _RemoveTagFrom(obj: any, tag: string): void;
  1647. /**
  1648. * Defines if tags hosted on an object match a given query
  1649. * @param obj defines the object to use
  1650. * @param tagsQuery defines the tag query
  1651. * @returns a boolean
  1652. */
  1653. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1654. }
  1655. }
  1656. declare module "babylonjs/Maths/math.scalar" {
  1657. /**
  1658. * Scalar computation library
  1659. */
  1660. export class Scalar {
  1661. /**
  1662. * Two pi constants convenient for computation.
  1663. */
  1664. static TwoPi: number;
  1665. /**
  1666. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. * @param a number
  1668. * @param b number
  1669. * @param epsilon (default = 1.401298E-45)
  1670. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1671. */
  1672. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1673. /**
  1674. * Returns a string : the upper case translation of the number i to hexadecimal.
  1675. * @param i number
  1676. * @returns the upper case translation of the number i to hexadecimal.
  1677. */
  1678. static ToHex(i: number): string;
  1679. /**
  1680. * Returns -1 if value is negative and +1 is value is positive.
  1681. * @param value the value
  1682. * @returns the value itself if it's equal to zero.
  1683. */
  1684. static Sign(value: number): number;
  1685. /**
  1686. * Returns the value itself if it's between min and max.
  1687. * Returns min if the value is lower than min.
  1688. * Returns max if the value is greater than max.
  1689. * @param value the value to clmap
  1690. * @param min the min value to clamp to (default: 0)
  1691. * @param max the max value to clamp to (default: 1)
  1692. * @returns the clamped value
  1693. */
  1694. static Clamp(value: number, min?: number, max?: number): number;
  1695. /**
  1696. * the log2 of value.
  1697. * @param value the value to compute log2 of
  1698. * @returns the log2 of value.
  1699. */
  1700. static Log2(value: number): number;
  1701. /**
  1702. * Loops the value, so that it is never larger than length and never smaller than 0.
  1703. *
  1704. * This is similar to the modulo operator but it works with floating point numbers.
  1705. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1706. * With t = 5 and length = 2.5, the result would be 0.0.
  1707. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1708. * @param value the value
  1709. * @param length the length
  1710. * @returns the looped value
  1711. */
  1712. static Repeat(value: number, length: number): number;
  1713. /**
  1714. * Normalize the value between 0.0 and 1.0 using min and max values
  1715. * @param value value to normalize
  1716. * @param min max to normalize between
  1717. * @param max min to normalize between
  1718. * @returns the normalized value
  1719. */
  1720. static Normalize(value: number, min: number, max: number): number;
  1721. /**
  1722. * Denormalize the value from 0.0 and 1.0 using min and max values
  1723. * @param normalized value to denormalize
  1724. * @param min max to denormalize between
  1725. * @param max min to denormalize between
  1726. * @returns the denormalized value
  1727. */
  1728. static Denormalize(normalized: number, min: number, max: number): number;
  1729. /**
  1730. * Calculates the shortest difference between two given angles given in degrees.
  1731. * @param current current angle in degrees
  1732. * @param target target angle in degrees
  1733. * @returns the delta
  1734. */
  1735. static DeltaAngle(current: number, target: number): number;
  1736. /**
  1737. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1738. * @param tx value
  1739. * @param length length
  1740. * @returns The returned value will move back and forth between 0 and length
  1741. */
  1742. static PingPong(tx: number, length: number): number;
  1743. /**
  1744. * Interpolates between min and max with smoothing at the limits.
  1745. *
  1746. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1747. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1748. * @param from from
  1749. * @param to to
  1750. * @param tx value
  1751. * @returns the smooth stepped value
  1752. */
  1753. static SmoothStep(from: number, to: number, tx: number): number;
  1754. /**
  1755. * Moves a value current towards target.
  1756. *
  1757. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1758. * Negative values of maxDelta pushes the value away from target.
  1759. * @param current current value
  1760. * @param target target value
  1761. * @param maxDelta max distance to move
  1762. * @returns resulting value
  1763. */
  1764. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1765. /**
  1766. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1767. *
  1768. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1769. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1770. * @param current current value
  1771. * @param target target value
  1772. * @param maxDelta max distance to move
  1773. * @returns resulting angle
  1774. */
  1775. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1776. /**
  1777. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1778. * @param start start value
  1779. * @param end target value
  1780. * @param amount amount to lerp between
  1781. * @returns the lerped value
  1782. */
  1783. static Lerp(start: number, end: number, amount: number): number;
  1784. /**
  1785. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1786. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1787. * @param start start value
  1788. * @param end target value
  1789. * @param amount amount to lerp between
  1790. * @returns the lerped value
  1791. */
  1792. static LerpAngle(start: number, end: number, amount: number): number;
  1793. /**
  1794. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1795. * @param a start value
  1796. * @param b target value
  1797. * @param value value between a and b
  1798. * @returns the inverseLerp value
  1799. */
  1800. static InverseLerp(a: number, b: number, value: number): number;
  1801. /**
  1802. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1803. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1804. * @param value1 spline value
  1805. * @param tangent1 spline value
  1806. * @param value2 spline value
  1807. * @param tangent2 spline value
  1808. * @param amount input value
  1809. * @returns hermite result
  1810. */
  1811. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1812. /**
  1813. * Returns a random float number between and min and max values
  1814. * @param min min value of random
  1815. * @param max max value of random
  1816. * @returns random value
  1817. */
  1818. static RandomRange(min: number, max: number): number;
  1819. /**
  1820. * This function returns percentage of a number in a given range.
  1821. *
  1822. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1823. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1824. * @param number to convert to percentage
  1825. * @param min min range
  1826. * @param max max range
  1827. * @returns the percentage
  1828. */
  1829. static RangeToPercent(number: number, min: number, max: number): number;
  1830. /**
  1831. * This function returns number that corresponds to the percentage in a given range.
  1832. *
  1833. * PercentToRange(0.34,0,100) will return 34.
  1834. * @param percent to convert to number
  1835. * @param min min range
  1836. * @param max max range
  1837. * @returns the number
  1838. */
  1839. static PercentToRange(percent: number, min: number, max: number): number;
  1840. /**
  1841. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1842. * @param angle The angle to normalize in radian.
  1843. * @return The converted angle.
  1844. */
  1845. static NormalizeRadians(angle: number): number;
  1846. }
  1847. }
  1848. declare module "babylonjs/Maths/math.constants" {
  1849. /**
  1850. * Constant used to convert a value to gamma space
  1851. * @ignorenaming
  1852. */
  1853. export const ToGammaSpace: number;
  1854. /**
  1855. * Constant used to convert a value to linear space
  1856. * @ignorenaming
  1857. */
  1858. export const ToLinearSpace = 2.2;
  1859. /**
  1860. * Constant used to define the minimal number value in Babylon.js
  1861. * @ignorenaming
  1862. */
  1863. let Epsilon: number;
  1864. export { Epsilon };
  1865. }
  1866. declare module "babylonjs/Maths/math.viewport" {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module "babylonjs/Misc/arrayTools" {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module "babylonjs/Maths/math.vector" {
  1932. import { Viewport } from "babylonjs/Maths/math.viewport";
  1933. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1934. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1935. /**
  1936. * Class representing a vector containing 2 coordinates
  1937. */
  1938. export class Vector2 {
  1939. /** defines the first coordinate */
  1940. x: number;
  1941. /** defines the second coordinate */
  1942. y: number;
  1943. /**
  1944. * Creates a new Vector2 from the given x and y coordinates
  1945. * @param x defines the first coordinate
  1946. * @param y defines the second coordinate
  1947. */
  1948. constructor(
  1949. /** defines the first coordinate */
  1950. x?: number,
  1951. /** defines the second coordinate */
  1952. y?: number);
  1953. /**
  1954. * Gets a string with the Vector2 coordinates
  1955. * @returns a string with the Vector2 coordinates
  1956. */
  1957. toString(): string;
  1958. /**
  1959. * Gets class name
  1960. * @returns the string "Vector2"
  1961. */
  1962. getClassName(): string;
  1963. /**
  1964. * Gets current vector hash code
  1965. * @returns the Vector2 hash code as a number
  1966. */
  1967. getHashCode(): number;
  1968. /**
  1969. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1970. * @param array defines the source array
  1971. * @param index defines the offset in source array
  1972. * @returns the current Vector2
  1973. */
  1974. toArray(array: FloatArray, index?: number): Vector2;
  1975. /**
  1976. * Copy the current vector to an array
  1977. * @returns a new array with 2 elements: the Vector2 coordinates.
  1978. */
  1979. asArray(): number[];
  1980. /**
  1981. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1982. * @param source defines the source Vector2
  1983. * @returns the current updated Vector2
  1984. */
  1985. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Sets the Vector2 coordinates with the given floats
  1988. * @param x defines the first coordinate
  1989. * @param y defines the second coordinate
  1990. * @returns the current updated Vector2
  1991. */
  1992. copyFromFloats(x: number, y: number): Vector2;
  1993. /**
  1994. * Sets the Vector2 coordinates with the given floats
  1995. * @param x defines the first coordinate
  1996. * @param y defines the second coordinate
  1997. * @returns the current updated Vector2
  1998. */
  1999. set(x: number, y: number): Vector2;
  2000. /**
  2001. * Add another vector with the current one
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2004. */
  2005. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @param result defines the target vector
  2010. * @returns the unmodified current Vector2
  2011. */
  2012. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2013. /**
  2014. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns the current updated Vector2
  2017. */
  2018. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns a new Vector2
  2023. */
  2024. addVector3(otherVector: Vector3): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2027. * @param otherVector defines the other vector
  2028. * @returns a new Vector2
  2029. */
  2030. subtract(otherVector: Vector2): Vector2;
  2031. /**
  2032. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2033. * @param otherVector defines the other vector
  2034. * @param result defines the target vector
  2035. * @returns the unmodified current Vector2
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2038. /**
  2039. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @returns the current updated Vector2
  2042. */
  2043. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2044. /**
  2045. * Multiplies in place the current Vector2 coordinates by the given ones
  2046. * @param otherVector defines the other vector
  2047. * @returns the current updated Vector2
  2048. */
  2049. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2050. /**
  2051. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2052. * @param otherVector defines the other vector
  2053. * @returns a new Vector2
  2054. */
  2055. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2058. * @param otherVector defines the other vector
  2059. * @param result defines the target vector
  2060. * @returns the unmodified current Vector2
  2061. */
  2062. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2063. /**
  2064. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. * @returns a new Vector2
  2068. */
  2069. multiplyByFloats(x: number, y: number): Vector2;
  2070. /**
  2071. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2072. * @param otherVector defines the other vector
  2073. * @returns a new Vector2
  2074. */
  2075. divide(otherVector: Vector2): Vector2;
  2076. /**
  2077. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2078. * @param otherVector defines the other vector
  2079. * @param result defines the target vector
  2080. * @returns the unmodified current Vector2
  2081. */
  2082. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2083. /**
  2084. * Divides the current Vector2 coordinates by the given ones
  2085. * @param otherVector defines the other vector
  2086. * @returns the current updated Vector2
  2087. */
  2088. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2089. /**
  2090. * Gets a new Vector2 with current Vector2 negated coordinates
  2091. * @returns a new Vector2
  2092. */
  2093. negate(): Vector2;
  2094. /**
  2095. * Negate this vector in place
  2096. * @returns this
  2097. */
  2098. negateInPlace(): Vector2;
  2099. /**
  2100. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2101. * @param result defines the Vector3 object where to store the result
  2102. * @returns the current Vector2
  2103. */
  2104. negateToRef(result: Vector2): Vector2;
  2105. /**
  2106. * Multiply the Vector2 coordinates by scale
  2107. * @param scale defines the scaling factor
  2108. * @returns the current updated Vector2
  2109. */
  2110. scaleInPlace(scale: number): Vector2;
  2111. /**
  2112. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2113. * @param scale defines the scaling factor
  2114. * @returns a new Vector2
  2115. */
  2116. scale(scale: number): Vector2;
  2117. /**
  2118. * Scale the current Vector2 values by a factor to a given Vector2
  2119. * @param scale defines the scale factor
  2120. * @param result defines the Vector2 object where to store the result
  2121. * @returns the unmodified current Vector2
  2122. */
  2123. scaleToRef(scale: number, result: Vector2): Vector2;
  2124. /**
  2125. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2126. * @param scale defines the scale factor
  2127. * @param result defines the Vector2 object where to store the result
  2128. * @returns the unmodified current Vector2
  2129. */
  2130. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2131. /**
  2132. * Gets a boolean if two vectors are equals
  2133. * @param otherVector defines the other vector
  2134. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2135. */
  2136. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2137. /**
  2138. * Gets a boolean if two vectors are equals (using an epsilon value)
  2139. * @param otherVector defines the other vector
  2140. * @param epsilon defines the minimal distance to consider equality
  2141. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2142. */
  2143. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2144. /**
  2145. * Gets a new Vector2 from current Vector2 floored values
  2146. * @returns a new Vector2
  2147. */
  2148. floor(): Vector2;
  2149. /**
  2150. * Gets a new Vector2 from current Vector2 floored values
  2151. * @returns a new Vector2
  2152. */
  2153. fract(): Vector2;
  2154. /**
  2155. * Gets the length of the vector
  2156. * @returns the vector length (float)
  2157. */
  2158. length(): number;
  2159. /**
  2160. * Gets the vector squared length
  2161. * @returns the vector squared length (float)
  2162. */
  2163. lengthSquared(): number;
  2164. /**
  2165. * Normalize the vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. normalize(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 copied from the Vector2
  2171. * @returns a new Vector2
  2172. */
  2173. clone(): Vector2;
  2174. /**
  2175. * Gets a new Vector2(0, 0)
  2176. * @returns a new Vector2
  2177. */
  2178. static Zero(): Vector2;
  2179. /**
  2180. * Gets a new Vector2(1, 1)
  2181. * @returns a new Vector2
  2182. */
  2183. static One(): Vector2;
  2184. /**
  2185. * Gets a new Vector2 set from the given index element of the given array
  2186. * @param array defines the data source
  2187. * @param offset defines the offset in the data source
  2188. * @returns a new Vector2
  2189. */
  2190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2191. /**
  2192. * Sets "result" from the given index element of the given array
  2193. * @param array defines the data source
  2194. * @param offset defines the offset in the data source
  2195. * @param result defines the target vector
  2196. */
  2197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2198. /**
  2199. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2200. * @param value1 defines 1st point of control
  2201. * @param value2 defines 2nd point of control
  2202. * @param value3 defines 3rd point of control
  2203. * @param value4 defines 4th point of control
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * 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".
  2210. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2211. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2212. * @param value defines the value to clamp
  2213. * @param min defines the lower limit
  2214. * @param max defines the upper limit
  2215. * @returns a new Vector2
  2216. */
  2217. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2218. /**
  2219. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2220. * @param value1 defines the 1st control point
  2221. * @param tangent1 defines the outgoing tangent
  2222. * @param value2 defines the 2nd control point
  2223. * @param tangent2 defines the incoming tangent
  2224. * @param amount defines the interpolation factor
  2225. * @returns a new Vector2
  2226. */
  2227. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2230. * @param start defines the start vector
  2231. * @param end defines the end vector
  2232. * @param amount defines the interpolation factor
  2233. * @returns a new Vector2
  2234. */
  2235. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2236. /**
  2237. * Gets the dot product of the vector "left" and the vector "right"
  2238. * @param left defines first vector
  2239. * @param right defines second vector
  2240. * @returns the dot product (float)
  2241. */
  2242. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2243. /**
  2244. * Returns a new Vector2 equal to the normalized given vector
  2245. * @param vector defines the vector to normalize
  2246. * @returns a new Vector2
  2247. */
  2248. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2251. * @param left defines 1st vector
  2252. * @param right defines 2nd vector
  2253. * @returns a new Vector2
  2254. */
  2255. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2256. /**
  2257. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2258. * @param left defines 1st vector
  2259. * @param right defines 2nd vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2265. * @param vector defines the vector to transform
  2266. * @param transformation defines the matrix to apply
  2267. * @returns a new Vector2
  2268. */
  2269. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2270. /**
  2271. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2272. * @param vector defines the vector to transform
  2273. * @param transformation defines the matrix to apply
  2274. * @param result defines the target vector
  2275. */
  2276. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2277. /**
  2278. * Determines if a given vector is included in a triangle
  2279. * @param p defines the vector to test
  2280. * @param p0 defines 1st triangle point
  2281. * @param p1 defines 2nd triangle point
  2282. * @param p2 defines 3rd triangle point
  2283. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2284. */
  2285. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2286. /**
  2287. * Gets the distance between the vectors "value1" and "value2"
  2288. * @param value1 defines first vector
  2289. * @param value2 defines second vector
  2290. * @returns the distance between vectors
  2291. */
  2292. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2293. /**
  2294. * Returns the squared distance between the vectors "value1" and "value2"
  2295. * @param value1 defines first vector
  2296. * @param value2 defines second vector
  2297. * @returns the squared distance between vectors
  2298. */
  2299. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2300. /**
  2301. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2302. * @param value1 defines first vector
  2303. * @param value2 defines second vector
  2304. * @returns a new Vector2
  2305. */
  2306. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2307. /**
  2308. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2309. * @param p defines the middle point
  2310. * @param segA defines one point of the segment
  2311. * @param segB defines the other point of the segment
  2312. * @returns the shortest distance
  2313. */
  2314. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2315. }
  2316. /**
  2317. * Class used to store (x,y,z) vector representation
  2318. * A Vector3 is the main object used in 3D geometry
  2319. * It can represent etiher the coordinates of a point the space, either a direction
  2320. * Reminder: js uses a left handed forward facing system
  2321. */
  2322. export class Vector3 {
  2323. /**
  2324. * Defines the first coordinates (on X axis)
  2325. */
  2326. x: number;
  2327. /**
  2328. * Defines the second coordinates (on Y axis)
  2329. */
  2330. y: number;
  2331. /**
  2332. * Defines the third coordinates (on Z axis)
  2333. */
  2334. z: number;
  2335. private static _UpReadOnly;
  2336. private static _ZeroReadOnly;
  2337. /**
  2338. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2339. * @param x defines the first coordinates (on X axis)
  2340. * @param y defines the second coordinates (on Y axis)
  2341. * @param z defines the third coordinates (on Z axis)
  2342. */
  2343. constructor(
  2344. /**
  2345. * Defines the first coordinates (on X axis)
  2346. */
  2347. x?: number,
  2348. /**
  2349. * Defines the second coordinates (on Y axis)
  2350. */
  2351. y?: number,
  2352. /**
  2353. * Defines the third coordinates (on Z axis)
  2354. */
  2355. z?: number);
  2356. /**
  2357. * Creates a string representation of the Vector3
  2358. * @returns a string with the Vector3 coordinates.
  2359. */
  2360. toString(): string;
  2361. /**
  2362. * Gets the class name
  2363. * @returns the string "Vector3"
  2364. */
  2365. getClassName(): string;
  2366. /**
  2367. * Creates the Vector3 hash code
  2368. * @returns a number which tends to be unique between Vector3 instances
  2369. */
  2370. getHashCode(): number;
  2371. /**
  2372. * Creates an array containing three elements : the coordinates of the Vector3
  2373. * @returns a new array of numbers
  2374. */
  2375. asArray(): number[];
  2376. /**
  2377. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2378. * @param array defines the destination array
  2379. * @param index defines the offset in the destination array
  2380. * @returns the current Vector3
  2381. */
  2382. toArray(array: FloatArray, index?: number): Vector3;
  2383. /**
  2384. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2385. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2386. */
  2387. toQuaternion(): Quaternion;
  2388. /**
  2389. * Adds the given vector to the current Vector3
  2390. * @param otherVector defines the second operand
  2391. * @returns the current updated Vector3
  2392. */
  2393. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Adds the given coordinates to the current Vector3
  2396. * @param x defines the x coordinate of the operand
  2397. * @param y defines the y coordinate of the operand
  2398. * @param z defines the z coordinate of the operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2402. /**
  2403. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Subtract the given vector from the current Vector3
  2417. * @param otherVector defines the second operand
  2418. * @returns the current updated Vector3
  2419. */
  2420. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2421. /**
  2422. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2423. * @param otherVector defines the second operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2427. /**
  2428. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2429. * @param otherVector defines the second operand
  2430. * @param result defines the Vector3 object where to store the result
  2431. * @returns the current Vector3
  2432. */
  2433. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2434. /**
  2435. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2436. * @param x defines the x coordinate of the operand
  2437. * @param y defines the y coordinate of the operand
  2438. * @param z defines the z coordinate of the operand
  2439. * @returns the resulting Vector3
  2440. */
  2441. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2442. /**
  2443. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2444. * @param x defines the x coordinate of the operand
  2445. * @param y defines the y coordinate of the operand
  2446. * @param z defines the z coordinate of the operand
  2447. * @param result defines the Vector3 object where to store the result
  2448. * @returns the current Vector3
  2449. */
  2450. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2451. /**
  2452. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2453. * @returns a new Vector3
  2454. */
  2455. negate(): Vector3;
  2456. /**
  2457. * Negate this vector in place
  2458. * @returns this
  2459. */
  2460. negateInPlace(): Vector3;
  2461. /**
  2462. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2463. * @param result defines the Vector3 object where to store the result
  2464. * @returns the current Vector3
  2465. */
  2466. negateToRef(result: Vector3): Vector3;
  2467. /**
  2468. * Multiplies the Vector3 coordinates by the float "scale"
  2469. * @param scale defines the multiplier factor
  2470. * @returns the current updated Vector3
  2471. */
  2472. scaleInPlace(scale: number): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2475. * @param scale defines the multiplier factor
  2476. * @returns a new Vector3
  2477. */
  2478. scale(scale: number): Vector3;
  2479. /**
  2480. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2481. * @param scale defines the multiplier factor
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the current Vector3
  2484. */
  2485. scaleToRef(scale: number, result: Vector3): Vector3;
  2486. /**
  2487. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2488. * @param scale defines the scale factor
  2489. * @param result defines the Vector3 object where to store the result
  2490. * @returns the unmodified current Vector3
  2491. */
  2492. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2493. /**
  2494. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2495. * @param otherVector defines the second operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2499. /**
  2500. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2501. * @param otherVector defines the second operand
  2502. * @param epsilon defines the minimal distance to define values as equals
  2503. * @returns true if both vectors are distant less than epsilon
  2504. */
  2505. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2506. /**
  2507. * Returns true if the current Vector3 coordinates equals the given floats
  2508. * @param x defines the x coordinate of the operand
  2509. * @param y defines the y coordinate of the operand
  2510. * @param z defines the z coordinate of the operand
  2511. * @returns true if both vectors are equals
  2512. */
  2513. equalsToFloats(x: number, y: number, z: number): boolean;
  2514. /**
  2515. * Multiplies the current Vector3 coordinates by the given ones
  2516. * @param otherVector defines the second operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2520. /**
  2521. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2535. * @param x defines the x coordinate of the operand
  2536. * @param y defines the y coordinate of the operand
  2537. * @param z defines the z coordinate of the operand
  2538. * @returns the new Vector3
  2539. */
  2540. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2541. /**
  2542. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2543. * @param otherVector defines the second operand
  2544. * @returns the new Vector3
  2545. */
  2546. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2549. * @param otherVector defines the second operand
  2550. * @param result defines the Vector3 object where to store the result
  2551. * @returns the current Vector3
  2552. */
  2553. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2554. /**
  2555. * Divides the current Vector3 coordinates by the given ones.
  2556. * @param otherVector defines the second operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. divideInPlace(otherVector: Vector3): Vector3;
  2560. /**
  2561. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2562. * @param other defines the second operand
  2563. * @returns the current updated Vector3
  2564. */
  2565. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2568. * @param other defines the second operand
  2569. * @returns the current updated Vector3
  2570. */
  2571. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2572. /**
  2573. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2574. * @param x defines the x coordinate of the operand
  2575. * @param y defines the y coordinate of the operand
  2576. * @param z defines the z coordinate of the operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2580. /**
  2581. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2590. * Check if is non uniform within a certain amount of decimal places to account for this
  2591. * @param epsilon the amount the values can differ
  2592. * @returns if the the vector is non uniform to a certain number of decimal places
  2593. */
  2594. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2595. /**
  2596. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2597. */
  2598. get isNonUniform(): boolean;
  2599. /**
  2600. * Gets a new Vector3 from current Vector3 floored values
  2601. * @returns a new Vector3
  2602. */
  2603. floor(): Vector3;
  2604. /**
  2605. * Gets a new Vector3 from current Vector3 floored values
  2606. * @returns a new Vector3
  2607. */
  2608. fract(): Vector3;
  2609. /**
  2610. * Gets the length of the Vector3
  2611. * @returns the length of the Vector3
  2612. */
  2613. length(): number;
  2614. /**
  2615. * Gets the squared length of the Vector3
  2616. * @returns squared length of the Vector3
  2617. */
  2618. lengthSquared(): number;
  2619. /**
  2620. * Normalize the current Vector3.
  2621. * Please note that this is an in place operation.
  2622. * @returns the current updated Vector3
  2623. */
  2624. normalize(): Vector3;
  2625. /**
  2626. * Reorders the x y z properties of the vector in place
  2627. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2628. * @returns the current updated vector
  2629. */
  2630. reorderInPlace(order: string): this;
  2631. /**
  2632. * Rotates the vector around 0,0,0 by a quaternion
  2633. * @param quaternion the rotation quaternion
  2634. * @param result vector to store the result
  2635. * @returns the resulting vector
  2636. */
  2637. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2638. /**
  2639. * Rotates a vector around a given point
  2640. * @param quaternion the rotation quaternion
  2641. * @param point the point to rotate around
  2642. * @param result vector to store the result
  2643. * @returns the resulting vector
  2644. */
  2645. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2646. /**
  2647. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2648. * The cross product is then orthogonal to both current and "other"
  2649. * @param other defines the right operand
  2650. * @returns the cross product
  2651. */
  2652. cross(other: Vector3): Vector3;
  2653. /**
  2654. * Normalize the current Vector3 with the given input length.
  2655. * Please note that this is an in place operation.
  2656. * @param len the length of the vector
  2657. * @returns the current updated Vector3
  2658. */
  2659. normalizeFromLength(len: number): Vector3;
  2660. /**
  2661. * Normalize the current Vector3 to a new vector
  2662. * @returns the new Vector3
  2663. */
  2664. normalizeToNew(): Vector3;
  2665. /**
  2666. * Normalize the current Vector3 to the reference
  2667. * @param reference define the Vector3 to update
  2668. * @returns the updated Vector3
  2669. */
  2670. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2671. /**
  2672. * Creates a new Vector3 copied from the current Vector3
  2673. * @returns the new Vector3
  2674. */
  2675. clone(): Vector3;
  2676. /**
  2677. * Copies the given vector coordinates to the current Vector3 ones
  2678. * @param source defines the source Vector3
  2679. * @returns the current updated Vector3
  2680. */
  2681. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2682. /**
  2683. * Copies the given floats to the current Vector3 coordinates
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. copyFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Copies the given floats to the current Vector3 coordinates
  2692. * @param x defines the x coordinate of the operand
  2693. * @param y defines the y coordinate of the operand
  2694. * @param z defines the z coordinate of the operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. set(x: number, y: number, z: number): Vector3;
  2698. /**
  2699. * Copies the given float to the current Vector3 coordinates
  2700. * @param v defines the x, y and z coordinates of the operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. setAll(v: number): Vector3;
  2704. /**
  2705. * Get the clip factor between two vectors
  2706. * @param vector0 defines the first operand
  2707. * @param vector1 defines the second operand
  2708. * @param axis defines the axis to use
  2709. * @param size defines the size along the axis
  2710. * @returns the clip factor
  2711. */
  2712. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2713. /**
  2714. * Get angle between two vectors
  2715. * @param vector0 angle between vector0 and vector1
  2716. * @param vector1 angle between vector0 and vector1
  2717. * @param normal direction of the normal
  2718. * @return the angle between vector0 and vector1
  2719. */
  2720. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2721. /**
  2722. * Returns a new Vector3 set from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @returns the new Vector3
  2726. */
  2727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @returns the new Vector3
  2733. * @deprecated Please use FromArray instead.
  2734. */
  2735. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2736. /**
  2737. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2738. * @param array defines the source array
  2739. * @param offset defines the offset in the source array
  2740. * @param result defines the Vector3 where to store the result
  2741. */
  2742. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2743. /**
  2744. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2745. * @param array defines the source array
  2746. * @param offset defines the offset in the source array
  2747. * @param result defines the Vector3 where to store the result
  2748. * @deprecated Please use FromArrayToRef instead.
  2749. */
  2750. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2751. /**
  2752. * Sets the given vector "result" with the given floats.
  2753. * @param x defines the x coordinate of the source
  2754. * @param y defines the y coordinate of the source
  2755. * @param z defines the z coordinate of the source
  2756. * @param result defines the Vector3 where to store the result
  2757. */
  2758. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2761. * @returns a new empty Vector3
  2762. */
  2763. static Zero(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2766. * @returns a new unit Vector3
  2767. */
  2768. static One(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2771. * @returns a new up Vector3
  2772. */
  2773. static Up(): Vector3;
  2774. /**
  2775. * Gets a up Vector3 that must not be updated
  2776. */
  2777. static get UpReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Gets a zero Vector3 that must not be updated
  2780. */
  2781. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2782. /**
  2783. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2784. * @returns a new down Vector3
  2785. */
  2786. static Down(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2789. * @returns a new forward Vector3
  2790. */
  2791. static Forward(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2794. * @returns a new forward Vector3
  2795. */
  2796. static Backward(): Vector3;
  2797. /**
  2798. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2799. * @returns a new right Vector3
  2800. */
  2801. static Right(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2804. * @returns a new left Vector3
  2805. */
  2806. static Left(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2809. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2810. * @param vector defines the Vector3 to transform
  2811. * @param transformation defines the transformation matrix
  2812. * @returns the transformed Vector3
  2813. */
  2814. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2815. /**
  2816. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2817. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2818. * @param vector defines the Vector3 to transform
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2825. * This method computes tranformed coordinates only, not transformed direction vectors
  2826. * @param x define the x coordinate of the source vector
  2827. * @param y define the y coordinate of the source vector
  2828. * @param z define the z coordinate of the source vector
  2829. * @param transformation defines the transformation matrix
  2830. * @param result defines the Vector3 where to store the result
  2831. */
  2832. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2833. /**
  2834. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2835. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2836. * @param vector defines the Vector3 to transform
  2837. * @param transformation defines the transformation matrix
  2838. * @returns the new Vector3
  2839. */
  2840. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2841. /**
  2842. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2843. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2844. * @param vector defines the Vector3 to transform
  2845. * @param transformation defines the transformation matrix
  2846. * @param result defines the Vector3 where to store the result
  2847. */
  2848. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2849. /**
  2850. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2851. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2852. * @param x define the x coordinate of the source vector
  2853. * @param y define the y coordinate of the source vector
  2854. * @param z define the z coordinate of the source vector
  2855. * @param transformation defines the transformation matrix
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2861. * @param value1 defines the first control point
  2862. * @param value2 defines the second control point
  2863. * @param value3 defines the third control point
  2864. * @param value4 defines the fourth control point
  2865. * @param amount defines the amount on the spline to use
  2866. * @returns the new Vector3
  2867. */
  2868. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * 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"
  2871. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2872. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2873. * @param value defines the current value
  2874. * @param min defines the lower range value
  2875. * @param max defines the upper range value
  2876. * @returns the new Vector3
  2877. */
  2878. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2879. /**
  2880. * 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"
  2881. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2882. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2883. * @param value defines the current value
  2884. * @param min defines the lower range value
  2885. * @param max defines the upper range value
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2889. /**
  2890. * Checks if a given vector is inside a specific range
  2891. * @param v defines the vector to test
  2892. * @param min defines the minimum range
  2893. * @param max defines the maximum range
  2894. */
  2895. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2896. /**
  2897. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2898. * @param value1 defines the first control point
  2899. * @param tangent1 defines the first tangent vector
  2900. * @param value2 defines the second control point
  2901. * @param tangent2 defines the second tangent vector
  2902. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2903. * @returns the new Vector3
  2904. */
  2905. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2906. /**
  2907. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2908. * @param start defines the start value
  2909. * @param end defines the end value
  2910. * @param amount max defines amount between both (between 0 and 1)
  2911. * @returns the new Vector3
  2912. */
  2913. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2916. * @param start defines the start value
  2917. * @param end defines the end value
  2918. * @param amount max defines amount between both (between 0 and 1)
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2922. /**
  2923. * Returns the dot product (float) between the vectors "left" and "right"
  2924. * @param left defines the left operand
  2925. * @param right defines the right operand
  2926. * @returns the dot product
  2927. */
  2928. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2929. /**
  2930. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2931. * The cross product is then orthogonal to both "left" and "right"
  2932. * @param left defines the left operand
  2933. * @param right defines the right operand
  2934. * @returns the cross product
  2935. */
  2936. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the cross product of "left" and "right"
  2939. * The cross product is then orthogonal to both "left" and "right"
  2940. * @param left defines the left operand
  2941. * @param right defines the right operand
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2945. /**
  2946. * Returns a new Vector3 as the normalization of the given vector
  2947. * @param vector defines the Vector3 to normalize
  2948. * @returns the new Vector3
  2949. */
  2950. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2951. /**
  2952. * Sets the given vector "result" with the normalization of the given first vector
  2953. * @param vector defines the Vector3 to normalize
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2957. /**
  2958. * Project a Vector3 onto screen space
  2959. * @param vector defines the Vector3 to project
  2960. * @param world defines the world matrix to use
  2961. * @param transform defines the transform (view x projection) matrix to use
  2962. * @param viewport defines the screen viewport to use
  2963. * @returns the new Vector3
  2964. */
  2965. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2966. /** @hidden */
  2967. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2968. /**
  2969. * Unproject from screen space to object space
  2970. * @param source defines the screen space Vector3 to use
  2971. * @param viewportWidth defines the current width of the viewport
  2972. * @param viewportHeight defines the current height of the viewport
  2973. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2974. * @param transform defines the transform (view x projection) matrix to use
  2975. * @returns the new Vector3
  2976. */
  2977. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2978. /**
  2979. * Unproject from screen space to object space
  2980. * @param source defines the screen space Vector3 to use
  2981. * @param viewportWidth defines the current width of the viewport
  2982. * @param viewportHeight defines the current height of the viewport
  2983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2984. * @param view defines the view matrix to use
  2985. * @param projection defines the projection matrix to use
  2986. * @returns the new Vector3
  2987. */
  2988. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Unproject from screen space to object space
  2991. * @param source defines the screen space Vector3 to use
  2992. * @param viewportWidth defines the current width of the viewport
  2993. * @param viewportHeight defines the current height of the viewport
  2994. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2995. * @param view defines the view matrix to use
  2996. * @param projection defines the projection matrix to use
  2997. * @param result defines the Vector3 where to store the result
  2998. */
  2999. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3000. /**
  3001. * Unproject from screen space to object space
  3002. * @param sourceX defines the screen space x coordinate to use
  3003. * @param sourceY defines the screen space y coordinate to use
  3004. * @param sourceZ defines the screen space z coordinate to use
  3005. * @param viewportWidth defines the current width of the viewport
  3006. * @param viewportHeight defines the current height of the viewport
  3007. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3008. * @param view defines the view matrix to use
  3009. * @param projection defines the projection matrix to use
  3010. * @param result defines the Vector3 where to store the result
  3011. */
  3012. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3013. /**
  3014. * Gets the minimal coordinate values between two Vector3
  3015. * @param left defines the first operand
  3016. * @param right defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Gets the maximal coordinate values between two Vector3
  3022. * @param left defines the first operand
  3023. * @param right defines the second operand
  3024. * @returns the new Vector3
  3025. */
  3026. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3027. /**
  3028. * Returns the distance between the vectors "value1" and "value2"
  3029. * @param value1 defines the first operand
  3030. * @param value2 defines the second operand
  3031. * @returns the distance
  3032. */
  3033. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3034. /**
  3035. * Returns the squared distance between the vectors "value1" and "value2"
  3036. * @param value1 defines the first operand
  3037. * @param value2 defines the second operand
  3038. * @returns the squared distance
  3039. */
  3040. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3041. /**
  3042. * Returns a new Vector3 located at the center between "value1" and "value2"
  3043. * @param value1 defines the first operand
  3044. * @param value2 defines the second operand
  3045. * @returns the new Vector3
  3046. */
  3047. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3050. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3051. * to something in order to rotate it from its local system to the given target system
  3052. * Note: axis1, axis2 and axis3 are normalized during this operation
  3053. * @param axis1 defines the first axis
  3054. * @param axis2 defines the second axis
  3055. * @param axis3 defines the third axis
  3056. * @returns a new Vector3
  3057. */
  3058. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3059. /**
  3060. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3061. * @param axis1 defines the first axis
  3062. * @param axis2 defines the second axis
  3063. * @param axis3 defines the third axis
  3064. * @param ref defines the Vector3 where to store the result
  3065. */
  3066. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3067. }
  3068. /**
  3069. * Vector4 class created for EulerAngle class conversion to Quaternion
  3070. */
  3071. export class Vector4 {
  3072. /** x value of the vector */
  3073. x: number;
  3074. /** y value of the vector */
  3075. y: number;
  3076. /** z value of the vector */
  3077. z: number;
  3078. /** w value of the vector */
  3079. w: number;
  3080. /**
  3081. * Creates a Vector4 object from the given floats.
  3082. * @param x x value of the vector
  3083. * @param y y value of the vector
  3084. * @param z z value of the vector
  3085. * @param w w value of the vector
  3086. */
  3087. constructor(
  3088. /** x value of the vector */
  3089. x: number,
  3090. /** y value of the vector */
  3091. y: number,
  3092. /** z value of the vector */
  3093. z: number,
  3094. /** w value of the vector */
  3095. w: number);
  3096. /**
  3097. * Returns the string with the Vector4 coordinates.
  3098. * @returns a string containing all the vector values
  3099. */
  3100. toString(): string;
  3101. /**
  3102. * Returns the string "Vector4".
  3103. * @returns "Vector4"
  3104. */
  3105. getClassName(): string;
  3106. /**
  3107. * Returns the Vector4 hash code.
  3108. * @returns a unique hash code
  3109. */
  3110. getHashCode(): number;
  3111. /**
  3112. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3113. * @returns the resulting array
  3114. */
  3115. asArray(): number[];
  3116. /**
  3117. * Populates the given array from the given index with the Vector4 coordinates.
  3118. * @param array array to populate
  3119. * @param index index of the array to start at (default: 0)
  3120. * @returns the Vector4.
  3121. */
  3122. toArray(array: FloatArray, index?: number): Vector4;
  3123. /**
  3124. * Adds the given vector to the current Vector4.
  3125. * @param otherVector the vector to add
  3126. * @returns the updated Vector4.
  3127. */
  3128. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3131. * @param otherVector the vector to add
  3132. * @returns the resulting vector
  3133. */
  3134. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3135. /**
  3136. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3137. * @param otherVector the vector to add
  3138. * @param result the vector to store the result
  3139. * @returns the current Vector4.
  3140. */
  3141. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3142. /**
  3143. * Subtract in place the given vector from the current Vector4.
  3144. * @param otherVector the vector to subtract
  3145. * @returns the updated Vector4.
  3146. */
  3147. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3148. /**
  3149. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3150. * @param otherVector the vector to add
  3151. * @returns the new vector with the result
  3152. */
  3153. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3154. /**
  3155. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3156. * @param otherVector the vector to subtract
  3157. * @param result the vector to store the result
  3158. * @returns the current Vector4.
  3159. */
  3160. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3161. /**
  3162. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3163. */
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. * @param x value to subtract
  3167. * @param y value to subtract
  3168. * @param z value to subtract
  3169. * @param w value to subtract
  3170. * @returns new vector containing the result
  3171. */
  3172. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3173. /**
  3174. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3175. * @param x value to subtract
  3176. * @param y value to subtract
  3177. * @param z value to subtract
  3178. * @param w value to subtract
  3179. * @param result the vector to store the result in
  3180. * @returns the current Vector4.
  3181. */
  3182. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3183. /**
  3184. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3185. * @returns a new vector with the negated values
  3186. */
  3187. negate(): Vector4;
  3188. /**
  3189. * Negate this vector in place
  3190. * @returns this
  3191. */
  3192. negateInPlace(): Vector4;
  3193. /**
  3194. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3195. * @param result defines the Vector3 object where to store the result
  3196. * @returns the current Vector4
  3197. */
  3198. negateToRef(result: Vector4): Vector4;
  3199. /**
  3200. * Multiplies the current Vector4 coordinates by scale (float).
  3201. * @param scale the number to scale with
  3202. * @returns the updated Vector4.
  3203. */
  3204. scaleInPlace(scale: number): Vector4;
  3205. /**
  3206. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3207. * @param scale the number to scale with
  3208. * @returns a new vector with the result
  3209. */
  3210. scale(scale: number): Vector4;
  3211. /**
  3212. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3213. * @param scale the number to scale with
  3214. * @param result a vector to store the result in
  3215. * @returns the current Vector4.
  3216. */
  3217. scaleToRef(scale: number, result: Vector4): Vector4;
  3218. /**
  3219. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3220. * @param scale defines the scale factor
  3221. * @param result defines the Vector4 object where to store the result
  3222. * @returns the unmodified current Vector4
  3223. */
  3224. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3225. /**
  3226. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3227. * @param otherVector the vector to compare against
  3228. * @returns true if they are equal
  3229. */
  3230. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3231. /**
  3232. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3233. * @param otherVector vector to compare against
  3234. * @param epsilon (Default: very small number)
  3235. * @returns true if they are equal
  3236. */
  3237. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3238. /**
  3239. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3240. * @param x x value to compare against
  3241. * @param y y value to compare against
  3242. * @param z z value to compare against
  3243. * @param w w value to compare against
  3244. * @returns true if equal
  3245. */
  3246. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3247. /**
  3248. * Multiplies in place the current Vector4 by the given one.
  3249. * @param otherVector vector to multiple with
  3250. * @returns the updated Vector4.
  3251. */
  3252. multiplyInPlace(otherVector: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3255. * @param otherVector vector to multiple with
  3256. * @returns resulting new vector
  3257. */
  3258. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3261. * @param otherVector vector to multiple with
  3262. * @param result vector to store the result
  3263. * @returns the current Vector4.
  3264. */
  3265. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3266. /**
  3267. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3268. * @param x x value multiply with
  3269. * @param y y value multiply with
  3270. * @param z z value multiply with
  3271. * @param w w value multiply with
  3272. * @returns resulting new vector
  3273. */
  3274. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3275. /**
  3276. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3277. * @param otherVector vector to devide with
  3278. * @returns resulting new vector
  3279. */
  3280. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3283. * @param otherVector vector to devide with
  3284. * @param result vector to store the result
  3285. * @returns the current Vector4.
  3286. */
  3287. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3288. /**
  3289. * Divides the current Vector3 coordinates by the given ones.
  3290. * @param otherVector vector to devide with
  3291. * @returns the updated Vector3.
  3292. */
  3293. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3296. * @param other defines the second operand
  3297. * @returns the current updated Vector4
  3298. */
  3299. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3302. * @param other defines the second operand
  3303. * @returns the current updated Vector4
  3304. */
  3305. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Gets a new Vector4 from current Vector4 floored values
  3308. * @returns a new Vector4
  3309. */
  3310. floor(): Vector4;
  3311. /**
  3312. * Gets a new Vector4 from current Vector3 floored values
  3313. * @returns a new Vector4
  3314. */
  3315. fract(): Vector4;
  3316. /**
  3317. * Returns the Vector4 length (float).
  3318. * @returns the length
  3319. */
  3320. length(): number;
  3321. /**
  3322. * Returns the Vector4 squared length (float).
  3323. * @returns the length squared
  3324. */
  3325. lengthSquared(): number;
  3326. /**
  3327. * Normalizes in place the Vector4.
  3328. * @returns the updated Vector4.
  3329. */
  3330. normalize(): Vector4;
  3331. /**
  3332. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3333. * @returns this converted to a new vector3
  3334. */
  3335. toVector3(): Vector3;
  3336. /**
  3337. * Returns a new Vector4 copied from the current one.
  3338. * @returns the new cloned vector
  3339. */
  3340. clone(): Vector4;
  3341. /**
  3342. * Updates the current Vector4 with the given one coordinates.
  3343. * @param source the source vector to copy from
  3344. * @returns the updated Vector4.
  3345. */
  3346. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3347. /**
  3348. * Updates the current Vector4 coordinates with the given floats.
  3349. * @param x float to copy from
  3350. * @param y float to copy from
  3351. * @param z float to copy from
  3352. * @param w float to copy from
  3353. * @returns the updated Vector4.
  3354. */
  3355. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3356. /**
  3357. * Updates the current Vector4 coordinates with the given floats.
  3358. * @param x float to set from
  3359. * @param y float to set from
  3360. * @param z float to set from
  3361. * @param w float to set from
  3362. * @returns the updated Vector4.
  3363. */
  3364. set(x: number, y: number, z: number, w: number): Vector4;
  3365. /**
  3366. * Copies the given float to the current Vector3 coordinates
  3367. * @param v defines the x, y, z and w coordinates of the operand
  3368. * @returns the current updated Vector3
  3369. */
  3370. setAll(v: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set from the starting index of the given array.
  3373. * @param array the array to pull values from
  3374. * @param offset the offset into the array to start at
  3375. * @returns the new vector
  3376. */
  3377. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3378. /**
  3379. * Updates the given vector "result" from the starting index of the given array.
  3380. * @param array the array to pull values from
  3381. * @param offset the offset into the array to start at
  3382. * @param result the vector to store the result in
  3383. */
  3384. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3385. /**
  3386. * Updates the given vector "result" from the starting index of the given Float32Array.
  3387. * @param array the array to pull values from
  3388. * @param offset the offset into the array to start at
  3389. * @param result the vector to store the result in
  3390. */
  3391. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3392. /**
  3393. * Updates the given vector "result" coordinates from the given floats.
  3394. * @param x float to set from
  3395. * @param y float to set from
  3396. * @param z float to set from
  3397. * @param w float to set from
  3398. * @param result the vector to the floats in
  3399. */
  3400. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3401. /**
  3402. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3403. * @returns the new vector
  3404. */
  3405. static Zero(): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3408. * @returns the new vector
  3409. */
  3410. static One(): Vector4;
  3411. /**
  3412. * Returns a new normalized Vector4 from the given one.
  3413. * @param vector the vector to normalize
  3414. * @returns the vector
  3415. */
  3416. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Updates the given vector "result" from the normalization of the given one.
  3419. * @param vector the vector to normalize
  3420. * @param result the vector to store the result in
  3421. */
  3422. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3423. /**
  3424. * Returns a vector with the minimum values from the left and right vectors
  3425. * @param left left vector to minimize
  3426. * @param right right vector to minimize
  3427. * @returns a new vector with the minimum of the left and right vector values
  3428. */
  3429. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a vector with the maximum values from the left and right vectors
  3432. * @param left left vector to maximize
  3433. * @param right right vector to maximize
  3434. * @returns a new vector with the maximum of the left and right vector values
  3435. */
  3436. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3437. /**
  3438. * Returns the distance (float) between the vectors "value1" and "value2".
  3439. * @param value1 value to calulate the distance between
  3440. * @param value2 value to calulate the distance between
  3441. * @return the distance between the two vectors
  3442. */
  3443. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3444. /**
  3445. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3446. * @param value1 value to calulate the distance between
  3447. * @param value2 value to calulate the distance between
  3448. * @return the distance between the two vectors squared
  3449. */
  3450. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3451. /**
  3452. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3453. * @param value1 value to calulate the center between
  3454. * @param value2 value to calulate the center between
  3455. * @return the center between the two vectors
  3456. */
  3457. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3460. * This methods computes transformed normalized direction vectors only.
  3461. * @param vector the vector to transform
  3462. * @param transformation the transformation matrix to apply
  3463. * @returns the new vector
  3464. */
  3465. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3466. /**
  3467. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3468. * This methods computes transformed normalized direction vectors only.
  3469. * @param vector the vector to transform
  3470. * @param transformation the transformation matrix to apply
  3471. * @param result the vector to store the result in
  3472. */
  3473. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3474. /**
  3475. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3476. * This methods computes transformed normalized direction vectors only.
  3477. * @param x value to transform
  3478. * @param y value to transform
  3479. * @param z value to transform
  3480. * @param w value to transform
  3481. * @param transformation the transformation matrix to apply
  3482. * @param result the vector to store the results in
  3483. */
  3484. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3485. /**
  3486. * Creates a new Vector4 from a Vector3
  3487. * @param source defines the source data
  3488. * @param w defines the 4th component (default is 0)
  3489. * @returns a new Vector4
  3490. */
  3491. static FromVector3(source: Vector3, w?: number): Vector4;
  3492. }
  3493. /**
  3494. * Class used to store quaternion data
  3495. * @see https://en.wikipedia.org/wiki/Quaternion
  3496. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3497. */
  3498. export class Quaternion {
  3499. /** defines the first component (0 by default) */
  3500. x: number;
  3501. /** defines the second component (0 by default) */
  3502. y: number;
  3503. /** defines the third component (0 by default) */
  3504. z: number;
  3505. /** defines the fourth component (1.0 by default) */
  3506. w: number;
  3507. /**
  3508. * Creates a new Quaternion from the given floats
  3509. * @param x defines the first component (0 by default)
  3510. * @param y defines the second component (0 by default)
  3511. * @param z defines the third component (0 by default)
  3512. * @param w defines the fourth component (1.0 by default)
  3513. */
  3514. constructor(
  3515. /** defines the first component (0 by default) */
  3516. x?: number,
  3517. /** defines the second component (0 by default) */
  3518. y?: number,
  3519. /** defines the third component (0 by default) */
  3520. z?: number,
  3521. /** defines the fourth component (1.0 by default) */
  3522. w?: number);
  3523. /**
  3524. * Gets a string representation for the current quaternion
  3525. * @returns a string with the Quaternion coordinates
  3526. */
  3527. toString(): string;
  3528. /**
  3529. * Gets the class name of the quaternion
  3530. * @returns the string "Quaternion"
  3531. */
  3532. getClassName(): string;
  3533. /**
  3534. * Gets a hash code for this quaternion
  3535. * @returns the quaternion hash code
  3536. */
  3537. getHashCode(): number;
  3538. /**
  3539. * Copy the quaternion to an array
  3540. * @returns a new array populated with 4 elements from the quaternion coordinates
  3541. */
  3542. asArray(): number[];
  3543. /**
  3544. * Check if two quaternions are equals
  3545. * @param otherQuaternion defines the second operand
  3546. * @return true if the current quaternion and the given one coordinates are strictly equals
  3547. */
  3548. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3549. /**
  3550. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3551. * @param otherQuaternion defines the other quaternion
  3552. * @param epsilon defines the minimal distance to consider equality
  3553. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3554. */
  3555. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3556. /**
  3557. * Clone the current quaternion
  3558. * @returns a new quaternion copied from the current one
  3559. */
  3560. clone(): Quaternion;
  3561. /**
  3562. * Copy a quaternion to the current one
  3563. * @param other defines the other quaternion
  3564. * @returns the updated current quaternion
  3565. */
  3566. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Updates the current quaternion with the given float coordinates
  3569. * @param x defines the x coordinate
  3570. * @param y defines the y coordinate
  3571. * @param z defines the z coordinate
  3572. * @param w defines the w coordinate
  3573. * @returns the updated current quaternion
  3574. */
  3575. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3576. /**
  3577. * Updates the current quaternion from the given float coordinates
  3578. * @param x defines the x coordinate
  3579. * @param y defines the y coordinate
  3580. * @param z defines the z coordinate
  3581. * @param w defines the w coordinate
  3582. * @returns the updated current quaternion
  3583. */
  3584. set(x: number, y: number, z: number, w: number): Quaternion;
  3585. /**
  3586. * Adds two quaternions
  3587. * @param other defines the second operand
  3588. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3589. */
  3590. add(other: DeepImmutable<Quaternion>): Quaternion;
  3591. /**
  3592. * Add a quaternion to the current one
  3593. * @param other defines the quaternion to add
  3594. * @returns the current quaternion
  3595. */
  3596. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3597. /**
  3598. * Subtract two quaternions
  3599. * @param other defines the second operand
  3600. * @returns a new quaternion as the subtraction result of the given one from the current one
  3601. */
  3602. subtract(other: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3607. */
  3608. scale(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies in place the current quaternion by a scale factor
  3618. * @param value defines the scale factor
  3619. * @returns the current modified quaternion
  3620. */
  3621. scaleInPlace(value: number): Quaternion;
  3622. /**
  3623. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3624. * @param scale defines the scale factor
  3625. * @param result defines the Quaternion object where to store the result
  3626. * @returns the unmodified current quaternion
  3627. */
  3628. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3629. /**
  3630. * Multiplies two quaternions
  3631. * @param q1 defines the second operand
  3632. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3633. */
  3634. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3637. * @param q1 defines the second operand
  3638. * @param result defines the target quaternion
  3639. * @returns the current quaternion
  3640. */
  3641. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3642. /**
  3643. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3644. * @param q1 defines the second operand
  3645. * @returns the currentupdated quaternion
  3646. */
  3647. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3648. /**
  3649. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3650. * @param ref defines the target quaternion
  3651. * @returns the current quaternion
  3652. */
  3653. conjugateToRef(ref: Quaternion): Quaternion;
  3654. /**
  3655. * Conjugates in place (1-q) the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. conjugateInPlace(): Quaternion;
  3659. /**
  3660. * Conjugates in place (1-q) the current quaternion
  3661. * @returns a new quaternion
  3662. */
  3663. conjugate(): Quaternion;
  3664. /**
  3665. * Gets length of current quaternion
  3666. * @returns the quaternion length (float)
  3667. */
  3668. length(): number;
  3669. /**
  3670. * Normalize in place the current quaternion
  3671. * @returns the current updated quaternion
  3672. */
  3673. normalize(): Quaternion;
  3674. /**
  3675. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3676. * @param order is a reserved parameter and is ignore for now
  3677. * @returns a new Vector3 containing the Euler angles
  3678. */
  3679. toEulerAngles(order?: string): Vector3;
  3680. /**
  3681. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3682. * @param result defines the vector which will be filled with the Euler angles
  3683. * @param order is a reserved parameter and is ignore for now
  3684. * @returns the current unchanged quaternion
  3685. */
  3686. toEulerAnglesToRef(result: Vector3): Quaternion;
  3687. /**
  3688. * Updates the given rotation matrix with the current quaternion values
  3689. * @param result defines the target matrix
  3690. * @returns the current unchanged quaternion
  3691. */
  3692. toRotationMatrix(result: Matrix): Quaternion;
  3693. /**
  3694. * Updates the current quaternion from the given rotation matrix values
  3695. * @param matrix defines the source matrix
  3696. * @returns the current updated quaternion
  3697. */
  3698. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3699. /**
  3700. * Creates a new quaternion from a rotation matrix
  3701. * @param matrix defines the source matrix
  3702. * @returns a new quaternion created from the given rotation matrix values
  3703. */
  3704. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3705. /**
  3706. * Updates the given quaternion with the given rotation matrix values
  3707. * @param matrix defines the source matrix
  3708. * @param result defines the target quaternion
  3709. */
  3710. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3711. /**
  3712. * Returns the dot product (float) between the quaternions "left" and "right"
  3713. * @param left defines the left operand
  3714. * @param right defines the right operand
  3715. * @returns the dot product
  3716. */
  3717. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3718. /**
  3719. * Checks if the two quaternions are close to each other
  3720. * @param quat0 defines the first quaternion to check
  3721. * @param quat1 defines the second quaternion to check
  3722. * @returns true if the two quaternions are close to each other
  3723. */
  3724. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3725. /**
  3726. * Creates an empty quaternion
  3727. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3728. */
  3729. static Zero(): Quaternion;
  3730. /**
  3731. * Inverse a given quaternion
  3732. * @param q defines the source quaternion
  3733. * @returns a new quaternion as the inverted current quaternion
  3734. */
  3735. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3736. /**
  3737. * Inverse a given quaternion
  3738. * @param q defines the source quaternion
  3739. * @param result the quaternion the result will be stored in
  3740. * @returns the result quaternion
  3741. */
  3742. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3743. /**
  3744. * Creates an identity quaternion
  3745. * @returns the identity quaternion
  3746. */
  3747. static Identity(): Quaternion;
  3748. /**
  3749. * Gets a boolean indicating if the given quaternion is identity
  3750. * @param quaternion defines the quaternion to check
  3751. * @returns true if the quaternion is identity
  3752. */
  3753. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3754. /**
  3755. * Creates a quaternion from a rotation around an axis
  3756. * @param axis defines the axis to use
  3757. * @param angle defines the angle to use
  3758. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3759. */
  3760. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3761. /**
  3762. * Creates a rotation around an axis and stores it into the given quaternion
  3763. * @param axis defines the axis to use
  3764. * @param angle defines the angle to use
  3765. * @param result defines the target quaternion
  3766. * @returns the target quaternion
  3767. */
  3768. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Creates a new quaternion from data stored into an array
  3771. * @param array defines the data source
  3772. * @param offset defines the offset in the source array where the data starts
  3773. * @returns a new quaternion
  3774. */
  3775. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3776. /**
  3777. * Updates the given quaternion "result" from the starting index of the given array.
  3778. * @param array the array to pull values from
  3779. * @param offset the offset into the array to start at
  3780. * @param result the quaternion to store the result in
  3781. */
  3782. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3783. /**
  3784. * Create a quaternion from Euler rotation angles
  3785. * @param x Pitch
  3786. * @param y Yaw
  3787. * @param z Roll
  3788. * @returns the new Quaternion
  3789. */
  3790. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3791. /**
  3792. * Updates a quaternion from Euler rotation angles
  3793. * @param x Pitch
  3794. * @param y Yaw
  3795. * @param z Roll
  3796. * @param result the quaternion to store the result
  3797. * @returns the updated quaternion
  3798. */
  3799. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3800. /**
  3801. * Create a quaternion from Euler rotation vector
  3802. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3803. * @returns the new Quaternion
  3804. */
  3805. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3806. /**
  3807. * Updates a quaternion from Euler rotation vector
  3808. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3809. * @param result the quaternion to store the result
  3810. * @returns the updated quaternion
  3811. */
  3812. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3813. /**
  3814. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3815. * @param yaw defines the rotation around Y axis
  3816. * @param pitch defines the rotation around X axis
  3817. * @param roll defines the rotation around Z axis
  3818. * @returns the new quaternion
  3819. */
  3820. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3821. /**
  3822. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3823. * @param yaw defines the rotation around Y axis
  3824. * @param pitch defines the rotation around X axis
  3825. * @param roll defines the rotation around Z axis
  3826. * @param result defines the target quaternion
  3827. */
  3828. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3829. /**
  3830. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3831. * @param alpha defines the rotation around first axis
  3832. * @param beta defines the rotation around second axis
  3833. * @param gamma defines the rotation around third axis
  3834. * @returns the new quaternion
  3835. */
  3836. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3837. /**
  3838. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3839. * @param alpha defines the rotation around first axis
  3840. * @param beta defines the rotation around second axis
  3841. * @param gamma defines the rotation around third axis
  3842. * @param result defines the target quaternion
  3843. */
  3844. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3845. /**
  3846. * 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)
  3847. * @param axis1 defines the first axis
  3848. * @param axis2 defines the second axis
  3849. * @param axis3 defines the third axis
  3850. * @returns the new quaternion
  3851. */
  3852. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3853. /**
  3854. * 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
  3855. * @param axis1 defines the first axis
  3856. * @param axis2 defines the second axis
  3857. * @param axis3 defines the third axis
  3858. * @param ref defines the target quaternion
  3859. */
  3860. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3861. /**
  3862. * Interpolates between two quaternions
  3863. * @param left defines first quaternion
  3864. * @param right defines second quaternion
  3865. * @param amount defines the gradient to use
  3866. * @returns the new interpolated quaternion
  3867. */
  3868. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3869. /**
  3870. * Interpolates between two quaternions and stores it into a target quaternion
  3871. * @param left defines first quaternion
  3872. * @param right defines second quaternion
  3873. * @param amount defines the gradient to use
  3874. * @param result defines the target quaternion
  3875. */
  3876. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3877. /**
  3878. * Interpolate between two quaternions using Hermite interpolation
  3879. * @param value1 defines first quaternion
  3880. * @param tangent1 defines the incoming tangent
  3881. * @param value2 defines second quaternion
  3882. * @param tangent2 defines the outgoing tangent
  3883. * @param amount defines the target quaternion
  3884. * @returns the new interpolated quaternion
  3885. */
  3886. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3887. }
  3888. /**
  3889. * Class used to store matrix data (4x4)
  3890. */
  3891. export class Matrix {
  3892. private static _updateFlagSeed;
  3893. private static _identityReadOnly;
  3894. private _isIdentity;
  3895. private _isIdentityDirty;
  3896. private _isIdentity3x2;
  3897. private _isIdentity3x2Dirty;
  3898. /**
  3899. * Gets the update flag of the matrix which is an unique number for the matrix.
  3900. * It will be incremented every time the matrix data change.
  3901. * You can use it to speed the comparison between two versions of the same matrix.
  3902. */
  3903. updateFlag: number;
  3904. private readonly _m;
  3905. /**
  3906. * Gets the internal data of the matrix
  3907. */
  3908. get m(): DeepImmutable<Float32Array>;
  3909. /** @hidden */
  3910. _markAsUpdated(): void;
  3911. /** @hidden */
  3912. private _updateIdentityStatus;
  3913. /**
  3914. * Creates an empty matrix (filled with zeros)
  3915. */
  3916. constructor();
  3917. /**
  3918. * Check if the current matrix is identity
  3919. * @returns true is the matrix is the identity matrix
  3920. */
  3921. isIdentity(): boolean;
  3922. /**
  3923. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3924. * @returns true is the matrix is the identity matrix
  3925. */
  3926. isIdentityAs3x2(): boolean;
  3927. /**
  3928. * Gets the determinant of the matrix
  3929. * @returns the matrix determinant
  3930. */
  3931. determinant(): number;
  3932. /**
  3933. * Returns the matrix as a Float32Array
  3934. * @returns the matrix underlying array
  3935. */
  3936. toArray(): DeepImmutable<Float32Array>;
  3937. /**
  3938. * Returns the matrix as a Float32Array
  3939. * @returns the matrix underlying array.
  3940. */
  3941. asArray(): DeepImmutable<Float32Array>;
  3942. /**
  3943. * Inverts the current matrix in place
  3944. * @returns the current inverted matrix
  3945. */
  3946. invert(): Matrix;
  3947. /**
  3948. * Sets all the matrix elements to zero
  3949. * @returns the current matrix
  3950. */
  3951. reset(): Matrix;
  3952. /**
  3953. * Adds the current matrix with a second one
  3954. * @param other defines the matrix to add
  3955. * @returns a new matrix as the addition of the current matrix and the given one
  3956. */
  3957. add(other: DeepImmutable<Matrix>): Matrix;
  3958. /**
  3959. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3960. * @param other defines the matrix to add
  3961. * @param result defines the target matrix
  3962. * @returns the current matrix
  3963. */
  3964. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3965. /**
  3966. * Adds in place the given matrix to the current matrix
  3967. * @param other defines the second operand
  3968. * @returns the current updated matrix
  3969. */
  3970. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3971. /**
  3972. * Sets the given matrix to the current inverted Matrix
  3973. * @param other defines the target matrix
  3974. * @returns the unmodified current matrix
  3975. */
  3976. invertToRef(other: Matrix): Matrix;
  3977. /**
  3978. * add a value at the specified position in the current Matrix
  3979. * @param index the index of the value within the matrix. between 0 and 15.
  3980. * @param value the value to be added
  3981. * @returns the current updated matrix
  3982. */
  3983. addAtIndex(index: number, value: number): Matrix;
  3984. /**
  3985. * mutiply the specified position in the current Matrix by a value
  3986. * @param index the index of the value within the matrix. between 0 and 15.
  3987. * @param value the value to be added
  3988. * @returns the current updated matrix
  3989. */
  3990. multiplyAtIndex(index: number, value: number): Matrix;
  3991. /**
  3992. * Inserts the translation vector (using 3 floats) in the current matrix
  3993. * @param x defines the 1st component of the translation
  3994. * @param y defines the 2nd component of the translation
  3995. * @param z defines the 3rd component of the translation
  3996. * @returns the current updated matrix
  3997. */
  3998. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3999. /**
  4000. * Adds the translation vector (using 3 floats) in the current matrix
  4001. * @param x defines the 1st component of the translation
  4002. * @param y defines the 2nd component of the translation
  4003. * @param z defines the 3rd component of the translation
  4004. * @returns the current updated matrix
  4005. */
  4006. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4007. /**
  4008. * Inserts the translation vector in the current matrix
  4009. * @param vector3 defines the translation to insert
  4010. * @returns the current updated matrix
  4011. */
  4012. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4013. /**
  4014. * Gets the translation value of the current matrix
  4015. * @returns a new Vector3 as the extracted translation from the matrix
  4016. */
  4017. getTranslation(): Vector3;
  4018. /**
  4019. * Fill a Vector3 with the extracted translation from the matrix
  4020. * @param result defines the Vector3 where to store the translation
  4021. * @returns the current matrix
  4022. */
  4023. getTranslationToRef(result: Vector3): Matrix;
  4024. /**
  4025. * Remove rotation and scaling part from the matrix
  4026. * @returns the updated matrix
  4027. */
  4028. removeRotationAndScaling(): Matrix;
  4029. /**
  4030. * Multiply two matrices
  4031. * @param other defines the second operand
  4032. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4033. */
  4034. multiply(other: DeepImmutable<Matrix>): Matrix;
  4035. /**
  4036. * Copy the current matrix from the given one
  4037. * @param other defines the source matrix
  4038. * @returns the current updated matrix
  4039. */
  4040. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4041. /**
  4042. * Populates the given array from the starting index with the current matrix values
  4043. * @param array defines the target array
  4044. * @param offset defines the offset in the target array where to start storing values
  4045. * @returns the current matrix
  4046. */
  4047. copyToArray(array: Float32Array, offset?: number): Matrix;
  4048. /**
  4049. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4050. * @param other defines the second operand
  4051. * @param result defines the matrix where to store the multiplication
  4052. * @returns the current matrix
  4053. */
  4054. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4055. /**
  4056. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4057. * @param other defines the second operand
  4058. * @param result defines the array where to store the multiplication
  4059. * @param offset defines the offset in the target array where to start storing values
  4060. * @returns the current matrix
  4061. */
  4062. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4063. /**
  4064. * Check equality between this matrix and a second one
  4065. * @param value defines the second matrix to compare
  4066. * @returns true is the current matrix and the given one values are strictly equal
  4067. */
  4068. equals(value: DeepImmutable<Matrix>): boolean;
  4069. /**
  4070. * Clone the current matrix
  4071. * @returns a new matrix from the current matrix
  4072. */
  4073. clone(): Matrix;
  4074. /**
  4075. * Returns the name of the current matrix class
  4076. * @returns the string "Matrix"
  4077. */
  4078. getClassName(): string;
  4079. /**
  4080. * Gets the hash code of the current matrix
  4081. * @returns the hash code
  4082. */
  4083. getHashCode(): number;
  4084. /**
  4085. * Decomposes the current Matrix into a translation, rotation and scaling components
  4086. * @param scale defines the scale vector3 given as a reference to update
  4087. * @param rotation defines the rotation quaternion given as a reference to update
  4088. * @param translation defines the translation vector3 given as a reference to update
  4089. * @returns true if operation was successful
  4090. */
  4091. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4092. /**
  4093. * Gets specific row of the matrix
  4094. * @param index defines the number of the row to get
  4095. * @returns the index-th row of the current matrix as a new Vector4
  4096. */
  4097. getRow(index: number): Nullable<Vector4>;
  4098. /**
  4099. * Sets the index-th row of the current matrix to the vector4 values
  4100. * @param index defines the number of the row to set
  4101. * @param row defines the target vector4
  4102. * @returns the updated current matrix
  4103. */
  4104. setRow(index: number, row: Vector4): Matrix;
  4105. /**
  4106. * Compute the transpose of the matrix
  4107. * @returns the new transposed matrix
  4108. */
  4109. transpose(): Matrix;
  4110. /**
  4111. * Compute the transpose of the matrix and store it in a given matrix
  4112. * @param result defines the target matrix
  4113. * @returns the current matrix
  4114. */
  4115. transposeToRef(result: Matrix): Matrix;
  4116. /**
  4117. * Sets the index-th row of the current matrix with the given 4 x float values
  4118. * @param index defines the row index
  4119. * @param x defines the x component to set
  4120. * @param y defines the y component to set
  4121. * @param z defines the z component to set
  4122. * @param w defines the w component to set
  4123. * @returns the updated current matrix
  4124. */
  4125. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4126. /**
  4127. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4128. * @param scale defines the scale factor
  4129. * @returns a new matrix
  4130. */
  4131. scale(scale: number): Matrix;
  4132. /**
  4133. * Scale the current matrix values by a factor to a given result matrix
  4134. * @param scale defines the scale factor
  4135. * @param result defines the matrix to store the result
  4136. * @returns the current matrix
  4137. */
  4138. scaleToRef(scale: number, result: Matrix): Matrix;
  4139. /**
  4140. * Scale the current matrix values by a factor and add the result to a given matrix
  4141. * @param scale defines the scale factor
  4142. * @param result defines the Matrix to store the result
  4143. * @returns the current matrix
  4144. */
  4145. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4146. /**
  4147. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4148. * @param ref matrix to store the result
  4149. */
  4150. toNormalMatrix(ref: Matrix): void;
  4151. /**
  4152. * Gets only rotation part of the current matrix
  4153. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4154. */
  4155. getRotationMatrix(): Matrix;
  4156. /**
  4157. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4158. * @param result defines the target matrix to store data to
  4159. * @returns the current matrix
  4160. */
  4161. getRotationMatrixToRef(result: Matrix): Matrix;
  4162. /**
  4163. * Toggles model matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleModelMatrixHandInPlace(): void;
  4166. /**
  4167. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4168. */
  4169. toggleProjectionMatrixHandInPlace(): void;
  4170. /**
  4171. * Creates a matrix from an array
  4172. * @param array defines the source array
  4173. * @param offset defines an offset in the source array
  4174. * @returns a new Matrix set from the starting index of the given array
  4175. */
  4176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4177. /**
  4178. * Copy the content of an array into a given matrix
  4179. * @param array defines the source array
  4180. * @param offset defines an offset in the source array
  4181. * @param result defines the target matrix
  4182. */
  4183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4184. /**
  4185. * Stores an array into a matrix after having multiplied each component by a given factor
  4186. * @param array defines the source array
  4187. * @param offset defines the offset in the source array
  4188. * @param scale defines the scaling factor
  4189. * @param result defines the target matrix
  4190. */
  4191. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4192. /**
  4193. * Gets an identity matrix that must not be updated
  4194. */
  4195. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4196. /**
  4197. * Stores a list of values (16) inside a given matrix
  4198. * @param initialM11 defines 1st value of 1st row
  4199. * @param initialM12 defines 2nd value of 1st row
  4200. * @param initialM13 defines 3rd value of 1st row
  4201. * @param initialM14 defines 4th value of 1st row
  4202. * @param initialM21 defines 1st value of 2nd row
  4203. * @param initialM22 defines 2nd value of 2nd row
  4204. * @param initialM23 defines 3rd value of 2nd row
  4205. * @param initialM24 defines 4th value of 2nd row
  4206. * @param initialM31 defines 1st value of 3rd row
  4207. * @param initialM32 defines 2nd value of 3rd row
  4208. * @param initialM33 defines 3rd value of 3rd row
  4209. * @param initialM34 defines 4th value of 3rd row
  4210. * @param initialM41 defines 1st value of 4th row
  4211. * @param initialM42 defines 2nd value of 4th row
  4212. * @param initialM43 defines 3rd value of 4th row
  4213. * @param initialM44 defines 4th value of 4th row
  4214. * @param result defines the target matrix
  4215. */
  4216. 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;
  4217. /**
  4218. * Creates new matrix from a list of values (16)
  4219. * @param initialM11 defines 1st value of 1st row
  4220. * @param initialM12 defines 2nd value of 1st row
  4221. * @param initialM13 defines 3rd value of 1st row
  4222. * @param initialM14 defines 4th value of 1st row
  4223. * @param initialM21 defines 1st value of 2nd row
  4224. * @param initialM22 defines 2nd value of 2nd row
  4225. * @param initialM23 defines 3rd value of 2nd row
  4226. * @param initialM24 defines 4th value of 2nd row
  4227. * @param initialM31 defines 1st value of 3rd row
  4228. * @param initialM32 defines 2nd value of 3rd row
  4229. * @param initialM33 defines 3rd value of 3rd row
  4230. * @param initialM34 defines 4th value of 3rd row
  4231. * @param initialM41 defines 1st value of 4th row
  4232. * @param initialM42 defines 2nd value of 4th row
  4233. * @param initialM43 defines 3rd value of 4th row
  4234. * @param initialM44 defines 4th value of 4th row
  4235. * @returns the new matrix
  4236. */
  4237. 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;
  4238. /**
  4239. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4240. * @param scale defines the scale vector3
  4241. * @param rotation defines the rotation quaternion
  4242. * @param translation defines the translation vector3
  4243. * @returns a new matrix
  4244. */
  4245. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4246. /**
  4247. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4248. * @param scale defines the scale vector3
  4249. * @param rotation defines the rotation quaternion
  4250. * @param translation defines the translation vector3
  4251. * @param result defines the target matrix
  4252. */
  4253. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4254. /**
  4255. * Creates a new identity matrix
  4256. * @returns a new identity matrix
  4257. */
  4258. static Identity(): Matrix;
  4259. /**
  4260. * Creates a new identity matrix and stores the result in a given matrix
  4261. * @param result defines the target matrix
  4262. */
  4263. static IdentityToRef(result: Matrix): void;
  4264. /**
  4265. * Creates a new zero matrix
  4266. * @returns a new zero matrix
  4267. */
  4268. static Zero(): Matrix;
  4269. /**
  4270. * Creates a new rotation matrix for "angle" radians around the X axis
  4271. * @param angle defines the angle (in radians) to use
  4272. * @return the new matrix
  4273. */
  4274. static RotationX(angle: number): Matrix;
  4275. /**
  4276. * Creates a new matrix as the invert of a given matrix
  4277. * @param source defines the source matrix
  4278. * @returns the new matrix
  4279. */
  4280. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4283. * @param angle defines the angle (in radians) to use
  4284. * @param result defines the target matrix
  4285. */
  4286. static RotationXToRef(angle: number, result: Matrix): void;
  4287. /**
  4288. * Creates a new rotation matrix for "angle" radians around the Y axis
  4289. * @param angle defines the angle (in radians) to use
  4290. * @return the new matrix
  4291. */
  4292. static RotationY(angle: number): Matrix;
  4293. /**
  4294. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationYToRef(angle: number, result: Matrix): void;
  4299. /**
  4300. * Creates a new rotation matrix for "angle" radians around the Z axis
  4301. * @param angle defines the angle (in radians) to use
  4302. * @return the new matrix
  4303. */
  4304. static RotationZ(angle: number): Matrix;
  4305. /**
  4306. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4307. * @param angle defines the angle (in radians) to use
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationZToRef(angle: number, result: Matrix): void;
  4311. /**
  4312. * Creates a new rotation matrix for "angle" radians around the given axis
  4313. * @param axis defines the axis to use
  4314. * @param angle defines the angle (in radians) to use
  4315. * @return the new matrix
  4316. */
  4317. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4318. /**
  4319. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4320. * @param axis defines the axis to use
  4321. * @param angle defines the angle (in radians) to use
  4322. * @param result defines the target matrix
  4323. */
  4324. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4325. /**
  4326. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4327. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4328. * @param from defines the vector to align
  4329. * @param to defines the vector to align to
  4330. * @param result defines the target matrix
  4331. */
  4332. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4333. /**
  4334. * Creates a rotation matrix
  4335. * @param yaw defines the yaw angle in radians (Y axis)
  4336. * @param pitch defines the pitch angle in radians (X axis)
  4337. * @param roll defines the roll angle in radians (X axis)
  4338. * @returns the new rotation matrix
  4339. */
  4340. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4341. /**
  4342. * Creates a rotation matrix and stores it in a given matrix
  4343. * @param yaw defines the yaw angle in radians (Y axis)
  4344. * @param pitch defines the pitch angle in radians (X axis)
  4345. * @param roll defines the roll angle in radians (X axis)
  4346. * @param result defines the target matrix
  4347. */
  4348. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4349. /**
  4350. * Creates a scaling matrix
  4351. * @param x defines the scale factor on X axis
  4352. * @param y defines the scale factor on Y axis
  4353. * @param z defines the scale factor on Z axis
  4354. * @returns the new matrix
  4355. */
  4356. static Scaling(x: number, y: number, z: number): Matrix;
  4357. /**
  4358. * Creates a scaling matrix and stores it in a given matrix
  4359. * @param x defines the scale factor on X axis
  4360. * @param y defines the scale factor on Y axis
  4361. * @param z defines the scale factor on Z axis
  4362. * @param result defines the target matrix
  4363. */
  4364. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4365. /**
  4366. * Creates a translation matrix
  4367. * @param x defines the translation on X axis
  4368. * @param y defines the translation on Y axis
  4369. * @param z defines the translationon Z axis
  4370. * @returns the new matrix
  4371. */
  4372. static Translation(x: number, y: number, z: number): Matrix;
  4373. /**
  4374. * Creates a translation matrix and stores it in a given matrix
  4375. * @param x defines the translation on X axis
  4376. * @param y defines the translation on Y axis
  4377. * @param z defines the translationon Z axis
  4378. * @param result defines the target matrix
  4379. */
  4380. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4381. /**
  4382. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4383. * @param startValue defines the start value
  4384. * @param endValue defines the end value
  4385. * @param gradient defines the gradient factor
  4386. * @returns the new matrix
  4387. */
  4388. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4389. /**
  4390. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4391. * @param startValue defines the start value
  4392. * @param endValue defines the end value
  4393. * @param gradient defines the gradient factor
  4394. * @param result defines the Matrix object where to store data
  4395. */
  4396. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * Builds a new matrix whose values are computed by:
  4399. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4400. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4401. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4402. * @param startValue defines the first matrix
  4403. * @param endValue defines the second matrix
  4404. * @param gradient defines the gradient between the two matrices
  4405. * @returns the new matrix
  4406. */
  4407. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4408. /**
  4409. * Update a matrix to values which are computed by:
  4410. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4411. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4412. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4413. * @param startValue defines the first matrix
  4414. * @param endValue defines the second matrix
  4415. * @param gradient defines the gradient between the two matrices
  4416. * @param result defines the target matrix
  4417. */
  4418. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4419. /**
  4420. * 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"
  4421. * This function works in left handed mode
  4422. * @param eye defines the final position of the entity
  4423. * @param target defines where the entity should look at
  4424. * @param up defines the up vector for the entity
  4425. * @returns the new matrix
  4426. */
  4427. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * 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".
  4430. * This function works in left handed mode
  4431. * @param eye defines the final position of the entity
  4432. * @param target defines where the entity should look at
  4433. * @param up defines the up vector for the entity
  4434. * @param result defines the target matrix
  4435. */
  4436. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * 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"
  4439. * This function works in right handed mode
  4440. * @param eye defines the final position of the entity
  4441. * @param target defines where the entity should look at
  4442. * @param up defines the up vector for the entity
  4443. * @returns the new matrix
  4444. */
  4445. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * 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".
  4448. * This function works in right handed mode
  4449. * @param eye defines the final position of the entity
  4450. * @param target defines where the entity should look at
  4451. * @param up defines the up vector for the entity
  4452. * @param result defines the target matrix
  4453. */
  4454. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4455. /**
  4456. * Create a left-handed orthographic projection matrix
  4457. * @param width defines the viewport width
  4458. * @param height defines the viewport height
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Store a left-handed orthographic projection to a given matrix
  4466. * @param width defines the viewport width
  4467. * @param height defines the viewport height
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Create a left-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a left-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a left-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a right-handed orthographic projection matrix
  4497. * @param left defines the viewport left coordinate
  4498. * @param right defines the viewport right coordinate
  4499. * @param bottom defines the viewport bottom coordinate
  4500. * @param top defines the viewport top coordinate
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a right-handed orthographic projection matrix
  4504. */
  4505. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Stores a right-handed orthographic projection into a given matrix
  4508. * @param left defines the viewport left coordinate
  4509. * @param right defines the viewport right coordinate
  4510. * @param bottom defines the viewport bottom coordinate
  4511. * @param top defines the viewport top coordinate
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. */
  4516. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4517. /**
  4518. * Creates a left-handed perspective projection matrix
  4519. * @param width defines the viewport width
  4520. * @param height defines the viewport height
  4521. * @param znear defines the near clip plane
  4522. * @param zfar defines the far clip plane
  4523. * @returns a new matrix as a left-handed perspective projection matrix
  4524. */
  4525. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4526. /**
  4527. * Creates a left-handed perspective projection matrix
  4528. * @param fov defines the horizontal field of view
  4529. * @param aspect defines the aspect ratio
  4530. * @param znear defines the near clip plane
  4531. * @param zfar defines the far clip plane
  4532. * @returns a new matrix as a left-handed perspective projection matrix
  4533. */
  4534. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4535. /**
  4536. * Stores a left-handed perspective projection into a given matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @param result defines the target matrix
  4542. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4543. */
  4544. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4545. /**
  4546. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4547. * @param fov defines the horizontal field of view
  4548. * @param aspect defines the aspect ratio
  4549. * @param znear defines the near clip plane
  4550. * @param zfar not used as infinity is used as far clip
  4551. * @param result defines the target matrix
  4552. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4553. */
  4554. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4555. /**
  4556. * Creates a right-handed perspective projection matrix
  4557. * @param fov defines the horizontal field of view
  4558. * @param aspect defines the aspect ratio
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @returns a new matrix as a right-handed perspective projection matrix
  4562. */
  4563. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4564. /**
  4565. * Stores a right-handed perspective projection into a given matrix
  4566. * @param fov defines the horizontal field of view
  4567. * @param aspect defines the aspect ratio
  4568. * @param znear defines the near clip plane
  4569. * @param zfar defines the far clip plane
  4570. * @param result defines the target matrix
  4571. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4572. */
  4573. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4574. /**
  4575. * Stores a right-handed perspective projection into a given matrix
  4576. * @param fov defines the horizontal field of view
  4577. * @param aspect defines the aspect ratio
  4578. * @param znear defines the near clip plane
  4579. * @param zfar not used as infinity is used as far clip
  4580. * @param result defines the target matrix
  4581. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4582. */
  4583. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4584. /**
  4585. * Stores a perspective projection for WebVR info a given matrix
  4586. * @param fov defines the field of view
  4587. * @param znear defines the near clip plane
  4588. * @param zfar defines the far clip plane
  4589. * @param result defines the target matrix
  4590. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4591. */
  4592. static PerspectiveFovWebVRToRef(fov: {
  4593. upDegrees: number;
  4594. downDegrees: number;
  4595. leftDegrees: number;
  4596. rightDegrees: number;
  4597. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4598. /**
  4599. * Computes a complete transformation matrix
  4600. * @param viewport defines the viewport to use
  4601. * @param world defines the world matrix
  4602. * @param view defines the view matrix
  4603. * @param projection defines the projection matrix
  4604. * @param zmin defines the near clip plane
  4605. * @param zmax defines the far clip plane
  4606. * @returns the transformation matrix
  4607. */
  4608. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4609. /**
  4610. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4611. * @param matrix defines the matrix to use
  4612. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4613. */
  4614. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4615. /**
  4616. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4617. * @param matrix defines the matrix to use
  4618. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4619. */
  4620. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4621. /**
  4622. * Compute the transpose of a given matrix
  4623. * @param matrix defines the matrix to transpose
  4624. * @returns the new matrix
  4625. */
  4626. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4627. /**
  4628. * Compute the transpose of a matrix and store it in a target matrix
  4629. * @param matrix defines the matrix to transpose
  4630. * @param result defines the target matrix
  4631. */
  4632. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4633. /**
  4634. * Computes a reflection matrix from a plane
  4635. * @param plane defines the reflection plane
  4636. * @returns a new matrix
  4637. */
  4638. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4639. /**
  4640. * Computes a reflection matrix from a plane
  4641. * @param plane defines the reflection plane
  4642. * @param result defines the target matrix
  4643. */
  4644. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4645. /**
  4646. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4647. * @param xaxis defines the value of the 1st axis
  4648. * @param yaxis defines the value of the 2nd axis
  4649. * @param zaxis defines the value of the 3rd axis
  4650. * @param result defines the target matrix
  4651. */
  4652. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4653. /**
  4654. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4655. * @param quat defines the quaternion to use
  4656. * @param result defines the target matrix
  4657. */
  4658. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4659. }
  4660. /**
  4661. * @hidden
  4662. */
  4663. export class TmpVectors {
  4664. static Vector2: Vector2[];
  4665. static Vector3: Vector3[];
  4666. static Vector4: Vector4[];
  4667. static Quaternion: Quaternion[];
  4668. static Matrix: Matrix[];
  4669. }
  4670. }
  4671. declare module "babylonjs/Maths/math.path" {
  4672. import { DeepImmutable, Nullable } from "babylonjs/types";
  4673. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4674. /**
  4675. * Defines potential orientation for back face culling
  4676. */
  4677. export enum Orientation {
  4678. /**
  4679. * Clockwise
  4680. */
  4681. CW = 0,
  4682. /** Counter clockwise */
  4683. CCW = 1
  4684. }
  4685. /** Class used to represent a Bezier curve */
  4686. export class BezierCurve {
  4687. /**
  4688. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4689. * @param t defines the time
  4690. * @param x1 defines the left coordinate on X axis
  4691. * @param y1 defines the left coordinate on Y axis
  4692. * @param x2 defines the right coordinate on X axis
  4693. * @param y2 defines the right coordinate on Y axis
  4694. * @returns the interpolated value
  4695. */
  4696. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4697. }
  4698. /**
  4699. * Defines angle representation
  4700. */
  4701. export class Angle {
  4702. private _radians;
  4703. /**
  4704. * Creates an Angle object of "radians" radians (float).
  4705. * @param radians the angle in radians
  4706. */
  4707. constructor(radians: number);
  4708. /**
  4709. * Get value in degrees
  4710. * @returns the Angle value in degrees (float)
  4711. */
  4712. degrees(): number;
  4713. /**
  4714. * Get value in radians
  4715. * @returns the Angle value in radians (float)
  4716. */
  4717. radians(): number;
  4718. /**
  4719. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4720. * @param a defines first vector
  4721. * @param b defines second vector
  4722. * @returns a new Angle
  4723. */
  4724. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4725. /**
  4726. * Gets a new Angle object from the given float in radians
  4727. * @param radians defines the angle value in radians
  4728. * @returns a new Angle
  4729. */
  4730. static FromRadians(radians: number): Angle;
  4731. /**
  4732. * Gets a new Angle object from the given float in degrees
  4733. * @param degrees defines the angle value in degrees
  4734. * @returns a new Angle
  4735. */
  4736. static FromDegrees(degrees: number): Angle;
  4737. }
  4738. /**
  4739. * This represents an arc in a 2d space.
  4740. */
  4741. export class Arc2 {
  4742. /** Defines the start point of the arc */
  4743. startPoint: Vector2;
  4744. /** Defines the mid point of the arc */
  4745. midPoint: Vector2;
  4746. /** Defines the end point of the arc */
  4747. endPoint: Vector2;
  4748. /**
  4749. * Defines the center point of the arc.
  4750. */
  4751. centerPoint: Vector2;
  4752. /**
  4753. * Defines the radius of the arc.
  4754. */
  4755. radius: number;
  4756. /**
  4757. * Defines the angle of the arc (from mid point to end point).
  4758. */
  4759. angle: Angle;
  4760. /**
  4761. * Defines the start angle of the arc (from start point to middle point).
  4762. */
  4763. startAngle: Angle;
  4764. /**
  4765. * Defines the orientation of the arc (clock wise/counter clock wise).
  4766. */
  4767. orientation: Orientation;
  4768. /**
  4769. * Creates an Arc object from the three given points : start, middle and end.
  4770. * @param startPoint Defines the start point of the arc
  4771. * @param midPoint Defines the midlle point of the arc
  4772. * @param endPoint Defines the end point of the arc
  4773. */
  4774. constructor(
  4775. /** Defines the start point of the arc */
  4776. startPoint: Vector2,
  4777. /** Defines the mid point of the arc */
  4778. midPoint: Vector2,
  4779. /** Defines the end point of the arc */
  4780. endPoint: Vector2);
  4781. }
  4782. /**
  4783. * Represents a 2D path made up of multiple 2D points
  4784. */
  4785. export class Path2 {
  4786. private _points;
  4787. private _length;
  4788. /**
  4789. * If the path start and end point are the same
  4790. */
  4791. closed: boolean;
  4792. /**
  4793. * Creates a Path2 object from the starting 2D coordinates x and y.
  4794. * @param x the starting points x value
  4795. * @param y the starting points y value
  4796. */
  4797. constructor(x: number, y: number);
  4798. /**
  4799. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4800. * @param x the added points x value
  4801. * @param y the added points y value
  4802. * @returns the updated Path2.
  4803. */
  4804. addLineTo(x: number, y: number): Path2;
  4805. /**
  4806. * 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.
  4807. * @param midX middle point x value
  4808. * @param midY middle point y value
  4809. * @param endX end point x value
  4810. * @param endY end point y value
  4811. * @param numberOfSegments (default: 36)
  4812. * @returns the updated Path2.
  4813. */
  4814. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4815. /**
  4816. * Closes the Path2.
  4817. * @returns the Path2.
  4818. */
  4819. close(): Path2;
  4820. /**
  4821. * Gets the sum of the distance between each sequential point in the path
  4822. * @returns the Path2 total length (float).
  4823. */
  4824. length(): number;
  4825. /**
  4826. * Gets the points which construct the path
  4827. * @returns the Path2 internal array of points.
  4828. */
  4829. getPoints(): Vector2[];
  4830. /**
  4831. * Retreives the point at the distance aways from the starting point
  4832. * @param normalizedLengthPosition the length along the path to retreive the point from
  4833. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4834. */
  4835. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4836. /**
  4837. * Creates a new path starting from an x and y position
  4838. * @param x starting x value
  4839. * @param y starting y value
  4840. * @returns a new Path2 starting at the coordinates (x, y).
  4841. */
  4842. static StartingAt(x: number, y: number): Path2;
  4843. }
  4844. /**
  4845. * Represents a 3D path made up of multiple 3D points
  4846. */
  4847. export class Path3D {
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[];
  4852. private _curve;
  4853. private _distances;
  4854. private _tangents;
  4855. private _normals;
  4856. private _binormals;
  4857. private _raw;
  4858. private _alignTangentsWithPath;
  4859. private readonly _pointAtData;
  4860. /**
  4861. * new Path3D(path, normal, raw)
  4862. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4863. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4864. * @param path an array of Vector3, the curve axis of the Path3D
  4865. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4866. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4867. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4868. */
  4869. constructor(
  4870. /**
  4871. * an array of Vector3, the curve axis of the Path3D
  4872. */
  4873. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4874. /**
  4875. * Returns the Path3D array of successive Vector3 designing its curve.
  4876. * @returns the Path3D array of successive Vector3 designing its curve.
  4877. */
  4878. getCurve(): Vector3[];
  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. getPoints(): Vector3[];
  4884. /**
  4885. * @returns the computed length (float) of the path.
  4886. */
  4887. length(): number;
  4888. /**
  4889. * Returns an array populated with tangent vectors on each Path3D curve point.
  4890. * @returns an array populated with tangent vectors on each Path3D curve point.
  4891. */
  4892. getTangents(): Vector3[];
  4893. /**
  4894. * Returns an array populated with normal vectors on each Path3D curve point.
  4895. * @returns an array populated with normal vectors on each Path3D curve point.
  4896. */
  4897. getNormals(): Vector3[];
  4898. /**
  4899. * Returns an array populated with binormal vectors on each Path3D curve point.
  4900. * @returns an array populated with binormal vectors on each Path3D curve point.
  4901. */
  4902. getBinormals(): Vector3[];
  4903. /**
  4904. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4905. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4906. */
  4907. getDistances(): number[];
  4908. /**
  4909. * Returns an interpolated point along this path
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @returns a new Vector3 as the point
  4912. */
  4913. getPointAt(position: number): Vector3;
  4914. /**
  4915. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4916. * @param position the position of the point along this path, from 0.0 to 1.0
  4917. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4918. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4919. */
  4920. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4921. /**
  4922. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4923. * @param position the position of the point along this path, from 0.0 to 1.0
  4924. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4925. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4926. */
  4927. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4928. /**
  4929. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4930. * @param position the position of the point along this path, from 0.0 to 1.0
  4931. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4932. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4933. */
  4934. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4935. /**
  4936. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4937. * @param position the position of the point along this path, from 0.0 to 1.0
  4938. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4939. */
  4940. getDistanceAt(position: number): number;
  4941. /**
  4942. * Returns the array index of the previous point of an interpolated point along this path
  4943. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4944. * @returns the array index
  4945. */
  4946. getPreviousPointIndexAt(position: number): number;
  4947. /**
  4948. * 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)
  4949. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4950. * @returns the sub position
  4951. */
  4952. getSubPositionAt(position: number): number;
  4953. /**
  4954. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4955. * @param target the vector of which to get the closest position to
  4956. * @returns the position of the closest virtual point on this path to the target vector
  4957. */
  4958. getClosestPositionTo(target: Vector3): number;
  4959. /**
  4960. * Returns a sub path (slice) of this path
  4961. * @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
  4962. * @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
  4963. * @returns a sub path (slice) of this path
  4964. */
  4965. slice(start?: number, end?: number): Path3D;
  4966. /**
  4967. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4968. * @param path path which all values are copied into the curves points
  4969. * @param firstNormal which should be projected onto the curve
  4970. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4971. * @returns the same object updated.
  4972. */
  4973. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4974. private _compute;
  4975. private _getFirstNonNullVector;
  4976. private _getLastNonNullVector;
  4977. private _normalVector;
  4978. /**
  4979. * Updates the point at data for an interpolated point along this curve
  4980. * @param position the position of the point along this curve, from 0.0 to 1.0
  4981. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4982. * @returns the (updated) point at data
  4983. */
  4984. private _updatePointAtData;
  4985. /**
  4986. * Updates the point at data from the specified parameters
  4987. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4988. * @param point the interpolated point
  4989. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4990. */
  4991. private _setPointAtData;
  4992. /**
  4993. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4994. */
  4995. private _updateInterpolationMatrix;
  4996. }
  4997. /**
  4998. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4999. * A Curve3 is designed from a series of successive Vector3.
  5000. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5001. */
  5002. export class Curve3 {
  5003. private _points;
  5004. private _length;
  5005. /**
  5006. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5007. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5008. * @param v1 (Vector3) the control point
  5009. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5016. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5017. * @param v1 (Vector3) the first control point
  5018. * @param v2 (Vector3) the second control point
  5019. * @param v3 (Vector3) the end point of the Cubic Bezier
  5020. * @param nbPoints (integer) the wanted number of points in the curve
  5021. * @returns the created Curve3
  5022. */
  5023. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5024. /**
  5025. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5026. * @param p1 (Vector3) the origin point of the Hermite Spline
  5027. * @param t1 (Vector3) the tangent vector at the origin point
  5028. * @param p2 (Vector3) the end point of the Hermite Spline
  5029. * @param t2 (Vector3) the tangent vector at the end point
  5030. * @param nbPoints (integer) the wanted number of points in the curve
  5031. * @returns the created Curve3
  5032. */
  5033. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5034. /**
  5035. * Returns a Curve3 object along a CatmullRom Spline curve :
  5036. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5037. * @param nbPoints (integer) the wanted number of points between each curve control points
  5038. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5039. * @returns the created Curve3
  5040. */
  5041. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5042. /**
  5043. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5044. * A Curve3 is designed from a series of successive Vector3.
  5045. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5046. * @param points points which make up the curve
  5047. */
  5048. constructor(points: Vector3[]);
  5049. /**
  5050. * @returns the Curve3 stored array of successive Vector3
  5051. */
  5052. getPoints(): Vector3[];
  5053. /**
  5054. * @returns the computed length (float) of the curve.
  5055. */
  5056. length(): number;
  5057. /**
  5058. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5059. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5060. * curveA and curveB keep unchanged.
  5061. * @param curve the curve to continue from this curve
  5062. * @returns the newly constructed curve
  5063. */
  5064. continue(curve: DeepImmutable<Curve3>): Curve3;
  5065. private _computeLength;
  5066. }
  5067. }
  5068. declare module "babylonjs/Animations/easing" {
  5069. /**
  5070. * This represents the main contract an easing function should follow.
  5071. * Easing functions are used throughout the animation system.
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export interface IEasingFunction {
  5075. /**
  5076. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5077. * of the easing function.
  5078. * The link below provides some of the most common examples of easing functions.
  5079. * @see https://easings.net/
  5080. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5081. * @returns the corresponding value on the curve defined by the easing function
  5082. */
  5083. ease(gradient: number): number;
  5084. }
  5085. /**
  5086. * Base class used for every default easing function.
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class EasingFunction implements IEasingFunction {
  5090. /**
  5091. * Interpolation follows the mathematical formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEIN: number;
  5094. /**
  5095. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5096. */
  5097. static readonly EASINGMODE_EASEOUT: number;
  5098. /**
  5099. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5100. */
  5101. static readonly EASINGMODE_EASEINOUT: number;
  5102. private _easingMode;
  5103. /**
  5104. * Sets the easing mode of the current function.
  5105. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5106. */
  5107. setEasingMode(easingMode: number): void;
  5108. /**
  5109. * Gets the current easing mode.
  5110. * @returns the easing mode
  5111. */
  5112. getEasingMode(): number;
  5113. /**
  5114. * @hidden
  5115. */
  5116. easeInCore(gradient: number): number;
  5117. /**
  5118. * Given an input gradient between 0 and 1, this returns the corresponding value
  5119. * of the easing function.
  5120. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5121. * @returns the corresponding value on the curve defined by the easing function
  5122. */
  5123. ease(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a circle shape (see link below).
  5127. * @see https://easings.net/#easeInCirc
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class CircleEase extends EasingFunction implements IEasingFunction {
  5131. /** @hidden */
  5132. easeInCore(gradient: number): number;
  5133. }
  5134. /**
  5135. * Easing function with a ease back shape (see link below).
  5136. * @see https://easings.net/#easeInBack
  5137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5138. */
  5139. export class BackEase extends EasingFunction implements IEasingFunction {
  5140. /** Defines the amplitude of the function */
  5141. amplitude: number;
  5142. /**
  5143. * Instantiates a back ease easing
  5144. * @see https://easings.net/#easeInBack
  5145. * @param amplitude Defines the amplitude of the function
  5146. */
  5147. constructor(
  5148. /** Defines the amplitude of the function */
  5149. amplitude?: number);
  5150. /** @hidden */
  5151. easeInCore(gradient: number): number;
  5152. }
  5153. /**
  5154. * Easing function with a bouncing shape (see link below).
  5155. * @see https://easings.net/#easeInBounce
  5156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5157. */
  5158. export class BounceEase extends EasingFunction implements IEasingFunction {
  5159. /** Defines the number of bounces */
  5160. bounces: number;
  5161. /** Defines the amplitude of the bounce */
  5162. bounciness: number;
  5163. /**
  5164. * Instantiates a bounce easing
  5165. * @see https://easings.net/#easeInBounce
  5166. * @param bounces Defines the number of bounces
  5167. * @param bounciness Defines the amplitude of the bounce
  5168. */
  5169. constructor(
  5170. /** Defines the number of bounces */
  5171. bounces?: number,
  5172. /** Defines the amplitude of the bounce */
  5173. bounciness?: number);
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a power of 3 shape (see link below).
  5179. * @see https://easings.net/#easeInCubic
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class CubicEase extends EasingFunction implements IEasingFunction {
  5183. /** @hidden */
  5184. easeInCore(gradient: number): number;
  5185. }
  5186. /**
  5187. * Easing function with an elastic shape (see link below).
  5188. * @see https://easings.net/#easeInElastic
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5192. /** Defines the number of oscillations*/
  5193. oscillations: number;
  5194. /** Defines the amplitude of the oscillations*/
  5195. springiness: number;
  5196. /**
  5197. * Instantiates an elastic easing function
  5198. * @see https://easings.net/#easeInElastic
  5199. * @param oscillations Defines the number of oscillations
  5200. * @param springiness Defines the amplitude of the oscillations
  5201. */
  5202. constructor(
  5203. /** Defines the number of oscillations*/
  5204. oscillations?: number,
  5205. /** Defines the amplitude of the oscillations*/
  5206. springiness?: number);
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with an exponential shape (see link below).
  5212. * @see https://easings.net/#easeInExpo
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5216. /** Defines the exponent of the function */
  5217. exponent: number;
  5218. /**
  5219. * Instantiates an exponential easing function
  5220. * @see https://easings.net/#easeInExpo
  5221. * @param exponent Defines the exponent of the function
  5222. */
  5223. constructor(
  5224. /** Defines the exponent of the function */
  5225. exponent?: number);
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power shape (see link below).
  5231. * @see https://easings.net/#easeInQuad
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class PowerEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the power of the function */
  5236. power: number;
  5237. /**
  5238. * Instantiates an power base easing function
  5239. * @see https://easings.net/#easeInQuad
  5240. * @param power Defines the power of the function
  5241. */
  5242. constructor(
  5243. /** Defines the power of the function */
  5244. power?: number);
  5245. /** @hidden */
  5246. easeInCore(gradient: number): number;
  5247. }
  5248. /**
  5249. * Easing function with a power of 2 shape (see link below).
  5250. * @see https://easings.net/#easeInQuad
  5251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5252. */
  5253. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5254. /** @hidden */
  5255. easeInCore(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a power of 4 shape (see link below).
  5259. * @see https://easings.net/#easeInQuart
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a power of 5 shape (see link below).
  5268. * @see https://easings.net/#easeInQuint
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5272. /** @hidden */
  5273. easeInCore(gradient: number): number;
  5274. }
  5275. /**
  5276. * Easing function with a sin shape (see link below).
  5277. * @see https://easings.net/#easeInSine
  5278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5279. */
  5280. export class SineEase extends EasingFunction implements IEasingFunction {
  5281. /** @hidden */
  5282. easeInCore(gradient: number): number;
  5283. }
  5284. /**
  5285. * Easing function with a bezier shape (see link below).
  5286. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5288. */
  5289. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5290. /** Defines the x component of the start tangent in the bezier curve */
  5291. x1: number;
  5292. /** Defines the y component of the start tangent in the bezier curve */
  5293. y1: number;
  5294. /** Defines the x component of the end tangent in the bezier curve */
  5295. x2: number;
  5296. /** Defines the y component of the end tangent in the bezier curve */
  5297. y2: number;
  5298. /**
  5299. * Instantiates a bezier function
  5300. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5301. * @param x1 Defines the x component of the start tangent in the bezier curve
  5302. * @param y1 Defines the y component of the start tangent in the bezier curve
  5303. * @param x2 Defines the x component of the end tangent in the bezier curve
  5304. * @param y2 Defines the y component of the end tangent in the bezier curve
  5305. */
  5306. constructor(
  5307. /** Defines the x component of the start tangent in the bezier curve */
  5308. x1?: number,
  5309. /** Defines the y component of the start tangent in the bezier curve */
  5310. y1?: number,
  5311. /** Defines the x component of the end tangent in the bezier curve */
  5312. x2?: number,
  5313. /** Defines the y component of the end tangent in the bezier curve */
  5314. y2?: number);
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. }
  5319. declare module "babylonjs/Maths/math.color" {
  5320. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5321. /**
  5322. * Class used to hold a RBG color
  5323. */
  5324. export class Color3 {
  5325. /**
  5326. * Defines the red component (between 0 and 1, default is 0)
  5327. */
  5328. r: number;
  5329. /**
  5330. * Defines the green component (between 0 and 1, default is 0)
  5331. */
  5332. g: number;
  5333. /**
  5334. * Defines the blue component (between 0 and 1, default is 0)
  5335. */
  5336. b: number;
  5337. /**
  5338. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5339. * @param r defines the red component (between 0 and 1, default is 0)
  5340. * @param g defines the green component (between 0 and 1, default is 0)
  5341. * @param b defines the blue component (between 0 and 1, default is 0)
  5342. */
  5343. constructor(
  5344. /**
  5345. * Defines the red component (between 0 and 1, default is 0)
  5346. */
  5347. r?: number,
  5348. /**
  5349. * Defines the green component (between 0 and 1, default is 0)
  5350. */
  5351. g?: number,
  5352. /**
  5353. * Defines the blue component (between 0 and 1, default is 0)
  5354. */
  5355. b?: number);
  5356. /**
  5357. * Creates a string with the Color3 current values
  5358. * @returns the string representation of the Color3 object
  5359. */
  5360. toString(): string;
  5361. /**
  5362. * Returns the string "Color3"
  5363. * @returns "Color3"
  5364. */
  5365. getClassName(): string;
  5366. /**
  5367. * Compute the Color3 hash code
  5368. * @returns an unique number that can be used to hash Color3 objects
  5369. */
  5370. getHashCode(): number;
  5371. /**
  5372. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5373. * @param array defines the array where to store the r,g,b components
  5374. * @param index defines an optional index in the target array to define where to start storing values
  5375. * @returns the current Color3 object
  5376. */
  5377. toArray(array: FloatArray, index?: number): Color3;
  5378. /**
  5379. * Returns a new Color4 object from the current Color3 and the given alpha
  5380. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5381. * @returns a new Color4 object
  5382. */
  5383. toColor4(alpha?: number): Color4;
  5384. /**
  5385. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5386. * @returns the new array
  5387. */
  5388. asArray(): number[];
  5389. /**
  5390. * Returns the luminance value
  5391. * @returns a float value
  5392. */
  5393. toLuminance(): number;
  5394. /**
  5395. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3 object
  5398. */
  5399. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines the Color3 object where to store the result
  5404. * @returns the current Color3
  5405. */
  5406. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Determines equality between Color3 objects
  5409. * @param otherColor defines the second operand
  5410. * @returns true if the rgb values are equal to the given ones
  5411. */
  5412. equals(otherColor: DeepImmutable<Color3>): boolean;
  5413. /**
  5414. * Determines equality between the current Color3 object and a set of r,b,g values
  5415. * @param r defines the red component to check
  5416. * @param g defines the green component to check
  5417. * @param b defines the blue component to check
  5418. * @returns true if the rgb values are equal to the given ones
  5419. */
  5420. equalsFloats(r: number, g: number, b: number): boolean;
  5421. /**
  5422. * Multiplies in place each rgb value by scale
  5423. * @param scale defines the scaling factor
  5424. * @returns the updated Color3
  5425. */
  5426. scale(scale: number): Color3;
  5427. /**
  5428. * Multiplies the rgb values by scale and stores the result into "result"
  5429. * @param scale defines the scaling factor
  5430. * @param result defines the Color3 object where to store the result
  5431. * @returns the unmodified current Color3
  5432. */
  5433. scaleToRef(scale: number, result: Color3): Color3;
  5434. /**
  5435. * Scale the current Color3 values by a factor and add the result to a given Color3
  5436. * @param scale defines the scale factor
  5437. * @param result defines color to store the result into
  5438. * @returns the unmodified current Color3
  5439. */
  5440. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5441. /**
  5442. * Clamps the rgb values by the min and max values and stores the result into "result"
  5443. * @param min defines minimum clamping value (default is 0)
  5444. * @param max defines maximum clamping value (default is 1)
  5445. * @param result defines color to store the result into
  5446. * @returns the original Color3
  5447. */
  5448. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5449. /**
  5450. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5451. * @param otherColor defines the second operand
  5452. * @returns the new Color3
  5453. */
  5454. add(otherColor: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5457. * @param otherColor defines the second operand
  5458. * @param result defines Color3 object to store the result into
  5459. * @returns the unmodified current Color3
  5460. */
  5461. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5462. /**
  5463. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5464. * @param otherColor defines the second operand
  5465. * @returns the new Color3
  5466. */
  5467. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5468. /**
  5469. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5470. * @param otherColor defines the second operand
  5471. * @param result defines Color3 object to store the result into
  5472. * @returns the unmodified current Color3
  5473. */
  5474. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5475. /**
  5476. * Copy the current object
  5477. * @returns a new Color3 copied the current one
  5478. */
  5479. clone(): Color3;
  5480. /**
  5481. * Copies the rgb values from the source in the current Color3
  5482. * @param source defines the source Color3 object
  5483. * @returns the updated Color3 object
  5484. */
  5485. copyFrom(source: DeepImmutable<Color3>): Color3;
  5486. /**
  5487. * Updates the Color3 rgb values from the given floats
  5488. * @param r defines the red component to read from
  5489. * @param g defines the green component to read from
  5490. * @param b defines the blue component to read from
  5491. * @returns the current Color3 object
  5492. */
  5493. copyFromFloats(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Updates the Color3 rgb values from the given floats
  5496. * @param r defines the red component to read from
  5497. * @param g defines the green component to read from
  5498. * @param b defines the blue component to read from
  5499. * @returns the current Color3 object
  5500. */
  5501. set(r: number, g: number, b: number): Color3;
  5502. /**
  5503. * Compute the Color3 hexadecimal code as a string
  5504. * @returns a string containing the hexadecimal representation of the Color3 object
  5505. */
  5506. toHexString(): string;
  5507. /**
  5508. * Computes a new Color3 converted from the current one to linear space
  5509. * @returns a new Color3 object
  5510. */
  5511. toLinearSpace(): Color3;
  5512. /**
  5513. * Converts current color in rgb space to HSV values
  5514. * @returns a new color3 representing the HSV values
  5515. */
  5516. toHSV(): Color3;
  5517. /**
  5518. * Converts current color in rgb space to HSV values
  5519. * @param result defines the Color3 where to store the HSV values
  5520. */
  5521. toHSVToRef(result: Color3): void;
  5522. /**
  5523. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5524. * @param convertedColor defines the Color3 object where to store the linear space version
  5525. * @returns the unmodified Color3
  5526. */
  5527. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5528. /**
  5529. * Computes a new Color3 converted from the current one to gamma space
  5530. * @returns a new Color3 object
  5531. */
  5532. toGammaSpace(): Color3;
  5533. /**
  5534. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5535. * @param convertedColor defines the Color3 object where to store the gamma space version
  5536. * @returns the unmodified Color3
  5537. */
  5538. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5539. private static _BlackReadOnly;
  5540. /**
  5541. * Convert Hue, saturation and value to a Color3 (RGB)
  5542. * @param hue defines the hue
  5543. * @param saturation defines the saturation
  5544. * @param value defines the value
  5545. * @param result defines the Color3 where to store the RGB values
  5546. */
  5547. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5548. /**
  5549. * Creates a new Color3 from the string containing valid hexadecimal values
  5550. * @param hex defines a string containing valid hexadecimal values
  5551. * @returns a new Color3 object
  5552. */
  5553. static FromHexString(hex: string): Color3;
  5554. /**
  5555. * Creates a new Color3 from the starting index of the given array
  5556. * @param array defines the source array
  5557. * @param offset defines an offset in the source array
  5558. * @returns a new Color3 object
  5559. */
  5560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5561. /**
  5562. * Creates a new Color3 from integer values (< 256)
  5563. * @param r defines the red component to read from (value between 0 and 255)
  5564. * @param g defines the green component to read from (value between 0 and 255)
  5565. * @param b defines the blue component to read from (value between 0 and 255)
  5566. * @returns a new Color3 object
  5567. */
  5568. static FromInts(r: number, g: number, b: number): Color3;
  5569. /**
  5570. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5571. * @param start defines the start Color3 value
  5572. * @param end defines the end Color3 value
  5573. * @param amount defines the gradient value between start and end
  5574. * @returns a new Color3 object
  5575. */
  5576. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5577. /**
  5578. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5579. * @param left defines the start value
  5580. * @param right defines the end value
  5581. * @param amount defines the gradient factor
  5582. * @param result defines the Color3 object where to store the result
  5583. */
  5584. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5585. /**
  5586. * Returns a Color3 value containing a red color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Red(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a green color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Green(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a blue color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Blue(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a black color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Black(): Color3;
  5605. /**
  5606. * Gets a Color3 value containing a black color that must not be updated
  5607. */
  5608. static get BlackReadOnly(): DeepImmutable<Color3>;
  5609. /**
  5610. * Returns a Color3 value containing a white color
  5611. * @returns a new Color3 object
  5612. */
  5613. static White(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a purple color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Purple(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a magenta color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Magenta(): Color3;
  5624. /**
  5625. * Returns a Color3 value containing a yellow color
  5626. * @returns a new Color3 object
  5627. */
  5628. static Yellow(): Color3;
  5629. /**
  5630. * Returns a Color3 value containing a gray color
  5631. * @returns a new Color3 object
  5632. */
  5633. static Gray(): Color3;
  5634. /**
  5635. * Returns a Color3 value containing a teal color
  5636. * @returns a new Color3 object
  5637. */
  5638. static Teal(): Color3;
  5639. /**
  5640. * Returns a Color3 value containing a random color
  5641. * @returns a new Color3 object
  5642. */
  5643. static Random(): Color3;
  5644. }
  5645. /**
  5646. * Class used to hold a RBGA color
  5647. */
  5648. export class Color4 {
  5649. /**
  5650. * Defines the red component (between 0 and 1, default is 0)
  5651. */
  5652. r: number;
  5653. /**
  5654. * Defines the green component (between 0 and 1, default is 0)
  5655. */
  5656. g: number;
  5657. /**
  5658. * Defines the blue component (between 0 and 1, default is 0)
  5659. */
  5660. b: number;
  5661. /**
  5662. * Defines the alpha component (between 0 and 1, default is 1)
  5663. */
  5664. a: number;
  5665. /**
  5666. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5667. * @param r defines the red component (between 0 and 1, default is 0)
  5668. * @param g defines the green component (between 0 and 1, default is 0)
  5669. * @param b defines the blue component (between 0 and 1, default is 0)
  5670. * @param a defines the alpha component (between 0 and 1, default is 1)
  5671. */
  5672. constructor(
  5673. /**
  5674. * Defines the red component (between 0 and 1, default is 0)
  5675. */
  5676. r?: number,
  5677. /**
  5678. * Defines the green component (between 0 and 1, default is 0)
  5679. */
  5680. g?: number,
  5681. /**
  5682. * Defines the blue component (between 0 and 1, default is 0)
  5683. */
  5684. b?: number,
  5685. /**
  5686. * Defines the alpha component (between 0 and 1, default is 1)
  5687. */
  5688. a?: number);
  5689. /**
  5690. * Adds in place the given Color4 values to the current Color4 object
  5691. * @param right defines the second operand
  5692. * @returns the current updated Color4 object
  5693. */
  5694. addInPlace(right: DeepImmutable<Color4>): Color4;
  5695. /**
  5696. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5697. * @returns the new array
  5698. */
  5699. asArray(): number[];
  5700. /**
  5701. * Stores from the starting index in the given array the Color4 successive values
  5702. * @param array defines the array where to store the r,g,b components
  5703. * @param index defines an optional index in the target array to define where to start storing values
  5704. * @returns the current Color4 object
  5705. */
  5706. toArray(array: number[], index?: number): Color4;
  5707. /**
  5708. * Determines equality between Color4 objects
  5709. * @param otherColor defines the second operand
  5710. * @returns true if the rgba values are equal to the given ones
  5711. */
  5712. equals(otherColor: DeepImmutable<Color4>): boolean;
  5713. /**
  5714. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5715. * @param right defines the second operand
  5716. * @returns a new Color4 object
  5717. */
  5718. add(right: DeepImmutable<Color4>): Color4;
  5719. /**
  5720. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5721. * @param right defines the second operand
  5722. * @returns a new Color4 object
  5723. */
  5724. subtract(right: DeepImmutable<Color4>): Color4;
  5725. /**
  5726. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5727. * @param right defines the second operand
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the current Color4 object
  5730. */
  5731. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5732. /**
  5733. * Creates a new Color4 with the current Color4 values multiplied by scale
  5734. * @param scale defines the scaling factor to apply
  5735. * @returns a new Color4 object
  5736. */
  5737. scale(scale: number): Color4;
  5738. /**
  5739. * Multiplies the current Color4 values by scale and stores the result in "result"
  5740. * @param scale defines the scaling factor to apply
  5741. * @param result defines the Color4 object where to store the result
  5742. * @returns the current unmodified Color4
  5743. */
  5744. scaleToRef(scale: number, result: Color4): Color4;
  5745. /**
  5746. * Scale the current Color4 values by a factor and add the result to a given Color4
  5747. * @param scale defines the scale factor
  5748. * @param result defines the Color4 object where to store the result
  5749. * @returns the unmodified current Color4
  5750. */
  5751. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5752. /**
  5753. * Clamps the rgb values by the min and max values and stores the result into "result"
  5754. * @param min defines minimum clamping value (default is 0)
  5755. * @param max defines maximum clamping value (default is 1)
  5756. * @param result defines color to store the result into.
  5757. * @returns the cuurent Color4
  5758. */
  5759. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5760. /**
  5761. * Multipy an Color4 value by another and return a new Color4 object
  5762. * @param color defines the Color4 value to multiply by
  5763. * @returns a new Color4 object
  5764. */
  5765. multiply(color: Color4): Color4;
  5766. /**
  5767. * Multipy a Color4 value by another and push the result in a reference value
  5768. * @param color defines the Color4 value to multiply by
  5769. * @param result defines the Color4 to fill the result in
  5770. * @returns the result Color4
  5771. */
  5772. multiplyToRef(color: Color4, result: Color4): Color4;
  5773. /**
  5774. * Creates a string with the Color4 current values
  5775. * @returns the string representation of the Color4 object
  5776. */
  5777. toString(): string;
  5778. /**
  5779. * Returns the string "Color4"
  5780. * @returns "Color4"
  5781. */
  5782. getClassName(): string;
  5783. /**
  5784. * Compute the Color4 hash code
  5785. * @returns an unique number that can be used to hash Color4 objects
  5786. */
  5787. getHashCode(): number;
  5788. /**
  5789. * Creates a new Color4 copied from the current one
  5790. * @returns a new Color4 object
  5791. */
  5792. clone(): Color4;
  5793. /**
  5794. * Copies the given Color4 values into the current one
  5795. * @param source defines the source Color4 object
  5796. * @returns the current updated Color4 object
  5797. */
  5798. copyFrom(source: Color4): Color4;
  5799. /**
  5800. * Copies the given float values into the current one
  5801. * @param r defines the red component to read from
  5802. * @param g defines the green component to read from
  5803. * @param b defines the blue component to read from
  5804. * @param a defines the alpha component to read from
  5805. * @returns the current updated Color4 object
  5806. */
  5807. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5808. /**
  5809. * Copies the given float values into the current one
  5810. * @param r defines the red component to read from
  5811. * @param g defines the green component to read from
  5812. * @param b defines the blue component to read from
  5813. * @param a defines the alpha component to read from
  5814. * @returns the current updated Color4 object
  5815. */
  5816. set(r: number, g: number, b: number, a: number): Color4;
  5817. /**
  5818. * Compute the Color4 hexadecimal code as a string
  5819. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5820. * @returns a string containing the hexadecimal representation of the Color4 object
  5821. */
  5822. toHexString(returnAsColor3?: boolean): string;
  5823. /**
  5824. * Computes a new Color4 converted from the current one to linear space
  5825. * @returns a new Color4 object
  5826. */
  5827. toLinearSpace(): Color4;
  5828. /**
  5829. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5830. * @param convertedColor defines the Color4 object where to store the linear space version
  5831. * @returns the unmodified Color4
  5832. */
  5833. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5834. /**
  5835. * Computes a new Color4 converted from the current one to gamma space
  5836. * @returns a new Color4 object
  5837. */
  5838. toGammaSpace(): Color4;
  5839. /**
  5840. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5841. * @param convertedColor defines the Color4 object where to store the gamma space version
  5842. * @returns the unmodified Color4
  5843. */
  5844. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5845. /**
  5846. * Creates a new Color4 from the string containing valid hexadecimal values
  5847. * @param hex defines a string containing valid hexadecimal values
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromHexString(hex: string): Color4;
  5851. /**
  5852. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5853. * @param left defines the start value
  5854. * @param right defines the end value
  5855. * @param amount defines the gradient factor
  5856. * @returns a new Color4 object
  5857. */
  5858. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5859. /**
  5860. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5861. * @param left defines the start value
  5862. * @param right defines the end value
  5863. * @param amount defines the gradient factor
  5864. * @param result defines the Color4 object where to store data
  5865. */
  5866. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5867. /**
  5868. * Creates a new Color4 from a Color3 and an alpha value
  5869. * @param color3 defines the source Color3 to read from
  5870. * @param alpha defines the alpha component (1.0 by default)
  5871. * @returns a new Color4 object
  5872. */
  5873. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5874. /**
  5875. * Creates a new Color4 from the starting index element of the given array
  5876. * @param array defines the source array to read from
  5877. * @param offset defines the offset in the source array
  5878. * @returns a new Color4 object
  5879. */
  5880. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5881. /**
  5882. * Creates a new Color3 from integer values (< 256)
  5883. * @param r defines the red component to read from (value between 0 and 255)
  5884. * @param g defines the green component to read from (value between 0 and 255)
  5885. * @param b defines the blue component to read from (value between 0 and 255)
  5886. * @param a defines the alpha component to read from (value between 0 and 255)
  5887. * @returns a new Color3 object
  5888. */
  5889. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5890. /**
  5891. * Check the content of a given array and convert it to an array containing RGBA data
  5892. * If the original array was already containing count * 4 values then it is returned directly
  5893. * @param colors defines the array to check
  5894. * @param count defines the number of RGBA data to expect
  5895. * @returns an array containing count * 4 values (RGBA)
  5896. */
  5897. static CheckColors4(colors: number[], count: number): number[];
  5898. }
  5899. /**
  5900. * @hidden
  5901. */
  5902. export class TmpColors {
  5903. static Color3: Color3[];
  5904. static Color4: Color4[];
  5905. }
  5906. }
  5907. declare module "babylonjs/Animations/animationKey" {
  5908. /**
  5909. * Defines an interface which represents an animation key frame
  5910. */
  5911. export interface IAnimationKey {
  5912. /**
  5913. * Frame of the key frame
  5914. */
  5915. frame: number;
  5916. /**
  5917. * Value at the specifies key frame
  5918. */
  5919. value: any;
  5920. /**
  5921. * The input tangent for the cubic hermite spline
  5922. */
  5923. inTangent?: any;
  5924. /**
  5925. * The output tangent for the cubic hermite spline
  5926. */
  5927. outTangent?: any;
  5928. /**
  5929. * The animation interpolation type
  5930. */
  5931. interpolation?: AnimationKeyInterpolation;
  5932. }
  5933. /**
  5934. * Enum for the animation key frame interpolation type
  5935. */
  5936. export enum AnimationKeyInterpolation {
  5937. /**
  5938. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5939. */
  5940. STEP = 1
  5941. }
  5942. }
  5943. declare module "babylonjs/Animations/animationRange" {
  5944. /**
  5945. * Represents the range of an animation
  5946. */
  5947. export class AnimationRange {
  5948. /**The name of the animation range**/
  5949. name: string;
  5950. /**The starting frame of the animation */
  5951. from: number;
  5952. /**The ending frame of the animation*/
  5953. to: number;
  5954. /**
  5955. * Initializes the range of an animation
  5956. * @param name The name of the animation range
  5957. * @param from The starting frame of the animation
  5958. * @param to The ending frame of the animation
  5959. */
  5960. constructor(
  5961. /**The name of the animation range**/
  5962. name: string,
  5963. /**The starting frame of the animation */
  5964. from: number,
  5965. /**The ending frame of the animation*/
  5966. to: number);
  5967. /**
  5968. * Makes a copy of the animation range
  5969. * @returns A copy of the animation range
  5970. */
  5971. clone(): AnimationRange;
  5972. }
  5973. }
  5974. declare module "babylonjs/Animations/animationEvent" {
  5975. /**
  5976. * Composed of a frame, and an action function
  5977. */
  5978. export class AnimationEvent {
  5979. /** The frame for which the event is triggered **/
  5980. frame: number;
  5981. /** The event to perform when triggered **/
  5982. action: (currentFrame: number) => void;
  5983. /** Specifies if the event should be triggered only once**/
  5984. onlyOnce?: boolean | undefined;
  5985. /**
  5986. * Specifies if the animation event is done
  5987. */
  5988. isDone: boolean;
  5989. /**
  5990. * Initializes the animation event
  5991. * @param frame The frame for which the event is triggered
  5992. * @param action The event to perform when triggered
  5993. * @param onlyOnce Specifies if the event should be triggered only once
  5994. */
  5995. constructor(
  5996. /** The frame for which the event is triggered **/
  5997. frame: number,
  5998. /** The event to perform when triggered **/
  5999. action: (currentFrame: number) => void,
  6000. /** Specifies if the event should be triggered only once**/
  6001. onlyOnce?: boolean | undefined);
  6002. /** @hidden */
  6003. _clone(): AnimationEvent;
  6004. }
  6005. }
  6006. declare module "babylonjs/Behaviors/behavior" {
  6007. import { Nullable } from "babylonjs/types";
  6008. /**
  6009. * Interface used to define a behavior
  6010. */
  6011. export interface Behavior<T> {
  6012. /** gets or sets behavior's name */
  6013. name: string;
  6014. /**
  6015. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6016. */
  6017. init(): void;
  6018. /**
  6019. * Called when the behavior is attached to a target
  6020. * @param target defines the target where the behavior is attached to
  6021. */
  6022. attach(target: T): void;
  6023. /**
  6024. * Called when the behavior is detached from its target
  6025. */
  6026. detach(): void;
  6027. }
  6028. /**
  6029. * Interface implemented by classes supporting behaviors
  6030. */
  6031. export interface IBehaviorAware<T> {
  6032. /**
  6033. * Attach a behavior
  6034. * @param behavior defines the behavior to attach
  6035. * @returns the current host
  6036. */
  6037. addBehavior(behavior: Behavior<T>): T;
  6038. /**
  6039. * Remove a behavior from the current object
  6040. * @param behavior defines the behavior to detach
  6041. * @returns the current host
  6042. */
  6043. removeBehavior(behavior: Behavior<T>): T;
  6044. /**
  6045. * Gets a behavior using its name to search
  6046. * @param name defines the name to search
  6047. * @returns the behavior or null if not found
  6048. */
  6049. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6050. }
  6051. }
  6052. declare module "babylonjs/Misc/smartArray" {
  6053. /**
  6054. * Defines an array and its length.
  6055. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6056. */
  6057. export interface ISmartArrayLike<T> {
  6058. /**
  6059. * The data of the array.
  6060. */
  6061. data: Array<T>;
  6062. /**
  6063. * The active length of the array.
  6064. */
  6065. length: number;
  6066. }
  6067. /**
  6068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6069. */
  6070. export class SmartArray<T> implements ISmartArrayLike<T> {
  6071. /**
  6072. * The full set of data from the array.
  6073. */
  6074. data: Array<T>;
  6075. /**
  6076. * The active length of the array.
  6077. */
  6078. length: number;
  6079. protected _id: number;
  6080. /**
  6081. * Instantiates a Smart Array.
  6082. * @param capacity defines the default capacity of the array.
  6083. */
  6084. constructor(capacity: number);
  6085. /**
  6086. * Pushes a value at the end of the active data.
  6087. * @param value defines the object to push in the array.
  6088. */
  6089. push(value: T): void;
  6090. /**
  6091. * Iterates over the active data and apply the lambda to them.
  6092. * @param func defines the action to apply on each value.
  6093. */
  6094. forEach(func: (content: T) => void): void;
  6095. /**
  6096. * Sorts the full sets of data.
  6097. * @param compareFn defines the comparison function to apply.
  6098. */
  6099. sort(compareFn: (a: T, b: T) => number): void;
  6100. /**
  6101. * Resets the active data to an empty array.
  6102. */
  6103. reset(): void;
  6104. /**
  6105. * Releases all the data from the array as well as the array.
  6106. */
  6107. dispose(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * @param array defines the data to concatenate with.
  6111. */
  6112. concat(array: any): void;
  6113. /**
  6114. * Returns the position of a value in the active data.
  6115. * @param value defines the value to find the index for
  6116. * @returns the index if found in the active data otherwise -1
  6117. */
  6118. indexOf(value: T): number;
  6119. /**
  6120. * Returns whether an element is part of the active data.
  6121. * @param value defines the value to look for
  6122. * @returns true if found in the active data otherwise false
  6123. */
  6124. contains(value: T): boolean;
  6125. private static _GlobalId;
  6126. }
  6127. /**
  6128. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6129. * The data in this array can only be present once
  6130. */
  6131. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6132. private _duplicateId;
  6133. /**
  6134. * Pushes a value at the end of the active data.
  6135. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6136. * @param value defines the object to push in the array.
  6137. */
  6138. push(value: T): void;
  6139. /**
  6140. * Pushes a value at the end of the active data.
  6141. * If the data is already present, it won t be added again
  6142. * @param value defines the object to push in the array.
  6143. * @returns true if added false if it was already present
  6144. */
  6145. pushNoDuplicate(value: T): boolean;
  6146. /**
  6147. * Resets the active data to an empty array.
  6148. */
  6149. reset(): void;
  6150. /**
  6151. * Concats the active data with a given array.
  6152. * This ensures no dupplicate will be present in the result.
  6153. * @param array defines the data to concatenate with.
  6154. */
  6155. concatWithNoDuplicate(array: any): void;
  6156. }
  6157. }
  6158. declare module "babylonjs/Cameras/cameraInputsManager" {
  6159. import { Nullable } from "babylonjs/types";
  6160. import { Camera } from "babylonjs/Cameras/camera";
  6161. /**
  6162. * @ignore
  6163. * This is a list of all the different input types that are available in the application.
  6164. * Fo instance: ArcRotateCameraGamepadInput...
  6165. */
  6166. export var CameraInputTypes: {};
  6167. /**
  6168. * This is the contract to implement in order to create a new input class.
  6169. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6170. */
  6171. export interface ICameraInput<TCamera extends Camera> {
  6172. /**
  6173. * Defines the camera the input is attached to.
  6174. */
  6175. camera: Nullable<TCamera>;
  6176. /**
  6177. * Gets the class name of the current intput.
  6178. * @returns the class name
  6179. */
  6180. getClassName(): string;
  6181. /**
  6182. * Get the friendly name associated with the input class.
  6183. * @returns the input friendly name
  6184. */
  6185. getSimpleName(): string;
  6186. /**
  6187. * Attach the input controls to a specific dom element to get the input from.
  6188. * @param element Defines the element the controls should be listened from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current controls from the specified dom element.
  6194. * @param element Defines the element to stop listening the inputs from
  6195. */
  6196. detachControl(element: Nullable<HTMLElement>): void;
  6197. /**
  6198. * Update the current camera state depending on the inputs that have been used this frame.
  6199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6200. */
  6201. checkInputs?: () => void;
  6202. }
  6203. /**
  6204. * Represents a map of input types to input instance or input index to input instance.
  6205. */
  6206. export interface CameraInputsMap<TCamera extends Camera> {
  6207. /**
  6208. * Accessor to the input by input type.
  6209. */
  6210. [name: string]: ICameraInput<TCamera>;
  6211. /**
  6212. * Accessor to the input by input index.
  6213. */
  6214. [idx: number]: ICameraInput<TCamera>;
  6215. }
  6216. /**
  6217. * This represents the input manager used within a camera.
  6218. * It helps dealing with all the different kind of input attached to a camera.
  6219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6220. */
  6221. export class CameraInputsManager<TCamera extends Camera> {
  6222. /**
  6223. * Defines the list of inputs attahed to the camera.
  6224. */
  6225. attached: CameraInputsMap<TCamera>;
  6226. /**
  6227. * Defines the dom element the camera is collecting inputs from.
  6228. * This is null if the controls have not been attached.
  6229. */
  6230. attachedElement: Nullable<HTMLElement>;
  6231. /**
  6232. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. noPreventDefault: boolean;
  6235. /**
  6236. * Defined the camera the input manager belongs to.
  6237. */
  6238. camera: TCamera;
  6239. /**
  6240. * Update the current camera state depending on the inputs that have been used this frame.
  6241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6242. */
  6243. checkInputs: () => void;
  6244. /**
  6245. * Instantiate a new Camera Input Manager.
  6246. * @param camera Defines the camera the input manager blongs to
  6247. */
  6248. constructor(camera: TCamera);
  6249. /**
  6250. * Add an input method to a camera
  6251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6252. * @param input camera input method
  6253. */
  6254. add(input: ICameraInput<TCamera>): void;
  6255. /**
  6256. * Remove a specific input method from a camera
  6257. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6258. * @param inputToRemove camera input method
  6259. */
  6260. remove(inputToRemove: ICameraInput<TCamera>): void;
  6261. /**
  6262. * Remove a specific input type from a camera
  6263. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6264. * @param inputType the type of the input to remove
  6265. */
  6266. removeByType(inputType: string): void;
  6267. private _addCheckInputs;
  6268. /**
  6269. * Attach the input controls to the currently attached dom element to listen the events from.
  6270. * @param input Defines the input to attach
  6271. */
  6272. attachInput(input: ICameraInput<TCamera>): void;
  6273. /**
  6274. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6275. * @param element Defines the dom element to collect the events from
  6276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6277. */
  6278. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6279. /**
  6280. * Detach the current manager inputs controls from a specific dom element.
  6281. * @param element Defines the dom element to collect the events from
  6282. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6283. */
  6284. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6285. /**
  6286. * Rebuild the dynamic inputCheck function from the current list of
  6287. * defined inputs in the manager.
  6288. */
  6289. rebuildInputCheck(): void;
  6290. /**
  6291. * Remove all attached input methods from a camera
  6292. */
  6293. clear(): void;
  6294. /**
  6295. * Serialize the current input manager attached to a camera.
  6296. * This ensures than once parsed,
  6297. * the input associated to the camera will be identical to the current ones
  6298. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6299. */
  6300. serialize(serializedCamera: any): void;
  6301. /**
  6302. * Parses an input manager serialized JSON to restore the previous list of inputs
  6303. * and states associated to a camera.
  6304. * @param parsedCamera Defines the JSON to parse
  6305. */
  6306. parse(parsedCamera: any): void;
  6307. }
  6308. }
  6309. declare module "babylonjs/Meshes/buffer" {
  6310. import { Nullable, DataArray } from "babylonjs/types";
  6311. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6312. /**
  6313. * Class used to store data that will be store in GPU memory
  6314. */
  6315. export class Buffer {
  6316. private _engine;
  6317. private _buffer;
  6318. /** @hidden */
  6319. _data: Nullable<DataArray>;
  6320. private _updatable;
  6321. private _instanced;
  6322. private _divisor;
  6323. /**
  6324. * Gets the byte stride.
  6325. */
  6326. readonly byteStride: number;
  6327. /**
  6328. * Constructor
  6329. * @param engine the engine
  6330. * @param data the data to use for this buffer
  6331. * @param updatable whether the data is updatable
  6332. * @param stride the stride (optional)
  6333. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6334. * @param instanced whether the buffer is instanced (optional)
  6335. * @param useBytes set to true if the stride in in bytes (optional)
  6336. * @param divisor sets an optional divisor for instances (1 by default)
  6337. */
  6338. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6339. /**
  6340. * Create a new VertexBuffer based on the current buffer
  6341. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6342. * @param offset defines offset in the buffer (0 by default)
  6343. * @param size defines the size in floats of attributes (position is 3 for instance)
  6344. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6345. * @param instanced defines if the vertex buffer contains indexed data
  6346. * @param useBytes defines if the offset and stride are in bytes *
  6347. * @param divisor sets an optional divisor for instances (1 by default)
  6348. * @returns the new vertex buffer
  6349. */
  6350. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6351. /**
  6352. * Gets a boolean indicating if the Buffer is updatable?
  6353. * @returns true if the buffer is updatable
  6354. */
  6355. isUpdatable(): boolean;
  6356. /**
  6357. * Gets current buffer's data
  6358. * @returns a DataArray or null
  6359. */
  6360. getData(): Nullable<DataArray>;
  6361. /**
  6362. * Gets underlying native buffer
  6363. * @returns underlying native buffer
  6364. */
  6365. getBuffer(): Nullable<DataBuffer>;
  6366. /**
  6367. * Gets the stride in float32 units (i.e. byte stride / 4).
  6368. * May not be an integer if the byte stride is not divisible by 4.
  6369. * @returns the stride in float32 units
  6370. * @deprecated Please use byteStride instead.
  6371. */
  6372. getStrideSize(): number;
  6373. /**
  6374. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6375. * @param data defines the data to store
  6376. */
  6377. create(data?: Nullable<DataArray>): void;
  6378. /** @hidden */
  6379. _rebuild(): void;
  6380. /**
  6381. * Update current buffer data
  6382. * @param data defines the data to store
  6383. */
  6384. update(data: DataArray): void;
  6385. /**
  6386. * Updates the data directly.
  6387. * @param data the new data
  6388. * @param offset the new offset
  6389. * @param vertexCount the vertex count (optional)
  6390. * @param useBytes set to true if the offset is in bytes
  6391. */
  6392. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6393. /**
  6394. * Release all resources
  6395. */
  6396. dispose(): void;
  6397. }
  6398. /**
  6399. * Specialized buffer used to store vertex data
  6400. */
  6401. export class VertexBuffer {
  6402. /** @hidden */
  6403. _buffer: Buffer;
  6404. private _kind;
  6405. private _size;
  6406. private _ownsBuffer;
  6407. private _instanced;
  6408. private _instanceDivisor;
  6409. /**
  6410. * The byte type.
  6411. */
  6412. static readonly BYTE: number;
  6413. /**
  6414. * The unsigned byte type.
  6415. */
  6416. static readonly UNSIGNED_BYTE: number;
  6417. /**
  6418. * The short type.
  6419. */
  6420. static readonly SHORT: number;
  6421. /**
  6422. * The unsigned short type.
  6423. */
  6424. static readonly UNSIGNED_SHORT: number;
  6425. /**
  6426. * The integer type.
  6427. */
  6428. static readonly INT: number;
  6429. /**
  6430. * The unsigned integer type.
  6431. */
  6432. static readonly UNSIGNED_INT: number;
  6433. /**
  6434. * The float type.
  6435. */
  6436. static readonly FLOAT: number;
  6437. /**
  6438. * Gets or sets the instance divisor when in instanced mode
  6439. */
  6440. get instanceDivisor(): number;
  6441. set instanceDivisor(value: number);
  6442. /**
  6443. * Gets the byte stride.
  6444. */
  6445. readonly byteStride: number;
  6446. /**
  6447. * Gets the byte offset.
  6448. */
  6449. readonly byteOffset: number;
  6450. /**
  6451. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6452. */
  6453. readonly normalized: boolean;
  6454. /**
  6455. * Gets the data type of each component in the array.
  6456. */
  6457. readonly type: number;
  6458. /**
  6459. * Constructor
  6460. * @param engine the engine
  6461. * @param data the data to use for this vertex buffer
  6462. * @param kind the vertex buffer kind
  6463. * @param updatable whether the data is updatable
  6464. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6465. * @param stride the stride (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param offset the offset of the data (optional)
  6468. * @param size the number of components (optional)
  6469. * @param type the type of the component (optional)
  6470. * @param normalized whether the data contains normalized data (optional)
  6471. * @param useBytes set to true if stride and offset are in bytes (optional)
  6472. * @param divisor defines the instance divisor to use (1 by default)
  6473. */
  6474. 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);
  6475. /** @hidden */
  6476. _rebuild(): void;
  6477. /**
  6478. * Returns the kind of the VertexBuffer (string)
  6479. * @returns a string
  6480. */
  6481. getKind(): string;
  6482. /**
  6483. * Gets a boolean indicating if the VertexBuffer is updatable?
  6484. * @returns true if the buffer is updatable
  6485. */
  6486. isUpdatable(): boolean;
  6487. /**
  6488. * Gets current buffer's data
  6489. * @returns a DataArray or null
  6490. */
  6491. getData(): Nullable<DataArray>;
  6492. /**
  6493. * Gets underlying native buffer
  6494. * @returns underlying native buffer
  6495. */
  6496. getBuffer(): Nullable<DataBuffer>;
  6497. /**
  6498. * Gets the stride in float32 units (i.e. byte stride / 4).
  6499. * May not be an integer if the byte stride is not divisible by 4.
  6500. * @returns the stride in float32 units
  6501. * @deprecated Please use byteStride instead.
  6502. */
  6503. getStrideSize(): number;
  6504. /**
  6505. * Returns the offset as a multiple of the type byte length.
  6506. * @returns the offset in bytes
  6507. * @deprecated Please use byteOffset instead.
  6508. */
  6509. getOffset(): number;
  6510. /**
  6511. * Returns the number of components per vertex attribute (integer)
  6512. * @returns the size in float
  6513. */
  6514. getSize(): number;
  6515. /**
  6516. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6517. * @returns true if this buffer is instanced
  6518. */
  6519. getIsInstanced(): boolean;
  6520. /**
  6521. * Returns the instancing divisor, zero for non-instanced (integer).
  6522. * @returns a number
  6523. */
  6524. getInstanceDivisor(): number;
  6525. /**
  6526. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6527. * @param data defines the data to store
  6528. */
  6529. create(data?: DataArray): void;
  6530. /**
  6531. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6532. * This function will create a new buffer if the current one is not updatable
  6533. * @param data defines the data to store
  6534. */
  6535. update(data: DataArray): void;
  6536. /**
  6537. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6538. * Returns the directly updated WebGLBuffer.
  6539. * @param data the new data
  6540. * @param offset the new offset
  6541. * @param useBytes set to true if the offset is in bytes
  6542. */
  6543. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6544. /**
  6545. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6546. */
  6547. dispose(): void;
  6548. /**
  6549. * Enumerates each value of this vertex buffer as numbers.
  6550. * @param count the number of values to enumerate
  6551. * @param callback the callback function called for each value
  6552. */
  6553. forEach(count: number, callback: (value: number, index: number) => void): void;
  6554. /**
  6555. * Positions
  6556. */
  6557. static readonly PositionKind: string;
  6558. /**
  6559. * Normals
  6560. */
  6561. static readonly NormalKind: string;
  6562. /**
  6563. * Tangents
  6564. */
  6565. static readonly TangentKind: string;
  6566. /**
  6567. * Texture coordinates
  6568. */
  6569. static readonly UVKind: string;
  6570. /**
  6571. * Texture coordinates 2
  6572. */
  6573. static readonly UV2Kind: string;
  6574. /**
  6575. * Texture coordinates 3
  6576. */
  6577. static readonly UV3Kind: string;
  6578. /**
  6579. * Texture coordinates 4
  6580. */
  6581. static readonly UV4Kind: string;
  6582. /**
  6583. * Texture coordinates 5
  6584. */
  6585. static readonly UV5Kind: string;
  6586. /**
  6587. * Texture coordinates 6
  6588. */
  6589. static readonly UV6Kind: string;
  6590. /**
  6591. * Colors
  6592. */
  6593. static readonly ColorKind: string;
  6594. /**
  6595. * Matrix indices (for bones)
  6596. */
  6597. static readonly MatricesIndicesKind: string;
  6598. /**
  6599. * Matrix weights (for bones)
  6600. */
  6601. static readonly MatricesWeightsKind: string;
  6602. /**
  6603. * Additional matrix indices (for bones)
  6604. */
  6605. static readonly MatricesIndicesExtraKind: string;
  6606. /**
  6607. * Additional matrix weights (for bones)
  6608. */
  6609. static readonly MatricesWeightsExtraKind: string;
  6610. /**
  6611. * Deduces the stride given a kind.
  6612. * @param kind The kind string to deduce
  6613. * @returns The deduced stride
  6614. */
  6615. static DeduceStride(kind: string): number;
  6616. /**
  6617. * Gets the byte length of the given type.
  6618. * @param type the type
  6619. * @returns the number of bytes
  6620. */
  6621. static GetTypeByteLength(type: number): number;
  6622. /**
  6623. * Enumerates each value of the given parameters as numbers.
  6624. * @param data the data to enumerate
  6625. * @param byteOffset the byte offset of the data
  6626. * @param byteStride the byte stride of the data
  6627. * @param componentCount the number of components per element
  6628. * @param componentType the type of the component
  6629. * @param count the number of values to enumerate
  6630. * @param normalized whether the data is normalized
  6631. * @param callback the callback function called for each value
  6632. */
  6633. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6634. private static _GetFloatValue;
  6635. }
  6636. }
  6637. declare module "babylonjs/Collisions/intersectionInfo" {
  6638. import { Nullable } from "babylonjs/types";
  6639. /**
  6640. * @hidden
  6641. */
  6642. export class IntersectionInfo {
  6643. bu: Nullable<number>;
  6644. bv: Nullable<number>;
  6645. distance: number;
  6646. faceId: number;
  6647. subMeshId: number;
  6648. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6649. }
  6650. }
  6651. declare module "babylonjs/Maths/math.plane" {
  6652. import { DeepImmutable } from "babylonjs/types";
  6653. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6654. /**
  6655. * Represens a plane by the equation ax + by + cz + d = 0
  6656. */
  6657. export class Plane {
  6658. private static _TmpMatrix;
  6659. /**
  6660. * Normal of the plane (a,b,c)
  6661. */
  6662. normal: Vector3;
  6663. /**
  6664. * d component of the plane
  6665. */
  6666. d: number;
  6667. /**
  6668. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6669. * @param a a component of the plane
  6670. * @param b b component of the plane
  6671. * @param c c component of the plane
  6672. * @param d d component of the plane
  6673. */
  6674. constructor(a: number, b: number, c: number, d: number);
  6675. /**
  6676. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6677. */
  6678. asArray(): number[];
  6679. /**
  6680. * @returns a new plane copied from the current Plane.
  6681. */
  6682. clone(): Plane;
  6683. /**
  6684. * @returns the string "Plane".
  6685. */
  6686. getClassName(): string;
  6687. /**
  6688. * @returns the Plane hash code.
  6689. */
  6690. getHashCode(): number;
  6691. /**
  6692. * Normalize the current Plane in place.
  6693. * @returns the updated Plane.
  6694. */
  6695. normalize(): Plane;
  6696. /**
  6697. * Applies a transformation the plane and returns the result
  6698. * @param transformation the transformation matrix to be applied to the plane
  6699. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6700. */
  6701. transform(transformation: DeepImmutable<Matrix>): Plane;
  6702. /**
  6703. * Calcualtte the dot product between the point and the plane normal
  6704. * @param point point to calculate the dot product with
  6705. * @returns the dot product (float) of the point coordinates and the plane normal.
  6706. */
  6707. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Updates the current Plane from the plane defined by the three given points.
  6710. * @param point1 one of the points used to contruct the plane
  6711. * @param point2 one of the points used to contruct the plane
  6712. * @param point3 one of the points used to contruct the plane
  6713. * @returns the updated Plane.
  6714. */
  6715. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6716. /**
  6717. * Checks if the plane is facing a given direction
  6718. * @param direction the direction to check if the plane is facing
  6719. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6720. * @returns True is the vector "direction" is the same side than the plane normal.
  6721. */
  6722. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6723. /**
  6724. * Calculates the distance to a point
  6725. * @param point point to calculate distance to
  6726. * @returns the signed distance (float) from the given point to the Plane.
  6727. */
  6728. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6729. /**
  6730. * Creates a plane from an array
  6731. * @param array the array to create a plane from
  6732. * @returns a new Plane from the given array.
  6733. */
  6734. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6735. /**
  6736. * Creates a plane from three points
  6737. * @param point1 point used to create the plane
  6738. * @param point2 point used to create the plane
  6739. * @param point3 point used to create the plane
  6740. * @returns a new Plane defined by the three given points.
  6741. */
  6742. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6743. /**
  6744. * Creates a plane from an origin point and a normal
  6745. * @param origin origin of the plane to be constructed
  6746. * @param normal normal of the plane to be constructed
  6747. * @returns a new Plane the normal vector to this plane at the given origin point.
  6748. * Note : the vector "normal" is updated because normalized.
  6749. */
  6750. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6751. /**
  6752. * Calculates the distance from a plane and a point
  6753. * @param origin origin of the plane to be constructed
  6754. * @param normal normal of the plane to be constructed
  6755. * @param point point to calculate distance to
  6756. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6757. */
  6758. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6759. }
  6760. }
  6761. declare module "babylonjs/Culling/boundingSphere" {
  6762. import { DeepImmutable } from "babylonjs/types";
  6763. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6764. import { Plane } from "babylonjs/Maths/math.plane";
  6765. /**
  6766. * Class used to store bounding sphere information
  6767. */
  6768. export class BoundingSphere {
  6769. /**
  6770. * Gets the center of the bounding sphere in local space
  6771. */
  6772. readonly center: Vector3;
  6773. /**
  6774. * Radius of the bounding sphere in local space
  6775. */
  6776. radius: number;
  6777. /**
  6778. * Gets the center of the bounding sphere in world space
  6779. */
  6780. readonly centerWorld: Vector3;
  6781. /**
  6782. * Radius of the bounding sphere in world space
  6783. */
  6784. radiusWorld: number;
  6785. /**
  6786. * Gets the minimum vector in local space
  6787. */
  6788. readonly minimum: Vector3;
  6789. /**
  6790. * Gets the maximum vector in local space
  6791. */
  6792. readonly maximum: Vector3;
  6793. private _worldMatrix;
  6794. private static readonly TmpVector3;
  6795. /**
  6796. * Creates a new bounding sphere
  6797. * @param min defines the minimum vector (in local space)
  6798. * @param max defines the maximum vector (in local space)
  6799. * @param worldMatrix defines the new world matrix
  6800. */
  6801. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6802. /**
  6803. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6804. * @param min defines the new minimum vector (in local space)
  6805. * @param max defines the new maximum vector (in local space)
  6806. * @param worldMatrix defines the new world matrix
  6807. */
  6808. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6809. /**
  6810. * Scale the current bounding sphere by applying a scale factor
  6811. * @param factor defines the scale factor to apply
  6812. * @returns the current bounding box
  6813. */
  6814. scale(factor: number): BoundingSphere;
  6815. /**
  6816. * Gets the world matrix of the bounding box
  6817. * @returns a matrix
  6818. */
  6819. getWorldMatrix(): DeepImmutable<Matrix>;
  6820. /** @hidden */
  6821. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6822. /**
  6823. * Tests if the bounding sphere is intersecting the frustum planes
  6824. * @param frustumPlanes defines the frustum planes to test
  6825. * @returns true if there is an intersection
  6826. */
  6827. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6828. /**
  6829. * Tests if the bounding sphere center is in between the frustum planes.
  6830. * Used for optimistic fast inclusion.
  6831. * @param frustumPlanes defines the frustum planes to test
  6832. * @returns true if the sphere center is in between the frustum planes
  6833. */
  6834. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6835. /**
  6836. * Tests if a point is inside the bounding sphere
  6837. * @param point defines the point to test
  6838. * @returns true if the point is inside the bounding sphere
  6839. */
  6840. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6841. /**
  6842. * Checks if two sphere intersct
  6843. * @param sphere0 sphere 0
  6844. * @param sphere1 sphere 1
  6845. * @returns true if the speres intersect
  6846. */
  6847. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6848. }
  6849. }
  6850. declare module "babylonjs/Culling/boundingBox" {
  6851. import { DeepImmutable } from "babylonjs/types";
  6852. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6853. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6854. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6855. import { Plane } from "babylonjs/Maths/math.plane";
  6856. /**
  6857. * Class used to store bounding box information
  6858. */
  6859. export class BoundingBox implements ICullable {
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in local space
  6862. */
  6863. readonly vectors: Vector3[];
  6864. /**
  6865. * Gets the center of the bounding box in local space
  6866. */
  6867. readonly center: Vector3;
  6868. /**
  6869. * Gets the center of the bounding box in world space
  6870. */
  6871. readonly centerWorld: Vector3;
  6872. /**
  6873. * Gets the extend size in local space
  6874. */
  6875. readonly extendSize: Vector3;
  6876. /**
  6877. * Gets the extend size in world space
  6878. */
  6879. readonly extendSizeWorld: Vector3;
  6880. /**
  6881. * Gets the OBB (object bounding box) directions
  6882. */
  6883. readonly directions: Vector3[];
  6884. /**
  6885. * Gets the 8 vectors representing the bounding box in world space
  6886. */
  6887. readonly vectorsWorld: Vector3[];
  6888. /**
  6889. * Gets the minimum vector in world space
  6890. */
  6891. readonly minimumWorld: Vector3;
  6892. /**
  6893. * Gets the maximum vector in world space
  6894. */
  6895. readonly maximumWorld: Vector3;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * @hidden
  6908. */
  6909. _tag: number;
  6910. /**
  6911. * Creates a new bounding box
  6912. * @param min defines the minimum vector (in local space)
  6913. * @param max defines the maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6917. /**
  6918. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6919. * @param min defines the new minimum vector (in local space)
  6920. * @param max defines the new maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6924. /**
  6925. * Scale the current bounding box by applying a scale factor
  6926. * @param factor defines the scale factor to apply
  6927. * @returns the current bounding box
  6928. */
  6929. scale(factor: number): BoundingBox;
  6930. /**
  6931. * Gets the world matrix of the bounding box
  6932. * @returns a matrix
  6933. */
  6934. getWorldMatrix(): DeepImmutable<Matrix>;
  6935. /** @hidden */
  6936. _update(world: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Tests if the bounding box is intersecting the frustum planes
  6939. * @param frustumPlanes defines the frustum planes to test
  6940. * @returns true if there is an intersection
  6941. */
  6942. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /**
  6944. * Tests if the bounding box is entirely inside the frustum planes
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if there is an inclusion
  6947. */
  6948. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding box
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding box
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Tests if the bounding box intersects with a bounding sphere
  6957. * @param sphere defines the sphere to test
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6961. /**
  6962. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6963. * @param min defines the min vector to use
  6964. * @param max defines the max vector to use
  6965. * @returns true if there is an intersection
  6966. */
  6967. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6968. /**
  6969. * Tests if two bounding boxes are intersections
  6970. * @param box0 defines the first box to test
  6971. * @param box1 defines the second box to test
  6972. * @returns true if there is an intersection
  6973. */
  6974. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6975. /**
  6976. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6977. * @param minPoint defines the minimum vector of the bounding box
  6978. * @param maxPoint defines the maximum vector of the bounding box
  6979. * @param sphereCenter defines the sphere center
  6980. * @param sphereRadius defines the sphere radius
  6981. * @returns true if there is an intersection
  6982. */
  6983. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an inclusion
  6989. */
  6990. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. /**
  6992. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6993. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6994. * @param frustumPlanes defines the frustum planes to test
  6995. * @return true if there is an intersection
  6996. */
  6997. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Collisions/collider" {
  7001. import { Nullable, IndicesArray } from "babylonjs/types";
  7002. import { Vector3 } from "babylonjs/Maths/math.vector";
  7003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7004. import { Plane } from "babylonjs/Maths/math.plane";
  7005. /** @hidden */
  7006. export class Collider {
  7007. /** Define if a collision was found */
  7008. collisionFound: boolean;
  7009. /**
  7010. * Define last intersection point in local space
  7011. */
  7012. intersectionPoint: Vector3;
  7013. /**
  7014. * Define last collided mesh
  7015. */
  7016. collidedMesh: Nullable<AbstractMesh>;
  7017. private _collisionPoint;
  7018. private _planeIntersectionPoint;
  7019. private _tempVector;
  7020. private _tempVector2;
  7021. private _tempVector3;
  7022. private _tempVector4;
  7023. private _edge;
  7024. private _baseToVertex;
  7025. private _destinationPoint;
  7026. private _slidePlaneNormal;
  7027. private _displacementVector;
  7028. /** @hidden */
  7029. _radius: Vector3;
  7030. /** @hidden */
  7031. _retry: number;
  7032. private _velocity;
  7033. private _basePoint;
  7034. private _epsilon;
  7035. /** @hidden */
  7036. _velocityWorldLength: number;
  7037. /** @hidden */
  7038. _basePointWorld: Vector3;
  7039. private _velocityWorld;
  7040. private _normalizedVelocity;
  7041. /** @hidden */
  7042. _initialVelocity: Vector3;
  7043. /** @hidden */
  7044. _initialPosition: Vector3;
  7045. private _nearestDistance;
  7046. private _collisionMask;
  7047. get collisionMask(): number;
  7048. set collisionMask(mask: number);
  7049. /**
  7050. * Gets the plane normal used to compute the sliding response (in local space)
  7051. */
  7052. get slidePlaneNormal(): Vector3;
  7053. /** @hidden */
  7054. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7055. /** @hidden */
  7056. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7057. /** @hidden */
  7058. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7059. /** @hidden */
  7060. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7061. /** @hidden */
  7062. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7063. /** @hidden */
  7064. _getResponse(pos: Vector3, vel: Vector3): void;
  7065. }
  7066. }
  7067. declare module "babylonjs/Culling/boundingInfo" {
  7068. import { DeepImmutable } from "babylonjs/types";
  7069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7070. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7071. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7072. import { Plane } from "babylonjs/Maths/math.plane";
  7073. import { Collider } from "babylonjs/Collisions/collider";
  7074. /**
  7075. * Interface for cullable objects
  7076. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7077. */
  7078. export interface ICullable {
  7079. /**
  7080. * Checks if the object or part of the object is in the frustum
  7081. * @param frustumPlanes Camera near/planes
  7082. * @returns true if the object is in frustum otherwise false
  7083. */
  7084. isInFrustum(frustumPlanes: Plane[]): boolean;
  7085. /**
  7086. * Checks if a cullable object (mesh...) is in the camera frustum
  7087. * Unlike isInFrustum this cheks the full bounding box
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7092. }
  7093. /**
  7094. * Info for a bounding data of a mesh
  7095. */
  7096. export class BoundingInfo implements ICullable {
  7097. /**
  7098. * Bounding box for the mesh
  7099. */
  7100. readonly boundingBox: BoundingBox;
  7101. /**
  7102. * Bounding sphere for the mesh
  7103. */
  7104. readonly boundingSphere: BoundingSphere;
  7105. private _isLocked;
  7106. private static readonly TmpVector3;
  7107. /**
  7108. * Constructs bounding info
  7109. * @param minimum min vector of the bounding box/sphere
  7110. * @param maximum max vector of the bounding box/sphere
  7111. * @param worldMatrix defines the new world matrix
  7112. */
  7113. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7114. /**
  7115. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7116. * @param min defines the new minimum vector (in local space)
  7117. * @param max defines the new maximum vector (in local space)
  7118. * @param worldMatrix defines the new world matrix
  7119. */
  7120. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7121. /**
  7122. * min vector of the bounding box/sphere
  7123. */
  7124. get minimum(): Vector3;
  7125. /**
  7126. * max vector of the bounding box/sphere
  7127. */
  7128. get maximum(): Vector3;
  7129. /**
  7130. * If the info is locked and won't be updated to avoid perf overhead
  7131. */
  7132. get isLocked(): boolean;
  7133. set isLocked(value: boolean);
  7134. /**
  7135. * Updates the bounding sphere and box
  7136. * @param world world matrix to be used to update
  7137. */
  7138. update(world: DeepImmutable<Matrix>): void;
  7139. /**
  7140. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7141. * @param center New center of the bounding info
  7142. * @param extend New extend of the bounding info
  7143. * @returns the current bounding info
  7144. */
  7145. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7146. /**
  7147. * Scale the current bounding info by applying a scale factor
  7148. * @param factor defines the scale factor to apply
  7149. * @returns the current bounding info
  7150. */
  7151. scale(factor: number): BoundingInfo;
  7152. /**
  7153. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7154. * @param frustumPlanes defines the frustum to test
  7155. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7156. * @returns true if the bounding info is in the frustum planes
  7157. */
  7158. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7159. /**
  7160. * Gets the world distance between the min and max points of the bounding box
  7161. */
  7162. get diagonalLength(): number;
  7163. /**
  7164. * Checks if a cullable object (mesh...) is in the camera frustum
  7165. * Unlike isInFrustum this cheks the full bounding box
  7166. * @param frustumPlanes Camera near/planes
  7167. * @returns true if the object is in frustum otherwise false
  7168. */
  7169. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7170. /** @hidden */
  7171. _checkCollision(collider: Collider): boolean;
  7172. /**
  7173. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7174. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7175. * @param point the point to check intersection with
  7176. * @returns if the point intersects
  7177. */
  7178. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7179. /**
  7180. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7181. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7182. * @param boundingInfo the bounding info to check intersection with
  7183. * @param precise if the intersection should be done using OBB
  7184. * @returns if the bounding info intersects
  7185. */
  7186. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7187. }
  7188. }
  7189. declare module "babylonjs/Maths/math.functions" {
  7190. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7191. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7192. /**
  7193. * Extracts minimum and maximum values from a list of indexed positions
  7194. * @param positions defines the positions to use
  7195. * @param indices defines the indices to the positions
  7196. * @param indexStart defines the start index
  7197. * @param indexCount defines the end index
  7198. * @param bias defines bias value to add to the result
  7199. * @return minimum and maximum values
  7200. */
  7201. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7202. minimum: Vector3;
  7203. maximum: Vector3;
  7204. };
  7205. /**
  7206. * Extracts minimum and maximum values from a list of positions
  7207. * @param positions defines the positions to use
  7208. * @param start defines the start index in the positions array
  7209. * @param count defines the number of positions to handle
  7210. * @param bias defines bias value to add to the result
  7211. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. }
  7219. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7221. /** @hidden */
  7222. export class WebGLDataBuffer extends DataBuffer {
  7223. private _buffer;
  7224. constructor(resource: WebGLBuffer);
  7225. get underlyingResource(): any;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7229. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7230. import { Nullable } from "babylonjs/types";
  7231. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7232. /** @hidden */
  7233. export class WebGLPipelineContext implements IPipelineContext {
  7234. engine: ThinEngine;
  7235. program: Nullable<WebGLProgram>;
  7236. context?: WebGLRenderingContext;
  7237. vertexShader?: WebGLShader;
  7238. fragmentShader?: WebGLShader;
  7239. isParallelCompiled: boolean;
  7240. onCompiled?: () => void;
  7241. transformFeedback?: WebGLTransformFeedback | null;
  7242. vertexCompilationError: Nullable<string>;
  7243. fragmentCompilationError: Nullable<string>;
  7244. programLinkError: Nullable<string>;
  7245. programValidationError: Nullable<string>;
  7246. get isAsync(): boolean;
  7247. get isReady(): boolean;
  7248. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7249. _getVertexShaderCode(): string | null;
  7250. _getFragmentShaderCode(): string | null;
  7251. }
  7252. }
  7253. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7254. import { FloatArray, Nullable } from "babylonjs/types";
  7255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7256. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7257. module "babylonjs/Engines/thinEngine" {
  7258. interface ThinEngine {
  7259. /**
  7260. * Create an uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Create a dynamic uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param elements defines the content of the uniform buffer
  7270. * @returns the webGL uniform buffer
  7271. */
  7272. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7273. /**
  7274. * Update an existing uniform buffer
  7275. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7276. * @param uniformBuffer defines the target uniform buffer
  7277. * @param elements defines the content to update
  7278. * @param offset defines the offset in the uniform buffer where update should start
  7279. * @param count defines the size of the data to update
  7280. */
  7281. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7282. /**
  7283. * Bind an uniform buffer to the current webGL context
  7284. * @param buffer defines the buffer to bind
  7285. */
  7286. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7287. /**
  7288. * Bind a buffer to the current webGL context at a given location
  7289. * @param buffer defines the buffer to bind
  7290. * @param location defines the index where to bind the buffer
  7291. */
  7292. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7293. /**
  7294. * Bind a specific block at a given index in a specific shader program
  7295. * @param pipelineContext defines the pipeline context to use
  7296. * @param blockName defines the block name
  7297. * @param index defines the index where to bind the block
  7298. */
  7299. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7300. }
  7301. }
  7302. }
  7303. declare module "babylonjs/Materials/uniformBuffer" {
  7304. import { Nullable, FloatArray } from "babylonjs/types";
  7305. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7306. import { Engine } from "babylonjs/Engines/engine";
  7307. import { Effect } from "babylonjs/Materials/effect";
  7308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7310. import { Color3 } from "babylonjs/Maths/math.color";
  7311. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7312. /**
  7313. * Uniform buffer objects.
  7314. *
  7315. * Handles blocks of uniform on the GPU.
  7316. *
  7317. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7318. *
  7319. * For more information, please refer to :
  7320. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7321. */
  7322. export class UniformBuffer {
  7323. private _engine;
  7324. private _buffer;
  7325. private _data;
  7326. private _bufferData;
  7327. private _dynamic?;
  7328. private _uniformLocations;
  7329. private _uniformSizes;
  7330. private _uniformLocationPointer;
  7331. private _needSync;
  7332. private _noUBO;
  7333. private _currentEffect;
  7334. /** @hidden */
  7335. _alreadyBound: boolean;
  7336. private static _MAX_UNIFORM_SIZE;
  7337. private static _tempBuffer;
  7338. /**
  7339. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7344. /**
  7345. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7346. * This is dynamic to allow compat with webgl 1 and 2.
  7347. * You will need to pass the name of the uniform as well as the value.
  7348. */
  7349. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7350. /**
  7351. * Lambda to Update a single float in a uniform buffer.
  7352. * This is dynamic to allow compat with webgl 1 and 2.
  7353. * You will need to pass the name of the uniform as well as the value.
  7354. */
  7355. updateFloat: (name: string, x: number) => void;
  7356. /**
  7357. * Lambda to Update a vec2 of float in a uniform buffer.
  7358. * This is dynamic to allow compat with webgl 1 and 2.
  7359. * You will need to pass the name of the uniform as well as the value.
  7360. */
  7361. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7362. /**
  7363. * Lambda to Update a vec3 of float in a uniform buffer.
  7364. * This is dynamic to allow compat with webgl 1 and 2.
  7365. * You will need to pass the name of the uniform as well as the value.
  7366. */
  7367. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7368. /**
  7369. * Lambda to Update a vec4 of float in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7374. /**
  7375. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix: (name: string, mat: Matrix) => void;
  7380. /**
  7381. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateVector3: (name: string, vector: Vector3) => void;
  7386. /**
  7387. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateVector4: (name: string, vector: Vector4) => void;
  7392. /**
  7393. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7404. /**
  7405. * Instantiates a new Uniform buffer objects.
  7406. *
  7407. * Handles blocks of uniform on the GPU.
  7408. *
  7409. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7410. *
  7411. * For more information, please refer to :
  7412. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7413. * @param engine Define the engine the buffer is associated with
  7414. * @param data Define the data contained in the buffer
  7415. * @param dynamic Define if the buffer is updatable
  7416. */
  7417. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7418. /**
  7419. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7420. * or just falling back on setUniformXXX calls.
  7421. */
  7422. get useUbo(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is in sync
  7425. * with the javascript cache data.
  7426. */
  7427. get isSync(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7430. * Also, a dynamic UniformBuffer will disable cache verification and always
  7431. * update the underlying WebGL uniform buffer to the GPU.
  7432. * @returns if Dynamic, otherwise false
  7433. */
  7434. isDynamic(): boolean;
  7435. /**
  7436. * The data cache on JS side.
  7437. * @returns the underlying data as a float array
  7438. */
  7439. getData(): Float32Array;
  7440. /**
  7441. * The underlying WebGL Uniform buffer.
  7442. * @returns the webgl buffer
  7443. */
  7444. getBuffer(): Nullable<DataBuffer>;
  7445. /**
  7446. * std140 layout specifies how to align data within an UBO structure.
  7447. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7448. * for specs.
  7449. */
  7450. private _fillAlignment;
  7451. /**
  7452. * Adds an uniform in the buffer.
  7453. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7454. * for the layout to be correct !
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. * @param size Data size, or data directly.
  7457. */
  7458. addUniform(name: string, size: number | number[]): void;
  7459. /**
  7460. * Adds a Matrix 4x4 to the uniform buffer.
  7461. * @param name Name of the uniform, as used in the uniform block in the shader.
  7462. * @param mat A 4x4 matrix.
  7463. */
  7464. addMatrix(name: string, mat: Matrix): void;
  7465. /**
  7466. * Adds a vec2 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec2
  7469. * @param y Define the y component value of the vec2
  7470. */
  7471. addFloat2(name: string, x: number, y: number): void;
  7472. /**
  7473. * Adds a vec3 to the uniform buffer.
  7474. * @param name Name of the uniform, as used in the uniform block in the shader.
  7475. * @param x Define the x component value of the vec3
  7476. * @param y Define the y component value of the vec3
  7477. * @param z Define the z component value of the vec3
  7478. */
  7479. addFloat3(name: string, x: number, y: number, z: number): void;
  7480. /**
  7481. * Adds a vec3 to the uniform buffer.
  7482. * @param name Name of the uniform, as used in the uniform block in the shader.
  7483. * @param color Define the vec3 from a Color
  7484. */
  7485. addColor3(name: string, color: Color3): void;
  7486. /**
  7487. * Adds a vec4 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param color Define the rgb components from a Color
  7490. * @param alpha Define the a component of the vec4
  7491. */
  7492. addColor4(name: string, color: Color3, alpha: number): void;
  7493. /**
  7494. * Adds a vec3 to the uniform buffer.
  7495. * @param name Name of the uniform, as used in the uniform block in the shader.
  7496. * @param vector Define the vec3 components from a Vector
  7497. */
  7498. addVector3(name: string, vector: Vector3): void;
  7499. /**
  7500. * Adds a Matrix 3x3 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix3x3(name: string): void;
  7504. /**
  7505. * Adds a Matrix 2x2 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix2x2(name: string): void;
  7509. /**
  7510. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7511. */
  7512. create(): void;
  7513. /** @hidden */
  7514. _rebuild(): void;
  7515. /**
  7516. * Updates the WebGL Uniform Buffer on the GPU.
  7517. * If the `dynamic` flag is set to true, no cache comparison is done.
  7518. * Otherwise, the buffer will be updated only if the cache differs.
  7519. */
  7520. update(): void;
  7521. /**
  7522. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7523. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7524. * @param data Define the flattened data
  7525. * @param size Define the size of the data.
  7526. */
  7527. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7528. private _valueCache;
  7529. private _cacheMatrix;
  7530. private _updateMatrix3x3ForUniform;
  7531. private _updateMatrix3x3ForEffect;
  7532. private _updateMatrix2x2ForEffect;
  7533. private _updateMatrix2x2ForUniform;
  7534. private _updateFloatForEffect;
  7535. private _updateFloatForUniform;
  7536. private _updateFloat2ForEffect;
  7537. private _updateFloat2ForUniform;
  7538. private _updateFloat3ForEffect;
  7539. private _updateFloat3ForUniform;
  7540. private _updateFloat4ForEffect;
  7541. private _updateFloat4ForUniform;
  7542. private _updateMatrixForEffect;
  7543. private _updateMatrixForUniform;
  7544. private _updateVector3ForEffect;
  7545. private _updateVector3ForUniform;
  7546. private _updateVector4ForEffect;
  7547. private _updateVector4ForUniform;
  7548. private _updateColor3ForEffect;
  7549. private _updateColor3ForUniform;
  7550. private _updateColor4ForEffect;
  7551. private _updateColor4ForUniform;
  7552. /**
  7553. * Sets a sampler uniform on the effect.
  7554. * @param name Define the name of the sampler.
  7555. * @param texture Define the texture to set in the sampler
  7556. */
  7557. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7558. /**
  7559. * Directly updates the value of the uniform in the cache AND on the GPU.
  7560. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7561. * @param data Define the flattened data
  7562. */
  7563. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7564. /**
  7565. * Binds this uniform buffer to an effect.
  7566. * @param effect Define the effect to bind the buffer to
  7567. * @param name Name of the uniform block in the shader.
  7568. */
  7569. bindToEffect(effect: Effect, name: string): void;
  7570. /**
  7571. * Disposes the uniform buffer.
  7572. */
  7573. dispose(): void;
  7574. }
  7575. }
  7576. declare module "babylonjs/Misc/iInspectable" {
  7577. /**
  7578. * Enum that determines the text-wrapping mode to use.
  7579. */
  7580. export enum InspectableType {
  7581. /**
  7582. * Checkbox for booleans
  7583. */
  7584. Checkbox = 0,
  7585. /**
  7586. * Sliders for numbers
  7587. */
  7588. Slider = 1,
  7589. /**
  7590. * Vector3
  7591. */
  7592. Vector3 = 2,
  7593. /**
  7594. * Quaternions
  7595. */
  7596. Quaternion = 3,
  7597. /**
  7598. * Color3
  7599. */
  7600. Color3 = 4,
  7601. /**
  7602. * String
  7603. */
  7604. String = 5
  7605. }
  7606. /**
  7607. * Interface used to define custom inspectable properties.
  7608. * This interface is used by the inspector to display custom property grids
  7609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7610. */
  7611. export interface IInspectable {
  7612. /**
  7613. * Gets the label to display
  7614. */
  7615. label: string;
  7616. /**
  7617. * Gets the name of the property to edit
  7618. */
  7619. propertyName: string;
  7620. /**
  7621. * Gets the type of the editor to use
  7622. */
  7623. type: InspectableType;
  7624. /**
  7625. * Gets the minimum value of the property when using in "slider" mode
  7626. */
  7627. min?: number;
  7628. /**
  7629. * Gets the maximum value of the property when using in "slider" mode
  7630. */
  7631. max?: number;
  7632. /**
  7633. * Gets the setp to use when using in "slider" mode
  7634. */
  7635. step?: number;
  7636. }
  7637. }
  7638. declare module "babylonjs/Misc/timingTools" {
  7639. /**
  7640. * Class used to provide helper for timing
  7641. */
  7642. export class TimingTools {
  7643. /**
  7644. * Polyfill for setImmediate
  7645. * @param action defines the action to execute after the current execution block
  7646. */
  7647. static SetImmediate(action: () => void): void;
  7648. }
  7649. }
  7650. declare module "babylonjs/Misc/instantiationTools" {
  7651. /**
  7652. * Class used to enable instatition of objects by class name
  7653. */
  7654. export class InstantiationTools {
  7655. /**
  7656. * Use this object to register external classes like custom textures or material
  7657. * to allow the laoders to instantiate them
  7658. */
  7659. static RegisteredExternalClasses: {
  7660. [key: string]: Object;
  7661. };
  7662. /**
  7663. * Tries to instantiate a new object from a given class name
  7664. * @param className defines the class name to instantiate
  7665. * @returns the new object or null if the system was not able to do the instantiation
  7666. */
  7667. static Instantiate(className: string): any;
  7668. }
  7669. }
  7670. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7671. /**
  7672. * Define options used to create a depth texture
  7673. */
  7674. export class DepthTextureCreationOptions {
  7675. /** Specifies whether or not a stencil should be allocated in the texture */
  7676. generateStencil?: boolean;
  7677. /** Specifies whether or not bilinear filtering is enable on the texture */
  7678. bilinearFiltering?: boolean;
  7679. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7680. comparisonFunction?: number;
  7681. /** Specifies if the created texture is a cube texture */
  7682. isCube?: boolean;
  7683. }
  7684. }
  7685. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. import { Nullable } from "babylonjs/types";
  7688. import { Scene } from "babylonjs/scene";
  7689. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7690. module "babylonjs/Engines/thinEngine" {
  7691. interface ThinEngine {
  7692. /**
  7693. * Creates a depth stencil cube texture.
  7694. * This is only available in WebGL 2.
  7695. * @param size The size of face edge in the cube texture.
  7696. * @param options The options defining the cube texture.
  7697. * @returns The cube texture
  7698. */
  7699. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7700. /**
  7701. * Creates a cube texture
  7702. * @param rootUrl defines the url where the files to load is located
  7703. * @param scene defines the current scene
  7704. * @param files defines the list of files to load (1 per face)
  7705. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7706. * @param onLoad defines an optional callback raised when the texture is loaded
  7707. * @param onError defines an optional callback raised if there is an issue to load the texture
  7708. * @param format defines the format of the data
  7709. * @param forcedExtension defines the extension to use to pick the right loader
  7710. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7711. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7712. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7713. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7714. * @returns the cube texture as an InternalTexture
  7715. */
  7716. 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;
  7717. /**
  7718. * Creates a cube texture
  7719. * @param rootUrl defines the url where the files to load is located
  7720. * @param scene defines the current scene
  7721. * @param files defines the list of files to load (1 per face)
  7722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7723. * @param onLoad defines an optional callback raised when the texture is loaded
  7724. * @param onError defines an optional callback raised if there is an issue to load the texture
  7725. * @param format defines the format of the data
  7726. * @param forcedExtension defines the extension to use to pick the right loader
  7727. * @returns the cube texture as an InternalTexture
  7728. */
  7729. 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;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @returns the cube texture as an InternalTexture
  7744. */
  7745. 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;
  7746. /** @hidden */
  7747. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7748. /** @hidden */
  7749. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7750. /** @hidden */
  7751. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7752. /** @hidden */
  7753. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7754. /**
  7755. * @hidden
  7756. */
  7757. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7758. }
  7759. }
  7760. }
  7761. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7762. import { Nullable } from "babylonjs/types";
  7763. import { Scene } from "babylonjs/scene";
  7764. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7766. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7767. import { Observable } from "babylonjs/Misc/observable";
  7768. /**
  7769. * Class for creating a cube texture
  7770. */
  7771. export class CubeTexture extends BaseTexture {
  7772. private _delayedOnLoad;
  7773. /**
  7774. * Observable triggered once the texture has been loaded.
  7775. */
  7776. onLoadObservable: Observable<CubeTexture>;
  7777. /**
  7778. * The url of the texture
  7779. */
  7780. url: string;
  7781. /**
  7782. * Gets or sets the center of the bounding box associated with the cube texture.
  7783. * It must define where the camera used to render the texture was set
  7784. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7785. */
  7786. boundingBoxPosition: Vector3;
  7787. private _boundingBoxSize;
  7788. /**
  7789. * Gets or sets the size of the bounding box associated with the cube texture
  7790. * When defined, the cubemap will switch to local mode
  7791. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7792. * @example https://www.babylonjs-playground.com/#RNASML
  7793. */
  7794. set boundingBoxSize(value: Vector3);
  7795. /**
  7796. * Returns the bounding box size
  7797. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7798. */
  7799. get boundingBoxSize(): Vector3;
  7800. protected _rotationY: number;
  7801. /**
  7802. * Sets texture matrix rotation angle around Y axis in radians.
  7803. */
  7804. set rotationY(value: number);
  7805. /**
  7806. * Gets texture matrix rotation angle around Y axis radians.
  7807. */
  7808. get rotationY(): number;
  7809. /**
  7810. * Are mip maps generated for this texture or not.
  7811. */
  7812. get noMipmap(): boolean;
  7813. private _noMipmap;
  7814. private _files;
  7815. protected _forcedExtension: Nullable<string>;
  7816. private _extensions;
  7817. private _textureMatrix;
  7818. private _format;
  7819. private _createPolynomials;
  7820. /** @hidden */
  7821. _prefiltered: boolean;
  7822. /**
  7823. * Creates a cube texture from an array of image urls
  7824. * @param files defines an array of image urls
  7825. * @param scene defines the hosting scene
  7826. * @param noMipmap specifies if mip maps are not used
  7827. * @returns a cube texture
  7828. */
  7829. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7830. /**
  7831. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7832. * @param url defines the url of the prefiltered texture
  7833. * @param scene defines the scene the texture is attached to
  7834. * @param forcedExtension defines the extension of the file if different from the url
  7835. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7836. * @return the prefiltered texture
  7837. */
  7838. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7839. /**
  7840. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7841. * as prefiltered data.
  7842. * @param rootUrl defines the url of the texture or the root name of the six images
  7843. * @param scene defines the scene the texture is attached to
  7844. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7845. * @param noMipmap defines if mipmaps should be created or not
  7846. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7847. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7848. * @param onError defines a callback triggered in case of error during load
  7849. * @param format defines the internal format to use for the texture once loaded
  7850. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7851. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7852. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7855. * @return the cube texture
  7856. */
  7857. 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);
  7858. /**
  7859. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7860. */
  7861. get isPrefiltered(): boolean;
  7862. /**
  7863. * Get the current class name of the texture useful for serialization or dynamic coding.
  7864. * @returns "CubeTexture"
  7865. */
  7866. getClassName(): string;
  7867. /**
  7868. * Update the url (and optional buffer) of this texture if url was null during construction.
  7869. * @param url the url of the texture
  7870. * @param forcedExtension defines the extension to use
  7871. * @param onLoad callback called when the texture is loaded (defaults to null)
  7872. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7873. */
  7874. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7875. /**
  7876. * Delays loading of the cube texture
  7877. * @param forcedExtension defines the extension to use
  7878. */
  7879. delayLoad(forcedExtension?: string): void;
  7880. /**
  7881. * Returns the reflection texture matrix
  7882. * @returns the reflection texture matrix
  7883. */
  7884. getReflectionTextureMatrix(): Matrix;
  7885. /**
  7886. * Sets the reflection texture matrix
  7887. * @param value Reflection texture matrix
  7888. */
  7889. setReflectionTextureMatrix(value: Matrix): void;
  7890. /**
  7891. * Parses text to create a cube texture
  7892. * @param parsedTexture define the serialized text to read from
  7893. * @param scene defines the hosting scene
  7894. * @param rootUrl defines the root url of the cube texture
  7895. * @returns a cube texture
  7896. */
  7897. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7898. /**
  7899. * Makes a clone, or deep copy, of the cube texture
  7900. * @returns a new cube texture
  7901. */
  7902. clone(): CubeTexture;
  7903. }
  7904. }
  7905. declare module "babylonjs/Materials/materialDefines" {
  7906. /**
  7907. * Manages the defines for the Material
  7908. */
  7909. export class MaterialDefines {
  7910. /** @hidden */
  7911. protected _keys: string[];
  7912. private _isDirty;
  7913. /** @hidden */
  7914. _renderId: number;
  7915. /** @hidden */
  7916. _areLightsDirty: boolean;
  7917. /** @hidden */
  7918. _areLightsDisposed: boolean;
  7919. /** @hidden */
  7920. _areAttributesDirty: boolean;
  7921. /** @hidden */
  7922. _areTexturesDirty: boolean;
  7923. /** @hidden */
  7924. _areFresnelDirty: boolean;
  7925. /** @hidden */
  7926. _areMiscDirty: boolean;
  7927. /** @hidden */
  7928. _areImageProcessingDirty: boolean;
  7929. /** @hidden */
  7930. _normals: boolean;
  7931. /** @hidden */
  7932. _uvs: boolean;
  7933. /** @hidden */
  7934. _needNormals: boolean;
  7935. /** @hidden */
  7936. _needUVs: boolean;
  7937. [id: string]: any;
  7938. /**
  7939. * Specifies if the material needs to be re-calculated
  7940. */
  7941. get isDirty(): boolean;
  7942. /**
  7943. * Marks the material to indicate that it has been re-calculated
  7944. */
  7945. markAsProcessed(): void;
  7946. /**
  7947. * Marks the material to indicate that it needs to be re-calculated
  7948. */
  7949. markAsUnprocessed(): void;
  7950. /**
  7951. * Marks the material to indicate all of its defines need to be re-calculated
  7952. */
  7953. markAllAsDirty(): void;
  7954. /**
  7955. * Marks the material to indicate that image processing needs to be re-calculated
  7956. */
  7957. markAsImageProcessingDirty(): void;
  7958. /**
  7959. * Marks the material to indicate the lights need to be re-calculated
  7960. * @param disposed Defines whether the light is dirty due to dispose or not
  7961. */
  7962. markAsLightDirty(disposed?: boolean): void;
  7963. /**
  7964. * Marks the attribute state as changed
  7965. */
  7966. markAsAttributesDirty(): void;
  7967. /**
  7968. * Marks the texture state as changed
  7969. */
  7970. markAsTexturesDirty(): void;
  7971. /**
  7972. * Marks the fresnel state as changed
  7973. */
  7974. markAsFresnelDirty(): void;
  7975. /**
  7976. * Marks the misc state as changed
  7977. */
  7978. markAsMiscDirty(): void;
  7979. /**
  7980. * Rebuilds the material defines
  7981. */
  7982. rebuild(): void;
  7983. /**
  7984. * Specifies if two material defines are equal
  7985. * @param other - A material define instance to compare to
  7986. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7987. */
  7988. isEqual(other: MaterialDefines): boolean;
  7989. /**
  7990. * Clones this instance's defines to another instance
  7991. * @param other - material defines to clone values to
  7992. */
  7993. cloneTo(other: MaterialDefines): void;
  7994. /**
  7995. * Resets the material define values
  7996. */
  7997. reset(): void;
  7998. /**
  7999. * Converts the material define values to a string
  8000. * @returns - String of material define information
  8001. */
  8002. toString(): string;
  8003. }
  8004. }
  8005. declare module "babylonjs/Materials/colorCurves" {
  8006. import { Effect } from "babylonjs/Materials/effect";
  8007. /**
  8008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8010. * 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;
  8011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8012. */
  8013. export class ColorCurves {
  8014. private _dirty;
  8015. private _tempColor;
  8016. private _globalCurve;
  8017. private _highlightsCurve;
  8018. private _midtonesCurve;
  8019. private _shadowsCurve;
  8020. private _positiveCurve;
  8021. private _negativeCurve;
  8022. private _globalHue;
  8023. private _globalDensity;
  8024. private _globalSaturation;
  8025. private _globalExposure;
  8026. /**
  8027. * Gets the global Hue value.
  8028. * 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).
  8029. */
  8030. get globalHue(): number;
  8031. /**
  8032. * Sets 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. set globalHue(value: number);
  8036. /**
  8037. * Gets the global Density value.
  8038. * 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.
  8039. * Values less than zero provide a filter of opposite hue.
  8040. */
  8041. get globalDensity(): number;
  8042. /**
  8043. * Sets the global Density value.
  8044. * 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.
  8045. * Values less than zero provide a filter of opposite hue.
  8046. */
  8047. set globalDensity(value: number);
  8048. /**
  8049. * Gets the global Saturation value.
  8050. * 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.
  8051. */
  8052. get globalSaturation(): number;
  8053. /**
  8054. * Sets 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. set globalSaturation(value: number);
  8058. /**
  8059. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  8061. */
  8062. get globalExposure(): number;
  8063. /**
  8064. * Sets 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. set globalExposure(value: number);
  8068. private _highlightsHue;
  8069. private _highlightsDensity;
  8070. private _highlightsSaturation;
  8071. private _highlightsExposure;
  8072. /**
  8073. * Gets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. get highlightsHue(): number;
  8077. /**
  8078. * Sets 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. set highlightsHue(value: number);
  8082. /**
  8083. * Gets the highlights Density value.
  8084. * 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.
  8085. * Values less than zero provide a filter of opposite hue.
  8086. */
  8087. get highlightsDensity(): number;
  8088. /**
  8089. * Sets the highlights Density value.
  8090. * 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.
  8091. * Values less than zero provide a filter of opposite hue.
  8092. */
  8093. set highlightsDensity(value: number);
  8094. /**
  8095. * Gets the highlights Saturation value.
  8096. * 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.
  8097. */
  8098. get highlightsSaturation(): number;
  8099. /**
  8100. * Sets 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. set highlightsSaturation(value: number);
  8104. /**
  8105. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  8107. */
  8108. get highlightsExposure(): number;
  8109. /**
  8110. * Sets 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. set highlightsExposure(value: number);
  8114. private _midtonesHue;
  8115. private _midtonesDensity;
  8116. private _midtonesSaturation;
  8117. private _midtonesExposure;
  8118. /**
  8119. * Gets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. get midtonesHue(): number;
  8123. /**
  8124. * Sets 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. set midtonesHue(value: number);
  8128. /**
  8129. * Gets the midtones Density value.
  8130. * 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.
  8131. * Values less than zero provide a filter of opposite hue.
  8132. */
  8133. get midtonesDensity(): number;
  8134. /**
  8135. * Sets the midtones Density value.
  8136. * 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.
  8137. * Values less than zero provide a filter of opposite hue.
  8138. */
  8139. set midtonesDensity(value: number);
  8140. /**
  8141. * Gets the midtones Saturation value.
  8142. * 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.
  8143. */
  8144. get midtonesSaturation(): number;
  8145. /**
  8146. * Sets 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. set midtonesSaturation(value: number);
  8150. /**
  8151. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  8153. */
  8154. get midtonesExposure(): number;
  8155. /**
  8156. * Sets 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. set midtonesExposure(value: number);
  8160. private _shadowsHue;
  8161. private _shadowsDensity;
  8162. private _shadowsSaturation;
  8163. private _shadowsExposure;
  8164. /**
  8165. * Gets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. get shadowsHue(): number;
  8169. /**
  8170. * Sets 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. set shadowsHue(value: number);
  8174. /**
  8175. * Gets the shadows Density value.
  8176. * 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.
  8177. * Values less than zero provide a filter of opposite hue.
  8178. */
  8179. get shadowsDensity(): number;
  8180. /**
  8181. * Sets the shadows Density value.
  8182. * 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.
  8183. * Values less than zero provide a filter of opposite hue.
  8184. */
  8185. set shadowsDensity(value: number);
  8186. /**
  8187. * Gets the shadows Saturation value.
  8188. * 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.
  8189. */
  8190. get shadowsSaturation(): number;
  8191. /**
  8192. * Sets 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. set shadowsSaturation(value: number);
  8196. /**
  8197. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  8199. */
  8200. get shadowsExposure(): number;
  8201. /**
  8202. * Sets 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. set shadowsExposure(value: number);
  8206. /**
  8207. * Returns the class name
  8208. * @returns The class name
  8209. */
  8210. getClassName(): string;
  8211. /**
  8212. * Binds the color curves to the shader.
  8213. * @param colorCurves The color curve to bind
  8214. * @param effect The effect to bind to
  8215. * @param positiveUniform The positive uniform shader parameter
  8216. * @param neutralUniform The neutral uniform shader parameter
  8217. * @param negativeUniform The negative uniform shader parameter
  8218. */
  8219. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8220. /**
  8221. * Prepare the list of uniforms associated with the ColorCurves effects.
  8222. * @param uniformsList The list of uniforms used in the effect
  8223. */
  8224. static PrepareUniforms(uniformsList: string[]): void;
  8225. /**
  8226. * Returns color grading data based on a hue, density, saturation and exposure value.
  8227. * @param filterHue The hue of the color filter.
  8228. * @param filterDensity The density of the color filter.
  8229. * @param saturation The saturation.
  8230. * @param exposure The exposure.
  8231. * @param result The result data container.
  8232. */
  8233. private getColorGradingDataToRef;
  8234. /**
  8235. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8236. * @param value The input slider value in range [-100,100].
  8237. * @returns Adjusted value.
  8238. */
  8239. private static applyColorGradingSliderNonlinear;
  8240. /**
  8241. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8242. * @param hue The hue (H) input.
  8243. * @param saturation The saturation (S) input.
  8244. * @param brightness The brightness (B) input.
  8245. * @result An RGBA color represented as Vector4.
  8246. */
  8247. private static fromHSBToRef;
  8248. /**
  8249. * Returns a value clamped between min and max
  8250. * @param value The value to clamp
  8251. * @param min The minimum of value
  8252. * @param max The maximum of value
  8253. * @returns The clamped value.
  8254. */
  8255. private static clamp;
  8256. /**
  8257. * Clones the current color curve instance.
  8258. * @return The cloned curves
  8259. */
  8260. clone(): ColorCurves;
  8261. /**
  8262. * Serializes the current color curve instance to a json representation.
  8263. * @return a JSON representation
  8264. */
  8265. serialize(): any;
  8266. /**
  8267. * Parses the color curve from a json representation.
  8268. * @param source the JSON source to parse
  8269. * @return The parsed curves
  8270. */
  8271. static Parse(source: any): ColorCurves;
  8272. }
  8273. }
  8274. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8275. import { Observable } from "babylonjs/Misc/observable";
  8276. import { Nullable } from "babylonjs/types";
  8277. import { Color4 } from "babylonjs/Maths/math.color";
  8278. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8279. import { Effect } from "babylonjs/Materials/effect";
  8280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8281. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8282. /**
  8283. * Interface to follow in your material defines to integrate easily the
  8284. * Image proccessing functions.
  8285. * @hidden
  8286. */
  8287. export interface IImageProcessingConfigurationDefines {
  8288. IMAGEPROCESSING: boolean;
  8289. VIGNETTE: boolean;
  8290. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8291. VIGNETTEBLENDMODEOPAQUE: boolean;
  8292. TONEMAPPING: boolean;
  8293. TONEMAPPING_ACES: boolean;
  8294. CONTRAST: boolean;
  8295. EXPOSURE: boolean;
  8296. COLORCURVES: boolean;
  8297. COLORGRADING: boolean;
  8298. COLORGRADING3D: boolean;
  8299. SAMPLER3DGREENDEPTH: boolean;
  8300. SAMPLER3DBGRMAP: boolean;
  8301. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8302. }
  8303. /**
  8304. * @hidden
  8305. */
  8306. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8307. IMAGEPROCESSING: boolean;
  8308. VIGNETTE: boolean;
  8309. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8310. VIGNETTEBLENDMODEOPAQUE: boolean;
  8311. TONEMAPPING: boolean;
  8312. TONEMAPPING_ACES: boolean;
  8313. CONTRAST: boolean;
  8314. COLORCURVES: boolean;
  8315. COLORGRADING: boolean;
  8316. COLORGRADING3D: boolean;
  8317. SAMPLER3DGREENDEPTH: boolean;
  8318. SAMPLER3DBGRMAP: boolean;
  8319. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8320. EXPOSURE: boolean;
  8321. constructor();
  8322. }
  8323. /**
  8324. * This groups together the common properties used for image processing either in direct forward pass
  8325. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8326. * or not.
  8327. */
  8328. export class ImageProcessingConfiguration {
  8329. /**
  8330. * Default tone mapping applied in BabylonJS.
  8331. */
  8332. static readonly TONEMAPPING_STANDARD: number;
  8333. /**
  8334. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8335. * to other engines rendering to increase portability.
  8336. */
  8337. static readonly TONEMAPPING_ACES: number;
  8338. /**
  8339. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8340. */
  8341. colorCurves: Nullable<ColorCurves>;
  8342. private _colorCurvesEnabled;
  8343. /**
  8344. * Gets wether the color curves effect is enabled.
  8345. */
  8346. get colorCurvesEnabled(): boolean;
  8347. /**
  8348. * Sets wether the color curves effect is enabled.
  8349. */
  8350. set colorCurvesEnabled(value: boolean);
  8351. private _colorGradingTexture;
  8352. /**
  8353. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8354. */
  8355. get colorGradingTexture(): Nullable<BaseTexture>;
  8356. /**
  8357. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8358. */
  8359. set colorGradingTexture(value: Nullable<BaseTexture>);
  8360. private _colorGradingEnabled;
  8361. /**
  8362. * Gets wether the color grading effect is enabled.
  8363. */
  8364. get colorGradingEnabled(): boolean;
  8365. /**
  8366. * Sets wether the color grading effect is enabled.
  8367. */
  8368. set colorGradingEnabled(value: boolean);
  8369. private _colorGradingWithGreenDepth;
  8370. /**
  8371. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8372. */
  8373. get colorGradingWithGreenDepth(): boolean;
  8374. /**
  8375. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8376. */
  8377. set colorGradingWithGreenDepth(value: boolean);
  8378. private _colorGradingBGR;
  8379. /**
  8380. * Gets wether the color grading texture contains BGR values.
  8381. */
  8382. get colorGradingBGR(): boolean;
  8383. /**
  8384. * Sets wether the color grading texture contains BGR values.
  8385. */
  8386. set colorGradingBGR(value: boolean);
  8387. /** @hidden */
  8388. _exposure: number;
  8389. /**
  8390. * Gets the Exposure used in the effect.
  8391. */
  8392. get exposure(): number;
  8393. /**
  8394. * Sets the Exposure used in the effect.
  8395. */
  8396. set exposure(value: number);
  8397. private _toneMappingEnabled;
  8398. /**
  8399. * Gets wether the tone mapping effect is enabled.
  8400. */
  8401. get toneMappingEnabled(): boolean;
  8402. /**
  8403. * Sets wether the tone mapping effect is enabled.
  8404. */
  8405. set toneMappingEnabled(value: boolean);
  8406. private _toneMappingType;
  8407. /**
  8408. * Gets the type of tone mapping effect.
  8409. */
  8410. get toneMappingType(): number;
  8411. /**
  8412. * Sets the type of tone mapping effect used in BabylonJS.
  8413. */
  8414. set toneMappingType(value: number);
  8415. protected _contrast: number;
  8416. /**
  8417. * Gets the contrast used in the effect.
  8418. */
  8419. get contrast(): number;
  8420. /**
  8421. * Sets the contrast used in the effect.
  8422. */
  8423. set contrast(value: number);
  8424. /**
  8425. * Vignette stretch size.
  8426. */
  8427. vignetteStretch: number;
  8428. /**
  8429. * Vignette centre X Offset.
  8430. */
  8431. vignetteCentreX: number;
  8432. /**
  8433. * Vignette centre Y Offset.
  8434. */
  8435. vignetteCentreY: number;
  8436. /**
  8437. * Vignette weight or intensity of the vignette effect.
  8438. */
  8439. vignetteWeight: number;
  8440. /**
  8441. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8442. * if vignetteEnabled is set to true.
  8443. */
  8444. vignetteColor: Color4;
  8445. /**
  8446. * Camera field of view used by the Vignette effect.
  8447. */
  8448. vignetteCameraFov: number;
  8449. private _vignetteBlendMode;
  8450. /**
  8451. * Gets the vignette blend mode allowing different kind of effect.
  8452. */
  8453. get vignetteBlendMode(): number;
  8454. /**
  8455. * Sets the vignette blend mode allowing different kind of effect.
  8456. */
  8457. set vignetteBlendMode(value: number);
  8458. private _vignetteEnabled;
  8459. /**
  8460. * Gets wether the vignette effect is enabled.
  8461. */
  8462. get vignetteEnabled(): boolean;
  8463. /**
  8464. * Sets wether the vignette effect is enabled.
  8465. */
  8466. set vignetteEnabled(value: boolean);
  8467. private _applyByPostProcess;
  8468. /**
  8469. * Gets wether the image processing is applied through a post process or not.
  8470. */
  8471. get applyByPostProcess(): boolean;
  8472. /**
  8473. * Sets wether the image processing is applied through a post process or not.
  8474. */
  8475. set applyByPostProcess(value: boolean);
  8476. private _isEnabled;
  8477. /**
  8478. * Gets wether the image processing is enabled or not.
  8479. */
  8480. get isEnabled(): boolean;
  8481. /**
  8482. * Sets wether the image processing is enabled or not.
  8483. */
  8484. set isEnabled(value: boolean);
  8485. /**
  8486. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8487. */
  8488. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8489. /**
  8490. * Method called each time the image processing information changes requires to recompile the effect.
  8491. */
  8492. protected _updateParameters(): void;
  8493. /**
  8494. * Gets the current class name.
  8495. * @return "ImageProcessingConfiguration"
  8496. */
  8497. getClassName(): string;
  8498. /**
  8499. * Prepare the list of uniforms associated with the Image Processing effects.
  8500. * @param uniforms The list of uniforms used in the effect
  8501. * @param defines the list of defines currently in use
  8502. */
  8503. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8504. /**
  8505. * Prepare the list of samplers associated with the Image Processing effects.
  8506. * @param samplersList The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of defines associated to the shader.
  8512. * @param defines the list of defines to complete
  8513. * @param forPostProcess Define if we are currently in post process mode or not
  8514. */
  8515. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8516. /**
  8517. * Returns true if all the image processing information are ready.
  8518. * @returns True if ready, otherwise, false
  8519. */
  8520. isReady(): boolean;
  8521. /**
  8522. * Binds the image processing to the shader.
  8523. * @param effect The effect to bind to
  8524. * @param overrideAspectRatio Override the aspect ratio of the effect
  8525. */
  8526. bind(effect: Effect, overrideAspectRatio?: number): void;
  8527. /**
  8528. * Clones the current image processing instance.
  8529. * @return The cloned image processing
  8530. */
  8531. clone(): ImageProcessingConfiguration;
  8532. /**
  8533. * Serializes the current image processing instance to a json representation.
  8534. * @return a JSON representation
  8535. */
  8536. serialize(): any;
  8537. /**
  8538. * Parses the image processing from a json representation.
  8539. * @param source the JSON source to parse
  8540. * @return The parsed image processing
  8541. */
  8542. static Parse(source: any): ImageProcessingConfiguration;
  8543. private static _VIGNETTEMODE_MULTIPLY;
  8544. private static _VIGNETTEMODE_OPAQUE;
  8545. /**
  8546. * Used to apply the vignette as a mix with the pixel color.
  8547. */
  8548. static get VIGNETTEMODE_MULTIPLY(): number;
  8549. /**
  8550. * Used to apply the vignette as a replacement of the pixel color.
  8551. */
  8552. static get VIGNETTEMODE_OPAQUE(): number;
  8553. }
  8554. }
  8555. declare module "babylonjs/Shaders/postprocess.vertex" {
  8556. /** @hidden */
  8557. export var postprocessVertexShader: {
  8558. name: string;
  8559. shader: string;
  8560. };
  8561. }
  8562. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8564. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8565. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8566. module "babylonjs/Engines/thinEngine" {
  8567. interface ThinEngine {
  8568. /**
  8569. * Creates a new render target texture
  8570. * @param size defines the size of the texture
  8571. * @param options defines the options used to create the texture
  8572. * @returns a new render target texture stored in an InternalTexture
  8573. */
  8574. createRenderTargetTexture(size: number | {
  8575. width: number;
  8576. height: number;
  8577. layers?: number;
  8578. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8579. /**
  8580. * Creates a depth stencil texture.
  8581. * This is only available in WebGL 2 or with the depth texture extension available.
  8582. * @param size The size of face edge in the texture.
  8583. * @param options The options defining the texture.
  8584. * @returns The texture
  8585. */
  8586. createDepthStencilTexture(size: number | {
  8587. width: number;
  8588. height: number;
  8589. layers?: number;
  8590. }, options: DepthTextureCreationOptions): InternalTexture;
  8591. /** @hidden */
  8592. _createDepthStencilTexture(size: number | {
  8593. width: number;
  8594. height: number;
  8595. layers?: number;
  8596. }, options: DepthTextureCreationOptions): InternalTexture;
  8597. }
  8598. }
  8599. }
  8600. declare module "babylonjs/Maths/math.axis" {
  8601. import { Vector3 } from "babylonjs/Maths/math.vector";
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module "babylonjs/Cameras/targetCamera" {
  8622. import { Nullable } from "babylonjs/types";
  8623. import { Camera } from "babylonjs/Cameras/camera";
  8624. import { Scene } from "babylonjs/scene";
  8625. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8626. /**
  8627. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8628. * This is the base of the follow, arc rotate cameras and Free camera
  8629. * @see http://doc.babylonjs.com/features/cameras
  8630. */
  8631. export class TargetCamera extends Camera {
  8632. private static _RigCamTransformMatrix;
  8633. private static _TargetTransformMatrix;
  8634. private static _TargetFocalPoint;
  8635. /**
  8636. * Define the current direction the camera is moving to
  8637. */
  8638. cameraDirection: Vector3;
  8639. /**
  8640. * Define the current rotation the camera is rotating to
  8641. */
  8642. cameraRotation: Vector2;
  8643. /**
  8644. * When set, the up vector of the camera will be updated by the rotation of the camera
  8645. */
  8646. updateUpVectorFromRotation: boolean;
  8647. private _tmpQuaternion;
  8648. /**
  8649. * Define the current rotation of the camera
  8650. */
  8651. rotation: Vector3;
  8652. /**
  8653. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8654. */
  8655. rotationQuaternion: Quaternion;
  8656. /**
  8657. * Define the current speed of the camera
  8658. */
  8659. speed: number;
  8660. /**
  8661. * Add constraint to the camera to prevent it to move freely in all directions and
  8662. * around all axis.
  8663. */
  8664. noRotationConstraint: boolean;
  8665. /**
  8666. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8667. * panning
  8668. */
  8669. invertRotation: boolean;
  8670. /**
  8671. * Speed multiplier for inverse camera panning
  8672. */
  8673. inverseRotationSpeed: number;
  8674. /**
  8675. * Define the current target of the camera as an object or a position.
  8676. */
  8677. lockedTarget: any;
  8678. /** @hidden */
  8679. _currentTarget: Vector3;
  8680. /** @hidden */
  8681. _initialFocalDistance: number;
  8682. /** @hidden */
  8683. _viewMatrix: Matrix;
  8684. /** @hidden */
  8685. _camMatrix: Matrix;
  8686. /** @hidden */
  8687. _cameraTransformMatrix: Matrix;
  8688. /** @hidden */
  8689. _cameraRotationMatrix: Matrix;
  8690. /** @hidden */
  8691. _referencePoint: Vector3;
  8692. /** @hidden */
  8693. _transformedReferencePoint: Vector3;
  8694. protected _globalCurrentTarget: Vector3;
  8695. protected _globalCurrentUpVector: Vector3;
  8696. /** @hidden */
  8697. _reset: () => void;
  8698. private _defaultUp;
  8699. /**
  8700. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8701. * This is the base of the follow, arc rotate cameras and Free camera
  8702. * @see http://doc.babylonjs.com/features/cameras
  8703. * @param name Defines the name of the camera in the scene
  8704. * @param position Defines the start position of the camera in the scene
  8705. * @param scene Defines the scene the camera belongs to
  8706. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8707. */
  8708. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8709. /**
  8710. * Gets the position in front of the camera at a given distance.
  8711. * @param distance The distance from the camera we want the position to be
  8712. * @returns the position
  8713. */
  8714. getFrontPosition(distance: number): Vector3;
  8715. /** @hidden */
  8716. _getLockedTargetPosition(): Nullable<Vector3>;
  8717. private _storedPosition;
  8718. private _storedRotation;
  8719. private _storedRotationQuaternion;
  8720. /**
  8721. * Store current camera state of the camera (fov, position, rotation, etc..)
  8722. * @returns the camera
  8723. */
  8724. storeState(): Camera;
  8725. /**
  8726. * Restored camera state. You must call storeState() first
  8727. * @returns whether it was successful or not
  8728. * @hidden
  8729. */
  8730. _restoreStateValues(): boolean;
  8731. /** @hidden */
  8732. _initCache(): void;
  8733. /** @hidden */
  8734. _updateCache(ignoreParentClass?: boolean): void;
  8735. /** @hidden */
  8736. _isSynchronizedViewMatrix(): boolean;
  8737. /** @hidden */
  8738. _computeLocalCameraSpeed(): number;
  8739. /**
  8740. * Defines the target the camera should look at.
  8741. * @param target Defines the new target as a Vector or a mesh
  8742. */
  8743. setTarget(target: Vector3): void;
  8744. /**
  8745. * Return the current target position of the camera. This value is expressed in local space.
  8746. * @returns the target position
  8747. */
  8748. getTarget(): Vector3;
  8749. /** @hidden */
  8750. _decideIfNeedsToMove(): boolean;
  8751. /** @hidden */
  8752. _updatePosition(): void;
  8753. /** @hidden */
  8754. _checkInputs(): void;
  8755. protected _updateCameraRotationMatrix(): void;
  8756. /**
  8757. * 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)
  8758. * @returns the current camera
  8759. */
  8760. private _rotateUpVectorWithCameraRotationMatrix;
  8761. private _cachedRotationZ;
  8762. private _cachedQuaternionRotationZ;
  8763. /** @hidden */
  8764. _getViewMatrix(): Matrix;
  8765. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8766. /**
  8767. * @hidden
  8768. */
  8769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8770. /**
  8771. * @hidden
  8772. */
  8773. _updateRigCameras(): void;
  8774. private _getRigCamPositionAndTarget;
  8775. /**
  8776. * Gets the current object class name.
  8777. * @return the class name
  8778. */
  8779. getClassName(): string;
  8780. }
  8781. }
  8782. declare module "babylonjs/Events/keyboardEvents" {
  8783. /**
  8784. * Gather the list of keyboard event types as constants.
  8785. */
  8786. export class KeyboardEventTypes {
  8787. /**
  8788. * The keydown event is fired when a key becomes active (pressed).
  8789. */
  8790. static readonly KEYDOWN: number;
  8791. /**
  8792. * The keyup event is fired when a key has been released.
  8793. */
  8794. static readonly KEYUP: number;
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8798. */
  8799. export class KeyboardInfo {
  8800. /**
  8801. * Defines the type of event (KeyboardEventTypes)
  8802. */
  8803. type: number;
  8804. /**
  8805. * Defines the related dom event
  8806. */
  8807. event: KeyboardEvent;
  8808. /**
  8809. * Instantiates a new keyboard info.
  8810. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8811. * @param type Defines the type of event (KeyboardEventTypes)
  8812. * @param event Defines the related dom event
  8813. */
  8814. constructor(
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number,
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent);
  8823. }
  8824. /**
  8825. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8826. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8827. */
  8828. export class KeyboardInfoPre extends KeyboardInfo {
  8829. /**
  8830. * Defines the type of event (KeyboardEventTypes)
  8831. */
  8832. type: number;
  8833. /**
  8834. * Defines the related dom event
  8835. */
  8836. event: KeyboardEvent;
  8837. /**
  8838. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8839. */
  8840. skipOnPointerObservable: boolean;
  8841. /**
  8842. * Instantiates a new keyboard pre info.
  8843. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8844. * @param type Defines the type of event (KeyboardEventTypes)
  8845. * @param event Defines the related dom event
  8846. */
  8847. constructor(
  8848. /**
  8849. * Defines the type of event (KeyboardEventTypes)
  8850. */
  8851. type: number,
  8852. /**
  8853. * Defines the related dom event
  8854. */
  8855. event: KeyboardEvent);
  8856. }
  8857. }
  8858. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8859. import { Nullable } from "babylonjs/types";
  8860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8861. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8862. /**
  8863. * Manage the keyboard inputs to control the movement of a free camera.
  8864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8865. */
  8866. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8867. /**
  8868. * Defines the camera the input is attached to.
  8869. */
  8870. camera: FreeCamera;
  8871. /**
  8872. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8873. */
  8874. keysUp: number[];
  8875. /**
  8876. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8877. */
  8878. keysUpward: number[];
  8879. /**
  8880. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8881. */
  8882. keysDown: number[];
  8883. /**
  8884. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8885. */
  8886. keysDownward: number[];
  8887. /**
  8888. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8889. */
  8890. keysLeft: number[];
  8891. /**
  8892. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8893. */
  8894. keysRight: number[];
  8895. private _keys;
  8896. private _onCanvasBlurObserver;
  8897. private _onKeyboardObserver;
  8898. private _engine;
  8899. private _scene;
  8900. /**
  8901. * Attach the input controls to a specific dom element to get the input from.
  8902. * @param element Defines the element the controls should be listened from
  8903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8904. */
  8905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8906. /**
  8907. * Detach the current controls from the specified dom element.
  8908. * @param element Defines the element to stop listening the inputs from
  8909. */
  8910. detachControl(element: Nullable<HTMLElement>): void;
  8911. /**
  8912. * Update the current camera state depending on the inputs that have been used this frame.
  8913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8914. */
  8915. checkInputs(): void;
  8916. /**
  8917. * Gets the class name of the current intput.
  8918. * @returns the class name
  8919. */
  8920. getClassName(): string;
  8921. /** @hidden */
  8922. _onLostFocus(): void;
  8923. /**
  8924. * Get the friendly name associated with the input class.
  8925. * @returns the input friendly name
  8926. */
  8927. getSimpleName(): string;
  8928. }
  8929. }
  8930. declare module "babylonjs/Lights/shadowLight" {
  8931. import { Camera } from "babylonjs/Cameras/camera";
  8932. import { Scene } from "babylonjs/scene";
  8933. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8935. import { Light } from "babylonjs/Lights/light";
  8936. /**
  8937. * Interface describing all the common properties and methods a shadow light needs to implement.
  8938. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8939. * as well as binding the different shadow properties to the effects.
  8940. */
  8941. export interface IShadowLight extends Light {
  8942. /**
  8943. * The light id in the scene (used in scene.findLighById for instance)
  8944. */
  8945. id: string;
  8946. /**
  8947. * The position the shdow will be casted from.
  8948. */
  8949. position: Vector3;
  8950. /**
  8951. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8952. */
  8953. direction: Vector3;
  8954. /**
  8955. * The transformed position. Position of the light in world space taking parenting in account.
  8956. */
  8957. transformedPosition: Vector3;
  8958. /**
  8959. * The transformed direction. Direction of the light in world space taking parenting in account.
  8960. */
  8961. transformedDirection: Vector3;
  8962. /**
  8963. * The friendly name of the light in the scene.
  8964. */
  8965. name: string;
  8966. /**
  8967. * Defines the shadow projection clipping minimum z value.
  8968. */
  8969. shadowMinZ: number;
  8970. /**
  8971. * Defines the shadow projection clipping maximum z value.
  8972. */
  8973. shadowMaxZ: number;
  8974. /**
  8975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8977. */
  8978. computeTransformedInformation(): boolean;
  8979. /**
  8980. * Gets the scene the light belongs to.
  8981. * @returns The scene
  8982. */
  8983. getScene(): Scene;
  8984. /**
  8985. * Callback defining a custom Projection Matrix Builder.
  8986. * This can be used to override the default projection matrix computation.
  8987. */
  8988. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8989. /**
  8990. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8991. * @param matrix The materix to updated with the projection information
  8992. * @param viewMatrix The transform matrix of the light
  8993. * @param renderList The list of mesh to render in the map
  8994. * @returns The current light
  8995. */
  8996. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8997. /**
  8998. * Gets the current depth scale used in ESM.
  8999. * @returns The scale
  9000. */
  9001. getDepthScale(): number;
  9002. /**
  9003. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9004. * @returns true if a cube texture needs to be use
  9005. */
  9006. needCube(): boolean;
  9007. /**
  9008. * Detects if the projection matrix requires to be recomputed this frame.
  9009. * @returns true if it requires to be recomputed otherwise, false.
  9010. */
  9011. needProjectionMatrixCompute(): boolean;
  9012. /**
  9013. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9014. */
  9015. forceProjectionMatrixCompute(): void;
  9016. /**
  9017. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9018. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9019. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9020. */
  9021. getShadowDirection(faceIndex?: number): Vector3;
  9022. /**
  9023. * Gets the minZ used for shadow according to both the scene and the light.
  9024. * @param activeCamera The camera we are returning the min for
  9025. * @returns the depth min z
  9026. */
  9027. getDepthMinZ(activeCamera: Camera): number;
  9028. /**
  9029. * Gets the maxZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the max for
  9031. * @returns the depth max z
  9032. */
  9033. getDepthMaxZ(activeCamera: Camera): number;
  9034. }
  9035. /**
  9036. * Base implementation IShadowLight
  9037. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9038. */
  9039. export abstract class ShadowLight extends Light implements IShadowLight {
  9040. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9041. protected _position: Vector3;
  9042. protected _setPosition(value: Vector3): void;
  9043. /**
  9044. * Sets the position the shadow will be casted from. Also use as the light position for both
  9045. * point and spot lights.
  9046. */
  9047. get position(): Vector3;
  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. set position(value: Vector3);
  9053. protected _direction: Vector3;
  9054. protected _setDirection(value: Vector3): void;
  9055. /**
  9056. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9057. * Also use as the light direction on spot and directional lights.
  9058. */
  9059. get direction(): Vector3;
  9060. /**
  9061. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9062. * Also use as the light direction on spot and directional lights.
  9063. */
  9064. set direction(value: Vector3);
  9065. protected _shadowMinZ: number;
  9066. /**
  9067. * Gets the shadow projection clipping minimum z value.
  9068. */
  9069. get shadowMinZ(): number;
  9070. /**
  9071. * Sets the shadow projection clipping minimum z value.
  9072. */
  9073. set shadowMinZ(value: number);
  9074. protected _shadowMaxZ: number;
  9075. /**
  9076. * Sets the shadow projection clipping maximum z value.
  9077. */
  9078. get shadowMaxZ(): number;
  9079. /**
  9080. * Gets the shadow projection clipping maximum z value.
  9081. */
  9082. set shadowMaxZ(value: number);
  9083. /**
  9084. * Callback defining a custom Projection Matrix Builder.
  9085. * This can be used to override the default projection matrix computation.
  9086. */
  9087. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9088. /**
  9089. * The transformed position. Position of the light in world space taking parenting in account.
  9090. */
  9091. transformedPosition: Vector3;
  9092. /**
  9093. * The transformed direction. Direction of the light in world space taking parenting in account.
  9094. */
  9095. transformedDirection: Vector3;
  9096. private _needProjectionMatrixCompute;
  9097. /**
  9098. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9099. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9100. */
  9101. computeTransformedInformation(): boolean;
  9102. /**
  9103. * Return the depth scale used for the shadow map.
  9104. * @returns the depth scale.
  9105. */
  9106. getDepthScale(): number;
  9107. /**
  9108. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9109. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9110. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9111. */
  9112. getShadowDirection(faceIndex?: number): Vector3;
  9113. /**
  9114. * Returns the ShadowLight absolute position in the World.
  9115. * @returns the position vector in world space
  9116. */
  9117. getAbsolutePosition(): Vector3;
  9118. /**
  9119. * Sets the ShadowLight direction toward the passed target.
  9120. * @param target The point to target in local space
  9121. * @returns the updated ShadowLight direction
  9122. */
  9123. setDirectionToTarget(target: Vector3): Vector3;
  9124. /**
  9125. * Returns the light rotation in euler definition.
  9126. * @returns the x y z rotation in local space.
  9127. */
  9128. getRotation(): Vector3;
  9129. /**
  9130. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9131. * @returns true if a cube texture needs to be use
  9132. */
  9133. needCube(): boolean;
  9134. /**
  9135. * Detects if the projection matrix requires to be recomputed this frame.
  9136. * @returns true if it requires to be recomputed otherwise, false.
  9137. */
  9138. needProjectionMatrixCompute(): boolean;
  9139. /**
  9140. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9141. */
  9142. forceProjectionMatrixCompute(): void;
  9143. /** @hidden */
  9144. _initCache(): void;
  9145. /** @hidden */
  9146. _isSynchronized(): boolean;
  9147. /**
  9148. * Computes the world matrix of the node
  9149. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9150. * @returns the world matrix
  9151. */
  9152. computeWorldMatrix(force?: boolean): Matrix;
  9153. /**
  9154. * Gets the minZ used for shadow according to both the scene and the light.
  9155. * @param activeCamera The camera we are returning the min for
  9156. * @returns the depth min z
  9157. */
  9158. getDepthMinZ(activeCamera: Camera): number;
  9159. /**
  9160. * Gets the maxZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the max for
  9162. * @returns the depth max z
  9163. */
  9164. getDepthMaxZ(activeCamera: Camera): number;
  9165. /**
  9166. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9167. * @param matrix The materix to updated with the projection information
  9168. * @param viewMatrix The transform matrix of the light
  9169. * @param renderList The list of mesh to render in the map
  9170. * @returns The current light
  9171. */
  9172. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/effectFallbacks" {
  9176. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9177. import { Effect } from "babylonjs/Materials/effect";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. /**
  9180. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9181. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9182. */
  9183. export class EffectFallbacks implements IEffectFallbacks {
  9184. private _defines;
  9185. private _currentRank;
  9186. private _maxRank;
  9187. private _mesh;
  9188. /**
  9189. * Removes the fallback from the bound mesh.
  9190. */
  9191. unBindMesh(): void;
  9192. /**
  9193. * Adds a fallback on the specified property.
  9194. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9195. * @param define The name of the define in the shader
  9196. */
  9197. addFallback(rank: number, define: string): void;
  9198. /**
  9199. * Sets the mesh to use CPU skinning when needing to fallback.
  9200. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9201. * @param mesh The mesh to use the fallbacks.
  9202. */
  9203. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9204. /**
  9205. * Checks to see if more fallbacks are still availible.
  9206. */
  9207. get hasMoreFallbacks(): boolean;
  9208. /**
  9209. * Removes the defines that should be removed when falling back.
  9210. * @param currentDefines defines the current define statements for the shader.
  9211. * @param effect defines the current effect we try to compile
  9212. * @returns The resulting defines with defines of the current rank removed.
  9213. */
  9214. reduce(currentDefines: string, effect: Effect): string;
  9215. }
  9216. }
  9217. declare module "babylonjs/Materials/materialHelper" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Engine } from "babylonjs/Engines/engine";
  9221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9222. import { Light } from "babylonjs/Lights/light";
  9223. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9224. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9226. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9227. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9228. /**
  9229. * "Static Class" containing the most commonly used helper while dealing with material for
  9230. * rendering purpose.
  9231. *
  9232. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9233. *
  9234. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9235. */
  9236. export class MaterialHelper {
  9237. /**
  9238. * Bind the current view position to an effect.
  9239. * @param effect The effect to be bound
  9240. * @param scene The scene the eyes position is used from
  9241. */
  9242. static BindEyePosition(effect: Effect, scene: Scene): void;
  9243. /**
  9244. * Helps preparing the defines values about the UVs in used in the effect.
  9245. * UVs are shared as much as we can accross channels in the shaders.
  9246. * @param texture The texture we are preparing the UVs for
  9247. * @param defines The defines to update
  9248. * @param key The channel key "diffuse", "specular"... used in the shader
  9249. */
  9250. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9251. /**
  9252. * Binds a texture matrix value to its corrsponding uniform
  9253. * @param texture The texture to bind the matrix for
  9254. * @param uniformBuffer The uniform buffer receivin the data
  9255. * @param key The channel key "diffuse", "specular"... used in the shader
  9256. */
  9257. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9258. /**
  9259. * Gets the current status of the fog (should it be enabled?)
  9260. * @param mesh defines the mesh to evaluate for fog support
  9261. * @param scene defines the hosting scene
  9262. * @returns true if fog must be enabled
  9263. */
  9264. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9267. * @param mesh defines the current mesh
  9268. * @param scene defines the current scene
  9269. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9270. * @param pointsCloud defines if point cloud rendering has to be turned on
  9271. * @param fogEnabled defines if fog has to be turned on
  9272. * @param alphaTest defines if alpha testing has to be turned on
  9273. * @param defines defines the current list of defines
  9274. */
  9275. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9276. /**
  9277. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9278. * @param scene defines the current scene
  9279. * @param engine defines the current engine
  9280. * @param defines specifies the list of active defines
  9281. * @param useInstances defines if instances have to be turned on
  9282. * @param useClipPlane defines if clip plane have to be turned on
  9283. */
  9284. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9285. /**
  9286. * Prepares the defines for bones
  9287. * @param mesh The mesh containing the geometry data we will draw
  9288. * @param defines The defines to update
  9289. */
  9290. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9291. /**
  9292. * Prepares the defines for morph targets
  9293. * @param mesh The mesh containing the geometry data we will draw
  9294. * @param defines The defines to update
  9295. */
  9296. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9297. /**
  9298. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9299. * @param mesh The mesh containing the geometry data we will draw
  9300. * @param defines The defines to update
  9301. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9302. * @param useBones Precise whether bones should be used or not (override mesh info)
  9303. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9304. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9305. * @returns false if defines are considered not dirty and have not been checked
  9306. */
  9307. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9308. /**
  9309. * Prepares the defines related to multiview
  9310. * @param scene The scene we are intending to draw
  9311. * @param defines The defines to update
  9312. */
  9313. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9314. /**
  9315. * Prepares the defines related to the light information passed in parameter
  9316. * @param scene The scene we are intending to draw
  9317. * @param mesh The mesh the effect is compiling for
  9318. * @param light The light the effect is compiling for
  9319. * @param lightIndex The index of the light
  9320. * @param defines The defines to update
  9321. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9322. * @param state Defines the current state regarding what is needed (normals, etc...)
  9323. */
  9324. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9325. needNormals: boolean;
  9326. needRebuild: boolean;
  9327. shadowEnabled: boolean;
  9328. specularEnabled: boolean;
  9329. lightmapMode: boolean;
  9330. }): void;
  9331. /**
  9332. * Prepares the defines related to the light information passed in parameter
  9333. * @param scene The scene we are intending to draw
  9334. * @param mesh The mesh the effect is compiling for
  9335. * @param defines The defines to update
  9336. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9337. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9338. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9339. * @returns true if normals will be required for the rest of the effect
  9340. */
  9341. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9342. /**
  9343. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9344. * @param lightIndex defines the light index
  9345. * @param uniformsList The uniform list
  9346. * @param samplersList The sampler list
  9347. * @param projectedLightTexture defines if projected texture must be used
  9348. * @param uniformBuffersList defines an optional list of uniform buffers
  9349. */
  9350. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9351. /**
  9352. * Prepares the uniforms and samplers list to be used in the effect
  9353. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9354. * @param samplersList The sampler list
  9355. * @param defines The defines helping in the list generation
  9356. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9357. */
  9358. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9359. /**
  9360. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9361. * @param defines The defines to update while falling back
  9362. * @param fallbacks The authorized effect fallbacks
  9363. * @param maxSimultaneousLights The maximum number of lights allowed
  9364. * @param rank the current rank of the Effect
  9365. * @returns The newly affected rank
  9366. */
  9367. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9368. private static _TmpMorphInfluencers;
  9369. /**
  9370. * Prepares the list of attributes required for morph targets according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param mesh The mesh to prepare the morph targets attributes for
  9373. * @param influencers The number of influencers
  9374. */
  9375. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9376. /**
  9377. * Prepares the list of attributes required for morph targets according to the effect defines.
  9378. * @param attribs The current list of supported attribs
  9379. * @param mesh The mesh to prepare the morph targets attributes for
  9380. * @param defines The current Defines of the effect
  9381. */
  9382. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9383. /**
  9384. * Prepares the list of attributes required for bones according to the effect defines.
  9385. * @param attribs The current list of supported attribs
  9386. * @param mesh The mesh to prepare the bones attributes for
  9387. * @param defines The current Defines of the effect
  9388. * @param fallbacks The current efffect fallback strategy
  9389. */
  9390. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9391. /**
  9392. * Check and prepare the list of attributes required for instances according to the effect defines.
  9393. * @param attribs The current list of supported attribs
  9394. * @param defines The current MaterialDefines of the effect
  9395. */
  9396. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9397. /**
  9398. * Add the list of attributes required for instances to the attribs array.
  9399. * @param attribs The current list of supported attribs
  9400. */
  9401. static PushAttributesForInstances(attribs: string[]): void;
  9402. /**
  9403. * Binds the light information to the effect.
  9404. * @param light The light containing the generator
  9405. * @param effect The effect we are binding the data to
  9406. * @param lightIndex The light index in the effect used to render
  9407. */
  9408. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9409. /**
  9410. * Binds the lights information from the scene to the effect for the given mesh.
  9411. * @param light Light to bind
  9412. * @param lightIndex Light index
  9413. * @param scene The scene where the light belongs to
  9414. * @param effect The effect we are binding the data to
  9415. * @param useSpecular Defines if specular is supported
  9416. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9417. */
  9418. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9419. /**
  9420. * Binds the lights information from the scene to the effect for the given mesh.
  9421. * @param scene The scene the lights belongs to
  9422. * @param mesh The mesh we are binding the information to render
  9423. * @param effect The effect we are binding the data to
  9424. * @param defines The generated defines for the effect
  9425. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9426. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9427. */
  9428. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9429. private static _tempFogColor;
  9430. /**
  9431. * Binds the fog information from the scene to the effect for the given mesh.
  9432. * @param scene The scene the lights belongs to
  9433. * @param mesh The mesh we are binding the information to render
  9434. * @param effect The effect we are binding the data to
  9435. * @param linearSpace Defines if the fog effect is applied in linear space
  9436. */
  9437. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9438. /**
  9439. * Binds the bones information from the mesh to the effect.
  9440. * @param mesh The mesh we are binding the information to render
  9441. * @param effect The effect we are binding the data to
  9442. */
  9443. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9444. /**
  9445. * Binds the morph targets information from the mesh to the effect.
  9446. * @param abstractMesh The mesh we are binding the information to render
  9447. * @param effect The effect we are binding the data to
  9448. */
  9449. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9450. /**
  9451. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9452. * @param defines The generated defines used in the effect
  9453. * @param effect The effect we are binding the data to
  9454. * @param scene The scene we are willing to render with logarithmic scale for
  9455. */
  9456. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9457. /**
  9458. * Binds the clip plane information from the scene to the effect.
  9459. * @param scene The scene the clip plane information are extracted from
  9460. * @param effect The effect we are binding the data to
  9461. */
  9462. static BindClipPlane(effect: Effect, scene: Scene): void;
  9463. }
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9466. /** @hidden */
  9467. export var packingFunctions: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9473. /** @hidden */
  9474. export var clipPlaneFragmentDeclaration: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9480. /** @hidden */
  9481. export var clipPlaneFragment: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9487. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9488. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9489. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9490. /** @hidden */
  9491. export var shadowMapPixelShader: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9497. /** @hidden */
  9498. export var bonesDeclaration: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9504. /** @hidden */
  9505. export var morphTargetsVertexGlobalDeclaration: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9511. /** @hidden */
  9512. export var morphTargetsVertexDeclaration: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9518. /** @hidden */
  9519. export var instancesDeclaration: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9525. /** @hidden */
  9526. export var helperFunctions: {
  9527. name: string;
  9528. shader: string;
  9529. };
  9530. }
  9531. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9532. /** @hidden */
  9533. export var clipPlaneVertexDeclaration: {
  9534. name: string;
  9535. shader: string;
  9536. };
  9537. }
  9538. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9539. /** @hidden */
  9540. export var morphTargetsVertex: {
  9541. name: string;
  9542. shader: string;
  9543. };
  9544. }
  9545. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9546. /** @hidden */
  9547. export var instancesVertex: {
  9548. name: string;
  9549. shader: string;
  9550. };
  9551. }
  9552. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9553. /** @hidden */
  9554. export var bonesVertex: {
  9555. name: string;
  9556. shader: string;
  9557. };
  9558. }
  9559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9560. /** @hidden */
  9561. export var clipPlaneVertex: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9567. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9570. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9574. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9575. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9576. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9577. /** @hidden */
  9578. export var shadowMapVertexShader: {
  9579. name: string;
  9580. shader: string;
  9581. };
  9582. }
  9583. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9584. /** @hidden */
  9585. export var depthBoxBlurPixelShader: {
  9586. name: string;
  9587. shader: string;
  9588. };
  9589. }
  9590. declare module "babylonjs/Culling/ray" {
  9591. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9594. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9595. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9596. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9597. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9598. import { Plane } from "babylonjs/Maths/math.plane";
  9599. /**
  9600. * Class representing a ray with position and direction
  9601. */
  9602. export class Ray {
  9603. /** origin point */
  9604. origin: Vector3;
  9605. /** direction */
  9606. direction: Vector3;
  9607. /** length of the ray */
  9608. length: number;
  9609. private static readonly TmpVector3;
  9610. private _tmpRay;
  9611. /**
  9612. * Creates a new ray
  9613. * @param origin origin point
  9614. * @param direction direction
  9615. * @param length length of the ray
  9616. */
  9617. constructor(
  9618. /** origin point */
  9619. origin: Vector3,
  9620. /** direction */
  9621. direction: Vector3,
  9622. /** length of the ray */
  9623. length?: number);
  9624. /**
  9625. * Checks if the ray intersects a box
  9626. * @param minimum bound of the box
  9627. * @param maximum bound of the box
  9628. * @param intersectionTreshold extra extend to be added to the box in all direction
  9629. * @returns if the box was hit
  9630. */
  9631. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9632. /**
  9633. * Checks if the ray intersects a box
  9634. * @param box the bounding box to check
  9635. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9636. * @returns if the box was hit
  9637. */
  9638. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9639. /**
  9640. * If the ray hits a sphere
  9641. * @param sphere the bounding sphere to check
  9642. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9643. * @returns true if it hits the sphere
  9644. */
  9645. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9646. /**
  9647. * If the ray hits a triange
  9648. * @param vertex0 triangle vertex
  9649. * @param vertex1 triangle vertex
  9650. * @param vertex2 triangle vertex
  9651. * @returns intersection information if hit
  9652. */
  9653. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9654. /**
  9655. * Checks if ray intersects a plane
  9656. * @param plane the plane to check
  9657. * @returns the distance away it was hit
  9658. */
  9659. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9660. /**
  9661. * Calculate the intercept of a ray on a given axis
  9662. * @param axis to check 'x' | 'y' | 'z'
  9663. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9664. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9665. */
  9666. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9667. /**
  9668. * Checks if ray intersects a mesh
  9669. * @param mesh the mesh to check
  9670. * @param fastCheck if only the bounding box should checked
  9671. * @returns picking info of the intersecton
  9672. */
  9673. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9674. /**
  9675. * Checks if ray intersects a mesh
  9676. * @param meshes the meshes to check
  9677. * @param fastCheck if only the bounding box should checked
  9678. * @param results array to store result in
  9679. * @returns Array of picking infos
  9680. */
  9681. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9682. private _comparePickingInfo;
  9683. private static smallnum;
  9684. private static rayl;
  9685. /**
  9686. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9687. * @param sega the first point of the segment to test the intersection against
  9688. * @param segb the second point of the segment to test the intersection against
  9689. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9690. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9691. */
  9692. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9693. /**
  9694. * Update the ray from viewport position
  9695. * @param x position
  9696. * @param y y position
  9697. * @param viewportWidth viewport width
  9698. * @param viewportHeight viewport height
  9699. * @param world world matrix
  9700. * @param view view matrix
  9701. * @param projection projection matrix
  9702. * @returns this ray updated
  9703. */
  9704. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9705. /**
  9706. * Creates a ray with origin and direction of 0,0,0
  9707. * @returns the new ray
  9708. */
  9709. static Zero(): Ray;
  9710. /**
  9711. * Creates a new ray from screen space and viewport
  9712. * @param x position
  9713. * @param y y position
  9714. * @param viewportWidth viewport width
  9715. * @param viewportHeight viewport height
  9716. * @param world world matrix
  9717. * @param view view matrix
  9718. * @param projection projection matrix
  9719. * @returns new ray
  9720. */
  9721. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9722. /**
  9723. * 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
  9724. * transformed to the given world matrix.
  9725. * @param origin The origin point
  9726. * @param end The end point
  9727. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9728. * @returns the new ray
  9729. */
  9730. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9731. /**
  9732. * Transforms a ray by a matrix
  9733. * @param ray ray to transform
  9734. * @param matrix matrix to apply
  9735. * @returns the resulting new ray
  9736. */
  9737. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9738. /**
  9739. * Transforms a ray by a matrix
  9740. * @param ray ray to transform
  9741. * @param matrix matrix to apply
  9742. * @param result ray to store result in
  9743. */
  9744. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9745. /**
  9746. * Unproject a ray from screen space to object space
  9747. * @param sourceX defines the screen space x coordinate to use
  9748. * @param sourceY defines the screen space y coordinate to use
  9749. * @param viewportWidth defines the current width of the viewport
  9750. * @param viewportHeight defines the current height of the viewport
  9751. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9752. * @param view defines the view matrix to use
  9753. * @param projection defines the projection matrix to use
  9754. */
  9755. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9756. }
  9757. /**
  9758. * Type used to define predicate used to select faces when a mesh intersection is detected
  9759. */
  9760. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9761. module "babylonjs/scene" {
  9762. interface Scene {
  9763. /** @hidden */
  9764. _tempPickingRay: Nullable<Ray>;
  9765. /** @hidden */
  9766. _cachedRayForTransform: Ray;
  9767. /** @hidden */
  9768. _pickWithRayInverseMatrix: Matrix;
  9769. /** @hidden */
  9770. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9771. /** @hidden */
  9772. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9773. }
  9774. }
  9775. }
  9776. declare module "babylonjs/sceneComponent" {
  9777. import { Scene } from "babylonjs/scene";
  9778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9779. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9780. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9781. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9782. import { Nullable } from "babylonjs/types";
  9783. import { Camera } from "babylonjs/Cameras/camera";
  9784. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9785. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9786. import { AbstractScene } from "babylonjs/abstractScene";
  9787. import { Mesh } from "babylonjs/Meshes/mesh";
  9788. /**
  9789. * Groups all the scene component constants in one place to ease maintenance.
  9790. * @hidden
  9791. */
  9792. export class SceneComponentConstants {
  9793. static readonly NAME_EFFECTLAYER: string;
  9794. static readonly NAME_LAYER: string;
  9795. static readonly NAME_LENSFLARESYSTEM: string;
  9796. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9797. static readonly NAME_PARTICLESYSTEM: string;
  9798. static readonly NAME_GAMEPAD: string;
  9799. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9800. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9801. static readonly NAME_DEPTHRENDERER: string;
  9802. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9803. static readonly NAME_SPRITE: string;
  9804. static readonly NAME_OUTLINERENDERER: string;
  9805. static readonly NAME_PROCEDURALTEXTURE: string;
  9806. static readonly NAME_SHADOWGENERATOR: string;
  9807. static readonly NAME_OCTREE: string;
  9808. static readonly NAME_PHYSICSENGINE: string;
  9809. static readonly NAME_AUDIO: string;
  9810. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9811. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9812. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9813. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9814. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9815. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9816. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9817. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9818. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9819. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9820. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9821. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9822. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9823. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9824. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9825. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9826. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9827. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9828. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9829. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9830. static readonly STEP_AFTERRENDER_AUDIO: number;
  9831. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9832. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9833. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9834. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9835. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9836. static readonly STEP_POINTERMOVE_SPRITE: number;
  9837. static readonly STEP_POINTERDOWN_SPRITE: number;
  9838. static readonly STEP_POINTERUP_SPRITE: number;
  9839. }
  9840. /**
  9841. * This represents a scene component.
  9842. *
  9843. * This is used to decouple the dependency the scene is having on the different workloads like
  9844. * layers, post processes...
  9845. */
  9846. export interface ISceneComponent {
  9847. /**
  9848. * The name of the component. Each component must have a unique name.
  9849. */
  9850. name: string;
  9851. /**
  9852. * The scene the component belongs to.
  9853. */
  9854. scene: Scene;
  9855. /**
  9856. * Register the component to one instance of a scene.
  9857. */
  9858. register(): void;
  9859. /**
  9860. * Rebuilds the elements related to this component in case of
  9861. * context lost for instance.
  9862. */
  9863. rebuild(): void;
  9864. /**
  9865. * Disposes the component and the associated ressources.
  9866. */
  9867. dispose(): void;
  9868. }
  9869. /**
  9870. * This represents a SERIALIZABLE scene component.
  9871. *
  9872. * This extends Scene Component to add Serialization methods on top.
  9873. */
  9874. export interface ISceneSerializableComponent extends ISceneComponent {
  9875. /**
  9876. * Adds all the elements from the container to the scene
  9877. * @param container the container holding the elements
  9878. */
  9879. addFromContainer(container: AbstractScene): void;
  9880. /**
  9881. * Removes all the elements in the container from the scene
  9882. * @param container contains the elements to remove
  9883. * @param dispose if the removed element should be disposed (default: false)
  9884. */
  9885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9886. /**
  9887. * Serializes the component data to the specified json object
  9888. * @param serializationObject The object to serialize to
  9889. */
  9890. serialize(serializationObject: any): void;
  9891. }
  9892. /**
  9893. * Strong typing of a Mesh related stage step action
  9894. */
  9895. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9896. /**
  9897. * Strong typing of a Evaluate Sub Mesh related stage step action
  9898. */
  9899. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9900. /**
  9901. * Strong typing of a Active Mesh related stage step action
  9902. */
  9903. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9904. /**
  9905. * Strong typing of a Camera related stage step action
  9906. */
  9907. export type CameraStageAction = (camera: Camera) => void;
  9908. /**
  9909. * Strong typing of a Camera Frame buffer related stage step action
  9910. */
  9911. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9912. /**
  9913. * Strong typing of a Render Target related stage step action
  9914. */
  9915. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9916. /**
  9917. * Strong typing of a RenderingGroup related stage step action
  9918. */
  9919. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9920. /**
  9921. * Strong typing of a Mesh Render related stage step action
  9922. */
  9923. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9924. /**
  9925. * Strong typing of a simple stage step action
  9926. */
  9927. export type SimpleStageAction = () => void;
  9928. /**
  9929. * Strong typing of a render target action.
  9930. */
  9931. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9932. /**
  9933. * Strong typing of a pointer move action.
  9934. */
  9935. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9936. /**
  9937. * Strong typing of a pointer up/down action.
  9938. */
  9939. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9940. /**
  9941. * Representation of a stage in the scene (Basically a list of ordered steps)
  9942. * @hidden
  9943. */
  9944. export class Stage<T extends Function> extends Array<{
  9945. index: number;
  9946. component: ISceneComponent;
  9947. action: T;
  9948. }> {
  9949. /**
  9950. * Hide ctor from the rest of the world.
  9951. * @param items The items to add.
  9952. */
  9953. private constructor();
  9954. /**
  9955. * Creates a new Stage.
  9956. * @returns A new instance of a Stage
  9957. */
  9958. static Create<T extends Function>(): Stage<T>;
  9959. /**
  9960. * Registers a step in an ordered way in the targeted stage.
  9961. * @param index Defines the position to register the step in
  9962. * @param component Defines the component attached to the step
  9963. * @param action Defines the action to launch during the step
  9964. */
  9965. registerStep(index: number, component: ISceneComponent, action: T): void;
  9966. /**
  9967. * Clears all the steps from the stage.
  9968. */
  9969. clear(): void;
  9970. }
  9971. }
  9972. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9973. import { Nullable } from "babylonjs/types";
  9974. import { Observable } from "babylonjs/Misc/observable";
  9975. import { Scene } from "babylonjs/scene";
  9976. import { Sprite } from "babylonjs/Sprites/sprite";
  9977. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9978. import { Ray } from "babylonjs/Culling/ray";
  9979. import { Camera } from "babylonjs/Cameras/camera";
  9980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9981. import { ISceneComponent } from "babylonjs/sceneComponent";
  9982. module "babylonjs/scene" {
  9983. interface Scene {
  9984. /** @hidden */
  9985. _pointerOverSprite: Nullable<Sprite>;
  9986. /** @hidden */
  9987. _pickedDownSprite: Nullable<Sprite>;
  9988. /** @hidden */
  9989. _tempSpritePickingRay: Nullable<Ray>;
  9990. /**
  9991. * All of the sprite managers added to this scene
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. spriteManagers: Array<ISpriteManager>;
  9995. /**
  9996. * An event triggered when sprites rendering is about to start
  9997. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9998. */
  9999. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10000. /**
  10001. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  10005. /** @hidden */
  10006. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10007. /** Launch a ray to try to pick a sprite in the scene
  10008. * @param x position on screen
  10009. * @param y position on screen
  10010. * @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
  10011. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10012. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10013. * @returns a PickingInfo
  10014. */
  10015. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10016. /** Use the given ray to pick a sprite in the scene
  10017. * @param ray The ray (in world space) to use to pick meshes
  10018. * @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
  10019. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10020. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10021. * @returns a PickingInfo
  10022. */
  10023. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10024. /** @hidden */
  10025. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10026. /** Launch a ray to try to pick sprites in the scene
  10027. * @param x position on screen
  10028. * @param y position on screen
  10029. * @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
  10030. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10031. * @returns a PickingInfo array
  10032. */
  10033. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10034. /** Use the given ray to pick sprites in the scene
  10035. * @param ray The ray (in world space) to use to pick meshes
  10036. * @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
  10037. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10038. * @returns a PickingInfo array
  10039. */
  10040. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10041. /**
  10042. * Force the sprite under the pointer
  10043. * @param sprite defines the sprite to use
  10044. */
  10045. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10046. /**
  10047. * Gets the sprite under the pointer
  10048. * @returns a Sprite or null if no sprite is under the pointer
  10049. */
  10050. getPointerOverSprite(): Nullable<Sprite>;
  10051. }
  10052. }
  10053. /**
  10054. * Defines the sprite scene component responsible to manage sprites
  10055. * in a given scene.
  10056. */
  10057. export class SpriteSceneComponent implements ISceneComponent {
  10058. /**
  10059. * The component name helpfull to identify the component in the list of scene components.
  10060. */
  10061. readonly name: string;
  10062. /**
  10063. * The scene the component belongs to.
  10064. */
  10065. scene: Scene;
  10066. /** @hidden */
  10067. private _spritePredicate;
  10068. /**
  10069. * Creates a new instance of the component for the given scene
  10070. * @param scene Defines the scene to register the component in
  10071. */
  10072. constructor(scene: Scene);
  10073. /**
  10074. * Registers the component in a given scene
  10075. */
  10076. register(): void;
  10077. /**
  10078. * Rebuilds the elements related to this component in case of
  10079. * context lost for instance.
  10080. */
  10081. rebuild(): void;
  10082. /**
  10083. * Disposes the component and the associated ressources.
  10084. */
  10085. dispose(): void;
  10086. private _pickSpriteButKeepRay;
  10087. private _pointerMove;
  10088. private _pointerDown;
  10089. private _pointerUp;
  10090. }
  10091. }
  10092. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10093. /** @hidden */
  10094. export var fogFragmentDeclaration: {
  10095. name: string;
  10096. shader: string;
  10097. };
  10098. }
  10099. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10100. /** @hidden */
  10101. export var fogFragment: {
  10102. name: string;
  10103. shader: string;
  10104. };
  10105. }
  10106. declare module "babylonjs/Shaders/sprites.fragment" {
  10107. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10108. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10109. /** @hidden */
  10110. export var spritesPixelShader: {
  10111. name: string;
  10112. shader: string;
  10113. };
  10114. }
  10115. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10116. /** @hidden */
  10117. export var fogVertexDeclaration: {
  10118. name: string;
  10119. shader: string;
  10120. };
  10121. }
  10122. declare module "babylonjs/Shaders/sprites.vertex" {
  10123. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10124. /** @hidden */
  10125. export var spritesVertexShader: {
  10126. name: string;
  10127. shader: string;
  10128. };
  10129. }
  10130. declare module "babylonjs/Sprites/spriteManager" {
  10131. import { IDisposable, Scene } from "babylonjs/scene";
  10132. import { Nullable } from "babylonjs/types";
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Sprite } from "babylonjs/Sprites/sprite";
  10135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10136. import { Camera } from "babylonjs/Cameras/camera";
  10137. import { Texture } from "babylonjs/Materials/Textures/texture";
  10138. import "babylonjs/Shaders/sprites.fragment";
  10139. import "babylonjs/Shaders/sprites.vertex";
  10140. import { Ray } from "babylonjs/Culling/ray";
  10141. /**
  10142. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10143. */
  10144. export interface ISpriteManager extends IDisposable {
  10145. /**
  10146. * Restricts the camera to viewing objects with the same layerMask.
  10147. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10148. */
  10149. layerMask: number;
  10150. /**
  10151. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10152. */
  10153. isPickable: boolean;
  10154. /**
  10155. * Specifies the rendering group id for this mesh (0 by default)
  10156. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10157. */
  10158. renderingGroupId: number;
  10159. /**
  10160. * Defines the list of sprites managed by the manager.
  10161. */
  10162. sprites: Array<Sprite>;
  10163. /**
  10164. * Tests the intersection of a sprite with a specific ray.
  10165. * @param ray The ray we are sending to test the collision
  10166. * @param camera The camera space we are sending rays in
  10167. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10168. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10169. * @returns picking info or null.
  10170. */
  10171. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10172. /**
  10173. * Intersects the sprites with a ray
  10174. * @param ray defines the ray to intersect with
  10175. * @param camera defines the current active camera
  10176. * @param predicate defines a predicate used to select candidate sprites
  10177. * @returns null if no hit or a PickingInfo array
  10178. */
  10179. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10180. /**
  10181. * Renders the list of sprites on screen.
  10182. */
  10183. render(): void;
  10184. }
  10185. /**
  10186. * Class used to manage multiple sprites on the same spritesheet
  10187. * @see http://doc.babylonjs.com/babylon101/sprites
  10188. */
  10189. export class SpriteManager implements ISpriteManager {
  10190. /** defines the manager's name */
  10191. name: string;
  10192. /** Gets the list of sprites */
  10193. sprites: Sprite[];
  10194. /** Gets or sets the rendering group id (0 by default) */
  10195. renderingGroupId: number;
  10196. /** Gets or sets camera layer mask */
  10197. layerMask: number;
  10198. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10199. fogEnabled: boolean;
  10200. /** Gets or sets a boolean indicating if the sprites are pickable */
  10201. isPickable: boolean;
  10202. /** Defines the default width of a cell in the spritesheet */
  10203. cellWidth: number;
  10204. /** Defines the default height of a cell in the spritesheet */
  10205. cellHeight: number;
  10206. /** Associative array from JSON sprite data file */
  10207. private _cellData;
  10208. /** Array of sprite names from JSON sprite data file */
  10209. private _spriteMap;
  10210. /** True when packed cell data from JSON file is ready*/
  10211. private _packedAndReady;
  10212. /**
  10213. * An event triggered when the manager is disposed.
  10214. */
  10215. onDisposeObservable: Observable<SpriteManager>;
  10216. private _onDisposeObserver;
  10217. /**
  10218. * Callback called when the manager is disposed
  10219. */
  10220. set onDispose(callback: () => void);
  10221. private _capacity;
  10222. private _fromPacked;
  10223. private _spriteTexture;
  10224. private _epsilon;
  10225. private _scene;
  10226. private _vertexData;
  10227. private _buffer;
  10228. private _vertexBuffers;
  10229. private _indexBuffer;
  10230. private _effectBase;
  10231. private _effectFog;
  10232. /**
  10233. * Gets or sets the spritesheet texture
  10234. */
  10235. get texture(): Texture;
  10236. set texture(value: Texture);
  10237. private _blendMode;
  10238. /**
  10239. * Blend mode use to render the particle, it can be any of
  10240. * the static Constants.ALPHA_x properties provided in this class.
  10241. * Default value is Constants.ALPHA_COMBINE
  10242. */
  10243. get blendMode(): number;
  10244. set blendMode(blendMode: number);
  10245. /** Disables writing to the depth buffer when rendering the sprites.
  10246. * It can be handy to disable depth writing when using textures without alpha channel
  10247. * and setting some specific blend modes.
  10248. */
  10249. disableDepthWrite: boolean;
  10250. /**
  10251. * Creates a new sprite manager
  10252. * @param name defines the manager's name
  10253. * @param imgUrl defines the sprite sheet url
  10254. * @param capacity defines the maximum allowed number of sprites
  10255. * @param cellSize defines the size of a sprite cell
  10256. * @param scene defines the hosting scene
  10257. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10258. * @param samplingMode defines the smapling mode to use with spritesheet
  10259. * @param fromPacked set to false; do not alter
  10260. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10261. */
  10262. constructor(
  10263. /** defines the manager's name */
  10264. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10265. private _makePacked;
  10266. private _appendSpriteVertex;
  10267. /**
  10268. * Intersects the sprites with a ray
  10269. * @param ray defines the ray to intersect with
  10270. * @param camera defines the current active camera
  10271. * @param predicate defines a predicate used to select candidate sprites
  10272. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10273. * @returns null if no hit or a PickingInfo
  10274. */
  10275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10276. /**
  10277. * Intersects the sprites with a ray
  10278. * @param ray defines the ray to intersect with
  10279. * @param camera defines the current active camera
  10280. * @param predicate defines a predicate used to select candidate sprites
  10281. * @returns null if no hit or a PickingInfo array
  10282. */
  10283. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10284. /**
  10285. * Render all child sprites
  10286. */
  10287. render(): void;
  10288. /**
  10289. * Release associated resources
  10290. */
  10291. dispose(): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Misc/gradients" {
  10295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10296. /** Interface used by value gradients (color, factor, ...) */
  10297. export interface IValueGradient {
  10298. /**
  10299. * Gets or sets the gradient value (between 0 and 1)
  10300. */
  10301. gradient: number;
  10302. }
  10303. /** Class used to store color4 gradient */
  10304. export class ColorGradient implements IValueGradient {
  10305. /**
  10306. * Gets or sets the gradient value (between 0 and 1)
  10307. */
  10308. gradient: number;
  10309. /**
  10310. * Gets or sets first associated color
  10311. */
  10312. color1: Color4;
  10313. /**
  10314. * Gets or sets second associated color
  10315. */
  10316. color2?: Color4 | undefined;
  10317. /**
  10318. * Creates a new color4 gradient
  10319. * @param gradient gets or sets the gradient value (between 0 and 1)
  10320. * @param color1 gets or sets first associated color
  10321. * @param color2 gets or sets first second color
  10322. */
  10323. constructor(
  10324. /**
  10325. * Gets or sets the gradient value (between 0 and 1)
  10326. */
  10327. gradient: number,
  10328. /**
  10329. * Gets or sets first associated color
  10330. */
  10331. color1: Color4,
  10332. /**
  10333. * Gets or sets second associated color
  10334. */
  10335. color2?: Color4 | undefined);
  10336. /**
  10337. * Will get a color picked randomly between color1 and color2.
  10338. * If color2 is undefined then color1 will be used
  10339. * @param result defines the target Color4 to store the result in
  10340. */
  10341. getColorToRef(result: Color4): void;
  10342. }
  10343. /** Class used to store color 3 gradient */
  10344. export class Color3Gradient implements IValueGradient {
  10345. /**
  10346. * Gets or sets the gradient value (between 0 and 1)
  10347. */
  10348. gradient: number;
  10349. /**
  10350. * Gets or sets the associated color
  10351. */
  10352. color: Color3;
  10353. /**
  10354. * Creates a new color3 gradient
  10355. * @param gradient gets or sets the gradient value (between 0 and 1)
  10356. * @param color gets or sets associated color
  10357. */
  10358. constructor(
  10359. /**
  10360. * Gets or sets the gradient value (between 0 and 1)
  10361. */
  10362. gradient: number,
  10363. /**
  10364. * Gets or sets the associated color
  10365. */
  10366. color: Color3);
  10367. }
  10368. /** Class used to store factor gradient */
  10369. export class FactorGradient implements IValueGradient {
  10370. /**
  10371. * Gets or sets the gradient value (between 0 and 1)
  10372. */
  10373. gradient: number;
  10374. /**
  10375. * Gets or sets first associated factor
  10376. */
  10377. factor1: number;
  10378. /**
  10379. * Gets or sets second associated factor
  10380. */
  10381. factor2?: number | undefined;
  10382. /**
  10383. * Creates a new factor gradient
  10384. * @param gradient gets or sets the gradient value (between 0 and 1)
  10385. * @param factor1 gets or sets first associated factor
  10386. * @param factor2 gets or sets second associated factor
  10387. */
  10388. constructor(
  10389. /**
  10390. * Gets or sets the gradient value (between 0 and 1)
  10391. */
  10392. gradient: number,
  10393. /**
  10394. * Gets or sets first associated factor
  10395. */
  10396. factor1: number,
  10397. /**
  10398. * Gets or sets second associated factor
  10399. */
  10400. factor2?: number | undefined);
  10401. /**
  10402. * Will get a number picked randomly between factor1 and factor2.
  10403. * If factor2 is undefined then factor1 will be used
  10404. * @returns the picked number
  10405. */
  10406. getFactor(): number;
  10407. }
  10408. /**
  10409. * Helper used to simplify some generic gradient tasks
  10410. */
  10411. export class GradientHelper {
  10412. /**
  10413. * Gets the current gradient from an array of IValueGradient
  10414. * @param ratio defines the current ratio to get
  10415. * @param gradients defines the array of IValueGradient
  10416. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10417. */
  10418. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Maths/math.size" {
  10422. /**
  10423. * Interface for the size containing width and height
  10424. */
  10425. export interface ISize {
  10426. /**
  10427. * Width
  10428. */
  10429. width: number;
  10430. /**
  10431. * Heighht
  10432. */
  10433. height: number;
  10434. }
  10435. /**
  10436. * Size containing widht and height
  10437. */
  10438. export class Size implements ISize {
  10439. /**
  10440. * Width
  10441. */
  10442. width: number;
  10443. /**
  10444. * Height
  10445. */
  10446. height: number;
  10447. /**
  10448. * Creates a Size object from the given width and height (floats).
  10449. * @param width width of the new size
  10450. * @param height height of the new size
  10451. */
  10452. constructor(width: number, height: number);
  10453. /**
  10454. * Returns a string with the Size width and height
  10455. * @returns a string with the Size width and height
  10456. */
  10457. toString(): string;
  10458. /**
  10459. * "Size"
  10460. * @returns the string "Size"
  10461. */
  10462. getClassName(): string;
  10463. /**
  10464. * Returns the Size hash code.
  10465. * @returns a hash code for a unique width and height
  10466. */
  10467. getHashCode(): number;
  10468. /**
  10469. * Updates the current size from the given one.
  10470. * @param src the given size
  10471. */
  10472. copyFrom(src: Size): void;
  10473. /**
  10474. * Updates in place the current Size from the given floats.
  10475. * @param width width of the new size
  10476. * @param height height of the new size
  10477. * @returns the updated Size.
  10478. */
  10479. copyFromFloats(width: number, height: number): Size;
  10480. /**
  10481. * Updates in place the current Size from the given floats.
  10482. * @param width width to set
  10483. * @param height height to set
  10484. * @returns the updated Size.
  10485. */
  10486. set(width: number, height: number): Size;
  10487. /**
  10488. * Multiplies the width and height by numbers
  10489. * @param w factor to multiple the width by
  10490. * @param h factor to multiple the height by
  10491. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10492. */
  10493. multiplyByFloats(w: number, h: number): Size;
  10494. /**
  10495. * Clones the size
  10496. * @returns a new Size copied from the given one.
  10497. */
  10498. clone(): Size;
  10499. /**
  10500. * True if the current Size and the given one width and height are strictly equal.
  10501. * @param other the other size to compare against
  10502. * @returns True if the current Size and the given one width and height are strictly equal.
  10503. */
  10504. equals(other: Size): boolean;
  10505. /**
  10506. * The surface of the Size : width * height (float).
  10507. */
  10508. get surface(): number;
  10509. /**
  10510. * Create a new size of zero
  10511. * @returns a new Size set to (0.0, 0.0)
  10512. */
  10513. static Zero(): Size;
  10514. /**
  10515. * Sums the width and height of two sizes
  10516. * @param otherSize size to add to this size
  10517. * @returns a new Size set as the addition result of the current Size and the given one.
  10518. */
  10519. add(otherSize: Size): Size;
  10520. /**
  10521. * Subtracts the width and height of two
  10522. * @param otherSize size to subtract to this size
  10523. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10524. */
  10525. subtract(otherSize: Size): Size;
  10526. /**
  10527. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10528. * @param start starting size to lerp between
  10529. * @param end end size to lerp between
  10530. * @param amount amount to lerp between the start and end values
  10531. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10532. */
  10533. static Lerp(start: Size, end: Size, amount: number): Size;
  10534. }
  10535. }
  10536. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10538. import { Nullable } from "babylonjs/types";
  10539. module "babylonjs/Engines/thinEngine" {
  10540. interface ThinEngine {
  10541. /**
  10542. * Creates a dynamic texture
  10543. * @param width defines the width of the texture
  10544. * @param height defines the height of the texture
  10545. * @param generateMipMaps defines if the engine should generate the mip levels
  10546. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10547. * @returns the dynamic texture inside an InternalTexture
  10548. */
  10549. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10550. /**
  10551. * Update the content of a dynamic texture
  10552. * @param texture defines the texture to update
  10553. * @param canvas defines the canvas containing the source
  10554. * @param invertY defines if data must be stored with Y axis inverted
  10555. * @param premulAlpha defines if alpha is stored as premultiplied
  10556. * @param format defines the format of the data
  10557. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10558. */
  10559. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10560. }
  10561. }
  10562. }
  10563. declare module "babylonjs/Misc/canvasGenerator" {
  10564. /**
  10565. * Helper class used to generate a canvas to manipulate images
  10566. */
  10567. export class CanvasGenerator {
  10568. /**
  10569. * Create a new canvas (or offscreen canvas depending on the context)
  10570. * @param width defines the expected width
  10571. * @param height defines the expected height
  10572. * @return a new canvas or offscreen canvas
  10573. */
  10574. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10575. }
  10576. }
  10577. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10578. import { Scene } from "babylonjs/scene";
  10579. import { Texture } from "babylonjs/Materials/Textures/texture";
  10580. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10581. /**
  10582. * A class extending Texture allowing drawing on a texture
  10583. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10584. */
  10585. export class DynamicTexture extends Texture {
  10586. private _generateMipMaps;
  10587. private _canvas;
  10588. private _context;
  10589. private _engine;
  10590. /**
  10591. * Creates a DynamicTexture
  10592. * @param name defines the name of the texture
  10593. * @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
  10594. * @param scene defines the scene where you want the texture
  10595. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10596. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10597. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10598. */
  10599. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10600. /**
  10601. * Get the current class name of the texture useful for serialization or dynamic coding.
  10602. * @returns "DynamicTexture"
  10603. */
  10604. getClassName(): string;
  10605. /**
  10606. * Gets the current state of canRescale
  10607. */
  10608. get canRescale(): boolean;
  10609. private _recreate;
  10610. /**
  10611. * Scales the texture
  10612. * @param ratio the scale factor to apply to both width and height
  10613. */
  10614. scale(ratio: number): void;
  10615. /**
  10616. * Resizes the texture
  10617. * @param width the new width
  10618. * @param height the new height
  10619. */
  10620. scaleTo(width: number, height: number): void;
  10621. /**
  10622. * Gets the context of the canvas used by the texture
  10623. * @returns the canvas context of the dynamic texture
  10624. */
  10625. getContext(): CanvasRenderingContext2D;
  10626. /**
  10627. * Clears the texture
  10628. */
  10629. clear(): void;
  10630. /**
  10631. * Updates the texture
  10632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10633. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10634. */
  10635. update(invertY?: boolean, premulAlpha?: boolean): void;
  10636. /**
  10637. * Draws text onto the texture
  10638. * @param text defines the text to be drawn
  10639. * @param x defines the placement of the text from the left
  10640. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10641. * @param font defines the font to be used with font-style, font-size, font-name
  10642. * @param color defines the color used for the text
  10643. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10644. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10645. * @param update defines whether texture is immediately update (default is true)
  10646. */
  10647. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10648. /**
  10649. * Clones the texture
  10650. * @returns the clone of the texture.
  10651. */
  10652. clone(): DynamicTexture;
  10653. /**
  10654. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10655. * @returns a serialized dynamic texture object
  10656. */
  10657. serialize(): any;
  10658. /** @hidden */
  10659. _rebuild(): void;
  10660. }
  10661. }
  10662. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10663. import { Nullable } from "babylonjs/types";
  10664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10665. import { Scene } from "babylonjs/scene";
  10666. module "babylonjs/Engines/engine" {
  10667. interface Engine {
  10668. /**
  10669. * Creates a raw texture
  10670. * @param data defines the data to store in the texture
  10671. * @param width defines the width of the texture
  10672. * @param height defines the height of the texture
  10673. * @param format defines the format of the data
  10674. * @param generateMipMaps defines if the engine should generate the mip levels
  10675. * @param invertY defines if data must be stored with Y axis inverted
  10676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10677. * @param compression defines the compression used (null by default)
  10678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10679. * @returns the raw texture inside an InternalTexture
  10680. */
  10681. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10682. /**
  10683. * Update a raw texture
  10684. * @param texture defines the texture to update
  10685. * @param data defines the data to store in the texture
  10686. * @param format defines the format of the data
  10687. * @param invertY defines if data must be stored with Y axis inverted
  10688. */
  10689. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10690. /**
  10691. * Update a raw texture
  10692. * @param texture defines the texture to update
  10693. * @param data defines the data to store in the texture
  10694. * @param format defines the format of the data
  10695. * @param invertY defines if data must be stored with Y axis inverted
  10696. * @param compression defines the compression used (null by default)
  10697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10698. */
  10699. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10700. /**
  10701. * Creates a new raw cube texture
  10702. * @param data defines the array of data to use to create each face
  10703. * @param size defines the size of the textures
  10704. * @param format defines the format of the data
  10705. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10706. * @param generateMipMaps defines if the engine should generate the mip levels
  10707. * @param invertY defines if data must be stored with Y axis inverted
  10708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10709. * @param compression defines the compression used (null by default)
  10710. * @returns the cube texture as an InternalTexture
  10711. */
  10712. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10713. /**
  10714. * Update a raw cube texture
  10715. * @param texture defines the texture to udpdate
  10716. * @param data defines the data to store
  10717. * @param format defines the data format
  10718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10719. * @param invertY defines if data must be stored with Y axis inverted
  10720. */
  10721. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10722. /**
  10723. * Update a raw cube texture
  10724. * @param texture defines the texture to udpdate
  10725. * @param data defines the data to store
  10726. * @param format defines the data format
  10727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10728. * @param invertY defines if data must be stored with Y axis inverted
  10729. * @param compression defines the compression used (null by default)
  10730. */
  10731. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10732. /**
  10733. * Update a raw cube texture
  10734. * @param texture defines the texture to udpdate
  10735. * @param data defines the data to store
  10736. * @param format defines the data format
  10737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. * @param compression defines the compression used (null by default)
  10740. * @param level defines which level of the texture to update
  10741. */
  10742. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10743. /**
  10744. * Creates a new raw cube texture from a specified url
  10745. * @param url defines the url where the data is located
  10746. * @param scene defines the current scene
  10747. * @param size defines the size of the textures
  10748. * @param format defines the format of the data
  10749. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10750. * @param noMipmap defines if the engine should avoid generating the mip levels
  10751. * @param callback defines a callback used to extract texture data from loaded data
  10752. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10753. * @param onLoad defines a callback called when texture is loaded
  10754. * @param onError defines a callback called if there is an error
  10755. * @returns the cube texture as an InternalTexture
  10756. */
  10757. 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;
  10758. /**
  10759. * Creates a new raw cube texture from a specified url
  10760. * @param url defines the url where the data is located
  10761. * @param scene defines the current scene
  10762. * @param size defines the size of the textures
  10763. * @param format defines the format of the data
  10764. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10765. * @param noMipmap defines if the engine should avoid generating the mip levels
  10766. * @param callback defines a callback used to extract texture data from loaded data
  10767. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10768. * @param onLoad defines a callback called when texture is loaded
  10769. * @param onError defines a callback called if there is an error
  10770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. * @returns the cube texture as an InternalTexture
  10773. */
  10774. 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;
  10775. /**
  10776. * Creates a new raw 3D texture
  10777. * @param data defines the data used to create the texture
  10778. * @param width defines the width of the texture
  10779. * @param height defines the height of the texture
  10780. * @param depth defines the depth of the texture
  10781. * @param format defines the format of the texture
  10782. * @param generateMipMaps defines if the engine must generate mip levels
  10783. * @param invertY defines if data must be stored with Y axis inverted
  10784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10785. * @param compression defines the compressed used (can be null)
  10786. * @param textureType defines the compressed used (can be null)
  10787. * @returns a new raw 3D texture (stored in an InternalTexture)
  10788. */
  10789. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10790. /**
  10791. * Update a raw 3D texture
  10792. * @param texture defines the texture to update
  10793. * @param data defines the data to store
  10794. * @param format defines the data format
  10795. * @param invertY defines if data must be stored with Y axis inverted
  10796. */
  10797. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10798. /**
  10799. * Update a raw 3D texture
  10800. * @param texture defines the texture to update
  10801. * @param data defines the data to store
  10802. * @param format defines the data format
  10803. * @param invertY defines if data must be stored with Y axis inverted
  10804. * @param compression defines the used compression (can be null)
  10805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10806. */
  10807. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10808. /**
  10809. * Creates a new raw 2D array texture
  10810. * @param data defines the data used to create the texture
  10811. * @param width defines the width of the texture
  10812. * @param height defines the height of the texture
  10813. * @param depth defines the number of layers of the texture
  10814. * @param format defines the format of the texture
  10815. * @param generateMipMaps defines if the engine must generate mip levels
  10816. * @param invertY defines if data must be stored with Y axis inverted
  10817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10818. * @param compression defines the compressed used (can be null)
  10819. * @param textureType defines the compressed used (can be null)
  10820. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10821. */
  10822. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10823. /**
  10824. * Update a raw 2D array texture
  10825. * @param texture defines the texture to update
  10826. * @param data defines the data to store
  10827. * @param format defines the data format
  10828. * @param invertY defines if data must be stored with Y axis inverted
  10829. */
  10830. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10831. /**
  10832. * Update a raw 2D array texture
  10833. * @param texture defines the texture to update
  10834. * @param data defines the data to store
  10835. * @param format defines the data format
  10836. * @param invertY defines if data must be stored with Y axis inverted
  10837. * @param compression defines the used compression (can be null)
  10838. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10839. */
  10840. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10841. }
  10842. }
  10843. }
  10844. declare module "babylonjs/Materials/Textures/rawTexture" {
  10845. import { Scene } from "babylonjs/scene";
  10846. import { Texture } from "babylonjs/Materials/Textures/texture";
  10847. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10848. /**
  10849. * Raw texture can help creating a texture directly from an array of data.
  10850. * This can be super useful if you either get the data from an uncompressed source or
  10851. * if you wish to create your texture pixel by pixel.
  10852. */
  10853. export class RawTexture extends Texture {
  10854. /**
  10855. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10856. */
  10857. format: number;
  10858. private _engine;
  10859. /**
  10860. * Instantiates a new RawTexture.
  10861. * Raw texture can help creating a texture directly from an array of data.
  10862. * This can be super useful if you either get the data from an uncompressed source or
  10863. * if you wish to create your texture pixel by pixel.
  10864. * @param data define the array of data to use to create the texture
  10865. * @param width define the width of the texture
  10866. * @param height define the height of the texture
  10867. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10868. * @param scene define the scene the texture belongs to
  10869. * @param generateMipMaps define whether mip maps should be generated or not
  10870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10873. */
  10874. constructor(data: ArrayBufferView, width: number, height: number,
  10875. /**
  10876. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10877. */
  10878. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10879. /**
  10880. * Updates the texture underlying data.
  10881. * @param data Define the new data of the texture
  10882. */
  10883. update(data: ArrayBufferView): void;
  10884. /**
  10885. * Creates a luminance texture from some data.
  10886. * @param data Define the texture data
  10887. * @param width Define the width of the texture
  10888. * @param height Define the height of the texture
  10889. * @param scene Define the scene the texture belongs to
  10890. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10891. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10892. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10893. * @returns the luminance texture
  10894. */
  10895. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10896. /**
  10897. * Creates a luminance alpha texture from some data.
  10898. * @param data Define the texture data
  10899. * @param width Define the width of the texture
  10900. * @param height Define the height of the texture
  10901. * @param scene Define the scene the texture belongs to
  10902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10905. * @returns the luminance alpha texture
  10906. */
  10907. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10908. /**
  10909. * Creates an alpha texture from some data.
  10910. * @param data Define the texture data
  10911. * @param width Define the width of the texture
  10912. * @param height Define the height of the texture
  10913. * @param scene Define the scene the texture belongs to
  10914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10917. * @returns the alpha texture
  10918. */
  10919. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10920. /**
  10921. * Creates a RGB texture from some data.
  10922. * @param data Define the texture data
  10923. * @param width Define the width of the texture
  10924. * @param height Define the height of the texture
  10925. * @param scene Define the scene the texture belongs to
  10926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10930. * @returns the RGB alpha texture
  10931. */
  10932. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10933. /**
  10934. * Creates a RGBA texture from some data.
  10935. * @param data Define the texture data
  10936. * @param width Define the width of the texture
  10937. * @param height Define the height of the texture
  10938. * @param scene Define the scene the texture belongs to
  10939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10942. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10943. * @returns the RGBA texture
  10944. */
  10945. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10946. /**
  10947. * Creates a R texture from some data.
  10948. * @param data Define the texture data
  10949. * @param width Define the width of the texture
  10950. * @param height Define the height of the texture
  10951. * @param scene Define the scene the texture belongs to
  10952. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10955. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10956. * @returns the R texture
  10957. */
  10958. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10959. }
  10960. }
  10961. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10962. import { Scene } from "babylonjs/scene";
  10963. import { ISceneComponent } from "babylonjs/sceneComponent";
  10964. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10965. module "babylonjs/abstractScene" {
  10966. interface AbstractScene {
  10967. /**
  10968. * The list of procedural textures added to the scene
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10970. */
  10971. proceduralTextures: Array<ProceduralTexture>;
  10972. }
  10973. }
  10974. /**
  10975. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10976. * in a given scene.
  10977. */
  10978. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10979. /**
  10980. * The component name helpfull to identify the component in the list of scene components.
  10981. */
  10982. readonly name: string;
  10983. /**
  10984. * The scene the component belongs to.
  10985. */
  10986. scene: Scene;
  10987. /**
  10988. * Creates a new instance of the component for the given scene
  10989. * @param scene Defines the scene to register the component in
  10990. */
  10991. constructor(scene: Scene);
  10992. /**
  10993. * Registers the component in a given scene
  10994. */
  10995. register(): void;
  10996. /**
  10997. * Rebuilds the elements related to this component in case of
  10998. * context lost for instance.
  10999. */
  11000. rebuild(): void;
  11001. /**
  11002. * Disposes the component and the associated ressources.
  11003. */
  11004. dispose(): void;
  11005. private _beforeClear;
  11006. }
  11007. }
  11008. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11010. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11011. module "babylonjs/Engines/thinEngine" {
  11012. interface ThinEngine {
  11013. /**
  11014. * Creates a new render target cube texture
  11015. * @param size defines the size of the texture
  11016. * @param options defines the options used to create the texture
  11017. * @returns a new render target cube texture stored in an InternalTexture
  11018. */
  11019. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11020. }
  11021. }
  11022. }
  11023. declare module "babylonjs/Shaders/procedural.vertex" {
  11024. /** @hidden */
  11025. export var proceduralVertexShader: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11031. import { Observable } from "babylonjs/Misc/observable";
  11032. import { Nullable } from "babylonjs/types";
  11033. import { Scene } from "babylonjs/scene";
  11034. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11035. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11036. import { Effect } from "babylonjs/Materials/effect";
  11037. import { Texture } from "babylonjs/Materials/Textures/texture";
  11038. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11039. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11040. import "babylonjs/Shaders/procedural.vertex";
  11041. /**
  11042. * 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.
  11043. * This is the base class of any Procedural texture and contains most of the shareable code.
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11045. */
  11046. export class ProceduralTexture extends Texture {
  11047. isCube: boolean;
  11048. /**
  11049. * Define if the texture is enabled or not (disabled texture will not render)
  11050. */
  11051. isEnabled: boolean;
  11052. /**
  11053. * Define if the texture must be cleared before rendering (default is true)
  11054. */
  11055. autoClear: boolean;
  11056. /**
  11057. * Callback called when the texture is generated
  11058. */
  11059. onGenerated: () => void;
  11060. /**
  11061. * Event raised when the texture is generated
  11062. */
  11063. onGeneratedObservable: Observable<ProceduralTexture>;
  11064. /** @hidden */
  11065. _generateMipMaps: boolean;
  11066. /** @hidden **/
  11067. _effect: Effect;
  11068. /** @hidden */
  11069. _textures: {
  11070. [key: string]: Texture;
  11071. };
  11072. /** @hidden */
  11073. protected _fallbackTexture: Nullable<Texture>;
  11074. private _size;
  11075. private _currentRefreshId;
  11076. private _frameId;
  11077. private _refreshRate;
  11078. private _vertexBuffers;
  11079. private _indexBuffer;
  11080. private _uniforms;
  11081. private _samplers;
  11082. private _fragment;
  11083. private _floats;
  11084. private _ints;
  11085. private _floatsArrays;
  11086. private _colors3;
  11087. private _colors4;
  11088. private _vectors2;
  11089. private _vectors3;
  11090. private _matrices;
  11091. private _fallbackTextureUsed;
  11092. private _engine;
  11093. private _cachedDefines;
  11094. private _contentUpdateId;
  11095. private _contentData;
  11096. /**
  11097. * Instantiates a new procedural texture.
  11098. * 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.
  11099. * This is the base class of any Procedural texture and contains most of the shareable code.
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11101. * @param name Define the name of the texture
  11102. * @param size Define the size of the texture to create
  11103. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11104. * @param scene Define the scene the texture belongs to
  11105. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11106. * @param generateMipMaps Define if the texture should creates mip maps or not
  11107. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11108. */
  11109. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11110. /**
  11111. * The effect that is created when initializing the post process.
  11112. * @returns The created effect corresponding the the postprocess.
  11113. */
  11114. getEffect(): Effect;
  11115. /**
  11116. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11117. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11118. */
  11119. getContent(): Nullable<ArrayBufferView>;
  11120. private _createIndexBuffer;
  11121. /** @hidden */
  11122. _rebuild(): void;
  11123. /**
  11124. * Resets the texture in order to recreate its associated resources.
  11125. * This can be called in case of context loss
  11126. */
  11127. reset(): void;
  11128. protected _getDefines(): string;
  11129. /**
  11130. * Is the texture ready to be used ? (rendered at least once)
  11131. * @returns true if ready, otherwise, false.
  11132. */
  11133. isReady(): boolean;
  11134. /**
  11135. * Resets the refresh counter of the texture and start bak from scratch.
  11136. * Could be useful to regenerate the texture if it is setup to render only once.
  11137. */
  11138. resetRefreshCounter(): void;
  11139. /**
  11140. * Set the fragment shader to use in order to render the texture.
  11141. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11142. */
  11143. setFragment(fragment: any): void;
  11144. /**
  11145. * Define the refresh rate of the texture or the rendering frequency.
  11146. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11147. */
  11148. get refreshRate(): number;
  11149. set refreshRate(value: number);
  11150. /** @hidden */
  11151. _shouldRender(): boolean;
  11152. /**
  11153. * Get the size the texture is rendering at.
  11154. * @returns the size (texture is always squared)
  11155. */
  11156. getRenderSize(): number;
  11157. /**
  11158. * Resize the texture to new value.
  11159. * @param size Define the new size the texture should have
  11160. * @param generateMipMaps Define whether the new texture should create mip maps
  11161. */
  11162. resize(size: number, generateMipMaps: boolean): void;
  11163. private _checkUniform;
  11164. /**
  11165. * Set a texture in the shader program used to render.
  11166. * @param name Define the name of the uniform samplers as defined in the shader
  11167. * @param texture Define the texture to bind to this sampler
  11168. * @return the texture itself allowing "fluent" like uniform updates
  11169. */
  11170. setTexture(name: string, texture: Texture): ProceduralTexture;
  11171. /**
  11172. * Set a float in the shader.
  11173. * @param name Define the name of the uniform as defined in the shader
  11174. * @param value Define the value to give to the uniform
  11175. * @return the texture itself allowing "fluent" like uniform updates
  11176. */
  11177. setFloat(name: string, value: number): ProceduralTexture;
  11178. /**
  11179. * Set a int in the shader.
  11180. * @param name Define the name of the uniform as defined in the shader
  11181. * @param value Define the value to give to the uniform
  11182. * @return the texture itself allowing "fluent" like uniform updates
  11183. */
  11184. setInt(name: string, value: number): ProceduralTexture;
  11185. /**
  11186. * Set an array of floats in the shader.
  11187. * @param name Define the name of the uniform as defined in the shader
  11188. * @param value Define the value to give to the uniform
  11189. * @return the texture itself allowing "fluent" like uniform updates
  11190. */
  11191. setFloats(name: string, value: number[]): ProceduralTexture;
  11192. /**
  11193. * Set a vec3 in the shader from a Color3.
  11194. * @param name Define the name of the uniform as defined in the shader
  11195. * @param value Define the value to give to the uniform
  11196. * @return the texture itself allowing "fluent" like uniform updates
  11197. */
  11198. setColor3(name: string, value: Color3): ProceduralTexture;
  11199. /**
  11200. * Set a vec4 in the shader from a Color4.
  11201. * @param name Define the name of the uniform as defined in the shader
  11202. * @param value Define the value to give to the uniform
  11203. * @return the texture itself allowing "fluent" like uniform updates
  11204. */
  11205. setColor4(name: string, value: Color4): ProceduralTexture;
  11206. /**
  11207. * Set a vec2 in the shader from a Vector2.
  11208. * @param name Define the name of the uniform as defined in the shader
  11209. * @param value Define the value to give to the uniform
  11210. * @return the texture itself allowing "fluent" like uniform updates
  11211. */
  11212. setVector2(name: string, value: Vector2): ProceduralTexture;
  11213. /**
  11214. * Set a vec3 in the shader from a Vector3.
  11215. * @param name Define the name of the uniform as defined in the shader
  11216. * @param value Define the value to give to the uniform
  11217. * @return the texture itself allowing "fluent" like uniform updates
  11218. */
  11219. setVector3(name: string, value: Vector3): ProceduralTexture;
  11220. /**
  11221. * Set a mat4 in the shader from a MAtrix.
  11222. * @param name Define the name of the uniform as defined in the shader
  11223. * @param value Define the value to give to the uniform
  11224. * @return the texture itself allowing "fluent" like uniform updates
  11225. */
  11226. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11227. /**
  11228. * Render the texture to its associated render target.
  11229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11230. */
  11231. render(useCameraPostProcess?: boolean): void;
  11232. /**
  11233. * Clone the texture.
  11234. * @returns the cloned texture
  11235. */
  11236. clone(): ProceduralTexture;
  11237. /**
  11238. * Dispose the texture and release its asoociated resources.
  11239. */
  11240. dispose(): void;
  11241. }
  11242. }
  11243. declare module "babylonjs/Particles/baseParticleSystem" {
  11244. import { Nullable } from "babylonjs/types";
  11245. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11247. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11248. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11249. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11250. import { Scene } from "babylonjs/scene";
  11251. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11252. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11253. import { Texture } from "babylonjs/Materials/Textures/texture";
  11254. import { Color4 } from "babylonjs/Maths/math.color";
  11255. import { Animation } from "babylonjs/Animations/animation";
  11256. /**
  11257. * This represents the base class for particle system in Babylon.
  11258. * 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.
  11259. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11260. * @example https://doc.babylonjs.com/babylon101/particles
  11261. */
  11262. export class BaseParticleSystem {
  11263. /**
  11264. * Source color is added to the destination color without alpha affecting the result
  11265. */
  11266. static BLENDMODE_ONEONE: number;
  11267. /**
  11268. * Blend current color and particle color using particle’s alpha
  11269. */
  11270. static BLENDMODE_STANDARD: number;
  11271. /**
  11272. * Add current color and particle color multiplied by particle’s alpha
  11273. */
  11274. static BLENDMODE_ADD: number;
  11275. /**
  11276. * Multiply current color with particle color
  11277. */
  11278. static BLENDMODE_MULTIPLY: number;
  11279. /**
  11280. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11281. */
  11282. static BLENDMODE_MULTIPLYADD: number;
  11283. /**
  11284. * List of animations used by the particle system.
  11285. */
  11286. animations: Animation[];
  11287. /**
  11288. * Gets or sets the unique id of the particle system
  11289. */
  11290. uniqueId: number;
  11291. /**
  11292. * The id of the Particle system.
  11293. */
  11294. id: string;
  11295. /**
  11296. * The friendly name of the Particle system.
  11297. */
  11298. name: string;
  11299. /**
  11300. * Snippet ID if the particle system was created from the snippet server
  11301. */
  11302. snippetId: string;
  11303. /**
  11304. * The rendering group used by the Particle system to chose when to render.
  11305. */
  11306. renderingGroupId: number;
  11307. /**
  11308. * The emitter represents the Mesh or position we are attaching the particle system to.
  11309. */
  11310. emitter: Nullable<AbstractMesh | Vector3>;
  11311. /**
  11312. * The maximum number of particles to emit per frame
  11313. */
  11314. emitRate: number;
  11315. /**
  11316. * If you want to launch only a few particles at once, that can be done, as well.
  11317. */
  11318. manualEmitCount: number;
  11319. /**
  11320. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11321. */
  11322. updateSpeed: number;
  11323. /**
  11324. * The amount of time the particle system is running (depends of the overall update speed).
  11325. */
  11326. targetStopDuration: number;
  11327. /**
  11328. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11329. */
  11330. disposeOnStop: boolean;
  11331. /**
  11332. * Minimum power of emitting particles.
  11333. */
  11334. minEmitPower: number;
  11335. /**
  11336. * Maximum power of emitting particles.
  11337. */
  11338. maxEmitPower: number;
  11339. /**
  11340. * Minimum life time of emitting particles.
  11341. */
  11342. minLifeTime: number;
  11343. /**
  11344. * Maximum life time of emitting particles.
  11345. */
  11346. maxLifeTime: number;
  11347. /**
  11348. * Minimum Size of emitting particles.
  11349. */
  11350. minSize: number;
  11351. /**
  11352. * Maximum Size of emitting particles.
  11353. */
  11354. maxSize: number;
  11355. /**
  11356. * Minimum scale of emitting particles on X axis.
  11357. */
  11358. minScaleX: number;
  11359. /**
  11360. * Maximum scale of emitting particles on X axis.
  11361. */
  11362. maxScaleX: number;
  11363. /**
  11364. * Minimum scale of emitting particles on Y axis.
  11365. */
  11366. minScaleY: number;
  11367. /**
  11368. * Maximum scale of emitting particles on Y axis.
  11369. */
  11370. maxScaleY: number;
  11371. /**
  11372. * Gets or sets the minimal initial rotation in radians.
  11373. */
  11374. minInitialRotation: number;
  11375. /**
  11376. * Gets or sets the maximal initial rotation in radians.
  11377. */
  11378. maxInitialRotation: number;
  11379. /**
  11380. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11381. */
  11382. minAngularSpeed: number;
  11383. /**
  11384. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11385. */
  11386. maxAngularSpeed: number;
  11387. /**
  11388. * The texture used to render each particle. (this can be a spritesheet)
  11389. */
  11390. particleTexture: Nullable<Texture>;
  11391. /**
  11392. * The layer mask we are rendering the particles through.
  11393. */
  11394. layerMask: number;
  11395. /**
  11396. * This can help using your own shader to render the particle system.
  11397. * The according effect will be created
  11398. */
  11399. customShader: any;
  11400. /**
  11401. * By default particle system starts as soon as they are created. This prevents the
  11402. * automatic start to happen and let you decide when to start emitting particles.
  11403. */
  11404. preventAutoStart: boolean;
  11405. private _noiseTexture;
  11406. /**
  11407. * Gets or sets a texture used to add random noise to particle positions
  11408. */
  11409. get noiseTexture(): Nullable<ProceduralTexture>;
  11410. set noiseTexture(value: Nullable<ProceduralTexture>);
  11411. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11412. noiseStrength: Vector3;
  11413. /**
  11414. * Callback triggered when the particle animation is ending.
  11415. */
  11416. onAnimationEnd: Nullable<() => void>;
  11417. /**
  11418. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11419. */
  11420. blendMode: number;
  11421. /**
  11422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11423. * to override the particles.
  11424. */
  11425. forceDepthWrite: boolean;
  11426. /** 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 */
  11427. preWarmCycles: number;
  11428. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11429. preWarmStepOffset: number;
  11430. /**
  11431. * 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)
  11432. */
  11433. spriteCellChangeSpeed: number;
  11434. /**
  11435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11436. */
  11437. startSpriteCellID: number;
  11438. /**
  11439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11440. */
  11441. endSpriteCellID: number;
  11442. /**
  11443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11444. */
  11445. spriteCellWidth: number;
  11446. /**
  11447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11448. */
  11449. spriteCellHeight: number;
  11450. /**
  11451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11452. */
  11453. spriteRandomStartCell: boolean;
  11454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11455. translationPivot: Vector2;
  11456. /** @hidden */
  11457. protected _isAnimationSheetEnabled: boolean;
  11458. /**
  11459. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11460. */
  11461. beginAnimationOnStart: boolean;
  11462. /**
  11463. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11464. */
  11465. beginAnimationFrom: number;
  11466. /**
  11467. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11468. */
  11469. beginAnimationTo: number;
  11470. /**
  11471. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11472. */
  11473. beginAnimationLoop: boolean;
  11474. /**
  11475. * Gets or sets a world offset applied to all particles
  11476. */
  11477. worldOffset: Vector3;
  11478. /**
  11479. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11480. */
  11481. get isAnimationSheetEnabled(): boolean;
  11482. set isAnimationSheetEnabled(value: boolean);
  11483. /**
  11484. * Get hosting scene
  11485. * @returns the scene
  11486. */
  11487. getScene(): Scene;
  11488. /**
  11489. * You can use gravity if you want to give an orientation to your particles.
  11490. */
  11491. gravity: Vector3;
  11492. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11493. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11494. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11495. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11496. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11497. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11498. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11499. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11500. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11501. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11502. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11503. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11504. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11505. /**
  11506. * Defines the delay in milliseconds before starting the system (0 by default)
  11507. */
  11508. startDelay: number;
  11509. /**
  11510. * Gets the current list of drag gradients.
  11511. * You must use addDragGradient and removeDragGradient to udpate this list
  11512. * @returns the list of drag gradients
  11513. */
  11514. getDragGradients(): Nullable<Array<FactorGradient>>;
  11515. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11516. limitVelocityDamping: number;
  11517. /**
  11518. * Gets the current list of limit velocity gradients.
  11519. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11520. * @returns the list of limit velocity gradients
  11521. */
  11522. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11523. /**
  11524. * Gets the current list of color gradients.
  11525. * You must use addColorGradient and removeColorGradient to udpate this list
  11526. * @returns the list of color gradients
  11527. */
  11528. getColorGradients(): Nullable<Array<ColorGradient>>;
  11529. /**
  11530. * Gets the current list of size gradients.
  11531. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11532. * @returns the list of size gradients
  11533. */
  11534. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11535. /**
  11536. * Gets the current list of color remap gradients.
  11537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11538. * @returns the list of color remap gradients
  11539. */
  11540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11541. /**
  11542. * Gets the current list of alpha remap gradients.
  11543. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11544. * @returns the list of alpha remap gradients
  11545. */
  11546. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11547. /**
  11548. * Gets the current list of life time gradients.
  11549. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11550. * @returns the list of life time gradients
  11551. */
  11552. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11553. /**
  11554. * Gets the current list of angular speed gradients.
  11555. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11556. * @returns the list of angular speed gradients
  11557. */
  11558. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11559. /**
  11560. * Gets the current list of velocity gradients.
  11561. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11562. * @returns the list of velocity gradients
  11563. */
  11564. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11565. /**
  11566. * Gets the current list of start size gradients.
  11567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11568. * @returns the list of start size gradients
  11569. */
  11570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11571. /**
  11572. * Gets the current list of emit rate gradients.
  11573. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11574. * @returns the list of emit rate gradients
  11575. */
  11576. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11577. /**
  11578. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11580. */
  11581. get direction1(): Vector3;
  11582. set direction1(value: Vector3);
  11583. /**
  11584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11586. */
  11587. get direction2(): Vector3;
  11588. set direction2(value: Vector3);
  11589. /**
  11590. * 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.
  11591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11592. */
  11593. get minEmitBox(): Vector3;
  11594. set minEmitBox(value: Vector3);
  11595. /**
  11596. * 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.
  11597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11598. */
  11599. get maxEmitBox(): Vector3;
  11600. set maxEmitBox(value: Vector3);
  11601. /**
  11602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11603. */
  11604. color1: Color4;
  11605. /**
  11606. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11607. */
  11608. color2: Color4;
  11609. /**
  11610. * Color the particle will have at the end of its lifetime
  11611. */
  11612. colorDead: Color4;
  11613. /**
  11614. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11615. */
  11616. textureMask: Color4;
  11617. /**
  11618. * The particle emitter type defines the emitter used by the particle system.
  11619. * It can be for example box, sphere, or cone...
  11620. */
  11621. particleEmitterType: IParticleEmitterType;
  11622. /** @hidden */
  11623. _isSubEmitter: boolean;
  11624. /**
  11625. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11626. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11627. */
  11628. billboardMode: number;
  11629. protected _isBillboardBased: boolean;
  11630. /**
  11631. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11632. */
  11633. get isBillboardBased(): boolean;
  11634. set isBillboardBased(value: boolean);
  11635. /**
  11636. * The scene the particle system belongs to.
  11637. */
  11638. protected _scene: Scene;
  11639. /**
  11640. * Local cache of defines for image processing.
  11641. */
  11642. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11643. /**
  11644. * Default configuration related to image processing available in the standard Material.
  11645. */
  11646. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11647. /**
  11648. * Gets the image processing configuration used either in this material.
  11649. */
  11650. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11651. /**
  11652. * Sets the Default image processing configuration used either in the this material.
  11653. *
  11654. * If sets to null, the scene one is in use.
  11655. */
  11656. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11657. /**
  11658. * Attaches a new image processing configuration to the Standard Material.
  11659. * @param configuration
  11660. */
  11661. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11662. /** @hidden */
  11663. protected _reset(): void;
  11664. /** @hidden */
  11665. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11666. /**
  11667. * Instantiates a particle system.
  11668. * 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.
  11669. * @param name The name of the particle system
  11670. */
  11671. constructor(name: string);
  11672. /**
  11673. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11676. * @returns the emitter
  11677. */
  11678. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11679. /**
  11680. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11681. * @param radius The radius of the hemisphere to emit from
  11682. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11683. * @returns the emitter
  11684. */
  11685. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11686. /**
  11687. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11688. * @param radius The radius of the sphere to emit from
  11689. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11690. * @returns the emitter
  11691. */
  11692. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11693. /**
  11694. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11695. * @param radius The radius of the sphere to emit from
  11696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11698. * @returns the emitter
  11699. */
  11700. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11701. /**
  11702. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11703. * @param radius The radius of the emission cylinder
  11704. * @param height The height of the emission cylinder
  11705. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11706. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11707. * @returns the emitter
  11708. */
  11709. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11710. /**
  11711. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11712. * @param radius The radius of the cylinder to emit from
  11713. * @param height The height of the emission cylinder
  11714. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11717. * @returns the emitter
  11718. */
  11719. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11720. /**
  11721. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11722. * @param radius The radius of the cone to emit from
  11723. * @param angle The base angle of the cone
  11724. * @returns the emitter
  11725. */
  11726. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11727. /**
  11728. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11731. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11732. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11733. * @returns the emitter
  11734. */
  11735. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11736. }
  11737. }
  11738. declare module "babylonjs/Particles/subEmitter" {
  11739. import { Scene } from "babylonjs/scene";
  11740. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11741. /**
  11742. * Type of sub emitter
  11743. */
  11744. export enum SubEmitterType {
  11745. /**
  11746. * Attached to the particle over it's lifetime
  11747. */
  11748. ATTACHED = 0,
  11749. /**
  11750. * Created when the particle dies
  11751. */
  11752. END = 1
  11753. }
  11754. /**
  11755. * Sub emitter class used to emit particles from an existing particle
  11756. */
  11757. export class SubEmitter {
  11758. /**
  11759. * the particle system to be used by the sub emitter
  11760. */
  11761. particleSystem: ParticleSystem;
  11762. /**
  11763. * Type of the submitter (Default: END)
  11764. */
  11765. type: SubEmitterType;
  11766. /**
  11767. * 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)
  11768. * Note: This only is supported when using an emitter of type Mesh
  11769. */
  11770. inheritDirection: boolean;
  11771. /**
  11772. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11773. */
  11774. inheritedVelocityAmount: number;
  11775. /**
  11776. * Creates a sub emitter
  11777. * @param particleSystem the particle system to be used by the sub emitter
  11778. */
  11779. constructor(
  11780. /**
  11781. * the particle system to be used by the sub emitter
  11782. */
  11783. particleSystem: ParticleSystem);
  11784. /**
  11785. * Clones the sub emitter
  11786. * @returns the cloned sub emitter
  11787. */
  11788. clone(): SubEmitter;
  11789. /**
  11790. * Serialize current object to a JSON object
  11791. * @returns the serialized object
  11792. */
  11793. serialize(): any;
  11794. /** @hidden */
  11795. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11796. /**
  11797. * Creates a new SubEmitter from a serialized JSON version
  11798. * @param serializationObject defines the JSON object to read from
  11799. * @param scene defines the hosting scene
  11800. * @param rootUrl defines the rootUrl for data loading
  11801. * @returns a new SubEmitter
  11802. */
  11803. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11804. /** Release associated resources */
  11805. dispose(): void;
  11806. }
  11807. }
  11808. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11809. /** @hidden */
  11810. export var imageProcessingDeclaration: {
  11811. name: string;
  11812. shader: string;
  11813. };
  11814. }
  11815. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11816. /** @hidden */
  11817. export var imageProcessingFunctions: {
  11818. name: string;
  11819. shader: string;
  11820. };
  11821. }
  11822. declare module "babylonjs/Shaders/particles.fragment" {
  11823. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11824. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11826. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11828. /** @hidden */
  11829. export var particlesPixelShader: {
  11830. name: string;
  11831. shader: string;
  11832. };
  11833. }
  11834. declare module "babylonjs/Shaders/particles.vertex" {
  11835. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11836. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11837. /** @hidden */
  11838. export var particlesVertexShader: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Particles/particleSystem" {
  11844. import { Nullable } from "babylonjs/types";
  11845. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11846. import { Observable } from "babylonjs/Misc/observable";
  11847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11848. import { Effect } from "babylonjs/Materials/effect";
  11849. import { Scene, IDisposable } from "babylonjs/scene";
  11850. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11851. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11852. import { Particle } from "babylonjs/Particles/particle";
  11853. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11854. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11855. import "babylonjs/Shaders/particles.fragment";
  11856. import "babylonjs/Shaders/particles.vertex";
  11857. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11858. /**
  11859. * This represents a particle system in Babylon.
  11860. * 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.
  11861. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11862. * @example https://doc.babylonjs.com/babylon101/particles
  11863. */
  11864. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11865. /**
  11866. * Billboard mode will only apply to Y axis
  11867. */
  11868. static readonly BILLBOARDMODE_Y: number;
  11869. /**
  11870. * Billboard mode will apply to all axes
  11871. */
  11872. static readonly BILLBOARDMODE_ALL: number;
  11873. /**
  11874. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11875. */
  11876. static readonly BILLBOARDMODE_STRETCHED: number;
  11877. /**
  11878. * This function can be defined to provide custom update for active particles.
  11879. * This function will be called instead of regular update (age, position, color, etc.).
  11880. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11881. */
  11882. updateFunction: (particles: Particle[]) => void;
  11883. private _emitterWorldMatrix;
  11884. /**
  11885. * This function can be defined to specify initial direction for every new particle.
  11886. * It by default use the emitterType defined function
  11887. */
  11888. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11889. /**
  11890. * This function can be defined to specify initial position for every new particle.
  11891. * It by default use the emitterType defined function
  11892. */
  11893. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11894. /**
  11895. * @hidden
  11896. */
  11897. _inheritedVelocityOffset: Vector3;
  11898. /**
  11899. * An event triggered when the system is disposed
  11900. */
  11901. onDisposeObservable: Observable<ParticleSystem>;
  11902. private _onDisposeObserver;
  11903. /**
  11904. * Sets a callback that will be triggered when the system is disposed
  11905. */
  11906. set onDispose(callback: () => void);
  11907. private _particles;
  11908. private _epsilon;
  11909. private _capacity;
  11910. private _stockParticles;
  11911. private _newPartsExcess;
  11912. private _vertexData;
  11913. private _vertexBuffer;
  11914. private _vertexBuffers;
  11915. private _spriteBuffer;
  11916. private _indexBuffer;
  11917. private _effect;
  11918. private _customEffect;
  11919. private _cachedDefines;
  11920. private _scaledColorStep;
  11921. private _colorDiff;
  11922. private _scaledDirection;
  11923. private _scaledGravity;
  11924. private _currentRenderId;
  11925. private _alive;
  11926. private _useInstancing;
  11927. private _started;
  11928. private _stopped;
  11929. private _actualFrame;
  11930. private _scaledUpdateSpeed;
  11931. private _vertexBufferSize;
  11932. /** @hidden */
  11933. _currentEmitRateGradient: Nullable<FactorGradient>;
  11934. /** @hidden */
  11935. _currentEmitRate1: number;
  11936. /** @hidden */
  11937. _currentEmitRate2: number;
  11938. /** @hidden */
  11939. _currentStartSizeGradient: Nullable<FactorGradient>;
  11940. /** @hidden */
  11941. _currentStartSize1: number;
  11942. /** @hidden */
  11943. _currentStartSize2: number;
  11944. private readonly _rawTextureWidth;
  11945. private _rampGradientsTexture;
  11946. private _useRampGradients;
  11947. /** Gets or sets a boolean indicating that ramp gradients must be used
  11948. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11949. */
  11950. get useRampGradients(): boolean;
  11951. set useRampGradients(value: boolean);
  11952. /**
  11953. * 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.
  11954. * 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: [])
  11955. */
  11956. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11957. private _subEmitters;
  11958. /**
  11959. * @hidden
  11960. * If the particle systems emitter should be disposed when the particle system is disposed
  11961. */
  11962. _disposeEmitterOnDispose: boolean;
  11963. /**
  11964. * The current active Sub-systems, this property is used by the root particle system only.
  11965. */
  11966. activeSubSystems: Array<ParticleSystem>;
  11967. /**
  11968. * Specifies if the particles are updated in emitter local space or world space
  11969. */
  11970. isLocal: boolean;
  11971. private _rootParticleSystem;
  11972. /**
  11973. * Gets the current list of active particles
  11974. */
  11975. get particles(): Particle[];
  11976. /**
  11977. * Gets the number of particles active at the same time.
  11978. * @returns The number of active particles.
  11979. */
  11980. getActiveCount(): number;
  11981. /**
  11982. * Returns the string "ParticleSystem"
  11983. * @returns a string containing the class name
  11984. */
  11985. getClassName(): string;
  11986. /**
  11987. * Gets a boolean indicating that the system is stopping
  11988. * @returns true if the system is currently stopping
  11989. */
  11990. isStopping(): boolean;
  11991. /**
  11992. * Instantiates a particle system.
  11993. * 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.
  11994. * @param name The name of the particle system
  11995. * @param capacity The max number of particles alive at the same time
  11996. * @param scene The scene the particle system belongs to
  11997. * @param customEffect a custom effect used to change the way particles are rendered by default
  11998. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11999. * @param epsilon Offset used to render the particles
  12000. */
  12001. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12002. private _addFactorGradient;
  12003. private _removeFactorGradient;
  12004. /**
  12005. * Adds a new life time gradient
  12006. * @param gradient defines the gradient to use (between 0 and 1)
  12007. * @param factor defines the life time factor to affect to the specified gradient
  12008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12009. * @returns the current particle system
  12010. */
  12011. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12012. /**
  12013. * Remove a specific life time gradient
  12014. * @param gradient defines the gradient to remove
  12015. * @returns the current particle system
  12016. */
  12017. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12018. /**
  12019. * Adds a new size gradient
  12020. * @param gradient defines the gradient to use (between 0 and 1)
  12021. * @param factor defines the size factor to affect to the specified gradient
  12022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12023. * @returns the current particle system
  12024. */
  12025. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12026. /**
  12027. * Remove a specific size gradient
  12028. * @param gradient defines the gradient to remove
  12029. * @returns the current particle system
  12030. */
  12031. removeSizeGradient(gradient: number): IParticleSystem;
  12032. /**
  12033. * Adds a new color remap gradient
  12034. * @param gradient defines the gradient to use (between 0 and 1)
  12035. * @param min defines the color remap minimal range
  12036. * @param max defines the color remap maximal range
  12037. * @returns the current particle system
  12038. */
  12039. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12040. /**
  12041. * Remove a specific color remap gradient
  12042. * @param gradient defines the gradient to remove
  12043. * @returns the current particle system
  12044. */
  12045. removeColorRemapGradient(gradient: number): IParticleSystem;
  12046. /**
  12047. * Adds a new alpha remap gradient
  12048. * @param gradient defines the gradient to use (between 0 and 1)
  12049. * @param min defines the alpha remap minimal range
  12050. * @param max defines the alpha remap maximal range
  12051. * @returns the current particle system
  12052. */
  12053. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12054. /**
  12055. * Remove a specific alpha remap gradient
  12056. * @param gradient defines the gradient to remove
  12057. * @returns the current particle system
  12058. */
  12059. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12060. /**
  12061. * Adds a new angular speed gradient
  12062. * @param gradient defines the gradient to use (between 0 and 1)
  12063. * @param factor defines the angular speed to affect to the specified gradient
  12064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12065. * @returns the current particle system
  12066. */
  12067. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12068. /**
  12069. * Remove a specific angular speed gradient
  12070. * @param gradient defines the gradient to remove
  12071. * @returns the current particle system
  12072. */
  12073. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12074. /**
  12075. * Adds a new velocity gradient
  12076. * @param gradient defines the gradient to use (between 0 and 1)
  12077. * @param factor defines the velocity to affect to the specified gradient
  12078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12079. * @returns the current particle system
  12080. */
  12081. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12082. /**
  12083. * Remove a specific velocity gradient
  12084. * @param gradient defines the gradient to remove
  12085. * @returns the current particle system
  12086. */
  12087. removeVelocityGradient(gradient: number): IParticleSystem;
  12088. /**
  12089. * Adds a new limit velocity gradient
  12090. * @param gradient defines the gradient to use (between 0 and 1)
  12091. * @param factor defines the limit velocity value to affect to the specified gradient
  12092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12093. * @returns the current particle system
  12094. */
  12095. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12096. /**
  12097. * Remove a specific limit velocity gradient
  12098. * @param gradient defines the gradient to remove
  12099. * @returns the current particle system
  12100. */
  12101. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12102. /**
  12103. * Adds a new drag gradient
  12104. * @param gradient defines the gradient to use (between 0 and 1)
  12105. * @param factor defines the drag value to affect to the specified gradient
  12106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12107. * @returns the current particle system
  12108. */
  12109. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12110. /**
  12111. * Remove a specific drag gradient
  12112. * @param gradient defines the gradient to remove
  12113. * @returns the current particle system
  12114. */
  12115. removeDragGradient(gradient: number): IParticleSystem;
  12116. /**
  12117. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12118. * @param gradient defines the gradient to use (between 0 and 1)
  12119. * @param factor defines the emit rate value to affect to the specified gradient
  12120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12121. * @returns the current particle system
  12122. */
  12123. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12124. /**
  12125. * Remove a specific emit rate gradient
  12126. * @param gradient defines the gradient to remove
  12127. * @returns the current particle system
  12128. */
  12129. removeEmitRateGradient(gradient: number): IParticleSystem;
  12130. /**
  12131. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12132. * @param gradient defines the gradient to use (between 0 and 1)
  12133. * @param factor defines the start size value to affect to the specified gradient
  12134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12135. * @returns the current particle system
  12136. */
  12137. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12138. /**
  12139. * Remove a specific start size gradient
  12140. * @param gradient defines the gradient to remove
  12141. * @returns the current particle system
  12142. */
  12143. removeStartSizeGradient(gradient: number): IParticleSystem;
  12144. private _createRampGradientTexture;
  12145. /**
  12146. * Gets the current list of ramp gradients.
  12147. * You must use addRampGradient and removeRampGradient to udpate this list
  12148. * @returns the list of ramp gradients
  12149. */
  12150. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12151. /**
  12152. * Adds a new ramp gradient used to remap particle colors
  12153. * @param gradient defines the gradient to use (between 0 and 1)
  12154. * @param color defines the color to affect to the specified gradient
  12155. * @returns the current particle system
  12156. */
  12157. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12158. /**
  12159. * Remove a specific ramp gradient
  12160. * @param gradient defines the gradient to remove
  12161. * @returns the current particle system
  12162. */
  12163. removeRampGradient(gradient: number): ParticleSystem;
  12164. /**
  12165. * Adds a new color gradient
  12166. * @param gradient defines the gradient to use (between 0 and 1)
  12167. * @param color1 defines the color to affect to the specified gradient
  12168. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12169. * @returns this particle system
  12170. */
  12171. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12172. /**
  12173. * Remove a specific color gradient
  12174. * @param gradient defines the gradient to remove
  12175. * @returns this particle system
  12176. */
  12177. removeColorGradient(gradient: number): IParticleSystem;
  12178. private _fetchR;
  12179. protected _reset(): void;
  12180. private _resetEffect;
  12181. private _createVertexBuffers;
  12182. private _createIndexBuffer;
  12183. /**
  12184. * Gets the maximum number of particles active at the same time.
  12185. * @returns The max number of active particles.
  12186. */
  12187. getCapacity(): number;
  12188. /**
  12189. * Gets whether there are still active particles in the system.
  12190. * @returns True if it is alive, otherwise false.
  12191. */
  12192. isAlive(): boolean;
  12193. /**
  12194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12195. * @returns True if it has been started, otherwise false.
  12196. */
  12197. isStarted(): boolean;
  12198. private _prepareSubEmitterInternalArray;
  12199. /**
  12200. * Starts the particle system and begins to emit
  12201. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12202. */
  12203. start(delay?: number): void;
  12204. /**
  12205. * Stops the particle system.
  12206. * @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.
  12207. */
  12208. stop(stopSubEmitters?: boolean): void;
  12209. /**
  12210. * Remove all active particles
  12211. */
  12212. reset(): void;
  12213. /**
  12214. * @hidden (for internal use only)
  12215. */
  12216. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12217. /**
  12218. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12219. * Its lifetime will start back at 0.
  12220. */
  12221. recycleParticle: (particle: Particle) => void;
  12222. private _stopSubEmitters;
  12223. private _createParticle;
  12224. private _removeFromRoot;
  12225. private _emitFromParticle;
  12226. private _update;
  12227. /** @hidden */
  12228. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12229. /** @hidden */
  12230. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12231. /** @hidden */
  12232. private _getEffect;
  12233. /**
  12234. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12235. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12236. */
  12237. animate(preWarmOnly?: boolean): void;
  12238. private _appendParticleVertices;
  12239. /**
  12240. * Rebuilds the particle system.
  12241. */
  12242. rebuild(): void;
  12243. /**
  12244. * Is this system ready to be used/rendered
  12245. * @return true if the system is ready
  12246. */
  12247. isReady(): boolean;
  12248. private _render;
  12249. /**
  12250. * Renders the particle system in its current state.
  12251. * @returns the current number of particles
  12252. */
  12253. render(): number;
  12254. /**
  12255. * Disposes the particle system and free the associated resources
  12256. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12257. */
  12258. dispose(disposeTexture?: boolean): void;
  12259. /**
  12260. * Clones the particle system.
  12261. * @param name The name of the cloned object
  12262. * @param newEmitter The new emitter to use
  12263. * @returns the cloned particle system
  12264. */
  12265. clone(name: string, newEmitter: any): ParticleSystem;
  12266. /**
  12267. * Serializes the particle system to a JSON object.
  12268. * @returns the JSON object
  12269. */
  12270. serialize(): any;
  12271. /** @hidden */
  12272. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12273. /** @hidden */
  12274. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12275. /**
  12276. * Parses a JSON object to create a particle system.
  12277. * @param parsedParticleSystem The JSON object to parse
  12278. * @param scene The scene to create the particle system in
  12279. * @param rootUrl The root url to use to load external dependencies like texture
  12280. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12281. * @returns the Parsed particle system
  12282. */
  12283. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12284. }
  12285. }
  12286. declare module "babylonjs/Particles/particle" {
  12287. import { Nullable } from "babylonjs/types";
  12288. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12289. import { Color4 } from "babylonjs/Maths/math.color";
  12290. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12291. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12292. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12293. /**
  12294. * A particle represents one of the element emitted by a particle system.
  12295. * This is mainly define by its coordinates, direction, velocity and age.
  12296. */
  12297. export class Particle {
  12298. /**
  12299. * The particle system the particle belongs to.
  12300. */
  12301. particleSystem: ParticleSystem;
  12302. private static _Count;
  12303. /**
  12304. * Unique ID of the particle
  12305. */
  12306. id: number;
  12307. /**
  12308. * The world position of the particle in the scene.
  12309. */
  12310. position: Vector3;
  12311. /**
  12312. * The world direction of the particle in the scene.
  12313. */
  12314. direction: Vector3;
  12315. /**
  12316. * The color of the particle.
  12317. */
  12318. color: Color4;
  12319. /**
  12320. * The color change of the particle per step.
  12321. */
  12322. colorStep: Color4;
  12323. /**
  12324. * Defines how long will the life of the particle be.
  12325. */
  12326. lifeTime: number;
  12327. /**
  12328. * The current age of the particle.
  12329. */
  12330. age: number;
  12331. /**
  12332. * The current size of the particle.
  12333. */
  12334. size: number;
  12335. /**
  12336. * The current scale of the particle.
  12337. */
  12338. scale: Vector2;
  12339. /**
  12340. * The current angle of the particle.
  12341. */
  12342. angle: number;
  12343. /**
  12344. * Defines how fast is the angle changing.
  12345. */
  12346. angularSpeed: number;
  12347. /**
  12348. * Defines the cell index used by the particle to be rendered from a sprite.
  12349. */
  12350. cellIndex: number;
  12351. /**
  12352. * The information required to support color remapping
  12353. */
  12354. remapData: Vector4;
  12355. /** @hidden */
  12356. _randomCellOffset?: number;
  12357. /** @hidden */
  12358. _initialDirection: Nullable<Vector3>;
  12359. /** @hidden */
  12360. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12361. /** @hidden */
  12362. _initialStartSpriteCellID: number;
  12363. /** @hidden */
  12364. _initialEndSpriteCellID: number;
  12365. /** @hidden */
  12366. _currentColorGradient: Nullable<ColorGradient>;
  12367. /** @hidden */
  12368. _currentColor1: Color4;
  12369. /** @hidden */
  12370. _currentColor2: Color4;
  12371. /** @hidden */
  12372. _currentSizeGradient: Nullable<FactorGradient>;
  12373. /** @hidden */
  12374. _currentSize1: number;
  12375. /** @hidden */
  12376. _currentSize2: number;
  12377. /** @hidden */
  12378. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12379. /** @hidden */
  12380. _currentAngularSpeed1: number;
  12381. /** @hidden */
  12382. _currentAngularSpeed2: number;
  12383. /** @hidden */
  12384. _currentVelocityGradient: Nullable<FactorGradient>;
  12385. /** @hidden */
  12386. _currentVelocity1: number;
  12387. /** @hidden */
  12388. _currentVelocity2: number;
  12389. /** @hidden */
  12390. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12391. /** @hidden */
  12392. _currentLimitVelocity1: number;
  12393. /** @hidden */
  12394. _currentLimitVelocity2: number;
  12395. /** @hidden */
  12396. _currentDragGradient: Nullable<FactorGradient>;
  12397. /** @hidden */
  12398. _currentDrag1: number;
  12399. /** @hidden */
  12400. _currentDrag2: number;
  12401. /** @hidden */
  12402. _randomNoiseCoordinates1: Vector3;
  12403. /** @hidden */
  12404. _randomNoiseCoordinates2: Vector3;
  12405. /** @hidden */
  12406. _localPosition?: Vector3;
  12407. /**
  12408. * Creates a new instance Particle
  12409. * @param particleSystem the particle system the particle belongs to
  12410. */
  12411. constructor(
  12412. /**
  12413. * The particle system the particle belongs to.
  12414. */
  12415. particleSystem: ParticleSystem);
  12416. private updateCellInfoFromSystem;
  12417. /**
  12418. * Defines how the sprite cell index is updated for the particle
  12419. */
  12420. updateCellIndex(): void;
  12421. /** @hidden */
  12422. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12423. /** @hidden */
  12424. _inheritParticleInfoToSubEmitters(): void;
  12425. /** @hidden */
  12426. _reset(): void;
  12427. /**
  12428. * Copy the properties of particle to another one.
  12429. * @param other the particle to copy the information to.
  12430. */
  12431. copyTo(other: Particle): void;
  12432. }
  12433. }
  12434. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12435. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12436. import { Effect } from "babylonjs/Materials/effect";
  12437. import { Particle } from "babylonjs/Particles/particle";
  12438. import { Scene } from "babylonjs/scene";
  12439. /**
  12440. * Particle emitter represents a volume emitting particles.
  12441. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12442. */
  12443. export interface IParticleEmitterType {
  12444. /**
  12445. * Called by the particle System when the direction is computed for the created particle.
  12446. * @param worldMatrix is the world matrix of the particle system
  12447. * @param directionToUpdate is the direction vector to update with the result
  12448. * @param particle is the particle we are computed the direction for
  12449. * @param isLocal defines if the direction should be set in local space
  12450. */
  12451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12452. /**
  12453. * Called by the particle System when the position is computed for the created particle.
  12454. * @param worldMatrix is the world matrix of the particle system
  12455. * @param positionToUpdate is the position vector to update with the result
  12456. * @param particle is the particle we are computed the position for
  12457. * @param isLocal defines if the position should be set in local space
  12458. */
  12459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12460. /**
  12461. * Clones the current emitter and returns a copy of it
  12462. * @returns the new emitter
  12463. */
  12464. clone(): IParticleEmitterType;
  12465. /**
  12466. * Called by the GPUParticleSystem to setup the update shader
  12467. * @param effect defines the update shader
  12468. */
  12469. applyToShader(effect: Effect): void;
  12470. /**
  12471. * Returns a string to use to update the GPU particles update shader
  12472. * @returns the effect defines string
  12473. */
  12474. getEffectDefines(): string;
  12475. /**
  12476. * Returns a string representing the class name
  12477. * @returns a string containing the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Serializes the particle system to a JSON object.
  12482. * @returns the JSON object
  12483. */
  12484. serialize(): any;
  12485. /**
  12486. * Parse properties from a JSON object
  12487. * @param serializationObject defines the JSON object
  12488. * @param scene defines the hosting scene
  12489. */
  12490. parse(serializationObject: any, scene: Scene): void;
  12491. }
  12492. }
  12493. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12494. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12495. import { Effect } from "babylonjs/Materials/effect";
  12496. import { Particle } from "babylonjs/Particles/particle";
  12497. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12498. /**
  12499. * Particle emitter emitting particles from the inside of a box.
  12500. * It emits the particles randomly between 2 given directions.
  12501. */
  12502. export class BoxParticleEmitter implements IParticleEmitterType {
  12503. /**
  12504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12505. */
  12506. direction1: Vector3;
  12507. /**
  12508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12509. */
  12510. direction2: Vector3;
  12511. /**
  12512. * 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.
  12513. */
  12514. minEmitBox: Vector3;
  12515. /**
  12516. * 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.
  12517. */
  12518. maxEmitBox: Vector3;
  12519. /**
  12520. * Creates a new instance BoxParticleEmitter
  12521. */
  12522. constructor();
  12523. /**
  12524. * Called by the particle System when the direction is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param directionToUpdate is the direction vector to update with the result
  12527. * @param particle is the particle we are computed the direction for
  12528. * @param isLocal defines if the direction should be set in local space
  12529. */
  12530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12531. /**
  12532. * Called by the particle System when the position is computed for the created particle.
  12533. * @param worldMatrix is the world matrix of the particle system
  12534. * @param positionToUpdate is the position vector to update with the result
  12535. * @param particle is the particle we are computed the position for
  12536. * @param isLocal defines if the position should be set in local space
  12537. */
  12538. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12539. /**
  12540. * Clones the current emitter and returns a copy of it
  12541. * @returns the new emitter
  12542. */
  12543. clone(): BoxParticleEmitter;
  12544. /**
  12545. * Called by the GPUParticleSystem to setup the update shader
  12546. * @param effect defines the update shader
  12547. */
  12548. applyToShader(effect: Effect): void;
  12549. /**
  12550. * Returns a string to use to update the GPU particles update shader
  12551. * @returns a string containng the defines string
  12552. */
  12553. getEffectDefines(): string;
  12554. /**
  12555. * Returns the string "BoxParticleEmitter"
  12556. * @returns a string containing the class name
  12557. */
  12558. getClassName(): string;
  12559. /**
  12560. * Serializes the particle system to a JSON object.
  12561. * @returns the JSON object
  12562. */
  12563. serialize(): any;
  12564. /**
  12565. * Parse properties from a JSON object
  12566. * @param serializationObject defines the JSON object
  12567. */
  12568. parse(serializationObject: any): void;
  12569. }
  12570. }
  12571. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12572. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12573. import { Effect } from "babylonjs/Materials/effect";
  12574. import { Particle } from "babylonjs/Particles/particle";
  12575. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12576. /**
  12577. * Particle emitter emitting particles from the inside of a cone.
  12578. * It emits the particles alongside the cone volume from the base to the particle.
  12579. * The emission direction might be randomized.
  12580. */
  12581. export class ConeParticleEmitter implements IParticleEmitterType {
  12582. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12583. directionRandomizer: number;
  12584. private _radius;
  12585. private _angle;
  12586. private _height;
  12587. /**
  12588. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12589. */
  12590. radiusRange: number;
  12591. /**
  12592. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12593. */
  12594. heightRange: number;
  12595. /**
  12596. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12597. */
  12598. emitFromSpawnPointOnly: boolean;
  12599. /**
  12600. * Gets or sets the radius of the emission cone
  12601. */
  12602. get radius(): number;
  12603. set radius(value: number);
  12604. /**
  12605. * Gets or sets the angle of the emission cone
  12606. */
  12607. get angle(): number;
  12608. set angle(value: number);
  12609. private _buildHeight;
  12610. /**
  12611. * Creates a new instance ConeParticleEmitter
  12612. * @param radius the radius of the emission cone (1 by default)
  12613. * @param angle the cone base angle (PI by default)
  12614. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12615. */
  12616. constructor(radius?: number, angle?: number,
  12617. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12618. directionRandomizer?: number);
  12619. /**
  12620. * Called by the particle System when the direction is computed for the created particle.
  12621. * @param worldMatrix is the world matrix of the particle system
  12622. * @param directionToUpdate is the direction vector to update with the result
  12623. * @param particle is the particle we are computed the direction for
  12624. * @param isLocal defines if the direction should be set in local space
  12625. */
  12626. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12627. /**
  12628. * Called by the particle System when the position is computed for the created particle.
  12629. * @param worldMatrix is the world matrix of the particle system
  12630. * @param positionToUpdate is the position vector to update with the result
  12631. * @param particle is the particle we are computed the position for
  12632. * @param isLocal defines if the position should be set in local space
  12633. */
  12634. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12635. /**
  12636. * Clones the current emitter and returns a copy of it
  12637. * @returns the new emitter
  12638. */
  12639. clone(): ConeParticleEmitter;
  12640. /**
  12641. * Called by the GPUParticleSystem to setup the update shader
  12642. * @param effect defines the update shader
  12643. */
  12644. applyToShader(effect: Effect): void;
  12645. /**
  12646. * Returns a string to use to update the GPU particles update shader
  12647. * @returns a string containng the defines string
  12648. */
  12649. getEffectDefines(): string;
  12650. /**
  12651. * Returns the string "ConeParticleEmitter"
  12652. * @returns a string containing the class name
  12653. */
  12654. getClassName(): string;
  12655. /**
  12656. * Serializes the particle system to a JSON object.
  12657. * @returns the JSON object
  12658. */
  12659. serialize(): any;
  12660. /**
  12661. * Parse properties from a JSON object
  12662. * @param serializationObject defines the JSON object
  12663. */
  12664. parse(serializationObject: any): void;
  12665. }
  12666. }
  12667. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12668. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12669. import { Effect } from "babylonjs/Materials/effect";
  12670. import { Particle } from "babylonjs/Particles/particle";
  12671. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12672. /**
  12673. * Particle emitter emitting particles from the inside of a cylinder.
  12674. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12675. */
  12676. export class CylinderParticleEmitter implements IParticleEmitterType {
  12677. /**
  12678. * The radius of the emission cylinder.
  12679. */
  12680. radius: number;
  12681. /**
  12682. * The height of the emission cylinder.
  12683. */
  12684. height: number;
  12685. /**
  12686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12687. */
  12688. radiusRange: number;
  12689. /**
  12690. * How much to randomize the particle direction [0-1].
  12691. */
  12692. directionRandomizer: number;
  12693. /**
  12694. * Creates a new instance CylinderParticleEmitter
  12695. * @param radius the radius of the emission cylinder (1 by default)
  12696. * @param height the height of the emission cylinder (1 by default)
  12697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12698. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12699. */
  12700. constructor(
  12701. /**
  12702. * The radius of the emission cylinder.
  12703. */
  12704. radius?: number,
  12705. /**
  12706. * The height of the emission cylinder.
  12707. */
  12708. height?: number,
  12709. /**
  12710. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12711. */
  12712. radiusRange?: number,
  12713. /**
  12714. * How much to randomize the particle direction [0-1].
  12715. */
  12716. directionRandomizer?: number);
  12717. /**
  12718. * Called by the particle System when the direction is computed for the created particle.
  12719. * @param worldMatrix is the world matrix of the particle system
  12720. * @param directionToUpdate is the direction vector to update with the result
  12721. * @param particle is the particle we are computed the direction for
  12722. * @param isLocal defines if the direction should be set in local space
  12723. */
  12724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12725. /**
  12726. * Called by the particle System when the position is computed for the created particle.
  12727. * @param worldMatrix is the world matrix of the particle system
  12728. * @param positionToUpdate is the position vector to update with the result
  12729. * @param particle is the particle we are computed the position for
  12730. * @param isLocal defines if the position should be set in local space
  12731. */
  12732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12733. /**
  12734. * Clones the current emitter and returns a copy of it
  12735. * @returns the new emitter
  12736. */
  12737. clone(): CylinderParticleEmitter;
  12738. /**
  12739. * Called by the GPUParticleSystem to setup the update shader
  12740. * @param effect defines the update shader
  12741. */
  12742. applyToShader(effect: Effect): void;
  12743. /**
  12744. * Returns a string to use to update the GPU particles update shader
  12745. * @returns a string containng the defines string
  12746. */
  12747. getEffectDefines(): string;
  12748. /**
  12749. * Returns the string "CylinderParticleEmitter"
  12750. * @returns a string containing the class name
  12751. */
  12752. getClassName(): string;
  12753. /**
  12754. * Serializes the particle system to a JSON object.
  12755. * @returns the JSON object
  12756. */
  12757. serialize(): any;
  12758. /**
  12759. * Parse properties from a JSON object
  12760. * @param serializationObject defines the JSON object
  12761. */
  12762. parse(serializationObject: any): void;
  12763. }
  12764. /**
  12765. * Particle emitter emitting particles from the inside of a cylinder.
  12766. * It emits the particles randomly between two vectors.
  12767. */
  12768. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12769. /**
  12770. * The min limit of the emission direction.
  12771. */
  12772. direction1: Vector3;
  12773. /**
  12774. * The max limit of the emission direction.
  12775. */
  12776. direction2: Vector3;
  12777. /**
  12778. * Creates a new instance CylinderDirectedParticleEmitter
  12779. * @param radius the radius of the emission cylinder (1 by default)
  12780. * @param height the height of the emission cylinder (1 by default)
  12781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12782. * @param direction1 the min limit of the emission direction (up vector by default)
  12783. * @param direction2 the max limit of the emission direction (up vector by default)
  12784. */
  12785. constructor(radius?: number, height?: number, radiusRange?: number,
  12786. /**
  12787. * The min limit of the emission direction.
  12788. */
  12789. direction1?: Vector3,
  12790. /**
  12791. * The max limit of the emission direction.
  12792. */
  12793. direction2?: Vector3);
  12794. /**
  12795. * Called by the particle System when the direction is computed for the created particle.
  12796. * @param worldMatrix is the world matrix of the particle system
  12797. * @param directionToUpdate is the direction vector to update with the result
  12798. * @param particle is the particle we are computed the direction for
  12799. */
  12800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12801. /**
  12802. * Clones the current emitter and returns a copy of it
  12803. * @returns the new emitter
  12804. */
  12805. clone(): CylinderDirectedParticleEmitter;
  12806. /**
  12807. * Called by the GPUParticleSystem to setup the update shader
  12808. * @param effect defines the update shader
  12809. */
  12810. applyToShader(effect: Effect): void;
  12811. /**
  12812. * Returns a string to use to update the GPU particles update shader
  12813. * @returns a string containng the defines string
  12814. */
  12815. getEffectDefines(): string;
  12816. /**
  12817. * Returns the string "CylinderDirectedParticleEmitter"
  12818. * @returns a string containing the class name
  12819. */
  12820. getClassName(): string;
  12821. /**
  12822. * Serializes the particle system to a JSON object.
  12823. * @returns the JSON object
  12824. */
  12825. serialize(): any;
  12826. /**
  12827. * Parse properties from a JSON object
  12828. * @param serializationObject defines the JSON object
  12829. */
  12830. parse(serializationObject: any): void;
  12831. }
  12832. }
  12833. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12834. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12835. import { Effect } from "babylonjs/Materials/effect";
  12836. import { Particle } from "babylonjs/Particles/particle";
  12837. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12838. /**
  12839. * Particle emitter emitting particles from the inside of a hemisphere.
  12840. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12841. */
  12842. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12843. /**
  12844. * The radius of the emission hemisphere.
  12845. */
  12846. radius: number;
  12847. /**
  12848. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12849. */
  12850. radiusRange: number;
  12851. /**
  12852. * How much to randomize the particle direction [0-1].
  12853. */
  12854. directionRandomizer: number;
  12855. /**
  12856. * Creates a new instance HemisphericParticleEmitter
  12857. * @param radius the radius of the emission hemisphere (1 by default)
  12858. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12859. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12860. */
  12861. constructor(
  12862. /**
  12863. * The radius of the emission hemisphere.
  12864. */
  12865. radius?: number,
  12866. /**
  12867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12868. */
  12869. radiusRange?: number,
  12870. /**
  12871. * How much to randomize the particle direction [0-1].
  12872. */
  12873. directionRandomizer?: number);
  12874. /**
  12875. * Called by the particle System when the direction is computed for the created particle.
  12876. * @param worldMatrix is the world matrix of the particle system
  12877. * @param directionToUpdate is the direction vector to update with the result
  12878. * @param particle is the particle we are computed the direction for
  12879. * @param isLocal defines if the direction should be set in local space
  12880. */
  12881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12882. /**
  12883. * Called by the particle System when the position is computed for the created particle.
  12884. * @param worldMatrix is the world matrix of the particle system
  12885. * @param positionToUpdate is the position vector to update with the result
  12886. * @param particle is the particle we are computed the position for
  12887. * @param isLocal defines if the position should be set in local space
  12888. */
  12889. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12890. /**
  12891. * Clones the current emitter and returns a copy of it
  12892. * @returns the new emitter
  12893. */
  12894. clone(): HemisphericParticleEmitter;
  12895. /**
  12896. * Called by the GPUParticleSystem to setup the update shader
  12897. * @param effect defines the update shader
  12898. */
  12899. applyToShader(effect: Effect): void;
  12900. /**
  12901. * Returns a string to use to update the GPU particles update shader
  12902. * @returns a string containng the defines string
  12903. */
  12904. getEffectDefines(): string;
  12905. /**
  12906. * Returns the string "HemisphericParticleEmitter"
  12907. * @returns a string containing the class name
  12908. */
  12909. getClassName(): string;
  12910. /**
  12911. * Serializes the particle system to a JSON object.
  12912. * @returns the JSON object
  12913. */
  12914. serialize(): any;
  12915. /**
  12916. * Parse properties from a JSON object
  12917. * @param serializationObject defines the JSON object
  12918. */
  12919. parse(serializationObject: any): void;
  12920. }
  12921. }
  12922. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12923. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12924. import { Effect } from "babylonjs/Materials/effect";
  12925. import { Particle } from "babylonjs/Particles/particle";
  12926. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12927. /**
  12928. * Particle emitter emitting particles from a point.
  12929. * It emits the particles randomly between 2 given directions.
  12930. */
  12931. export class PointParticleEmitter implements IParticleEmitterType {
  12932. /**
  12933. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12934. */
  12935. direction1: Vector3;
  12936. /**
  12937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12938. */
  12939. direction2: Vector3;
  12940. /**
  12941. * Creates a new instance PointParticleEmitter
  12942. */
  12943. constructor();
  12944. /**
  12945. * Called by the particle System when the direction is computed for the created particle.
  12946. * @param worldMatrix is the world matrix of the particle system
  12947. * @param directionToUpdate is the direction vector to update with the result
  12948. * @param particle is the particle we are computed the direction for
  12949. * @param isLocal defines if the direction should be set in local space
  12950. */
  12951. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12952. /**
  12953. * Called by the particle System when the position is computed for the created particle.
  12954. * @param worldMatrix is the world matrix of the particle system
  12955. * @param positionToUpdate is the position vector to update with the result
  12956. * @param particle is the particle we are computed the position for
  12957. * @param isLocal defines if the position should be set in local space
  12958. */
  12959. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12960. /**
  12961. * Clones the current emitter and returns a copy of it
  12962. * @returns the new emitter
  12963. */
  12964. clone(): PointParticleEmitter;
  12965. /**
  12966. * Called by the GPUParticleSystem to setup the update shader
  12967. * @param effect defines the update shader
  12968. */
  12969. applyToShader(effect: Effect): void;
  12970. /**
  12971. * Returns a string to use to update the GPU particles update shader
  12972. * @returns a string containng the defines string
  12973. */
  12974. getEffectDefines(): string;
  12975. /**
  12976. * Returns the string "PointParticleEmitter"
  12977. * @returns a string containing the class name
  12978. */
  12979. getClassName(): string;
  12980. /**
  12981. * Serializes the particle system to a JSON object.
  12982. * @returns the JSON object
  12983. */
  12984. serialize(): any;
  12985. /**
  12986. * Parse properties from a JSON object
  12987. * @param serializationObject defines the JSON object
  12988. */
  12989. parse(serializationObject: any): void;
  12990. }
  12991. }
  12992. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12993. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12994. import { Effect } from "babylonjs/Materials/effect";
  12995. import { Particle } from "babylonjs/Particles/particle";
  12996. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12997. /**
  12998. * Particle emitter emitting particles from the inside of a sphere.
  12999. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13000. */
  13001. export class SphereParticleEmitter implements IParticleEmitterType {
  13002. /**
  13003. * The radius of the emission sphere.
  13004. */
  13005. radius: number;
  13006. /**
  13007. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13008. */
  13009. radiusRange: number;
  13010. /**
  13011. * How much to randomize the particle direction [0-1].
  13012. */
  13013. directionRandomizer: number;
  13014. /**
  13015. * Creates a new instance SphereParticleEmitter
  13016. * @param radius the radius of the emission sphere (1 by default)
  13017. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13018. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13019. */
  13020. constructor(
  13021. /**
  13022. * The radius of the emission sphere.
  13023. */
  13024. radius?: number,
  13025. /**
  13026. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13027. */
  13028. radiusRange?: number,
  13029. /**
  13030. * How much to randomize the particle direction [0-1].
  13031. */
  13032. directionRandomizer?: number);
  13033. /**
  13034. * Called by the particle System when the direction is computed for the created particle.
  13035. * @param worldMatrix is the world matrix of the particle system
  13036. * @param directionToUpdate is the direction vector to update with the result
  13037. * @param particle is the particle we are computed the direction for
  13038. * @param isLocal defines if the direction should be set in local space
  13039. */
  13040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13041. /**
  13042. * Called by the particle System when the position is computed for the created particle.
  13043. * @param worldMatrix is the world matrix of the particle system
  13044. * @param positionToUpdate is the position vector to update with the result
  13045. * @param particle is the particle we are computed the position for
  13046. * @param isLocal defines if the position should be set in local space
  13047. */
  13048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13049. /**
  13050. * Clones the current emitter and returns a copy of it
  13051. * @returns the new emitter
  13052. */
  13053. clone(): SphereParticleEmitter;
  13054. /**
  13055. * Called by the GPUParticleSystem to setup the update shader
  13056. * @param effect defines the update shader
  13057. */
  13058. applyToShader(effect: Effect): void;
  13059. /**
  13060. * Returns a string to use to update the GPU particles update shader
  13061. * @returns a string containng the defines string
  13062. */
  13063. getEffectDefines(): string;
  13064. /**
  13065. * Returns the string "SphereParticleEmitter"
  13066. * @returns a string containing the class name
  13067. */
  13068. getClassName(): string;
  13069. /**
  13070. * Serializes the particle system to a JSON object.
  13071. * @returns the JSON object
  13072. */
  13073. serialize(): any;
  13074. /**
  13075. * Parse properties from a JSON object
  13076. * @param serializationObject defines the JSON object
  13077. */
  13078. parse(serializationObject: any): void;
  13079. }
  13080. /**
  13081. * Particle emitter emitting particles from the inside of a sphere.
  13082. * It emits the particles randomly between two vectors.
  13083. */
  13084. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13085. /**
  13086. * The min limit of the emission direction.
  13087. */
  13088. direction1: Vector3;
  13089. /**
  13090. * The max limit of the emission direction.
  13091. */
  13092. direction2: Vector3;
  13093. /**
  13094. * Creates a new instance SphereDirectedParticleEmitter
  13095. * @param radius the radius of the emission sphere (1 by default)
  13096. * @param direction1 the min limit of the emission direction (up vector by default)
  13097. * @param direction2 the max limit of the emission direction (up vector by default)
  13098. */
  13099. constructor(radius?: number,
  13100. /**
  13101. * The min limit of the emission direction.
  13102. */
  13103. direction1?: Vector3,
  13104. /**
  13105. * The max limit of the emission direction.
  13106. */
  13107. direction2?: Vector3);
  13108. /**
  13109. * Called by the particle System when the direction is computed for the created particle.
  13110. * @param worldMatrix is the world matrix of the particle system
  13111. * @param directionToUpdate is the direction vector to update with the result
  13112. * @param particle is the particle we are computed the direction for
  13113. */
  13114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13115. /**
  13116. * Clones the current emitter and returns a copy of it
  13117. * @returns the new emitter
  13118. */
  13119. clone(): SphereDirectedParticleEmitter;
  13120. /**
  13121. * Called by the GPUParticleSystem to setup the update shader
  13122. * @param effect defines the update shader
  13123. */
  13124. applyToShader(effect: Effect): void;
  13125. /**
  13126. * Returns a string to use to update the GPU particles update shader
  13127. * @returns a string containng the defines string
  13128. */
  13129. getEffectDefines(): string;
  13130. /**
  13131. * Returns the string "SphereDirectedParticleEmitter"
  13132. * @returns a string containing the class name
  13133. */
  13134. getClassName(): string;
  13135. /**
  13136. * Serializes the particle system to a JSON object.
  13137. * @returns the JSON object
  13138. */
  13139. serialize(): any;
  13140. /**
  13141. * Parse properties from a JSON object
  13142. * @param serializationObject defines the JSON object
  13143. */
  13144. parse(serializationObject: any): void;
  13145. }
  13146. }
  13147. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13148. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13149. import { Effect } from "babylonjs/Materials/effect";
  13150. import { Particle } from "babylonjs/Particles/particle";
  13151. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13152. import { Nullable } from "babylonjs/types";
  13153. /**
  13154. * Particle emitter emitting particles from a custom list of positions.
  13155. */
  13156. export class CustomParticleEmitter implements IParticleEmitterType {
  13157. /**
  13158. * Gets or sets the position generator that will create the inital position of each particle.
  13159. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13160. */
  13161. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13162. /**
  13163. * Gets or sets the destination generator that will create the final destination of each particle.
  13164. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13165. */
  13166. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13167. /**
  13168. * Creates a new instance CustomParticleEmitter
  13169. */
  13170. constructor();
  13171. /**
  13172. * Called by the particle System when the direction is computed for the created particle.
  13173. * @param worldMatrix is the world matrix of the particle system
  13174. * @param directionToUpdate is the direction vector to update with the result
  13175. * @param particle is the particle we are computed the direction for
  13176. * @param isLocal defines if the direction should be set in local space
  13177. */
  13178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13179. /**
  13180. * Called by the particle System when the position is computed for the created particle.
  13181. * @param worldMatrix is the world matrix of the particle system
  13182. * @param positionToUpdate is the position vector to update with the result
  13183. * @param particle is the particle we are computed the position for
  13184. * @param isLocal defines if the position should be set in local space
  13185. */
  13186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13187. /**
  13188. * Clones the current emitter and returns a copy of it
  13189. * @returns the new emitter
  13190. */
  13191. clone(): CustomParticleEmitter;
  13192. /**
  13193. * Called by the GPUParticleSystem to setup the update shader
  13194. * @param effect defines the update shader
  13195. */
  13196. applyToShader(effect: Effect): void;
  13197. /**
  13198. * Returns a string to use to update the GPU particles update shader
  13199. * @returns a string containng the defines string
  13200. */
  13201. getEffectDefines(): string;
  13202. /**
  13203. * Returns the string "PointParticleEmitter"
  13204. * @returns a string containing the class name
  13205. */
  13206. getClassName(): string;
  13207. /**
  13208. * Serializes the particle system to a JSON object.
  13209. * @returns the JSON object
  13210. */
  13211. serialize(): any;
  13212. /**
  13213. * Parse properties from a JSON object
  13214. * @param serializationObject defines the JSON object
  13215. */
  13216. parse(serializationObject: any): void;
  13217. }
  13218. }
  13219. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13220. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13221. import { Effect } from "babylonjs/Materials/effect";
  13222. import { Particle } from "babylonjs/Particles/particle";
  13223. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13224. import { Nullable } from "babylonjs/types";
  13225. import { Scene } from "babylonjs/scene";
  13226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13227. /**
  13228. * Particle emitter emitting particles from the inside of a box.
  13229. * It emits the particles randomly between 2 given directions.
  13230. */
  13231. export class MeshParticleEmitter implements IParticleEmitterType {
  13232. private _indices;
  13233. private _positions;
  13234. private _normals;
  13235. private _storedNormal;
  13236. private _mesh;
  13237. /**
  13238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13239. */
  13240. direction1: Vector3;
  13241. /**
  13242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13243. */
  13244. direction2: Vector3;
  13245. /**
  13246. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13247. */
  13248. useMeshNormalsForDirection: boolean;
  13249. /** Defines the mesh to use as source */
  13250. get mesh(): Nullable<AbstractMesh>;
  13251. set mesh(value: Nullable<AbstractMesh>);
  13252. /**
  13253. * Creates a new instance MeshParticleEmitter
  13254. * @param mesh defines the mesh to use as source
  13255. */
  13256. constructor(mesh?: Nullable<AbstractMesh>);
  13257. /**
  13258. * Called by the particle System when the direction is computed for the created particle.
  13259. * @param worldMatrix is the world matrix of the particle system
  13260. * @param directionToUpdate is the direction vector to update with the result
  13261. * @param particle is the particle we are computed the direction for
  13262. * @param isLocal defines if the direction should be set in local space
  13263. */
  13264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13265. /**
  13266. * Called by the particle System when the position is computed for the created particle.
  13267. * @param worldMatrix is the world matrix of the particle system
  13268. * @param positionToUpdate is the position vector to update with the result
  13269. * @param particle is the particle we are computed the position for
  13270. * @param isLocal defines if the position should be set in local space
  13271. */
  13272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13273. /**
  13274. * Clones the current emitter and returns a copy of it
  13275. * @returns the new emitter
  13276. */
  13277. clone(): MeshParticleEmitter;
  13278. /**
  13279. * Called by the GPUParticleSystem to setup the update shader
  13280. * @param effect defines the update shader
  13281. */
  13282. applyToShader(effect: Effect): void;
  13283. /**
  13284. * Returns a string to use to update the GPU particles update shader
  13285. * @returns a string containng the defines string
  13286. */
  13287. getEffectDefines(): string;
  13288. /**
  13289. * Returns the string "BoxParticleEmitter"
  13290. * @returns a string containing the class name
  13291. */
  13292. getClassName(): string;
  13293. /**
  13294. * Serializes the particle system to a JSON object.
  13295. * @returns the JSON object
  13296. */
  13297. serialize(): any;
  13298. /**
  13299. * Parse properties from a JSON object
  13300. * @param serializationObject defines the JSON object
  13301. * @param scene defines the hosting scene
  13302. */
  13303. parse(serializationObject: any, scene: Scene): void;
  13304. }
  13305. }
  13306. declare module "babylonjs/Particles/EmitterTypes/index" {
  13307. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13308. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13309. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13310. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13311. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13312. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13313. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13314. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13315. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13316. }
  13317. declare module "babylonjs/Particles/IParticleSystem" {
  13318. import { Nullable } from "babylonjs/types";
  13319. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13320. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13323. import { Texture } from "babylonjs/Materials/Textures/texture";
  13324. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13325. import { Scene } from "babylonjs/scene";
  13326. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13327. import { Animation } from "babylonjs/Animations/animation";
  13328. /**
  13329. * Interface representing a particle system in Babylon.js.
  13330. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13331. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13332. */
  13333. export interface IParticleSystem {
  13334. /**
  13335. * List of animations used by the particle system.
  13336. */
  13337. animations: Animation[];
  13338. /**
  13339. * The id of the Particle system.
  13340. */
  13341. id: string;
  13342. /**
  13343. * The name of the Particle system.
  13344. */
  13345. name: string;
  13346. /**
  13347. * The emitter represents the Mesh or position we are attaching the particle system to.
  13348. */
  13349. emitter: Nullable<AbstractMesh | Vector3>;
  13350. /**
  13351. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13352. */
  13353. isBillboardBased: boolean;
  13354. /**
  13355. * The rendering group used by the Particle system to chose when to render.
  13356. */
  13357. renderingGroupId: number;
  13358. /**
  13359. * The layer mask we are rendering the particles through.
  13360. */
  13361. layerMask: number;
  13362. /**
  13363. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13364. */
  13365. updateSpeed: number;
  13366. /**
  13367. * The amount of time the particle system is running (depends of the overall update speed).
  13368. */
  13369. targetStopDuration: number;
  13370. /**
  13371. * The texture used to render each particle. (this can be a spritesheet)
  13372. */
  13373. particleTexture: Nullable<Texture>;
  13374. /**
  13375. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13376. */
  13377. blendMode: number;
  13378. /**
  13379. * Minimum life time of emitting particles.
  13380. */
  13381. minLifeTime: number;
  13382. /**
  13383. * Maximum life time of emitting particles.
  13384. */
  13385. maxLifeTime: number;
  13386. /**
  13387. * Minimum Size of emitting particles.
  13388. */
  13389. minSize: number;
  13390. /**
  13391. * Maximum Size of emitting particles.
  13392. */
  13393. maxSize: number;
  13394. /**
  13395. * Minimum scale of emitting particles on X axis.
  13396. */
  13397. minScaleX: number;
  13398. /**
  13399. * Maximum scale of emitting particles on X axis.
  13400. */
  13401. maxScaleX: number;
  13402. /**
  13403. * Minimum scale of emitting particles on Y axis.
  13404. */
  13405. minScaleY: number;
  13406. /**
  13407. * Maximum scale of emitting particles on Y axis.
  13408. */
  13409. maxScaleY: number;
  13410. /**
  13411. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13412. */
  13413. color1: Color4;
  13414. /**
  13415. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13416. */
  13417. color2: Color4;
  13418. /**
  13419. * Color the particle will have at the end of its lifetime.
  13420. */
  13421. colorDead: Color4;
  13422. /**
  13423. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13424. */
  13425. emitRate: number;
  13426. /**
  13427. * You can use gravity if you want to give an orientation to your particles.
  13428. */
  13429. gravity: Vector3;
  13430. /**
  13431. * Minimum power of emitting particles.
  13432. */
  13433. minEmitPower: number;
  13434. /**
  13435. * Maximum power of emitting particles.
  13436. */
  13437. maxEmitPower: number;
  13438. /**
  13439. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13440. */
  13441. minAngularSpeed: number;
  13442. /**
  13443. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13444. */
  13445. maxAngularSpeed: number;
  13446. /**
  13447. * Gets or sets the minimal initial rotation in radians.
  13448. */
  13449. minInitialRotation: number;
  13450. /**
  13451. * Gets or sets the maximal initial rotation in radians.
  13452. */
  13453. maxInitialRotation: number;
  13454. /**
  13455. * The particle emitter type defines the emitter used by the particle system.
  13456. * It can be for example box, sphere, or cone...
  13457. */
  13458. particleEmitterType: Nullable<IParticleEmitterType>;
  13459. /**
  13460. * Defines the delay in milliseconds before starting the system (0 by default)
  13461. */
  13462. startDelay: number;
  13463. /**
  13464. * 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
  13465. */
  13466. preWarmCycles: number;
  13467. /**
  13468. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13469. */
  13470. preWarmStepOffset: number;
  13471. /**
  13472. * 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)
  13473. */
  13474. spriteCellChangeSpeed: number;
  13475. /**
  13476. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13477. */
  13478. startSpriteCellID: number;
  13479. /**
  13480. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13481. */
  13482. endSpriteCellID: number;
  13483. /**
  13484. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13485. */
  13486. spriteCellWidth: number;
  13487. /**
  13488. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13489. */
  13490. spriteCellHeight: number;
  13491. /**
  13492. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13493. */
  13494. spriteRandomStartCell: boolean;
  13495. /**
  13496. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13497. */
  13498. isAnimationSheetEnabled: boolean;
  13499. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13500. translationPivot: Vector2;
  13501. /**
  13502. * Gets or sets a texture used to add random noise to particle positions
  13503. */
  13504. noiseTexture: Nullable<BaseTexture>;
  13505. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13506. noiseStrength: Vector3;
  13507. /**
  13508. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13509. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13510. */
  13511. billboardMode: number;
  13512. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13513. limitVelocityDamping: number;
  13514. /**
  13515. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13516. */
  13517. beginAnimationOnStart: boolean;
  13518. /**
  13519. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13520. */
  13521. beginAnimationFrom: number;
  13522. /**
  13523. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13524. */
  13525. beginAnimationTo: number;
  13526. /**
  13527. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13528. */
  13529. beginAnimationLoop: boolean;
  13530. /**
  13531. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13532. */
  13533. disposeOnStop: boolean;
  13534. /**
  13535. * Specifies if the particles are updated in emitter local space or world space
  13536. */
  13537. isLocal: boolean;
  13538. /** Snippet ID if the particle system was created from the snippet server */
  13539. snippetId: string;
  13540. /**
  13541. * Gets the maximum number of particles active at the same time.
  13542. * @returns The max number of active particles.
  13543. */
  13544. getCapacity(): number;
  13545. /**
  13546. * Gets the number of particles active at the same time.
  13547. * @returns The number of active particles.
  13548. */
  13549. getActiveCount(): number;
  13550. /**
  13551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13552. * @returns True if it has been started, otherwise false.
  13553. */
  13554. isStarted(): boolean;
  13555. /**
  13556. * Animates the particle system for this frame.
  13557. */
  13558. animate(): void;
  13559. /**
  13560. * Renders the particle system in its current state.
  13561. * @returns the current number of particles
  13562. */
  13563. render(): number;
  13564. /**
  13565. * Dispose the particle system and frees its associated resources.
  13566. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13567. */
  13568. dispose(disposeTexture?: boolean): void;
  13569. /**
  13570. * Clones the particle system.
  13571. * @param name The name of the cloned object
  13572. * @param newEmitter The new emitter to use
  13573. * @returns the cloned particle system
  13574. */
  13575. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13576. /**
  13577. * Serializes the particle system to a JSON object.
  13578. * @returns the JSON object
  13579. */
  13580. serialize(): any;
  13581. /**
  13582. * Rebuild the particle system
  13583. */
  13584. rebuild(): void;
  13585. /**
  13586. * Starts the particle system and begins to emit
  13587. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13588. */
  13589. start(delay?: number): void;
  13590. /**
  13591. * Stops the particle system.
  13592. */
  13593. stop(): void;
  13594. /**
  13595. * Remove all active particles
  13596. */
  13597. reset(): void;
  13598. /**
  13599. * Gets a boolean indicating that the system is stopping
  13600. * @returns true if the system is currently stopping
  13601. */
  13602. isStopping(): boolean;
  13603. /**
  13604. * Is this system ready to be used/rendered
  13605. * @return true if the system is ready
  13606. */
  13607. isReady(): boolean;
  13608. /**
  13609. * Returns the string "ParticleSystem"
  13610. * @returns a string containing the class name
  13611. */
  13612. getClassName(): string;
  13613. /**
  13614. * Adds a new color gradient
  13615. * @param gradient defines the gradient to use (between 0 and 1)
  13616. * @param color1 defines the color to affect to the specified gradient
  13617. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13618. * @returns the current particle system
  13619. */
  13620. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13621. /**
  13622. * Remove a specific color gradient
  13623. * @param gradient defines the gradient to remove
  13624. * @returns the current particle system
  13625. */
  13626. removeColorGradient(gradient: number): IParticleSystem;
  13627. /**
  13628. * Adds a new size gradient
  13629. * @param gradient defines the gradient to use (between 0 and 1)
  13630. * @param factor defines the size factor to affect to the specified gradient
  13631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13632. * @returns the current particle system
  13633. */
  13634. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13635. /**
  13636. * Remove a specific size gradient
  13637. * @param gradient defines the gradient to remove
  13638. * @returns the current particle system
  13639. */
  13640. removeSizeGradient(gradient: number): IParticleSystem;
  13641. /**
  13642. * Gets the current list of color gradients.
  13643. * You must use addColorGradient and removeColorGradient to udpate this list
  13644. * @returns the list of color gradients
  13645. */
  13646. getColorGradients(): Nullable<Array<ColorGradient>>;
  13647. /**
  13648. * Gets the current list of size gradients.
  13649. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13650. * @returns the list of size gradients
  13651. */
  13652. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13653. /**
  13654. * Gets the current list of angular speed gradients.
  13655. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13656. * @returns the list of angular speed gradients
  13657. */
  13658. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13659. /**
  13660. * Adds a new angular speed gradient
  13661. * @param gradient defines the gradient to use (between 0 and 1)
  13662. * @param factor defines the angular speed to affect to the specified gradient
  13663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13664. * @returns the current particle system
  13665. */
  13666. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13667. /**
  13668. * Remove a specific angular speed gradient
  13669. * @param gradient defines the gradient to remove
  13670. * @returns the current particle system
  13671. */
  13672. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13673. /**
  13674. * Gets the current list of velocity gradients.
  13675. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13676. * @returns the list of velocity gradients
  13677. */
  13678. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13679. /**
  13680. * Adds a new velocity gradient
  13681. * @param gradient defines the gradient to use (between 0 and 1)
  13682. * @param factor defines the velocity to affect to the specified gradient
  13683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13684. * @returns the current particle system
  13685. */
  13686. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13687. /**
  13688. * Remove a specific velocity gradient
  13689. * @param gradient defines the gradient to remove
  13690. * @returns the current particle system
  13691. */
  13692. removeVelocityGradient(gradient: number): IParticleSystem;
  13693. /**
  13694. * Gets the current list of limit velocity gradients.
  13695. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13696. * @returns the list of limit velocity gradients
  13697. */
  13698. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13699. /**
  13700. * Adds a new limit velocity gradient
  13701. * @param gradient defines the gradient to use (between 0 and 1)
  13702. * @param factor defines the limit velocity to affect to the specified gradient
  13703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13704. * @returns the current particle system
  13705. */
  13706. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13707. /**
  13708. * Remove a specific limit velocity gradient
  13709. * @param gradient defines the gradient to remove
  13710. * @returns the current particle system
  13711. */
  13712. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13713. /**
  13714. * Adds a new drag gradient
  13715. * @param gradient defines the gradient to use (between 0 and 1)
  13716. * @param factor defines the drag to affect to the specified gradient
  13717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13718. * @returns the current particle system
  13719. */
  13720. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13721. /**
  13722. * Remove a specific drag gradient
  13723. * @param gradient defines the gradient to remove
  13724. * @returns the current particle system
  13725. */
  13726. removeDragGradient(gradient: number): IParticleSystem;
  13727. /**
  13728. * Gets the current list of drag gradients.
  13729. * You must use addDragGradient and removeDragGradient to udpate this list
  13730. * @returns the list of drag gradients
  13731. */
  13732. getDragGradients(): Nullable<Array<FactorGradient>>;
  13733. /**
  13734. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13735. * @param gradient defines the gradient to use (between 0 and 1)
  13736. * @param factor defines the emit rate to affect to the specified gradient
  13737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13738. * @returns the current particle system
  13739. */
  13740. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13741. /**
  13742. * Remove a specific emit rate gradient
  13743. * @param gradient defines the gradient to remove
  13744. * @returns the current particle system
  13745. */
  13746. removeEmitRateGradient(gradient: number): IParticleSystem;
  13747. /**
  13748. * Gets the current list of emit rate gradients.
  13749. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13750. * @returns the list of emit rate gradients
  13751. */
  13752. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13753. /**
  13754. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13755. * @param gradient defines the gradient to use (between 0 and 1)
  13756. * @param factor defines the start size to affect to the specified gradient
  13757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13758. * @returns the current particle system
  13759. */
  13760. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13761. /**
  13762. * Remove a specific start size gradient
  13763. * @param gradient defines the gradient to remove
  13764. * @returns the current particle system
  13765. */
  13766. removeStartSizeGradient(gradient: number): IParticleSystem;
  13767. /**
  13768. * Gets the current list of start size gradients.
  13769. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13770. * @returns the list of start size gradients
  13771. */
  13772. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13773. /**
  13774. * Adds a new life time gradient
  13775. * @param gradient defines the gradient to use (between 0 and 1)
  13776. * @param factor defines the life time factor to affect to the specified gradient
  13777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13778. * @returns the current particle system
  13779. */
  13780. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13781. /**
  13782. * Remove a specific life time gradient
  13783. * @param gradient defines the gradient to remove
  13784. * @returns the current particle system
  13785. */
  13786. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13787. /**
  13788. * Gets the current list of life time gradients.
  13789. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13790. * @returns the list of life time gradients
  13791. */
  13792. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13793. /**
  13794. * Gets the current list of color gradients.
  13795. * You must use addColorGradient and removeColorGradient to udpate this list
  13796. * @returns the list of color gradients
  13797. */
  13798. getColorGradients(): Nullable<Array<ColorGradient>>;
  13799. /**
  13800. * Adds a new ramp gradient used to remap particle colors
  13801. * @param gradient defines the gradient to use (between 0 and 1)
  13802. * @param color defines the color to affect to the specified gradient
  13803. * @returns the current particle system
  13804. */
  13805. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13806. /**
  13807. * Gets the current list of ramp gradients.
  13808. * You must use addRampGradient and removeRampGradient to udpate this list
  13809. * @returns the list of ramp gradients
  13810. */
  13811. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13812. /** Gets or sets a boolean indicating that ramp gradients must be used
  13813. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13814. */
  13815. useRampGradients: boolean;
  13816. /**
  13817. * Adds a new color remap gradient
  13818. * @param gradient defines the gradient to use (between 0 and 1)
  13819. * @param min defines the color remap minimal range
  13820. * @param max defines the color remap maximal range
  13821. * @returns the current particle system
  13822. */
  13823. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13824. /**
  13825. * Gets the current list of color remap gradients.
  13826. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13827. * @returns the list of color remap gradients
  13828. */
  13829. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13830. /**
  13831. * Adds a new alpha remap gradient
  13832. * @param gradient defines the gradient to use (between 0 and 1)
  13833. * @param min defines the alpha remap minimal range
  13834. * @param max defines the alpha remap maximal range
  13835. * @returns the current particle system
  13836. */
  13837. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13838. /**
  13839. * Gets the current list of alpha remap gradients.
  13840. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13841. * @returns the list of alpha remap gradients
  13842. */
  13843. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13844. /**
  13845. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13846. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13847. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13848. * @returns the emitter
  13849. */
  13850. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13851. /**
  13852. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13853. * @param radius The radius of the hemisphere to emit from
  13854. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13855. * @returns the emitter
  13856. */
  13857. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13858. /**
  13859. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13860. * @param radius The radius of the sphere to emit from
  13861. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13862. * @returns the emitter
  13863. */
  13864. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13865. /**
  13866. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13867. * @param radius The radius of the sphere to emit from
  13868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13870. * @returns the emitter
  13871. */
  13872. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13873. /**
  13874. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13875. * @param radius The radius of the emission cylinder
  13876. * @param height The height of the emission cylinder
  13877. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13878. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13879. * @returns the emitter
  13880. */
  13881. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13882. /**
  13883. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13884. * @param radius The radius of the cylinder to emit from
  13885. * @param height The height of the emission cylinder
  13886. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13887. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13888. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13889. * @returns the emitter
  13890. */
  13891. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13892. /**
  13893. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13894. * @param radius The radius of the cone to emit from
  13895. * @param angle The base angle of the cone
  13896. * @returns the emitter
  13897. */
  13898. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13899. /**
  13900. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13903. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13904. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13905. * @returns the emitter
  13906. */
  13907. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13908. /**
  13909. * Get hosting scene
  13910. * @returns the scene
  13911. */
  13912. getScene(): Scene;
  13913. }
  13914. }
  13915. declare module "babylonjs/Meshes/transformNode" {
  13916. import { DeepImmutable } from "babylonjs/types";
  13917. import { Observable } from "babylonjs/Misc/observable";
  13918. import { Nullable } from "babylonjs/types";
  13919. import { Camera } from "babylonjs/Cameras/camera";
  13920. import { Scene } from "babylonjs/scene";
  13921. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13922. import { Node } from "babylonjs/node";
  13923. import { Bone } from "babylonjs/Bones/bone";
  13924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13925. import { Space } from "babylonjs/Maths/math.axis";
  13926. /**
  13927. * 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.
  13928. * @see https://doc.babylonjs.com/how_to/transformnode
  13929. */
  13930. export class TransformNode extends Node {
  13931. /**
  13932. * Object will not rotate to face the camera
  13933. */
  13934. static BILLBOARDMODE_NONE: number;
  13935. /**
  13936. * Object will rotate to face the camera but only on the x axis
  13937. */
  13938. static BILLBOARDMODE_X: number;
  13939. /**
  13940. * Object will rotate to face the camera but only on the y axis
  13941. */
  13942. static BILLBOARDMODE_Y: number;
  13943. /**
  13944. * Object will rotate to face the camera but only on the z axis
  13945. */
  13946. static BILLBOARDMODE_Z: number;
  13947. /**
  13948. * Object will rotate to face the camera
  13949. */
  13950. static BILLBOARDMODE_ALL: number;
  13951. /**
  13952. * Object will rotate to face the camera's position instead of orientation
  13953. */
  13954. static BILLBOARDMODE_USE_POSITION: number;
  13955. private _forward;
  13956. private _forwardInverted;
  13957. private _up;
  13958. private _right;
  13959. private _rightInverted;
  13960. private _position;
  13961. private _rotation;
  13962. private _rotationQuaternion;
  13963. protected _scaling: Vector3;
  13964. protected _isDirty: boolean;
  13965. private _transformToBoneReferal;
  13966. private _isAbsoluteSynced;
  13967. private _billboardMode;
  13968. /**
  13969. * Gets or sets the billboard mode. Default is 0.
  13970. *
  13971. * | Value | Type | Description |
  13972. * | --- | --- | --- |
  13973. * | 0 | BILLBOARDMODE_NONE | |
  13974. * | 1 | BILLBOARDMODE_X | |
  13975. * | 2 | BILLBOARDMODE_Y | |
  13976. * | 4 | BILLBOARDMODE_Z | |
  13977. * | 7 | BILLBOARDMODE_ALL | |
  13978. *
  13979. */
  13980. get billboardMode(): number;
  13981. set billboardMode(value: number);
  13982. private _preserveParentRotationForBillboard;
  13983. /**
  13984. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13985. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13986. */
  13987. get preserveParentRotationForBillboard(): boolean;
  13988. set preserveParentRotationForBillboard(value: boolean);
  13989. /**
  13990. * 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
  13991. */
  13992. scalingDeterminant: number;
  13993. private _infiniteDistance;
  13994. /**
  13995. * Gets or sets the distance of the object to max, often used by skybox
  13996. */
  13997. get infiniteDistance(): boolean;
  13998. set infiniteDistance(value: boolean);
  13999. /**
  14000. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14001. * By default the system will update normals to compensate
  14002. */
  14003. ignoreNonUniformScaling: boolean;
  14004. /**
  14005. * 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
  14006. */
  14007. reIntegrateRotationIntoRotationQuaternion: boolean;
  14008. /** @hidden */
  14009. _poseMatrix: Nullable<Matrix>;
  14010. /** @hidden */
  14011. _localMatrix: Matrix;
  14012. private _usePivotMatrix;
  14013. private _absolutePosition;
  14014. private _absoluteScaling;
  14015. private _absoluteRotationQuaternion;
  14016. private _pivotMatrix;
  14017. private _pivotMatrixInverse;
  14018. protected _postMultiplyPivotMatrix: boolean;
  14019. protected _isWorldMatrixFrozen: boolean;
  14020. /** @hidden */
  14021. _indexInSceneTransformNodesArray: number;
  14022. /**
  14023. * An event triggered after the world matrix is updated
  14024. */
  14025. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14026. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14027. /**
  14028. * Gets a string identifying the name of the class
  14029. * @returns "TransformNode" string
  14030. */
  14031. getClassName(): string;
  14032. /**
  14033. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14034. */
  14035. get position(): Vector3;
  14036. set position(newPosition: Vector3);
  14037. /**
  14038. * 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)).
  14039. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14040. */
  14041. get rotation(): Vector3;
  14042. set rotation(newRotation: Vector3);
  14043. /**
  14044. * 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)).
  14045. */
  14046. get scaling(): Vector3;
  14047. set scaling(newScaling: Vector3);
  14048. /**
  14049. * 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).
  14050. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14051. */
  14052. get rotationQuaternion(): Nullable<Quaternion>;
  14053. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14054. /**
  14055. * The forward direction of that transform in world space.
  14056. */
  14057. get forward(): Vector3;
  14058. /**
  14059. * The up direction of that transform in world space.
  14060. */
  14061. get up(): Vector3;
  14062. /**
  14063. * The right direction of that transform in world space.
  14064. */
  14065. get right(): Vector3;
  14066. /**
  14067. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14068. * @param matrix the matrix to copy the pose from
  14069. * @returns this TransformNode.
  14070. */
  14071. updatePoseMatrix(matrix: Matrix): TransformNode;
  14072. /**
  14073. * Returns the mesh Pose matrix.
  14074. * @returns the pose matrix
  14075. */
  14076. getPoseMatrix(): Matrix;
  14077. /** @hidden */
  14078. _isSynchronized(): boolean;
  14079. /** @hidden */
  14080. _initCache(): void;
  14081. /**
  14082. * Flag the transform node as dirty (Forcing it to update everything)
  14083. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14084. * @returns this transform node
  14085. */
  14086. markAsDirty(property: string): TransformNode;
  14087. /**
  14088. * Returns the current mesh absolute position.
  14089. * Returns a Vector3.
  14090. */
  14091. get absolutePosition(): Vector3;
  14092. /**
  14093. * Returns the current mesh absolute scaling.
  14094. * Returns a Vector3.
  14095. */
  14096. get absoluteScaling(): Vector3;
  14097. /**
  14098. * Returns the current mesh absolute rotation.
  14099. * Returns a Quaternion.
  14100. */
  14101. get absoluteRotationQuaternion(): Quaternion;
  14102. /**
  14103. * Sets a new matrix to apply before all other transformation
  14104. * @param matrix defines the transform matrix
  14105. * @returns the current TransformNode
  14106. */
  14107. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14108. /**
  14109. * Sets a new pivot matrix to the current node
  14110. * @param matrix defines the new pivot matrix to use
  14111. * @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
  14112. * @returns the current TransformNode
  14113. */
  14114. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14115. /**
  14116. * Returns the mesh pivot matrix.
  14117. * Default : Identity.
  14118. * @returns the matrix
  14119. */
  14120. getPivotMatrix(): Matrix;
  14121. /**
  14122. * Instantiate (when possible) or clone that node with its hierarchy
  14123. * @param newParent defines the new parent to use for the instance (or clone)
  14124. * @param options defines options to configure how copy is done
  14125. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14126. * @returns an instance (or a clone) of the current node with its hiearchy
  14127. */
  14128. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14129. doNotInstantiate: boolean;
  14130. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14131. /**
  14132. * Prevents the World matrix to be computed any longer
  14133. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14134. * @returns the TransformNode.
  14135. */
  14136. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14137. /**
  14138. * Allows back the World matrix computation.
  14139. * @returns the TransformNode.
  14140. */
  14141. unfreezeWorldMatrix(): this;
  14142. /**
  14143. * True if the World matrix has been frozen.
  14144. */
  14145. get isWorldMatrixFrozen(): boolean;
  14146. /**
  14147. * Retuns the mesh absolute position in the World.
  14148. * @returns a Vector3.
  14149. */
  14150. getAbsolutePosition(): Vector3;
  14151. /**
  14152. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14153. * @param absolutePosition the absolute position to set
  14154. * @returns the TransformNode.
  14155. */
  14156. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14157. /**
  14158. * Sets the mesh position in its local space.
  14159. * @param vector3 the position to set in localspace
  14160. * @returns the TransformNode.
  14161. */
  14162. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14163. /**
  14164. * Returns the mesh position in the local space from the current World matrix values.
  14165. * @returns a new Vector3.
  14166. */
  14167. getPositionExpressedInLocalSpace(): Vector3;
  14168. /**
  14169. * Translates the mesh along the passed Vector3 in its local space.
  14170. * @param vector3 the distance to translate in localspace
  14171. * @returns the TransformNode.
  14172. */
  14173. locallyTranslate(vector3: Vector3): TransformNode;
  14174. private static _lookAtVectorCache;
  14175. /**
  14176. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14177. * @param targetPoint the position (must be in same space as current mesh) to look at
  14178. * @param yawCor optional yaw (y-axis) correction in radians
  14179. * @param pitchCor optional pitch (x-axis) correction in radians
  14180. * @param rollCor optional roll (z-axis) correction in radians
  14181. * @param space the choosen space of the target
  14182. * @returns the TransformNode.
  14183. */
  14184. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14185. /**
  14186. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14187. * This Vector3 is expressed in the World space.
  14188. * @param localAxis axis to rotate
  14189. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14190. */
  14191. getDirection(localAxis: Vector3): Vector3;
  14192. /**
  14193. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14194. * localAxis is expressed in the mesh local space.
  14195. * result is computed in the Wordl space from the mesh World matrix.
  14196. * @param localAxis axis to rotate
  14197. * @param result the resulting transformnode
  14198. * @returns this TransformNode.
  14199. */
  14200. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14201. /**
  14202. * Sets this transform node rotation to the given local axis.
  14203. * @param localAxis the axis in local space
  14204. * @param yawCor optional yaw (y-axis) correction in radians
  14205. * @param pitchCor optional pitch (x-axis) correction in radians
  14206. * @param rollCor optional roll (z-axis) correction in radians
  14207. * @returns this TransformNode
  14208. */
  14209. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14210. /**
  14211. * Sets a new pivot point to the current node
  14212. * @param point defines the new pivot point to use
  14213. * @param space defines if the point is in world or local space (local by default)
  14214. * @returns the current TransformNode
  14215. */
  14216. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14217. /**
  14218. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14219. * @returns the pivot point
  14220. */
  14221. getPivotPoint(): Vector3;
  14222. /**
  14223. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14224. * @param result the vector3 to store the result
  14225. * @returns this TransformNode.
  14226. */
  14227. getPivotPointToRef(result: Vector3): TransformNode;
  14228. /**
  14229. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14230. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14231. */
  14232. getAbsolutePivotPoint(): Vector3;
  14233. /**
  14234. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14235. * @param result vector3 to store the result
  14236. * @returns this TransformNode.
  14237. */
  14238. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14239. /**
  14240. * Defines the passed node as the parent of the current node.
  14241. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14242. * @see https://doc.babylonjs.com/how_to/parenting
  14243. * @param node the node ot set as the parent
  14244. * @returns this TransformNode.
  14245. */
  14246. setParent(node: Nullable<Node>): TransformNode;
  14247. private _nonUniformScaling;
  14248. /**
  14249. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14250. */
  14251. get nonUniformScaling(): boolean;
  14252. /** @hidden */
  14253. _updateNonUniformScalingState(value: boolean): boolean;
  14254. /**
  14255. * Attach the current TransformNode to another TransformNode associated with a bone
  14256. * @param bone Bone affecting the TransformNode
  14257. * @param affectedTransformNode TransformNode associated with the bone
  14258. * @returns this object
  14259. */
  14260. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14261. /**
  14262. * Detach the transform node if its associated with a bone
  14263. * @returns this object
  14264. */
  14265. detachFromBone(): TransformNode;
  14266. private static _rotationAxisCache;
  14267. /**
  14268. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14269. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14270. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14271. * The passed axis is also normalized.
  14272. * @param axis the axis to rotate around
  14273. * @param amount the amount to rotate in radians
  14274. * @param space Space to rotate in (Default: local)
  14275. * @returns the TransformNode.
  14276. */
  14277. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14278. /**
  14279. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14280. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14281. * The passed axis is also normalized. .
  14282. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14283. * @param point the point to rotate around
  14284. * @param axis the axis to rotate around
  14285. * @param amount the amount to rotate in radians
  14286. * @returns the TransformNode
  14287. */
  14288. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14289. /**
  14290. * Translates the mesh along the axis vector for the passed distance in the given space.
  14291. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14292. * @param axis the axis to translate in
  14293. * @param distance the distance to translate
  14294. * @param space Space to rotate in (Default: local)
  14295. * @returns the TransformNode.
  14296. */
  14297. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14298. /**
  14299. * Adds a rotation step to the mesh current rotation.
  14300. * x, y, z are Euler angles expressed in radians.
  14301. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14302. * This means this rotation is made in the mesh local space only.
  14303. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14304. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14305. * ```javascript
  14306. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14307. * ```
  14308. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14309. * 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.
  14310. * @param x Rotation to add
  14311. * @param y Rotation to add
  14312. * @param z Rotation to add
  14313. * @returns the TransformNode.
  14314. */
  14315. addRotation(x: number, y: number, z: number): TransformNode;
  14316. /**
  14317. * @hidden
  14318. */
  14319. protected _getEffectiveParent(): Nullable<Node>;
  14320. /**
  14321. * Computes the world matrix of the node
  14322. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14323. * @returns the world matrix
  14324. */
  14325. computeWorldMatrix(force?: boolean): Matrix;
  14326. /**
  14327. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14328. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14329. */
  14330. resetLocalMatrix(independentOfChildren?: boolean): void;
  14331. protected _afterComputeWorldMatrix(): void;
  14332. /**
  14333. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14334. * @param func callback function to add
  14335. *
  14336. * @returns the TransformNode.
  14337. */
  14338. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14339. /**
  14340. * Removes a registered callback function.
  14341. * @param func callback function to remove
  14342. * @returns the TransformNode.
  14343. */
  14344. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14345. /**
  14346. * Gets the position of the current mesh in camera space
  14347. * @param camera defines the camera to use
  14348. * @returns a position
  14349. */
  14350. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14351. /**
  14352. * Returns the distance from the mesh to the active camera
  14353. * @param camera defines the camera to use
  14354. * @returns the distance
  14355. */
  14356. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14357. /**
  14358. * Clone the current transform node
  14359. * @param name Name of the new clone
  14360. * @param newParent New parent for the clone
  14361. * @param doNotCloneChildren Do not clone children hierarchy
  14362. * @returns the new transform node
  14363. */
  14364. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14365. /**
  14366. * Serializes the objects information.
  14367. * @param currentSerializationObject defines the object to serialize in
  14368. * @returns the serialized object
  14369. */
  14370. serialize(currentSerializationObject?: any): any;
  14371. /**
  14372. * Returns a new TransformNode object parsed from the source provided.
  14373. * @param parsedTransformNode is the source.
  14374. * @param scene the scne the object belongs to
  14375. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14376. * @returns a new TransformNode object parsed from the source provided.
  14377. */
  14378. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14379. /**
  14380. * Get all child-transformNodes of this node
  14381. * @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
  14382. * @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
  14383. * @returns an array of TransformNode
  14384. */
  14385. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14386. /**
  14387. * Releases resources associated with this transform node.
  14388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14390. */
  14391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14392. /**
  14393. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14394. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14395. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14396. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14397. * @returns the current mesh
  14398. */
  14399. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14400. private _syncAbsoluteScalingAndRotation;
  14401. }
  14402. }
  14403. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14404. /**
  14405. * Class used to override all child animations of a given target
  14406. */
  14407. export class AnimationPropertiesOverride {
  14408. /**
  14409. * Gets or sets a value indicating if animation blending must be used
  14410. */
  14411. enableBlending: boolean;
  14412. /**
  14413. * Gets or sets the blending speed to use when enableBlending is true
  14414. */
  14415. blendingSpeed: number;
  14416. /**
  14417. * Gets or sets the default loop mode to use
  14418. */
  14419. loopMode: number;
  14420. }
  14421. }
  14422. declare module "babylonjs/Bones/bone" {
  14423. import { Skeleton } from "babylonjs/Bones/skeleton";
  14424. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14425. import { Nullable } from "babylonjs/types";
  14426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14428. import { Node } from "babylonjs/node";
  14429. import { Space } from "babylonjs/Maths/math.axis";
  14430. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14431. /**
  14432. * Class used to store bone information
  14433. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14434. */
  14435. export class Bone extends Node {
  14436. /**
  14437. * defines the bone name
  14438. */
  14439. name: string;
  14440. private static _tmpVecs;
  14441. private static _tmpQuat;
  14442. private static _tmpMats;
  14443. /**
  14444. * Gets the list of child bones
  14445. */
  14446. children: Bone[];
  14447. /** Gets the animations associated with this bone */
  14448. animations: import("babylonjs/Animations/animation").Animation[];
  14449. /**
  14450. * Gets or sets bone length
  14451. */
  14452. length: number;
  14453. /**
  14454. * @hidden Internal only
  14455. * Set this value to map this bone to a different index in the transform matrices
  14456. * Set this value to -1 to exclude the bone from the transform matrices
  14457. */
  14458. _index: Nullable<number>;
  14459. private _skeleton;
  14460. private _localMatrix;
  14461. private _restPose;
  14462. private _baseMatrix;
  14463. private _absoluteTransform;
  14464. private _invertedAbsoluteTransform;
  14465. private _parent;
  14466. private _scalingDeterminant;
  14467. private _worldTransform;
  14468. private _localScaling;
  14469. private _localRotation;
  14470. private _localPosition;
  14471. private _needToDecompose;
  14472. private _needToCompose;
  14473. /** @hidden */
  14474. _linkedTransformNode: Nullable<TransformNode>;
  14475. /** @hidden */
  14476. _waitingTransformNodeId: Nullable<string>;
  14477. /** @hidden */
  14478. get _matrix(): Matrix;
  14479. /** @hidden */
  14480. set _matrix(value: Matrix);
  14481. /**
  14482. * Create a new bone
  14483. * @param name defines the bone name
  14484. * @param skeleton defines the parent skeleton
  14485. * @param parentBone defines the parent (can be null if the bone is the root)
  14486. * @param localMatrix defines the local matrix
  14487. * @param restPose defines the rest pose matrix
  14488. * @param baseMatrix defines the base matrix
  14489. * @param index defines index of the bone in the hiearchy
  14490. */
  14491. constructor(
  14492. /**
  14493. * defines the bone name
  14494. */
  14495. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14496. /**
  14497. * Gets the current object class name.
  14498. * @return the class name
  14499. */
  14500. getClassName(): string;
  14501. /**
  14502. * Gets the parent skeleton
  14503. * @returns a skeleton
  14504. */
  14505. getSkeleton(): Skeleton;
  14506. /**
  14507. * Gets parent bone
  14508. * @returns a bone or null if the bone is the root of the bone hierarchy
  14509. */
  14510. getParent(): Nullable<Bone>;
  14511. /**
  14512. * Returns an array containing the root bones
  14513. * @returns an array containing the root bones
  14514. */
  14515. getChildren(): Array<Bone>;
  14516. /**
  14517. * Gets the node index in matrix array generated for rendering
  14518. * @returns the node index
  14519. */
  14520. getIndex(): number;
  14521. /**
  14522. * Sets the parent bone
  14523. * @param parent defines the parent (can be null if the bone is the root)
  14524. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14525. */
  14526. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14527. /**
  14528. * Gets the local matrix
  14529. * @returns a matrix
  14530. */
  14531. getLocalMatrix(): Matrix;
  14532. /**
  14533. * Gets the base matrix (initial matrix which remains unchanged)
  14534. * @returns a matrix
  14535. */
  14536. getBaseMatrix(): Matrix;
  14537. /**
  14538. * Gets the rest pose matrix
  14539. * @returns a matrix
  14540. */
  14541. getRestPose(): Matrix;
  14542. /**
  14543. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14544. */
  14545. getWorldMatrix(): Matrix;
  14546. /**
  14547. * Sets the local matrix to rest pose matrix
  14548. */
  14549. returnToRest(): void;
  14550. /**
  14551. * Gets the inverse of the absolute transform matrix.
  14552. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14553. * @returns a matrix
  14554. */
  14555. getInvertedAbsoluteTransform(): Matrix;
  14556. /**
  14557. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14558. * @returns a matrix
  14559. */
  14560. getAbsoluteTransform(): Matrix;
  14561. /**
  14562. * Links with the given transform node.
  14563. * The local matrix of this bone is copied from the transform node every frame.
  14564. * @param transformNode defines the transform node to link to
  14565. */
  14566. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14567. /**
  14568. * Gets the node used to drive the bone's transformation
  14569. * @returns a transform node or null
  14570. */
  14571. getTransformNode(): Nullable<TransformNode>;
  14572. /** Gets or sets current position (in local space) */
  14573. get position(): Vector3;
  14574. set position(newPosition: Vector3);
  14575. /** Gets or sets current rotation (in local space) */
  14576. get rotation(): Vector3;
  14577. set rotation(newRotation: Vector3);
  14578. /** Gets or sets current rotation quaternion (in local space) */
  14579. get rotationQuaternion(): Quaternion;
  14580. set rotationQuaternion(newRotation: Quaternion);
  14581. /** Gets or sets current scaling (in local space) */
  14582. get scaling(): Vector3;
  14583. set scaling(newScaling: Vector3);
  14584. /**
  14585. * Gets the animation properties override
  14586. */
  14587. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14588. private _decompose;
  14589. private _compose;
  14590. /**
  14591. * Update the base and local matrices
  14592. * @param matrix defines the new base or local matrix
  14593. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14594. * @param updateLocalMatrix defines if the local matrix should be updated
  14595. */
  14596. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14597. /** @hidden */
  14598. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14599. /**
  14600. * Flag the bone as dirty (Forcing it to update everything)
  14601. */
  14602. markAsDirty(): void;
  14603. /** @hidden */
  14604. _markAsDirtyAndCompose(): void;
  14605. private _markAsDirtyAndDecompose;
  14606. /**
  14607. * Translate the bone in local or world space
  14608. * @param vec The amount to translate the bone
  14609. * @param space The space that the translation is in
  14610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14611. */
  14612. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14613. /**
  14614. * Set the postion of the bone in local or world space
  14615. * @param position The position to set the bone
  14616. * @param space The space that the position is in
  14617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14618. */
  14619. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14620. /**
  14621. * Set the absolute position of the bone (world space)
  14622. * @param position The position to set the bone
  14623. * @param mesh The mesh that this bone is attached to
  14624. */
  14625. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14626. /**
  14627. * Scale the bone on the x, y and z axes (in local space)
  14628. * @param x The amount to scale the bone on the x axis
  14629. * @param y The amount to scale the bone on the y axis
  14630. * @param z The amount to scale the bone on the z axis
  14631. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14632. */
  14633. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14634. /**
  14635. * Set the bone scaling in local space
  14636. * @param scale defines the scaling vector
  14637. */
  14638. setScale(scale: Vector3): void;
  14639. /**
  14640. * Gets the current scaling in local space
  14641. * @returns the current scaling vector
  14642. */
  14643. getScale(): Vector3;
  14644. /**
  14645. * Gets the current scaling in local space and stores it in a target vector
  14646. * @param result defines the target vector
  14647. */
  14648. getScaleToRef(result: Vector3): void;
  14649. /**
  14650. * Set the yaw, pitch, and roll of the bone in local or world space
  14651. * @param yaw The rotation of the bone on the y axis
  14652. * @param pitch The rotation of the bone on the x axis
  14653. * @param roll The rotation of the bone on the z axis
  14654. * @param space The space that the axes of rotation are in
  14655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14656. */
  14657. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14658. /**
  14659. * Add a rotation to the bone on an axis in local or world space
  14660. * @param axis The axis to rotate the bone on
  14661. * @param amount The amount to rotate the bone
  14662. * @param space The space that the axis is in
  14663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14664. */
  14665. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14666. /**
  14667. * Set the rotation of the bone to a particular axis angle in local or world space
  14668. * @param axis The axis to rotate the bone on
  14669. * @param angle The angle that the bone should be rotated to
  14670. * @param space The space that the axis is in
  14671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14672. */
  14673. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14674. /**
  14675. * Set the euler rotation of the bone in local of world space
  14676. * @param rotation The euler rotation that the bone should be set to
  14677. * @param space The space that the rotation is in
  14678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14679. */
  14680. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14681. /**
  14682. * Set the quaternion rotation of the bone in local of world space
  14683. * @param quat The quaternion rotation that the bone should be set to
  14684. * @param space The space that the rotation is in
  14685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14686. */
  14687. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14688. /**
  14689. * Set the rotation matrix of the bone in local of world space
  14690. * @param rotMat The rotation matrix that the bone should be set to
  14691. * @param space The space that the rotation is in
  14692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14693. */
  14694. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14695. private _rotateWithMatrix;
  14696. private _getNegativeRotationToRef;
  14697. /**
  14698. * Get the position of the bone in local or world space
  14699. * @param space The space that the returned position is in
  14700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14701. * @returns The position of the bone
  14702. */
  14703. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14704. /**
  14705. * Copy the position of the bone to a vector3 in local or world space
  14706. * @param space The space that the returned position is in
  14707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14708. * @param result The vector3 to copy the position to
  14709. */
  14710. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14711. /**
  14712. * Get the absolute position of the bone (world space)
  14713. * @param mesh The mesh that this bone is attached to
  14714. * @returns The absolute position of the bone
  14715. */
  14716. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14717. /**
  14718. * Copy the absolute position of the bone (world space) to the result param
  14719. * @param mesh The mesh that this bone is attached to
  14720. * @param result The vector3 to copy the absolute position to
  14721. */
  14722. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14723. /**
  14724. * Compute the absolute transforms of this bone and its children
  14725. */
  14726. computeAbsoluteTransforms(): void;
  14727. /**
  14728. * Get the world direction from an axis that is in the local space of the bone
  14729. * @param localAxis The local direction that is used to compute the world direction
  14730. * @param mesh The mesh that this bone is attached to
  14731. * @returns The world direction
  14732. */
  14733. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14734. /**
  14735. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14736. * @param localAxis The local direction that is used to compute the world direction
  14737. * @param mesh The mesh that this bone is attached to
  14738. * @param result The vector3 that the world direction will be copied to
  14739. */
  14740. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14741. /**
  14742. * Get the euler rotation of the bone in local or world space
  14743. * @param space The space that the rotation should be in
  14744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14745. * @returns The euler rotation
  14746. */
  14747. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14748. /**
  14749. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14750. * @param space The space that the rotation should be in
  14751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14752. * @param result The vector3 that the rotation should be copied to
  14753. */
  14754. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14755. /**
  14756. * Get the quaternion rotation of the bone in either local or world space
  14757. * @param space The space that the rotation should be in
  14758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14759. * @returns The quaternion rotation
  14760. */
  14761. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14762. /**
  14763. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14764. * @param space The space that the rotation should be in
  14765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14766. * @param result The quaternion that the rotation should be copied to
  14767. */
  14768. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14769. /**
  14770. * Get the rotation matrix of the bone in local or world space
  14771. * @param space The space that the rotation should be in
  14772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14773. * @returns The rotation matrix
  14774. */
  14775. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14776. /**
  14777. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14778. * @param space The space that the rotation should be in
  14779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14780. * @param result The quaternion that the rotation should be copied to
  14781. */
  14782. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14783. /**
  14784. * Get the world position of a point that is in the local space of the bone
  14785. * @param position The local position
  14786. * @param mesh The mesh that this bone is attached to
  14787. * @returns The world position
  14788. */
  14789. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14790. /**
  14791. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14792. * @param position The local position
  14793. * @param mesh The mesh that this bone is attached to
  14794. * @param result The vector3 that the world position should be copied to
  14795. */
  14796. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14797. /**
  14798. * Get the local position of a point that is in world space
  14799. * @param position The world position
  14800. * @param mesh The mesh that this bone is attached to
  14801. * @returns The local position
  14802. */
  14803. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14804. /**
  14805. * Get the local position of a point that is in world space and copy it to the result param
  14806. * @param position The world position
  14807. * @param mesh The mesh that this bone is attached to
  14808. * @param result The vector3 that the local position should be copied to
  14809. */
  14810. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14811. }
  14812. }
  14813. declare module "babylonjs/Animations/runtimeAnimation" {
  14814. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14815. import { Animatable } from "babylonjs/Animations/animatable";
  14816. import { Scene } from "babylonjs/scene";
  14817. /**
  14818. * Defines a runtime animation
  14819. */
  14820. export class RuntimeAnimation {
  14821. private _events;
  14822. /**
  14823. * The current frame of the runtime animation
  14824. */
  14825. private _currentFrame;
  14826. /**
  14827. * The animation used by the runtime animation
  14828. */
  14829. private _animation;
  14830. /**
  14831. * The target of the runtime animation
  14832. */
  14833. private _target;
  14834. /**
  14835. * The initiating animatable
  14836. */
  14837. private _host;
  14838. /**
  14839. * The original value of the runtime animation
  14840. */
  14841. private _originalValue;
  14842. /**
  14843. * The original blend value of the runtime animation
  14844. */
  14845. private _originalBlendValue;
  14846. /**
  14847. * The offsets cache of the runtime animation
  14848. */
  14849. private _offsetsCache;
  14850. /**
  14851. * The high limits cache of the runtime animation
  14852. */
  14853. private _highLimitsCache;
  14854. /**
  14855. * Specifies if the runtime animation has been stopped
  14856. */
  14857. private _stopped;
  14858. /**
  14859. * The blending factor of the runtime animation
  14860. */
  14861. private _blendingFactor;
  14862. /**
  14863. * The BabylonJS scene
  14864. */
  14865. private _scene;
  14866. /**
  14867. * The current value of the runtime animation
  14868. */
  14869. private _currentValue;
  14870. /** @hidden */
  14871. _animationState: _IAnimationState;
  14872. /**
  14873. * The active target of the runtime animation
  14874. */
  14875. private _activeTargets;
  14876. private _currentActiveTarget;
  14877. private _directTarget;
  14878. /**
  14879. * The target path of the runtime animation
  14880. */
  14881. private _targetPath;
  14882. /**
  14883. * The weight of the runtime animation
  14884. */
  14885. private _weight;
  14886. /**
  14887. * The ratio offset of the runtime animation
  14888. */
  14889. private _ratioOffset;
  14890. /**
  14891. * The previous delay of the runtime animation
  14892. */
  14893. private _previousDelay;
  14894. /**
  14895. * The previous ratio of the runtime animation
  14896. */
  14897. private _previousRatio;
  14898. private _enableBlending;
  14899. private _keys;
  14900. private _minFrame;
  14901. private _maxFrame;
  14902. private _minValue;
  14903. private _maxValue;
  14904. private _targetIsArray;
  14905. /**
  14906. * Gets the current frame of the runtime animation
  14907. */
  14908. get currentFrame(): number;
  14909. /**
  14910. * Gets the weight of the runtime animation
  14911. */
  14912. get weight(): number;
  14913. /**
  14914. * Gets the current value of the runtime animation
  14915. */
  14916. get currentValue(): any;
  14917. /**
  14918. * Gets the target path of the runtime animation
  14919. */
  14920. get targetPath(): string;
  14921. /**
  14922. * Gets the actual target of the runtime animation
  14923. */
  14924. get target(): any;
  14925. /**
  14926. * Gets the additive state of the runtime animation
  14927. */
  14928. get isAdditive(): boolean;
  14929. /** @hidden */
  14930. _onLoop: () => void;
  14931. /**
  14932. * Create a new RuntimeAnimation object
  14933. * @param target defines the target of the animation
  14934. * @param animation defines the source animation object
  14935. * @param scene defines the hosting scene
  14936. * @param host defines the initiating Animatable
  14937. */
  14938. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14939. private _preparePath;
  14940. /**
  14941. * Gets the animation from the runtime animation
  14942. */
  14943. get animation(): Animation;
  14944. /**
  14945. * Resets the runtime animation to the beginning
  14946. * @param restoreOriginal defines whether to restore the target property to the original value
  14947. */
  14948. reset(restoreOriginal?: boolean): void;
  14949. /**
  14950. * Specifies if the runtime animation is stopped
  14951. * @returns Boolean specifying if the runtime animation is stopped
  14952. */
  14953. isStopped(): boolean;
  14954. /**
  14955. * Disposes of the runtime animation
  14956. */
  14957. dispose(): void;
  14958. /**
  14959. * Apply the interpolated value to the target
  14960. * @param currentValue defines the value computed by the animation
  14961. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14962. */
  14963. setValue(currentValue: any, weight: number): void;
  14964. private _getOriginalValues;
  14965. private _setValue;
  14966. /**
  14967. * Gets the loop pmode of the runtime animation
  14968. * @returns Loop Mode
  14969. */
  14970. private _getCorrectLoopMode;
  14971. /**
  14972. * Move the current animation to a given frame
  14973. * @param frame defines the frame to move to
  14974. */
  14975. goToFrame(frame: number): void;
  14976. /**
  14977. * @hidden Internal use only
  14978. */
  14979. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14980. /**
  14981. * Execute the current animation
  14982. * @param delay defines the delay to add to the current frame
  14983. * @param from defines the lower bound of the animation range
  14984. * @param to defines the upper bound of the animation range
  14985. * @param loop defines if the current animation must loop
  14986. * @param speedRatio defines the current speed ratio
  14987. * @param weight defines the weight of the animation (default is -1 so no weight)
  14988. * @param onLoop optional callback called when animation loops
  14989. * @returns a boolean indicating if the animation is running
  14990. */
  14991. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14992. }
  14993. }
  14994. declare module "babylonjs/Animations/animatable" {
  14995. import { Animation } from "babylonjs/Animations/animation";
  14996. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14997. import { Nullable } from "babylonjs/types";
  14998. import { Observable } from "babylonjs/Misc/observable";
  14999. import { Scene } from "babylonjs/scene";
  15000. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15001. import { Node } from "babylonjs/node";
  15002. /**
  15003. * Class used to store an actual running animation
  15004. */
  15005. export class Animatable {
  15006. /** defines the target object */
  15007. target: any;
  15008. /** defines the starting frame number (default is 0) */
  15009. fromFrame: number;
  15010. /** defines the ending frame number (default is 100) */
  15011. toFrame: number;
  15012. /** defines if the animation must loop (default is false) */
  15013. loopAnimation: boolean;
  15014. /** defines a callback to call when animation ends if it is not looping */
  15015. onAnimationEnd?: (() => void) | null | undefined;
  15016. /** defines a callback to call when animation loops */
  15017. onAnimationLoop?: (() => void) | null | undefined;
  15018. /** defines whether the animation should be evaluated additively */
  15019. isAdditive: boolean;
  15020. private _localDelayOffset;
  15021. private _pausedDelay;
  15022. private _runtimeAnimations;
  15023. private _paused;
  15024. private _scene;
  15025. private _speedRatio;
  15026. private _weight;
  15027. private _syncRoot;
  15028. /**
  15029. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15030. * This will only apply for non looping animation (default is true)
  15031. */
  15032. disposeOnEnd: boolean;
  15033. /**
  15034. * Gets a boolean indicating if the animation has started
  15035. */
  15036. animationStarted: boolean;
  15037. /**
  15038. * Observer raised when the animation ends
  15039. */
  15040. onAnimationEndObservable: Observable<Animatable>;
  15041. /**
  15042. * Observer raised when the animation loops
  15043. */
  15044. onAnimationLoopObservable: Observable<Animatable>;
  15045. /**
  15046. * Gets the root Animatable used to synchronize and normalize animations
  15047. */
  15048. get syncRoot(): Nullable<Animatable>;
  15049. /**
  15050. * Gets the current frame of the first RuntimeAnimation
  15051. * Used to synchronize Animatables
  15052. */
  15053. get masterFrame(): number;
  15054. /**
  15055. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15056. */
  15057. get weight(): number;
  15058. set weight(value: number);
  15059. /**
  15060. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15061. */
  15062. get speedRatio(): number;
  15063. set speedRatio(value: number);
  15064. /**
  15065. * Creates a new Animatable
  15066. * @param scene defines the hosting scene
  15067. * @param target defines the target object
  15068. * @param fromFrame defines the starting frame number (default is 0)
  15069. * @param toFrame defines the ending frame number (default is 100)
  15070. * @param loopAnimation defines if the animation must loop (default is false)
  15071. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15072. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15073. * @param animations defines a group of animation to add to the new Animatable
  15074. * @param onAnimationLoop defines a callback to call when animation loops
  15075. * @param isAdditive defines whether the animation should be evaluated additively
  15076. */
  15077. constructor(scene: Scene,
  15078. /** defines the target object */
  15079. target: any,
  15080. /** defines the starting frame number (default is 0) */
  15081. fromFrame?: number,
  15082. /** defines the ending frame number (default is 100) */
  15083. toFrame?: number,
  15084. /** defines if the animation must loop (default is false) */
  15085. loopAnimation?: boolean, speedRatio?: number,
  15086. /** defines a callback to call when animation ends if it is not looping */
  15087. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15088. /** defines a callback to call when animation loops */
  15089. onAnimationLoop?: (() => void) | null | undefined,
  15090. /** defines whether the animation should be evaluated additively */
  15091. isAdditive?: boolean);
  15092. /**
  15093. * Synchronize and normalize current Animatable with a source Animatable
  15094. * This is useful when using animation weights and when animations are not of the same length
  15095. * @param root defines the root Animatable to synchronize with
  15096. * @returns the current Animatable
  15097. */
  15098. syncWith(root: Animatable): Animatable;
  15099. /**
  15100. * Gets the list of runtime animations
  15101. * @returns an array of RuntimeAnimation
  15102. */
  15103. getAnimations(): RuntimeAnimation[];
  15104. /**
  15105. * Adds more animations to the current animatable
  15106. * @param target defines the target of the animations
  15107. * @param animations defines the new animations to add
  15108. */
  15109. appendAnimations(target: any, animations: Animation[]): void;
  15110. /**
  15111. * Gets the source animation for a specific property
  15112. * @param property defines the propertyu to look for
  15113. * @returns null or the source animation for the given property
  15114. */
  15115. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15116. /**
  15117. * Gets the runtime animation for a specific property
  15118. * @param property defines the propertyu to look for
  15119. * @returns null or the runtime animation for the given property
  15120. */
  15121. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15122. /**
  15123. * Resets the animatable to its original state
  15124. */
  15125. reset(): void;
  15126. /**
  15127. * Allows the animatable to blend with current running animations
  15128. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15129. * @param blendingSpeed defines the blending speed to use
  15130. */
  15131. enableBlending(blendingSpeed: number): void;
  15132. /**
  15133. * Disable animation blending
  15134. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15135. */
  15136. disableBlending(): void;
  15137. /**
  15138. * Jump directly to a given frame
  15139. * @param frame defines the frame to jump to
  15140. */
  15141. goToFrame(frame: number): void;
  15142. /**
  15143. * Pause the animation
  15144. */
  15145. pause(): void;
  15146. /**
  15147. * Restart the animation
  15148. */
  15149. restart(): void;
  15150. private _raiseOnAnimationEnd;
  15151. /**
  15152. * Stop and delete the current animation
  15153. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15154. * @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)
  15155. */
  15156. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15157. /**
  15158. * Wait asynchronously for the animation to end
  15159. * @returns a promise which will be fullfilled when the animation ends
  15160. */
  15161. waitAsync(): Promise<Animatable>;
  15162. /** @hidden */
  15163. _animate(delay: number): boolean;
  15164. }
  15165. module "babylonjs/scene" {
  15166. interface Scene {
  15167. /** @hidden */
  15168. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15169. /** @hidden */
  15170. _processLateAnimationBindingsForMatrices(holder: {
  15171. totalWeight: number;
  15172. totalAdditiveWeight: number;
  15173. animations: RuntimeAnimation[];
  15174. additiveAnimations: RuntimeAnimation[];
  15175. originalValue: Matrix;
  15176. }): any;
  15177. /** @hidden */
  15178. _processLateAnimationBindingsForQuaternions(holder: {
  15179. totalWeight: number;
  15180. totalAdditiveWeight: number;
  15181. animations: RuntimeAnimation[];
  15182. additiveAnimations: RuntimeAnimation[];
  15183. originalValue: Quaternion;
  15184. }, refQuaternion: Quaternion): Quaternion;
  15185. /** @hidden */
  15186. _processLateAnimationBindings(): void;
  15187. /**
  15188. * Will start the animation sequence of a given target
  15189. * @param target defines the target
  15190. * @param from defines from which frame should animation start
  15191. * @param to defines until which frame should animation run.
  15192. * @param weight defines the weight to apply to the animation (1.0 by default)
  15193. * @param loop defines if the animation loops
  15194. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15195. * @param onAnimationEnd defines the function to be executed when the animation ends
  15196. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15197. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15198. * @param onAnimationLoop defines the callback to call when an animation loops
  15199. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15200. * @returns the animatable object created for this animation
  15201. */
  15202. 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;
  15203. /**
  15204. * Will start the animation sequence of a given target
  15205. * @param target defines the target
  15206. * @param from defines from which frame should animation start
  15207. * @param to defines until which frame should animation run.
  15208. * @param loop defines if the animation loops
  15209. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15210. * @param onAnimationEnd defines the function to be executed when the animation ends
  15211. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15212. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15213. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15214. * @param onAnimationLoop defines the callback to call when an animation loops
  15215. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15216. * @returns the animatable object created for this animation
  15217. */
  15218. 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;
  15219. /**
  15220. * Will start the animation sequence of a given target and its hierarchy
  15221. * @param target defines the target
  15222. * @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.
  15223. * @param from defines from which frame should animation start
  15224. * @param to defines until which frame should animation run.
  15225. * @param loop defines if the animation loops
  15226. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15227. * @param onAnimationEnd defines the function to be executed when the animation ends
  15228. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15229. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15230. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15231. * @param onAnimationLoop defines the callback to call when an animation loops
  15232. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15233. * @returns the list of created animatables
  15234. */
  15235. 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[];
  15236. /**
  15237. * Begin a new animation on a given node
  15238. * @param target defines the target where the animation will take place
  15239. * @param animations defines the list of animations to start
  15240. * @param from defines the initial value
  15241. * @param to defines the final value
  15242. * @param loop defines if you want animation to loop (off by default)
  15243. * @param speedRatio defines the speed ratio to apply to all animations
  15244. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15245. * @param onAnimationLoop defines the callback to call when an animation loops
  15246. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15247. * @returns the list of created animatables
  15248. */
  15249. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15250. /**
  15251. * Begin a new animation on a given node and its hierarchy
  15252. * @param target defines the root node where the animation will take place
  15253. * @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.
  15254. * @param animations defines the list of animations to start
  15255. * @param from defines the initial value
  15256. * @param to defines the final value
  15257. * @param loop defines if you want animation to loop (off by default)
  15258. * @param speedRatio defines the speed ratio to apply to all animations
  15259. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15260. * @param onAnimationLoop defines the callback to call when an animation loops
  15261. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15262. * @returns the list of animatables created for all nodes
  15263. */
  15264. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15265. /**
  15266. * Gets the animatable associated with a specific target
  15267. * @param target defines the target of the animatable
  15268. * @returns the required animatable if found
  15269. */
  15270. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15271. /**
  15272. * Gets all animatables associated with a given target
  15273. * @param target defines the target to look animatables for
  15274. * @returns an array of Animatables
  15275. */
  15276. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15277. /**
  15278. * Stops and removes all animations that have been applied to the scene
  15279. */
  15280. stopAllAnimations(): void;
  15281. /**
  15282. * Gets the current delta time used by animation engine
  15283. */
  15284. deltaTime: number;
  15285. }
  15286. }
  15287. module "babylonjs/Bones/bone" {
  15288. interface Bone {
  15289. /**
  15290. * Copy an animation range from another bone
  15291. * @param source defines the source bone
  15292. * @param rangeName defines the range name to copy
  15293. * @param frameOffset defines the frame offset
  15294. * @param rescaleAsRequired defines if rescaling must be applied if required
  15295. * @param skelDimensionsRatio defines the scaling ratio
  15296. * @returns true if operation was successful
  15297. */
  15298. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15299. }
  15300. }
  15301. }
  15302. declare module "babylonjs/Bones/skeleton" {
  15303. import { Bone } from "babylonjs/Bones/bone";
  15304. import { Observable } from "babylonjs/Misc/observable";
  15305. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15306. import { Scene } from "babylonjs/scene";
  15307. import { Nullable } from "babylonjs/types";
  15308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15309. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15310. import { Animatable } from "babylonjs/Animations/animatable";
  15311. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15312. import { Animation } from "babylonjs/Animations/animation";
  15313. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15314. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15316. /**
  15317. * Class used to handle skinning animations
  15318. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15319. */
  15320. export class Skeleton implements IAnimatable {
  15321. /** defines the skeleton name */
  15322. name: string;
  15323. /** defines the skeleton Id */
  15324. id: string;
  15325. /**
  15326. * Defines the list of child bones
  15327. */
  15328. bones: Bone[];
  15329. /**
  15330. * Defines an estimate of the dimension of the skeleton at rest
  15331. */
  15332. dimensionsAtRest: Vector3;
  15333. /**
  15334. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15335. */
  15336. needInitialSkinMatrix: boolean;
  15337. /**
  15338. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15339. */
  15340. overrideMesh: Nullable<AbstractMesh>;
  15341. /**
  15342. * Gets the list of animations attached to this skeleton
  15343. */
  15344. animations: Array<Animation>;
  15345. private _scene;
  15346. private _isDirty;
  15347. private _transformMatrices;
  15348. private _transformMatrixTexture;
  15349. private _meshesWithPoseMatrix;
  15350. private _animatables;
  15351. private _identity;
  15352. private _synchronizedWithMesh;
  15353. private _ranges;
  15354. private _lastAbsoluteTransformsUpdateId;
  15355. private _canUseTextureForBones;
  15356. private _uniqueId;
  15357. /** @hidden */
  15358. _numBonesWithLinkedTransformNode: number;
  15359. /** @hidden */
  15360. _hasWaitingData: Nullable<boolean>;
  15361. /**
  15362. * Specifies if the skeleton should be serialized
  15363. */
  15364. doNotSerialize: boolean;
  15365. private _useTextureToStoreBoneMatrices;
  15366. /**
  15367. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15368. * Please note that this option is not available if the hardware does not support it
  15369. */
  15370. get useTextureToStoreBoneMatrices(): boolean;
  15371. set useTextureToStoreBoneMatrices(value: boolean);
  15372. private _animationPropertiesOverride;
  15373. /**
  15374. * Gets or sets the animation properties override
  15375. */
  15376. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15377. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15378. /**
  15379. * List of inspectable custom properties (used by the Inspector)
  15380. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15381. */
  15382. inspectableCustomProperties: IInspectable[];
  15383. /**
  15384. * An observable triggered before computing the skeleton's matrices
  15385. */
  15386. onBeforeComputeObservable: Observable<Skeleton>;
  15387. /**
  15388. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15389. */
  15390. get isUsingTextureForMatrices(): boolean;
  15391. /**
  15392. * Gets the unique ID of this skeleton
  15393. */
  15394. get uniqueId(): number;
  15395. /**
  15396. * Creates a new skeleton
  15397. * @param name defines the skeleton name
  15398. * @param id defines the skeleton Id
  15399. * @param scene defines the hosting scene
  15400. */
  15401. constructor(
  15402. /** defines the skeleton name */
  15403. name: string,
  15404. /** defines the skeleton Id */
  15405. id: string, scene: Scene);
  15406. /**
  15407. * Gets the current object class name.
  15408. * @return the class name
  15409. */
  15410. getClassName(): string;
  15411. /**
  15412. * Returns an array containing the root bones
  15413. * @returns an array containing the root bones
  15414. */
  15415. getChildren(): Array<Bone>;
  15416. /**
  15417. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15418. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15419. * @returns a Float32Array containing matrices data
  15420. */
  15421. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15422. /**
  15423. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15424. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15425. * @returns a raw texture containing the data
  15426. */
  15427. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15428. /**
  15429. * Gets the current hosting scene
  15430. * @returns a scene object
  15431. */
  15432. getScene(): Scene;
  15433. /**
  15434. * Gets a string representing the current skeleton data
  15435. * @param fullDetails defines a boolean indicating if we want a verbose version
  15436. * @returns a string representing the current skeleton data
  15437. */
  15438. toString(fullDetails?: boolean): string;
  15439. /**
  15440. * Get bone's index searching by name
  15441. * @param name defines bone's name to search for
  15442. * @return the indice of the bone. Returns -1 if not found
  15443. */
  15444. getBoneIndexByName(name: string): number;
  15445. /**
  15446. * Creater a new animation range
  15447. * @param name defines the name of the range
  15448. * @param from defines the start key
  15449. * @param to defines the end key
  15450. */
  15451. createAnimationRange(name: string, from: number, to: number): void;
  15452. /**
  15453. * Delete a specific animation range
  15454. * @param name defines the name of the range
  15455. * @param deleteFrames defines if frames must be removed as well
  15456. */
  15457. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15458. /**
  15459. * Gets a specific animation range
  15460. * @param name defines the name of the range to look for
  15461. * @returns the requested animation range or null if not found
  15462. */
  15463. getAnimationRange(name: string): Nullable<AnimationRange>;
  15464. /**
  15465. * Gets the list of all animation ranges defined on this skeleton
  15466. * @returns an array
  15467. */
  15468. getAnimationRanges(): Nullable<AnimationRange>[];
  15469. /**
  15470. * Copy animation range from a source skeleton.
  15471. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15472. * @param source defines the source skeleton
  15473. * @param name defines the name of the range to copy
  15474. * @param rescaleAsRequired defines if rescaling must be applied if required
  15475. * @returns true if operation was successful
  15476. */
  15477. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15478. /**
  15479. * Forces the skeleton to go to rest pose
  15480. */
  15481. returnToRest(): void;
  15482. private _getHighestAnimationFrame;
  15483. /**
  15484. * Begin a specific animation range
  15485. * @param name defines the name of the range to start
  15486. * @param loop defines if looping must be turned on (false by default)
  15487. * @param speedRatio defines the speed ratio to apply (1 by default)
  15488. * @param onAnimationEnd defines a callback which will be called when animation will end
  15489. * @returns a new animatable
  15490. */
  15491. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15492. /**
  15493. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15494. * @param skeleton defines the Skeleton containing the animation range to convert
  15495. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15496. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15497. * @returns the original skeleton
  15498. */
  15499. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15500. /** @hidden */
  15501. _markAsDirty(): void;
  15502. /** @hidden */
  15503. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15504. /** @hidden */
  15505. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15506. private _computeTransformMatrices;
  15507. /**
  15508. * Build all resources required to render a skeleton
  15509. */
  15510. prepare(): void;
  15511. /**
  15512. * Gets the list of animatables currently running for this skeleton
  15513. * @returns an array of animatables
  15514. */
  15515. getAnimatables(): IAnimatable[];
  15516. /**
  15517. * Clone the current skeleton
  15518. * @param name defines the name of the new skeleton
  15519. * @param id defines the id of the new skeleton
  15520. * @returns the new skeleton
  15521. */
  15522. clone(name: string, id?: string): Skeleton;
  15523. /**
  15524. * Enable animation blending for this skeleton
  15525. * @param blendingSpeed defines the blending speed to apply
  15526. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15527. */
  15528. enableBlending(blendingSpeed?: number): void;
  15529. /**
  15530. * Releases all resources associated with the current skeleton
  15531. */
  15532. dispose(): void;
  15533. /**
  15534. * Serialize the skeleton in a JSON object
  15535. * @returns a JSON object
  15536. */
  15537. serialize(): any;
  15538. /**
  15539. * Creates a new skeleton from serialized data
  15540. * @param parsedSkeleton defines the serialized data
  15541. * @param scene defines the hosting scene
  15542. * @returns a new skeleton
  15543. */
  15544. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15545. /**
  15546. * Compute all node absolute transforms
  15547. * @param forceUpdate defines if computation must be done even if cache is up to date
  15548. */
  15549. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15550. /**
  15551. * Gets the root pose matrix
  15552. * @returns a matrix
  15553. */
  15554. getPoseMatrix(): Nullable<Matrix>;
  15555. /**
  15556. * Sorts bones per internal index
  15557. */
  15558. sortBones(): void;
  15559. private _sortBones;
  15560. }
  15561. }
  15562. declare module "babylonjs/Meshes/instancedMesh" {
  15563. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15564. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15565. import { Camera } from "babylonjs/Cameras/camera";
  15566. import { Node } from "babylonjs/node";
  15567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15568. import { Mesh } from "babylonjs/Meshes/mesh";
  15569. import { Material } from "babylonjs/Materials/material";
  15570. import { Skeleton } from "babylonjs/Bones/skeleton";
  15571. import { Light } from "babylonjs/Lights/light";
  15572. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15573. /**
  15574. * Creates an instance based on a source mesh.
  15575. */
  15576. export class InstancedMesh extends AbstractMesh {
  15577. private _sourceMesh;
  15578. private _currentLOD;
  15579. /** @hidden */
  15580. _indexInSourceMeshInstanceArray: number;
  15581. constructor(name: string, source: Mesh);
  15582. /**
  15583. * Returns the string "InstancedMesh".
  15584. */
  15585. getClassName(): string;
  15586. /** Gets the list of lights affecting that mesh */
  15587. get lightSources(): Light[];
  15588. _resyncLightSources(): void;
  15589. _resyncLightSource(light: Light): void;
  15590. _removeLightSource(light: Light, dispose: boolean): void;
  15591. /**
  15592. * If the source mesh receives shadows
  15593. */
  15594. get receiveShadows(): boolean;
  15595. /**
  15596. * The material of the source mesh
  15597. */
  15598. get material(): Nullable<Material>;
  15599. /**
  15600. * Visibility of the source mesh
  15601. */
  15602. get visibility(): number;
  15603. /**
  15604. * Skeleton of the source mesh
  15605. */
  15606. get skeleton(): Nullable<Skeleton>;
  15607. /**
  15608. * Rendering ground id of the source mesh
  15609. */
  15610. get renderingGroupId(): number;
  15611. set renderingGroupId(value: number);
  15612. /**
  15613. * Returns the total number of vertices (integer).
  15614. */
  15615. getTotalVertices(): number;
  15616. /**
  15617. * Returns a positive integer : the total number of indices in this mesh geometry.
  15618. * @returns the numner of indices or zero if the mesh has no geometry.
  15619. */
  15620. getTotalIndices(): number;
  15621. /**
  15622. * The source mesh of the instance
  15623. */
  15624. get sourceMesh(): Mesh;
  15625. /**
  15626. * Is this node ready to be used/rendered
  15627. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15628. * @return {boolean} is it ready
  15629. */
  15630. isReady(completeCheck?: boolean): boolean;
  15631. /**
  15632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15633. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15634. * @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.
  15635. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15636. */
  15637. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15638. /**
  15639. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15640. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15641. * The `data` are either a numeric array either a Float32Array.
  15642. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15643. * 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).
  15644. * Note that a new underlying VertexBuffer object is created each call.
  15645. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15646. *
  15647. * Possible `kind` values :
  15648. * - VertexBuffer.PositionKind
  15649. * - VertexBuffer.UVKind
  15650. * - VertexBuffer.UV2Kind
  15651. * - VertexBuffer.UV3Kind
  15652. * - VertexBuffer.UV4Kind
  15653. * - VertexBuffer.UV5Kind
  15654. * - VertexBuffer.UV6Kind
  15655. * - VertexBuffer.ColorKind
  15656. * - VertexBuffer.MatricesIndicesKind
  15657. * - VertexBuffer.MatricesIndicesExtraKind
  15658. * - VertexBuffer.MatricesWeightsKind
  15659. * - VertexBuffer.MatricesWeightsExtraKind
  15660. *
  15661. * Returns the Mesh.
  15662. */
  15663. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15664. /**
  15665. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15666. * If the mesh has no geometry, it is simply returned as it is.
  15667. * The `data` are either a numeric array either a Float32Array.
  15668. * No new underlying VertexBuffer object is created.
  15669. * 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.
  15670. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15671. *
  15672. * Possible `kind` values :
  15673. * - VertexBuffer.PositionKind
  15674. * - VertexBuffer.UVKind
  15675. * - VertexBuffer.UV2Kind
  15676. * - VertexBuffer.UV3Kind
  15677. * - VertexBuffer.UV4Kind
  15678. * - VertexBuffer.UV5Kind
  15679. * - VertexBuffer.UV6Kind
  15680. * - VertexBuffer.ColorKind
  15681. * - VertexBuffer.MatricesIndicesKind
  15682. * - VertexBuffer.MatricesIndicesExtraKind
  15683. * - VertexBuffer.MatricesWeightsKind
  15684. * - VertexBuffer.MatricesWeightsExtraKind
  15685. *
  15686. * Returns the Mesh.
  15687. */
  15688. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15689. /**
  15690. * Sets the mesh indices.
  15691. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15692. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15693. * This method creates a new index buffer each call.
  15694. * Returns the Mesh.
  15695. */
  15696. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15697. /**
  15698. * Boolean : True if the mesh owns the requested kind of data.
  15699. */
  15700. isVerticesDataPresent(kind: string): boolean;
  15701. /**
  15702. * Returns an array of indices (IndicesArray).
  15703. */
  15704. getIndices(): Nullable<IndicesArray>;
  15705. get _positions(): Nullable<Vector3[]>;
  15706. /**
  15707. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15708. * This means the mesh underlying bounding box and sphere are recomputed.
  15709. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15710. * @returns the current mesh
  15711. */
  15712. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15713. /** @hidden */
  15714. _preActivate(): InstancedMesh;
  15715. /** @hidden */
  15716. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15717. /** @hidden */
  15718. _postActivate(): void;
  15719. getWorldMatrix(): Matrix;
  15720. get isAnInstance(): boolean;
  15721. /**
  15722. * Returns the current associated LOD AbstractMesh.
  15723. */
  15724. getLOD(camera: Camera): AbstractMesh;
  15725. /** @hidden */
  15726. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15727. /** @hidden */
  15728. _syncSubMeshes(): InstancedMesh;
  15729. /** @hidden */
  15730. _generatePointsArray(): boolean;
  15731. /**
  15732. * Creates a new InstancedMesh from the current mesh.
  15733. * - name (string) : the cloned mesh name
  15734. * - newParent (optional Node) : the optional Node to parent the clone to.
  15735. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15736. *
  15737. * Returns the clone.
  15738. */
  15739. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15740. /**
  15741. * Disposes the InstancedMesh.
  15742. * Returns nothing.
  15743. */
  15744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15745. }
  15746. module "babylonjs/Meshes/mesh" {
  15747. interface Mesh {
  15748. /**
  15749. * Register a custom buffer that will be instanced
  15750. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15751. * @param kind defines the buffer kind
  15752. * @param stride defines the stride in floats
  15753. */
  15754. registerInstancedBuffer(kind: string, stride: number): void;
  15755. /** @hidden */
  15756. _userInstancedBuffersStorage: {
  15757. data: {
  15758. [key: string]: Float32Array;
  15759. };
  15760. sizes: {
  15761. [key: string]: number;
  15762. };
  15763. vertexBuffers: {
  15764. [key: string]: Nullable<VertexBuffer>;
  15765. };
  15766. strides: {
  15767. [key: string]: number;
  15768. };
  15769. };
  15770. }
  15771. }
  15772. module "babylonjs/Meshes/abstractMesh" {
  15773. interface AbstractMesh {
  15774. /**
  15775. * Object used to store instanced buffers defined by user
  15776. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15777. */
  15778. instancedBuffers: {
  15779. [key: string]: any;
  15780. };
  15781. }
  15782. }
  15783. }
  15784. declare module "babylonjs/Materials/shaderMaterial" {
  15785. import { Scene } from "babylonjs/scene";
  15786. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15788. import { Mesh } from "babylonjs/Meshes/mesh";
  15789. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15791. import { Material } from "babylonjs/Materials/material";
  15792. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15793. /**
  15794. * Defines the options associated with the creation of a shader material.
  15795. */
  15796. export interface IShaderMaterialOptions {
  15797. /**
  15798. * Does the material work in alpha blend mode
  15799. */
  15800. needAlphaBlending: boolean;
  15801. /**
  15802. * Does the material work in alpha test mode
  15803. */
  15804. needAlphaTesting: boolean;
  15805. /**
  15806. * The list of attribute names used in the shader
  15807. */
  15808. attributes: string[];
  15809. /**
  15810. * The list of unifrom names used in the shader
  15811. */
  15812. uniforms: string[];
  15813. /**
  15814. * The list of UBO names used in the shader
  15815. */
  15816. uniformBuffers: string[];
  15817. /**
  15818. * The list of sampler names used in the shader
  15819. */
  15820. samplers: string[];
  15821. /**
  15822. * The list of defines used in the shader
  15823. */
  15824. defines: string[];
  15825. }
  15826. /**
  15827. * 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.
  15828. *
  15829. * This returned material effects how the mesh will look based on the code in the shaders.
  15830. *
  15831. * @see http://doc.babylonjs.com/how_to/shader_material
  15832. */
  15833. export class ShaderMaterial extends Material {
  15834. private _shaderPath;
  15835. private _options;
  15836. private _textures;
  15837. private _textureArrays;
  15838. private _floats;
  15839. private _ints;
  15840. private _floatsArrays;
  15841. private _colors3;
  15842. private _colors3Arrays;
  15843. private _colors4;
  15844. private _colors4Arrays;
  15845. private _vectors2;
  15846. private _vectors3;
  15847. private _vectors4;
  15848. private _matrices;
  15849. private _matrixArrays;
  15850. private _matrices3x3;
  15851. private _matrices2x2;
  15852. private _vectors2Arrays;
  15853. private _vectors3Arrays;
  15854. private _vectors4Arrays;
  15855. private _cachedWorldViewMatrix;
  15856. private _cachedWorldViewProjectionMatrix;
  15857. private _renderId;
  15858. private _multiview;
  15859. /**
  15860. * Instantiate a new shader material.
  15861. * 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.
  15862. * This returned material effects how the mesh will look based on the code in the shaders.
  15863. * @see http://doc.babylonjs.com/how_to/shader_material
  15864. * @param name Define the name of the material in the scene
  15865. * @param scene Define the scene the material belongs to
  15866. * @param shaderPath Defines the route to the shader code in one of three ways:
  15867. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15868. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15869. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15870. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15871. * @param options Define the options used to create the shader
  15872. */
  15873. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15874. /**
  15875. * Gets the shader path used to define the shader code
  15876. * It can be modified to trigger a new compilation
  15877. */
  15878. get shaderPath(): any;
  15879. /**
  15880. * Sets the shader path used to define the shader code
  15881. * It can be modified to trigger a new compilation
  15882. */
  15883. set shaderPath(shaderPath: any);
  15884. /**
  15885. * Gets the options used to compile the shader.
  15886. * They can be modified to trigger a new compilation
  15887. */
  15888. get options(): IShaderMaterialOptions;
  15889. /**
  15890. * Gets the current class name of the material e.g. "ShaderMaterial"
  15891. * Mainly use in serialization.
  15892. * @returns the class name
  15893. */
  15894. getClassName(): string;
  15895. /**
  15896. * Specifies if the material will require alpha blending
  15897. * @returns a boolean specifying if alpha blending is needed
  15898. */
  15899. needAlphaBlending(): boolean;
  15900. /**
  15901. * Specifies if this material should be rendered in alpha test mode
  15902. * @returns a boolean specifying if an alpha test is needed.
  15903. */
  15904. needAlphaTesting(): boolean;
  15905. private _checkUniform;
  15906. /**
  15907. * Set a texture in the shader.
  15908. * @param name Define the name of the uniform samplers as defined in the shader
  15909. * @param texture Define the texture to bind to this sampler
  15910. * @return the material itself allowing "fluent" like uniform updates
  15911. */
  15912. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15913. /**
  15914. * Set a texture array in the shader.
  15915. * @param name Define the name of the uniform sampler array as defined in the shader
  15916. * @param textures Define the list of textures to bind to this sampler
  15917. * @return the material itself allowing "fluent" like uniform updates
  15918. */
  15919. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15920. /**
  15921. * Set a float in the shader.
  15922. * @param name Define the name of the uniform as defined in the shader
  15923. * @param value Define the value to give to the uniform
  15924. * @return the material itself allowing "fluent" like uniform updates
  15925. */
  15926. setFloat(name: string, value: number): ShaderMaterial;
  15927. /**
  15928. * Set a int in the shader.
  15929. * @param name Define the name of the uniform as defined in the shader
  15930. * @param value Define the value to give to the uniform
  15931. * @return the material itself allowing "fluent" like uniform updates
  15932. */
  15933. setInt(name: string, value: number): ShaderMaterial;
  15934. /**
  15935. * Set an array of floats in the shader.
  15936. * @param name Define the name of the uniform as defined in the shader
  15937. * @param value Define the value to give to the uniform
  15938. * @return the material itself allowing "fluent" like uniform updates
  15939. */
  15940. setFloats(name: string, value: number[]): ShaderMaterial;
  15941. /**
  15942. * Set a vec3 in the shader from a Color3.
  15943. * @param name Define the name of the uniform as defined in the shader
  15944. * @param value Define the value to give to the uniform
  15945. * @return the material itself allowing "fluent" like uniform updates
  15946. */
  15947. setColor3(name: string, value: Color3): ShaderMaterial;
  15948. /**
  15949. * Set a vec3 array in the shader from a Color3 array.
  15950. * @param name Define the name of the uniform as defined in the shader
  15951. * @param value Define the value to give to the uniform
  15952. * @return the material itself allowing "fluent" like uniform updates
  15953. */
  15954. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15955. /**
  15956. * Set a vec4 in the shader from a Color4.
  15957. * @param name Define the name of the uniform as defined in the shader
  15958. * @param value Define the value to give to the uniform
  15959. * @return the material itself allowing "fluent" like uniform updates
  15960. */
  15961. setColor4(name: string, value: Color4): ShaderMaterial;
  15962. /**
  15963. * Set a vec4 array in the shader from a Color4 array.
  15964. * @param name Define the name of the uniform as defined in the shader
  15965. * @param value Define the value to give to the uniform
  15966. * @return the material itself allowing "fluent" like uniform updates
  15967. */
  15968. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15969. /**
  15970. * Set a vec2 in the shader from a Vector2.
  15971. * @param name Define the name of the uniform as defined in the shader
  15972. * @param value Define the value to give to the uniform
  15973. * @return the material itself allowing "fluent" like uniform updates
  15974. */
  15975. setVector2(name: string, value: Vector2): ShaderMaterial;
  15976. /**
  15977. * Set a vec3 in the shader from a Vector3.
  15978. * @param name Define the name of the uniform as defined in the shader
  15979. * @param value Define the value to give to the uniform
  15980. * @return the material itself allowing "fluent" like uniform updates
  15981. */
  15982. setVector3(name: string, value: Vector3): ShaderMaterial;
  15983. /**
  15984. * Set a vec4 in the shader from a Vector4.
  15985. * @param name Define the name of the uniform as defined in the shader
  15986. * @param value Define the value to give to the uniform
  15987. * @return the material itself allowing "fluent" like uniform updates
  15988. */
  15989. setVector4(name: string, value: Vector4): ShaderMaterial;
  15990. /**
  15991. * Set a mat4 in the shader from a Matrix.
  15992. * @param name Define the name of the uniform as defined in the shader
  15993. * @param value Define the value to give to the uniform
  15994. * @return the material itself allowing "fluent" like uniform updates
  15995. */
  15996. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15997. /**
  15998. * Set a float32Array in the shader from a matrix array.
  15999. * @param name Define the name of the uniform as defined in the shader
  16000. * @param value Define the value to give to the uniform
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16004. /**
  16005. * Set a mat3 in the shader from a Float32Array.
  16006. * @param name Define the name of the uniform as defined in the shader
  16007. * @param value Define the value to give to the uniform
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16011. /**
  16012. * Set a mat2 in the shader from a Float32Array.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16018. /**
  16019. * Set a vec2 array in the shader from a number array.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setArray2(name: string, value: number[]): ShaderMaterial;
  16025. /**
  16026. * Set a vec3 array in the shader from a number array.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setArray3(name: string, value: number[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec4 array in the shader from a number array.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setArray4(name: string, value: number[]): ShaderMaterial;
  16039. private _checkCache;
  16040. /**
  16041. * Specifies that the submesh is ready to be used
  16042. * @param mesh defines the mesh to check
  16043. * @param subMesh defines which submesh to check
  16044. * @param useInstances specifies that instances should be used
  16045. * @returns a boolean indicating that the submesh is ready or not
  16046. */
  16047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16048. /**
  16049. * Checks if the material is ready to render the requested mesh
  16050. * @param mesh Define the mesh to render
  16051. * @param useInstances Define whether or not the material is used with instances
  16052. * @returns true if ready, otherwise false
  16053. */
  16054. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16055. /**
  16056. * Binds the world matrix to the material
  16057. * @param world defines the world transformation matrix
  16058. */
  16059. bindOnlyWorldMatrix(world: Matrix): void;
  16060. /**
  16061. * Binds the material to the mesh
  16062. * @param world defines the world transformation matrix
  16063. * @param mesh defines the mesh to bind the material to
  16064. */
  16065. bind(world: Matrix, mesh?: Mesh): void;
  16066. /**
  16067. * Gets the active textures from the material
  16068. * @returns an array of textures
  16069. */
  16070. getActiveTextures(): BaseTexture[];
  16071. /**
  16072. * Specifies if the material uses a texture
  16073. * @param texture defines the texture to check against the material
  16074. * @returns a boolean specifying if the material uses the texture
  16075. */
  16076. hasTexture(texture: BaseTexture): boolean;
  16077. /**
  16078. * Makes a duplicate of the material, and gives it a new name
  16079. * @param name defines the new name for the duplicated material
  16080. * @returns the cloned material
  16081. */
  16082. clone(name: string): ShaderMaterial;
  16083. /**
  16084. * Disposes the material
  16085. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16086. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16087. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16088. */
  16089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16090. /**
  16091. * Serializes this material in a JSON representation
  16092. * @returns the serialized material object
  16093. */
  16094. serialize(): any;
  16095. /**
  16096. * Creates a shader material from parsed shader material data
  16097. * @param source defines the JSON represnetation of the material
  16098. * @param scene defines the hosting scene
  16099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16100. * @returns a new material
  16101. */
  16102. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16103. }
  16104. }
  16105. declare module "babylonjs/Shaders/color.fragment" {
  16106. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16107. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16108. /** @hidden */
  16109. export var colorPixelShader: {
  16110. name: string;
  16111. shader: string;
  16112. };
  16113. }
  16114. declare module "babylonjs/Shaders/color.vertex" {
  16115. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16117. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16118. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16119. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16121. /** @hidden */
  16122. export var colorVertexShader: {
  16123. name: string;
  16124. shader: string;
  16125. };
  16126. }
  16127. declare module "babylonjs/Meshes/linesMesh" {
  16128. import { Nullable } from "babylonjs/types";
  16129. import { Scene } from "babylonjs/scene";
  16130. import { Color3 } from "babylonjs/Maths/math.color";
  16131. import { Node } from "babylonjs/node";
  16132. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16133. import { Mesh } from "babylonjs/Meshes/mesh";
  16134. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16135. import { Effect } from "babylonjs/Materials/effect";
  16136. import { Material } from "babylonjs/Materials/material";
  16137. import "babylonjs/Shaders/color.fragment";
  16138. import "babylonjs/Shaders/color.vertex";
  16139. /**
  16140. * Line mesh
  16141. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16142. */
  16143. export class LinesMesh extends Mesh {
  16144. /**
  16145. * If vertex color should be applied to the mesh
  16146. */
  16147. readonly useVertexColor?: boolean | undefined;
  16148. /**
  16149. * If vertex alpha should be applied to the mesh
  16150. */
  16151. readonly useVertexAlpha?: boolean | undefined;
  16152. /**
  16153. * Color of the line (Default: White)
  16154. */
  16155. color: Color3;
  16156. /**
  16157. * Alpha of the line (Default: 1)
  16158. */
  16159. alpha: number;
  16160. /**
  16161. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16162. * This margin is expressed in world space coordinates, so its value may vary.
  16163. * Default value is 0.1
  16164. */
  16165. intersectionThreshold: number;
  16166. private _colorShader;
  16167. private color4;
  16168. /**
  16169. * Creates a new LinesMesh
  16170. * @param name defines the name
  16171. * @param scene defines the hosting scene
  16172. * @param parent defines the parent mesh if any
  16173. * @param source defines the optional source LinesMesh used to clone data from
  16174. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16175. * When false, achieved by calling a clone(), also passing False.
  16176. * This will make creation of children, recursive.
  16177. * @param useVertexColor defines if this LinesMesh supports vertex color
  16178. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16179. */
  16180. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16181. /**
  16182. * If vertex color should be applied to the mesh
  16183. */
  16184. useVertexColor?: boolean | undefined,
  16185. /**
  16186. * If vertex alpha should be applied to the mesh
  16187. */
  16188. useVertexAlpha?: boolean | undefined);
  16189. private _addClipPlaneDefine;
  16190. private _removeClipPlaneDefine;
  16191. isReady(): boolean;
  16192. /**
  16193. * Returns the string "LineMesh"
  16194. */
  16195. getClassName(): string;
  16196. /**
  16197. * @hidden
  16198. */
  16199. get material(): Material;
  16200. /**
  16201. * @hidden
  16202. */
  16203. set material(value: Material);
  16204. /**
  16205. * @hidden
  16206. */
  16207. get checkCollisions(): boolean;
  16208. /** @hidden */
  16209. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16210. /** @hidden */
  16211. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16212. /**
  16213. * Disposes of the line mesh
  16214. * @param doNotRecurse If children should be disposed
  16215. */
  16216. dispose(doNotRecurse?: boolean): void;
  16217. /**
  16218. * Returns a new LineMesh object cloned from the current one.
  16219. */
  16220. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16221. /**
  16222. * Creates a new InstancedLinesMesh object from the mesh model.
  16223. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16224. * @param name defines the name of the new instance
  16225. * @returns a new InstancedLinesMesh
  16226. */
  16227. createInstance(name: string): InstancedLinesMesh;
  16228. }
  16229. /**
  16230. * Creates an instance based on a source LinesMesh
  16231. */
  16232. export class InstancedLinesMesh extends InstancedMesh {
  16233. /**
  16234. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16235. * This margin is expressed in world space coordinates, so its value may vary.
  16236. * Initilized with the intersectionThreshold value of the source LinesMesh
  16237. */
  16238. intersectionThreshold: number;
  16239. constructor(name: string, source: LinesMesh);
  16240. /**
  16241. * Returns the string "InstancedLinesMesh".
  16242. */
  16243. getClassName(): string;
  16244. }
  16245. }
  16246. declare module "babylonjs/Shaders/line.fragment" {
  16247. /** @hidden */
  16248. export var linePixelShader: {
  16249. name: string;
  16250. shader: string;
  16251. };
  16252. }
  16253. declare module "babylonjs/Shaders/line.vertex" {
  16254. /** @hidden */
  16255. export var lineVertexShader: {
  16256. name: string;
  16257. shader: string;
  16258. };
  16259. }
  16260. declare module "babylonjs/Rendering/edgesRenderer" {
  16261. import { Nullable } from "babylonjs/types";
  16262. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16264. import { Vector3 } from "babylonjs/Maths/math.vector";
  16265. import { IDisposable } from "babylonjs/scene";
  16266. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16267. import "babylonjs/Shaders/line.fragment";
  16268. import "babylonjs/Shaders/line.vertex";
  16269. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16270. module "babylonjs/Meshes/abstractMesh" {
  16271. interface AbstractMesh {
  16272. /**
  16273. * Gets the edgesRenderer associated with the mesh
  16274. */
  16275. edgesRenderer: Nullable<EdgesRenderer>;
  16276. }
  16277. }
  16278. module "babylonjs/Meshes/linesMesh" {
  16279. interface LinesMesh {
  16280. /**
  16281. * Enables the edge rendering mode on the mesh.
  16282. * This mode makes the mesh edges visible
  16283. * @param epsilon defines the maximal distance between two angles to detect a face
  16284. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16285. * @returns the currentAbstractMesh
  16286. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16287. */
  16288. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16289. }
  16290. }
  16291. module "babylonjs/Meshes/linesMesh" {
  16292. interface InstancedLinesMesh {
  16293. /**
  16294. * Enables the edge rendering mode on the mesh.
  16295. * This mode makes the mesh edges visible
  16296. * @param epsilon defines the maximal distance between two angles to detect a face
  16297. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16298. * @returns the current InstancedLinesMesh
  16299. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16300. */
  16301. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16302. }
  16303. }
  16304. /**
  16305. * Defines the minimum contract an Edges renderer should follow.
  16306. */
  16307. export interface IEdgesRenderer extends IDisposable {
  16308. /**
  16309. * Gets or sets a boolean indicating if the edgesRenderer is active
  16310. */
  16311. isEnabled: boolean;
  16312. /**
  16313. * Renders the edges of the attached mesh,
  16314. */
  16315. render(): void;
  16316. /**
  16317. * Checks wether or not the edges renderer is ready to render.
  16318. * @return true if ready, otherwise false.
  16319. */
  16320. isReady(): boolean;
  16321. }
  16322. /**
  16323. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16324. */
  16325. export class EdgesRenderer implements IEdgesRenderer {
  16326. /**
  16327. * Define the size of the edges with an orthographic camera
  16328. */
  16329. edgesWidthScalerForOrthographic: number;
  16330. /**
  16331. * Define the size of the edges with a perspective camera
  16332. */
  16333. edgesWidthScalerForPerspective: number;
  16334. protected _source: AbstractMesh;
  16335. protected _linesPositions: number[];
  16336. protected _linesNormals: number[];
  16337. protected _linesIndices: number[];
  16338. protected _epsilon: number;
  16339. protected _indicesCount: number;
  16340. protected _lineShader: ShaderMaterial;
  16341. protected _ib: DataBuffer;
  16342. protected _buffers: {
  16343. [key: string]: Nullable<VertexBuffer>;
  16344. };
  16345. protected _checkVerticesInsteadOfIndices: boolean;
  16346. private _meshRebuildObserver;
  16347. private _meshDisposeObserver;
  16348. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16349. isEnabled: boolean;
  16350. /**
  16351. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16352. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16353. * @param source Mesh used to create edges
  16354. * @param epsilon sum of angles in adjacency to check for edge
  16355. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16356. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16357. */
  16358. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16359. protected _prepareRessources(): void;
  16360. /** @hidden */
  16361. _rebuild(): void;
  16362. /**
  16363. * Releases the required resources for the edges renderer
  16364. */
  16365. dispose(): void;
  16366. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16367. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16368. /**
  16369. * Checks if the pair of p0 and p1 is en edge
  16370. * @param faceIndex
  16371. * @param edge
  16372. * @param faceNormals
  16373. * @param p0
  16374. * @param p1
  16375. * @private
  16376. */
  16377. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16378. /**
  16379. * push line into the position, normal and index buffer
  16380. * @protected
  16381. */
  16382. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16383. /**
  16384. * Generates lines edges from adjacencjes
  16385. * @private
  16386. */
  16387. _generateEdgesLines(): void;
  16388. /**
  16389. * Checks wether or not the edges renderer is ready to render.
  16390. * @return true if ready, otherwise false.
  16391. */
  16392. isReady(): boolean;
  16393. /**
  16394. * Renders the edges of the attached mesh,
  16395. */
  16396. render(): void;
  16397. }
  16398. /**
  16399. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16400. */
  16401. export class LineEdgesRenderer extends EdgesRenderer {
  16402. /**
  16403. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16404. * @param source LineMesh used to generate edges
  16405. * @param epsilon not important (specified angle for edge detection)
  16406. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16407. */
  16408. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16409. /**
  16410. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16411. */
  16412. _generateEdgesLines(): void;
  16413. }
  16414. }
  16415. declare module "babylonjs/Rendering/renderingGroup" {
  16416. import { SmartArray } from "babylonjs/Misc/smartArray";
  16417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16419. import { Nullable } from "babylonjs/types";
  16420. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16421. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16422. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16423. import { Material } from "babylonjs/Materials/material";
  16424. import { Scene } from "babylonjs/scene";
  16425. /**
  16426. * This represents the object necessary to create a rendering group.
  16427. * This is exclusively used and created by the rendering manager.
  16428. * To modify the behavior, you use the available helpers in your scene or meshes.
  16429. * @hidden
  16430. */
  16431. export class RenderingGroup {
  16432. index: number;
  16433. private static _zeroVector;
  16434. private _scene;
  16435. private _opaqueSubMeshes;
  16436. private _transparentSubMeshes;
  16437. private _alphaTestSubMeshes;
  16438. private _depthOnlySubMeshes;
  16439. private _particleSystems;
  16440. private _spriteManagers;
  16441. private _opaqueSortCompareFn;
  16442. private _alphaTestSortCompareFn;
  16443. private _transparentSortCompareFn;
  16444. private _renderOpaque;
  16445. private _renderAlphaTest;
  16446. private _renderTransparent;
  16447. /** @hidden */
  16448. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16449. onBeforeTransparentRendering: () => void;
  16450. /**
  16451. * Set the opaque sort comparison function.
  16452. * If null the sub meshes will be render in the order they were created
  16453. */
  16454. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16455. /**
  16456. * Set the alpha test sort comparison function.
  16457. * If null the sub meshes will be render in the order they were created
  16458. */
  16459. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16460. /**
  16461. * Set the transparent sort comparison function.
  16462. * If null the sub meshes will be render in the order they were created
  16463. */
  16464. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16465. /**
  16466. * Creates a new rendering group.
  16467. * @param index The rendering group index
  16468. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16469. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16470. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16471. */
  16472. 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>);
  16473. /**
  16474. * Render all the sub meshes contained in the group.
  16475. * @param customRenderFunction Used to override the default render behaviour of the group.
  16476. * @returns true if rendered some submeshes.
  16477. */
  16478. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16479. /**
  16480. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16481. * @param subMeshes The submeshes to render
  16482. */
  16483. private renderOpaqueSorted;
  16484. /**
  16485. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16486. * @param subMeshes The submeshes to render
  16487. */
  16488. private renderAlphaTestSorted;
  16489. /**
  16490. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16491. * @param subMeshes The submeshes to render
  16492. */
  16493. private renderTransparentSorted;
  16494. /**
  16495. * Renders the submeshes in a specified order.
  16496. * @param subMeshes The submeshes to sort before render
  16497. * @param sortCompareFn The comparison function use to sort
  16498. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16499. * @param transparent Specifies to activate blending if true
  16500. */
  16501. private static renderSorted;
  16502. /**
  16503. * Renders the submeshes in the order they were dispatched (no sort applied).
  16504. * @param subMeshes The submeshes to render
  16505. */
  16506. private static renderUnsorted;
  16507. /**
  16508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16509. * are rendered back to front if in the same alpha index.
  16510. *
  16511. * @param a The first submesh
  16512. * @param b The second submesh
  16513. * @returns The result of the comparison
  16514. */
  16515. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16516. /**
  16517. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16518. * are rendered back to front.
  16519. *
  16520. * @param a The first submesh
  16521. * @param b The second submesh
  16522. * @returns The result of the comparison
  16523. */
  16524. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16525. /**
  16526. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16527. * are rendered front to back (prevent overdraw).
  16528. *
  16529. * @param a The first submesh
  16530. * @param b The second submesh
  16531. * @returns The result of the comparison
  16532. */
  16533. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16534. /**
  16535. * Resets the different lists of submeshes to prepare a new frame.
  16536. */
  16537. prepare(): void;
  16538. dispose(): void;
  16539. /**
  16540. * Inserts the submesh in its correct queue depending on its material.
  16541. * @param subMesh The submesh to dispatch
  16542. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16543. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16544. */
  16545. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16546. dispatchSprites(spriteManager: ISpriteManager): void;
  16547. dispatchParticles(particleSystem: IParticleSystem): void;
  16548. private _renderParticles;
  16549. private _renderSprites;
  16550. }
  16551. }
  16552. declare module "babylonjs/Rendering/renderingManager" {
  16553. import { Nullable } from "babylonjs/types";
  16554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16555. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16556. import { SmartArray } from "babylonjs/Misc/smartArray";
  16557. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16558. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16559. import { Material } from "babylonjs/Materials/material";
  16560. import { Scene } from "babylonjs/scene";
  16561. import { Camera } from "babylonjs/Cameras/camera";
  16562. /**
  16563. * Interface describing the different options available in the rendering manager
  16564. * regarding Auto Clear between groups.
  16565. */
  16566. export interface IRenderingManagerAutoClearSetup {
  16567. /**
  16568. * Defines whether or not autoclear is enable.
  16569. */
  16570. autoClear: boolean;
  16571. /**
  16572. * Defines whether or not to autoclear the depth buffer.
  16573. */
  16574. depth: boolean;
  16575. /**
  16576. * Defines whether or not to autoclear the stencil buffer.
  16577. */
  16578. stencil: boolean;
  16579. }
  16580. /**
  16581. * This class is used by the onRenderingGroupObservable
  16582. */
  16583. export class RenderingGroupInfo {
  16584. /**
  16585. * The Scene that being rendered
  16586. */
  16587. scene: Scene;
  16588. /**
  16589. * The camera currently used for the rendering pass
  16590. */
  16591. camera: Nullable<Camera>;
  16592. /**
  16593. * The ID of the renderingGroup being processed
  16594. */
  16595. renderingGroupId: number;
  16596. }
  16597. /**
  16598. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16599. * It is enable to manage the different groups as well as the different necessary sort functions.
  16600. * This should not be used directly aside of the few static configurations
  16601. */
  16602. export class RenderingManager {
  16603. /**
  16604. * The max id used for rendering groups (not included)
  16605. */
  16606. static MAX_RENDERINGGROUPS: number;
  16607. /**
  16608. * The min id used for rendering groups (included)
  16609. */
  16610. static MIN_RENDERINGGROUPS: number;
  16611. /**
  16612. * Used to globally prevent autoclearing scenes.
  16613. */
  16614. static AUTOCLEAR: boolean;
  16615. /**
  16616. * @hidden
  16617. */
  16618. _useSceneAutoClearSetup: boolean;
  16619. private _scene;
  16620. private _renderingGroups;
  16621. private _depthStencilBufferAlreadyCleaned;
  16622. private _autoClearDepthStencil;
  16623. private _customOpaqueSortCompareFn;
  16624. private _customAlphaTestSortCompareFn;
  16625. private _customTransparentSortCompareFn;
  16626. private _renderingGroupInfo;
  16627. /**
  16628. * Instantiates a new rendering group for a particular scene
  16629. * @param scene Defines the scene the groups belongs to
  16630. */
  16631. constructor(scene: Scene);
  16632. private _clearDepthStencilBuffer;
  16633. /**
  16634. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16635. * @hidden
  16636. */
  16637. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16638. /**
  16639. * Resets the different information of the group to prepare a new frame
  16640. * @hidden
  16641. */
  16642. reset(): void;
  16643. /**
  16644. * Dispose and release the group and its associated resources.
  16645. * @hidden
  16646. */
  16647. dispose(): void;
  16648. /**
  16649. * Clear the info related to rendering groups preventing retention points during dispose.
  16650. */
  16651. freeRenderingGroups(): void;
  16652. private _prepareRenderingGroup;
  16653. /**
  16654. * Add a sprite manager to the rendering manager in order to render it this frame.
  16655. * @param spriteManager Define the sprite manager to render
  16656. */
  16657. dispatchSprites(spriteManager: ISpriteManager): void;
  16658. /**
  16659. * Add a particle system to the rendering manager in order to render it this frame.
  16660. * @param particleSystem Define the particle system to render
  16661. */
  16662. dispatchParticles(particleSystem: IParticleSystem): void;
  16663. /**
  16664. * Add a submesh to the manager in order to render it this frame
  16665. * @param subMesh The submesh to dispatch
  16666. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16667. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16668. */
  16669. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16670. /**
  16671. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16672. * This allowed control for front to back rendering or reversly depending of the special needs.
  16673. *
  16674. * @param renderingGroupId The rendering group id corresponding to its index
  16675. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16676. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16677. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16678. */
  16679. 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;
  16680. /**
  16681. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16682. *
  16683. * @param renderingGroupId The rendering group id corresponding to its index
  16684. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16685. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16686. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16687. */
  16688. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16689. /**
  16690. * Gets the current auto clear configuration for one rendering group of the rendering
  16691. * manager.
  16692. * @param index the rendering group index to get the information for
  16693. * @returns The auto clear setup for the requested rendering group
  16694. */
  16695. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16696. }
  16697. }
  16698. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16699. import { SmartArray } from "babylonjs/Misc/smartArray";
  16700. import { Nullable } from "babylonjs/types";
  16701. import { Scene } from "babylonjs/scene";
  16702. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16705. import { Mesh } from "babylonjs/Meshes/mesh";
  16706. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16707. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16708. import { Effect } from "babylonjs/Materials/effect";
  16709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16711. import "babylonjs/Shaders/shadowMap.fragment";
  16712. import "babylonjs/Shaders/shadowMap.vertex";
  16713. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16714. import { Observable } from "babylonjs/Misc/observable";
  16715. /**
  16716. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16717. */
  16718. export interface ICustomShaderOptions {
  16719. /**
  16720. * Gets or sets the custom shader name to use
  16721. */
  16722. shaderName: string;
  16723. /**
  16724. * The list of attribute names used in the shader
  16725. */
  16726. attributes?: string[];
  16727. /**
  16728. * The list of unifrom names used in the shader
  16729. */
  16730. uniforms?: string[];
  16731. /**
  16732. * The list of sampler names used in the shader
  16733. */
  16734. samplers?: string[];
  16735. /**
  16736. * The list of defines used in the shader
  16737. */
  16738. defines?: string[];
  16739. }
  16740. /**
  16741. * Interface to implement to create a shadow generator compatible with BJS.
  16742. */
  16743. export interface IShadowGenerator {
  16744. /**
  16745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16746. * @returns The render target texture if present otherwise, null
  16747. */
  16748. getShadowMap(): Nullable<RenderTargetTexture>;
  16749. /**
  16750. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16751. * @param subMesh The submesh we want to render in the shadow map
  16752. * @param useInstances Defines wether will draw in the map using instances
  16753. * @returns true if ready otherwise, false
  16754. */
  16755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16756. /**
  16757. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16758. * @param defines Defines of the material we want to update
  16759. * @param lightIndex Index of the light in the enabled light list of the material
  16760. */
  16761. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16762. /**
  16763. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16764. * defined in the generator but impacting the effect).
  16765. * It implies the unifroms available on the materials are the standard BJS ones.
  16766. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16767. * @param effect The effect we are binfing the information for
  16768. */
  16769. bindShadowLight(lightIndex: string, effect: Effect): void;
  16770. /**
  16771. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16772. * (eq to shadow prjection matrix * light transform matrix)
  16773. * @returns The transform matrix used to create the shadow map
  16774. */
  16775. getTransformMatrix(): Matrix;
  16776. /**
  16777. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16778. * Cube and 2D textures for instance.
  16779. */
  16780. recreateShadowMap(): void;
  16781. /**
  16782. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16783. * @param onCompiled Callback triggered at the and of the effects compilation
  16784. * @param options Sets of optional options forcing the compilation with different modes
  16785. */
  16786. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16787. useInstances: boolean;
  16788. }>): void;
  16789. /**
  16790. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16791. * @param options Sets of optional options forcing the compilation with different modes
  16792. * @returns A promise that resolves when the compilation completes
  16793. */
  16794. forceCompilationAsync(options?: Partial<{
  16795. useInstances: boolean;
  16796. }>): Promise<void>;
  16797. /**
  16798. * Serializes the shadow generator setup to a json object.
  16799. * @returns The serialized JSON object
  16800. */
  16801. serialize(): any;
  16802. /**
  16803. * Disposes the Shadow map and related Textures and effects.
  16804. */
  16805. dispose(): void;
  16806. }
  16807. /**
  16808. * Default implementation IShadowGenerator.
  16809. * This is the main object responsible of generating shadows in the framework.
  16810. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16811. */
  16812. export class ShadowGenerator implements IShadowGenerator {
  16813. /**
  16814. * Name of the shadow generator class
  16815. */
  16816. static CLASSNAME: string;
  16817. /**
  16818. * Shadow generator mode None: no filtering applied.
  16819. */
  16820. static readonly FILTER_NONE: number;
  16821. /**
  16822. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16824. */
  16825. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16826. /**
  16827. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16828. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16829. */
  16830. static readonly FILTER_POISSONSAMPLING: number;
  16831. /**
  16832. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16833. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16834. */
  16835. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16836. /**
  16837. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16838. * edge artifacts on steep falloff.
  16839. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16840. */
  16841. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16842. /**
  16843. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16844. * edge artifacts on steep falloff.
  16845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16846. */
  16847. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16848. /**
  16849. * Shadow generator mode PCF: Percentage Closer Filtering
  16850. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16851. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16852. */
  16853. static readonly FILTER_PCF: number;
  16854. /**
  16855. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16856. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16857. * Contact Hardening
  16858. */
  16859. static readonly FILTER_PCSS: number;
  16860. /**
  16861. * Reserved for PCF and PCSS
  16862. * Highest Quality.
  16863. *
  16864. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16865. *
  16866. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16867. */
  16868. static readonly QUALITY_HIGH: number;
  16869. /**
  16870. * Reserved for PCF and PCSS
  16871. * Good tradeoff for quality/perf cross devices
  16872. *
  16873. * Execute PCF on a 3*3 kernel.
  16874. *
  16875. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16876. */
  16877. static readonly QUALITY_MEDIUM: number;
  16878. /**
  16879. * Reserved for PCF and PCSS
  16880. * The lowest quality but the fastest.
  16881. *
  16882. * Execute PCF on a 1*1 kernel.
  16883. *
  16884. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16885. */
  16886. static readonly QUALITY_LOW: number;
  16887. /** Gets or sets the custom shader name to use */
  16888. customShaderOptions: ICustomShaderOptions;
  16889. /**
  16890. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16891. */
  16892. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16893. /**
  16894. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16895. */
  16896. onAfterShadowMapRenderObservable: Observable<Effect>;
  16897. /**
  16898. * Observable triggered before a mesh is rendered in the shadow map.
  16899. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16900. */
  16901. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16902. /**
  16903. * Observable triggered after a mesh is rendered in the shadow map.
  16904. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16905. */
  16906. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16907. protected _bias: number;
  16908. /**
  16909. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16910. */
  16911. get bias(): number;
  16912. /**
  16913. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16914. */
  16915. set bias(bias: number);
  16916. protected _normalBias: number;
  16917. /**
  16918. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16919. */
  16920. get normalBias(): number;
  16921. /**
  16922. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16923. */
  16924. set normalBias(normalBias: number);
  16925. protected _blurBoxOffset: number;
  16926. /**
  16927. * Gets the blur box offset: offset applied during the blur pass.
  16928. * Only useful if useKernelBlur = false
  16929. */
  16930. get blurBoxOffset(): number;
  16931. /**
  16932. * Sets the blur box offset: offset applied during the blur pass.
  16933. * Only useful if useKernelBlur = false
  16934. */
  16935. set blurBoxOffset(value: number);
  16936. protected _blurScale: number;
  16937. /**
  16938. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16939. * 2 means half of the size.
  16940. */
  16941. get blurScale(): number;
  16942. /**
  16943. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16944. * 2 means half of the size.
  16945. */
  16946. set blurScale(value: number);
  16947. protected _blurKernel: number;
  16948. /**
  16949. * Gets the blur kernel: kernel size of the blur pass.
  16950. * Only useful if useKernelBlur = true
  16951. */
  16952. get blurKernel(): number;
  16953. /**
  16954. * Sets the blur kernel: kernel size of the blur pass.
  16955. * Only useful if useKernelBlur = true
  16956. */
  16957. set blurKernel(value: number);
  16958. protected _useKernelBlur: boolean;
  16959. /**
  16960. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16961. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16962. */
  16963. get useKernelBlur(): boolean;
  16964. /**
  16965. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16966. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16967. */
  16968. set useKernelBlur(value: boolean);
  16969. protected _depthScale: number;
  16970. /**
  16971. * Gets the depth scale used in ESM mode.
  16972. */
  16973. get depthScale(): number;
  16974. /**
  16975. * Sets the depth scale used in ESM mode.
  16976. * This can override the scale stored on the light.
  16977. */
  16978. set depthScale(value: number);
  16979. protected _validateFilter(filter: number): number;
  16980. protected _filter: number;
  16981. /**
  16982. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16983. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16984. */
  16985. get filter(): number;
  16986. /**
  16987. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16988. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16989. */
  16990. set filter(value: number);
  16991. /**
  16992. * Gets if the current filter is set to Poisson Sampling.
  16993. */
  16994. get usePoissonSampling(): boolean;
  16995. /**
  16996. * Sets the current filter to Poisson Sampling.
  16997. */
  16998. set usePoissonSampling(value: boolean);
  16999. /**
  17000. * Gets if the current filter is set to ESM.
  17001. */
  17002. get useExponentialShadowMap(): boolean;
  17003. /**
  17004. * Sets the current filter is to ESM.
  17005. */
  17006. set useExponentialShadowMap(value: boolean);
  17007. /**
  17008. * Gets if the current filter is set to filtered ESM.
  17009. */
  17010. get useBlurExponentialShadowMap(): boolean;
  17011. /**
  17012. * Gets if the current filter is set to filtered ESM.
  17013. */
  17014. set useBlurExponentialShadowMap(value: boolean);
  17015. /**
  17016. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17017. * exponential to prevent steep falloff artifacts).
  17018. */
  17019. get useCloseExponentialShadowMap(): boolean;
  17020. /**
  17021. * Sets the current filter to "close ESM" (using the inverse of the
  17022. * exponential to prevent steep falloff artifacts).
  17023. */
  17024. set useCloseExponentialShadowMap(value: boolean);
  17025. /**
  17026. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17027. * exponential to prevent steep falloff artifacts).
  17028. */
  17029. get useBlurCloseExponentialShadowMap(): boolean;
  17030. /**
  17031. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17032. * exponential to prevent steep falloff artifacts).
  17033. */
  17034. set useBlurCloseExponentialShadowMap(value: boolean);
  17035. /**
  17036. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17037. */
  17038. get usePercentageCloserFiltering(): boolean;
  17039. /**
  17040. * Sets the current filter to "PCF" (percentage closer filtering).
  17041. */
  17042. set usePercentageCloserFiltering(value: boolean);
  17043. protected _filteringQuality: number;
  17044. /**
  17045. * Gets the PCF or PCSS Quality.
  17046. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17047. */
  17048. get filteringQuality(): number;
  17049. /**
  17050. * Sets the PCF or PCSS Quality.
  17051. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17052. */
  17053. set filteringQuality(filteringQuality: number);
  17054. /**
  17055. * Gets if the current filter is set to "PCSS" (contact hardening).
  17056. */
  17057. get useContactHardeningShadow(): boolean;
  17058. /**
  17059. * Sets the current filter to "PCSS" (contact hardening).
  17060. */
  17061. set useContactHardeningShadow(value: boolean);
  17062. protected _contactHardeningLightSizeUVRatio: number;
  17063. /**
  17064. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17065. * Using a ratio helps keeping shape stability independently of the map size.
  17066. *
  17067. * It does not account for the light projection as it was having too much
  17068. * instability during the light setup or during light position changes.
  17069. *
  17070. * Only valid if useContactHardeningShadow is true.
  17071. */
  17072. get contactHardeningLightSizeUVRatio(): number;
  17073. /**
  17074. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17075. * Using a ratio helps keeping shape stability independently of the map size.
  17076. *
  17077. * It does not account for the light projection as it was having too much
  17078. * instability during the light setup or during light position changes.
  17079. *
  17080. * Only valid if useContactHardeningShadow is true.
  17081. */
  17082. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17083. protected _darkness: number;
  17084. /** Gets or sets the actual darkness of a shadow */
  17085. get darkness(): number;
  17086. set darkness(value: number);
  17087. /**
  17088. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17089. * 0 means strongest and 1 would means no shadow.
  17090. * @returns the darkness.
  17091. */
  17092. getDarkness(): number;
  17093. /**
  17094. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17095. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17096. * @returns the shadow generator allowing fluent coding.
  17097. */
  17098. setDarkness(darkness: number): ShadowGenerator;
  17099. protected _transparencyShadow: boolean;
  17100. /** Gets or sets the ability to have transparent shadow */
  17101. get transparencyShadow(): boolean;
  17102. set transparencyShadow(value: boolean);
  17103. /**
  17104. * Sets the ability to have transparent shadow (boolean).
  17105. * @param transparent True if transparent else False
  17106. * @returns the shadow generator allowing fluent coding
  17107. */
  17108. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17109. protected _shadowMap: Nullable<RenderTargetTexture>;
  17110. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17111. /**
  17112. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17113. * @returns The render target texture if present otherwise, null
  17114. */
  17115. getShadowMap(): Nullable<RenderTargetTexture>;
  17116. /**
  17117. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17118. * @returns The render target texture if the shadow map is present otherwise, null
  17119. */
  17120. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17121. /**
  17122. * Gets the class name of that object
  17123. * @returns "ShadowGenerator"
  17124. */
  17125. getClassName(): string;
  17126. /**
  17127. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17128. * @param mesh Mesh to add
  17129. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17130. * @returns the Shadow Generator itself
  17131. */
  17132. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17133. /**
  17134. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17135. * @param mesh Mesh to remove
  17136. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17137. * @returns the Shadow Generator itself
  17138. */
  17139. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17140. /**
  17141. * Controls the extent to which the shadows fade out at the edge of the frustum
  17142. */
  17143. frustumEdgeFalloff: number;
  17144. protected _light: IShadowLight;
  17145. /**
  17146. * Returns the associated light object.
  17147. * @returns the light generating the shadow
  17148. */
  17149. getLight(): IShadowLight;
  17150. /**
  17151. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17152. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17153. * It might on the other hand introduce peter panning.
  17154. */
  17155. forceBackFacesOnly: boolean;
  17156. protected _scene: Scene;
  17157. protected _lightDirection: Vector3;
  17158. protected _effect: Effect;
  17159. protected _viewMatrix: Matrix;
  17160. protected _projectionMatrix: Matrix;
  17161. protected _transformMatrix: Matrix;
  17162. protected _cachedPosition: Vector3;
  17163. protected _cachedDirection: Vector3;
  17164. protected _cachedDefines: string;
  17165. protected _currentRenderID: number;
  17166. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17167. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17168. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17169. protected _blurPostProcesses: PostProcess[];
  17170. protected _mapSize: number;
  17171. protected _currentFaceIndex: number;
  17172. protected _currentFaceIndexCache: number;
  17173. protected _textureType: number;
  17174. protected _defaultTextureMatrix: Matrix;
  17175. protected _storedUniqueId: Nullable<number>;
  17176. /** @hidden */
  17177. static _SceneComponentInitialization: (scene: Scene) => void;
  17178. /**
  17179. * Creates a ShadowGenerator object.
  17180. * A ShadowGenerator is the required tool to use the shadows.
  17181. * Each light casting shadows needs to use its own ShadowGenerator.
  17182. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17183. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17184. * @param light The light object generating the shadows.
  17185. * @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.
  17186. */
  17187. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17188. protected _initializeGenerator(): void;
  17189. protected _createTargetRenderTexture(): void;
  17190. protected _initializeShadowMap(): void;
  17191. protected _initializeBlurRTTAndPostProcesses(): void;
  17192. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17193. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17194. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17195. protected _applyFilterValues(): void;
  17196. /**
  17197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17198. * @param onCompiled Callback triggered at the and of the effects compilation
  17199. * @param options Sets of optional options forcing the compilation with different modes
  17200. */
  17201. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17202. useInstances: boolean;
  17203. }>): void;
  17204. /**
  17205. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17206. * @param options Sets of optional options forcing the compilation with different modes
  17207. * @returns A promise that resolves when the compilation completes
  17208. */
  17209. forceCompilationAsync(options?: Partial<{
  17210. useInstances: boolean;
  17211. }>): Promise<void>;
  17212. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17213. /**
  17214. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17215. * @param subMesh The submesh we want to render in the shadow map
  17216. * @param useInstances Defines wether will draw in the map using instances
  17217. * @returns true if ready otherwise, false
  17218. */
  17219. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17220. /**
  17221. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17222. * @param defines Defines of the material we want to update
  17223. * @param lightIndex Index of the light in the enabled light list of the material
  17224. */
  17225. prepareDefines(defines: any, lightIndex: number): void;
  17226. /**
  17227. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17228. * defined in the generator but impacting the effect).
  17229. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17230. * @param effect The effect we are binfing the information for
  17231. */
  17232. bindShadowLight(lightIndex: string, effect: Effect): void;
  17233. /**
  17234. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17235. * (eq to shadow prjection matrix * light transform matrix)
  17236. * @returns The transform matrix used to create the shadow map
  17237. */
  17238. getTransformMatrix(): Matrix;
  17239. /**
  17240. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17241. * Cube and 2D textures for instance.
  17242. */
  17243. recreateShadowMap(): void;
  17244. protected _disposeBlurPostProcesses(): void;
  17245. protected _disposeRTTandPostProcesses(): void;
  17246. /**
  17247. * Disposes the ShadowGenerator.
  17248. * Returns nothing.
  17249. */
  17250. dispose(): void;
  17251. /**
  17252. * Serializes the shadow generator setup to a json object.
  17253. * @returns The serialized JSON object
  17254. */
  17255. serialize(): any;
  17256. /**
  17257. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17258. * @param parsedShadowGenerator The JSON object to parse
  17259. * @param scene The scene to create the shadow map for
  17260. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17261. * @returns The parsed shadow generator
  17262. */
  17263. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17264. }
  17265. }
  17266. declare module "babylonjs/Lights/light" {
  17267. import { Nullable } from "babylonjs/types";
  17268. import { Scene } from "babylonjs/scene";
  17269. import { Vector3 } from "babylonjs/Maths/math.vector";
  17270. import { Color3 } from "babylonjs/Maths/math.color";
  17271. import { Node } from "babylonjs/node";
  17272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17273. import { Effect } from "babylonjs/Materials/effect";
  17274. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17275. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17276. /**
  17277. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17278. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17279. * 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.
  17280. */
  17281. export abstract class Light extends Node {
  17282. /**
  17283. * Falloff Default: light is falling off following the material specification:
  17284. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17285. */
  17286. static readonly FALLOFF_DEFAULT: number;
  17287. /**
  17288. * Falloff Physical: light is falling off following the inverse squared distance law.
  17289. */
  17290. static readonly FALLOFF_PHYSICAL: number;
  17291. /**
  17292. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17293. * to enhance interoperability with other engines.
  17294. */
  17295. static readonly FALLOFF_GLTF: number;
  17296. /**
  17297. * Falloff Standard: light is falling off like in the standard material
  17298. * to enhance interoperability with other materials.
  17299. */
  17300. static readonly FALLOFF_STANDARD: number;
  17301. /**
  17302. * If every light affecting the material is in this lightmapMode,
  17303. * material.lightmapTexture adds or multiplies
  17304. * (depends on material.useLightmapAsShadowmap)
  17305. * after every other light calculations.
  17306. */
  17307. static readonly LIGHTMAP_DEFAULT: number;
  17308. /**
  17309. * material.lightmapTexture as only diffuse lighting from this light
  17310. * adds only specular lighting from this light
  17311. * adds dynamic shadows
  17312. */
  17313. static readonly LIGHTMAP_SPECULAR: number;
  17314. /**
  17315. * material.lightmapTexture as only lighting
  17316. * no light calculation from this light
  17317. * only adds dynamic shadows from this light
  17318. */
  17319. static readonly LIGHTMAP_SHADOWSONLY: number;
  17320. /**
  17321. * Each light type uses the default quantity according to its type:
  17322. * point/spot lights use luminous intensity
  17323. * directional lights use illuminance
  17324. */
  17325. static readonly INTENSITYMODE_AUTOMATIC: number;
  17326. /**
  17327. * lumen (lm)
  17328. */
  17329. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17330. /**
  17331. * candela (lm/sr)
  17332. */
  17333. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17334. /**
  17335. * lux (lm/m^2)
  17336. */
  17337. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17338. /**
  17339. * nit (cd/m^2)
  17340. */
  17341. static readonly INTENSITYMODE_LUMINANCE: number;
  17342. /**
  17343. * Light type const id of the point light.
  17344. */
  17345. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17346. /**
  17347. * Light type const id of the directional light.
  17348. */
  17349. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17350. /**
  17351. * Light type const id of the spot light.
  17352. */
  17353. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17354. /**
  17355. * Light type const id of the hemispheric light.
  17356. */
  17357. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17358. /**
  17359. * Diffuse gives the basic color to an object.
  17360. */
  17361. diffuse: Color3;
  17362. /**
  17363. * Specular produces a highlight color on an object.
  17364. * Note: This is note affecting PBR materials.
  17365. */
  17366. specular: Color3;
  17367. /**
  17368. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17369. * falling off base on range or angle.
  17370. * This can be set to any values in Light.FALLOFF_x.
  17371. *
  17372. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17373. * other types of materials.
  17374. */
  17375. falloffType: number;
  17376. /**
  17377. * Strength of the light.
  17378. * Note: By default it is define in the framework own unit.
  17379. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17380. */
  17381. intensity: number;
  17382. private _range;
  17383. protected _inverseSquaredRange: number;
  17384. /**
  17385. * Defines how far from the source the light is impacting in scene units.
  17386. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17387. */
  17388. get range(): number;
  17389. /**
  17390. * Defines how far from the source the light is impacting in scene units.
  17391. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17392. */
  17393. set range(value: number);
  17394. /**
  17395. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17396. * of light.
  17397. */
  17398. private _photometricScale;
  17399. private _intensityMode;
  17400. /**
  17401. * Gets the photometric scale used to interpret the intensity.
  17402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17403. */
  17404. get intensityMode(): number;
  17405. /**
  17406. * Sets the photometric scale used to interpret the intensity.
  17407. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17408. */
  17409. set intensityMode(value: number);
  17410. private _radius;
  17411. /**
  17412. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17413. */
  17414. get radius(): number;
  17415. /**
  17416. * sets the light radius used by PBR Materials to simulate soft area lights.
  17417. */
  17418. set radius(value: number);
  17419. private _renderPriority;
  17420. /**
  17421. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17422. * exceeding the number allowed of the materials.
  17423. */
  17424. renderPriority: number;
  17425. private _shadowEnabled;
  17426. /**
  17427. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17428. * the current shadow generator.
  17429. */
  17430. get shadowEnabled(): boolean;
  17431. /**
  17432. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17433. * the current shadow generator.
  17434. */
  17435. set shadowEnabled(value: boolean);
  17436. private _includedOnlyMeshes;
  17437. /**
  17438. * Gets the only meshes impacted by this light.
  17439. */
  17440. get includedOnlyMeshes(): AbstractMesh[];
  17441. /**
  17442. * Sets the only meshes impacted by this light.
  17443. */
  17444. set includedOnlyMeshes(value: AbstractMesh[]);
  17445. private _excludedMeshes;
  17446. /**
  17447. * Gets the meshes not impacted by this light.
  17448. */
  17449. get excludedMeshes(): AbstractMesh[];
  17450. /**
  17451. * Sets the meshes not impacted by this light.
  17452. */
  17453. set excludedMeshes(value: AbstractMesh[]);
  17454. private _excludeWithLayerMask;
  17455. /**
  17456. * Gets the layer id use to find what meshes are not impacted by the light.
  17457. * Inactive if 0
  17458. */
  17459. get excludeWithLayerMask(): number;
  17460. /**
  17461. * Sets the layer id use to find what meshes are not impacted by the light.
  17462. * Inactive if 0
  17463. */
  17464. set excludeWithLayerMask(value: number);
  17465. private _includeOnlyWithLayerMask;
  17466. /**
  17467. * Gets the layer id use to find what meshes are impacted by the light.
  17468. * Inactive if 0
  17469. */
  17470. get includeOnlyWithLayerMask(): number;
  17471. /**
  17472. * Sets the layer id use to find what meshes are impacted by the light.
  17473. * Inactive if 0
  17474. */
  17475. set includeOnlyWithLayerMask(value: number);
  17476. private _lightmapMode;
  17477. /**
  17478. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17479. */
  17480. get lightmapMode(): number;
  17481. /**
  17482. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17483. */
  17484. set lightmapMode(value: number);
  17485. /**
  17486. * Shadow generator associted to the light.
  17487. * @hidden Internal use only.
  17488. */
  17489. _shadowGenerator: Nullable<IShadowGenerator>;
  17490. /**
  17491. * @hidden Internal use only.
  17492. */
  17493. _excludedMeshesIds: string[];
  17494. /**
  17495. * @hidden Internal use only.
  17496. */
  17497. _includedOnlyMeshesIds: string[];
  17498. /**
  17499. * The current light unifom buffer.
  17500. * @hidden Internal use only.
  17501. */
  17502. _uniformBuffer: UniformBuffer;
  17503. /** @hidden */
  17504. _renderId: number;
  17505. /**
  17506. * Creates a Light object in the scene.
  17507. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17508. * @param name The firendly name of the light
  17509. * @param scene The scene the light belongs too
  17510. */
  17511. constructor(name: string, scene: Scene);
  17512. protected abstract _buildUniformLayout(): void;
  17513. /**
  17514. * Sets the passed Effect "effect" with the Light information.
  17515. * @param effect The effect to update
  17516. * @param lightIndex The index of the light in the effect to update
  17517. * @returns The light
  17518. */
  17519. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17520. /**
  17521. * Sets the passed Effect "effect" with the Light textures.
  17522. * @param effect The effect to update
  17523. * @param lightIndex The index of the light in the effect to update
  17524. * @returns The light
  17525. */
  17526. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17527. /**
  17528. * Binds the lights information from the scene to the effect for the given mesh.
  17529. * @param lightIndex Light index
  17530. * @param scene The scene where the light belongs to
  17531. * @param effect The effect we are binding the data to
  17532. * @param useSpecular Defines if specular is supported
  17533. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17534. */
  17535. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17536. /**
  17537. * Sets the passed Effect "effect" with the Light information.
  17538. * @param effect The effect to update
  17539. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17540. * @returns The light
  17541. */
  17542. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17543. /**
  17544. * Returns the string "Light".
  17545. * @returns the class name
  17546. */
  17547. getClassName(): string;
  17548. /** @hidden */
  17549. readonly _isLight: boolean;
  17550. /**
  17551. * Converts the light information to a readable string for debug purpose.
  17552. * @param fullDetails Supports for multiple levels of logging within scene loading
  17553. * @returns the human readable light info
  17554. */
  17555. toString(fullDetails?: boolean): string;
  17556. /** @hidden */
  17557. protected _syncParentEnabledState(): void;
  17558. /**
  17559. * Set the enabled state of this node.
  17560. * @param value - the new enabled state
  17561. */
  17562. setEnabled(value: boolean): void;
  17563. /**
  17564. * Returns the Light associated shadow generator if any.
  17565. * @return the associated shadow generator.
  17566. */
  17567. getShadowGenerator(): Nullable<IShadowGenerator>;
  17568. /**
  17569. * Returns a Vector3, the absolute light position in the World.
  17570. * @returns the world space position of the light
  17571. */
  17572. getAbsolutePosition(): Vector3;
  17573. /**
  17574. * Specifies if the light will affect the passed mesh.
  17575. * @param mesh The mesh to test against the light
  17576. * @return true the mesh is affected otherwise, false.
  17577. */
  17578. canAffectMesh(mesh: AbstractMesh): boolean;
  17579. /**
  17580. * Sort function to order lights for rendering.
  17581. * @param a First Light object to compare to second.
  17582. * @param b Second Light object to compare first.
  17583. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17584. */
  17585. static CompareLightsPriority(a: Light, b: Light): number;
  17586. /**
  17587. * Releases resources associated with this node.
  17588. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17589. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17590. */
  17591. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17592. /**
  17593. * Returns the light type ID (integer).
  17594. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17595. */
  17596. getTypeID(): number;
  17597. /**
  17598. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17599. * @returns the scaled intensity in intensity mode unit
  17600. */
  17601. getScaledIntensity(): number;
  17602. /**
  17603. * Returns a new Light object, named "name", from the current one.
  17604. * @param name The name of the cloned light
  17605. * @returns the new created light
  17606. */
  17607. clone(name: string): Nullable<Light>;
  17608. /**
  17609. * Serializes the current light into a Serialization object.
  17610. * @returns the serialized object.
  17611. */
  17612. serialize(): any;
  17613. /**
  17614. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17615. * This new light is named "name" and added to the passed scene.
  17616. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17617. * @param name The friendly name of the light
  17618. * @param scene The scene the new light will belong to
  17619. * @returns the constructor function
  17620. */
  17621. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17622. /**
  17623. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17624. * @param parsedLight The JSON representation of the light
  17625. * @param scene The scene to create the parsed light in
  17626. * @returns the created light after parsing
  17627. */
  17628. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17629. private _hookArrayForExcluded;
  17630. private _hookArrayForIncludedOnly;
  17631. private _resyncMeshes;
  17632. /**
  17633. * Forces the meshes to update their light related information in their rendering used effects
  17634. * @hidden Internal Use Only
  17635. */
  17636. _markMeshesAsLightDirty(): void;
  17637. /**
  17638. * Recomputes the cached photometric scale if needed.
  17639. */
  17640. private _computePhotometricScale;
  17641. /**
  17642. * Returns the Photometric Scale according to the light type and intensity mode.
  17643. */
  17644. private _getPhotometricScale;
  17645. /**
  17646. * Reorder the light in the scene according to their defined priority.
  17647. * @hidden Internal Use Only
  17648. */
  17649. _reorderLightsInScene(): void;
  17650. /**
  17651. * Prepares the list of defines specific to the light type.
  17652. * @param defines the list of defines
  17653. * @param lightIndex defines the index of the light for the effect
  17654. */
  17655. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17656. }
  17657. }
  17658. declare module "babylonjs/Actions/action" {
  17659. import { Observable } from "babylonjs/Misc/observable";
  17660. import { Condition } from "babylonjs/Actions/condition";
  17661. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17662. import { ActionManager } from "babylonjs/Actions/actionManager";
  17663. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17664. /**
  17665. * Interface used to define Action
  17666. */
  17667. export interface IAction {
  17668. /**
  17669. * Trigger for the action
  17670. */
  17671. trigger: number;
  17672. /** Options of the trigger */
  17673. triggerOptions: any;
  17674. /**
  17675. * Gets the trigger parameters
  17676. * @returns the trigger parameters
  17677. */
  17678. getTriggerParameter(): any;
  17679. /**
  17680. * Internal only - executes current action event
  17681. * @hidden
  17682. */
  17683. _executeCurrent(evt?: ActionEvent): void;
  17684. /**
  17685. * Serialize placeholder for child classes
  17686. * @param parent of child
  17687. * @returns the serialized object
  17688. */
  17689. serialize(parent: any): any;
  17690. /**
  17691. * Internal only
  17692. * @hidden
  17693. */
  17694. _prepare(): void;
  17695. /**
  17696. * Internal only - manager for action
  17697. * @hidden
  17698. */
  17699. _actionManager: AbstractActionManager;
  17700. /**
  17701. * Adds action to chain of actions, may be a DoNothingAction
  17702. * @param action defines the next action to execute
  17703. * @returns The action passed in
  17704. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17705. */
  17706. then(action: IAction): IAction;
  17707. }
  17708. /**
  17709. * The action to be carried out following a trigger
  17710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17711. */
  17712. export class Action implements IAction {
  17713. /** the trigger, with or without parameters, for the action */
  17714. triggerOptions: any;
  17715. /**
  17716. * Trigger for the action
  17717. */
  17718. trigger: number;
  17719. /**
  17720. * Internal only - manager for action
  17721. * @hidden
  17722. */
  17723. _actionManager: ActionManager;
  17724. private _nextActiveAction;
  17725. private _child;
  17726. private _condition?;
  17727. private _triggerParameter;
  17728. /**
  17729. * An event triggered prior to action being executed.
  17730. */
  17731. onBeforeExecuteObservable: Observable<Action>;
  17732. /**
  17733. * Creates a new Action
  17734. * @param triggerOptions the trigger, with or without parameters, for the action
  17735. * @param condition an optional determinant of action
  17736. */
  17737. constructor(
  17738. /** the trigger, with or without parameters, for the action */
  17739. triggerOptions: any, condition?: Condition);
  17740. /**
  17741. * Internal only
  17742. * @hidden
  17743. */
  17744. _prepare(): void;
  17745. /**
  17746. * Gets the trigger parameters
  17747. * @returns the trigger parameters
  17748. */
  17749. getTriggerParameter(): any;
  17750. /**
  17751. * Internal only - executes current action event
  17752. * @hidden
  17753. */
  17754. _executeCurrent(evt?: ActionEvent): void;
  17755. /**
  17756. * Execute placeholder for child classes
  17757. * @param evt optional action event
  17758. */
  17759. execute(evt?: ActionEvent): void;
  17760. /**
  17761. * Skips to next active action
  17762. */
  17763. skipToNextActiveAction(): void;
  17764. /**
  17765. * Adds action to chain of actions, may be a DoNothingAction
  17766. * @param action defines the next action to execute
  17767. * @returns The action passed in
  17768. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17769. */
  17770. then(action: Action): Action;
  17771. /**
  17772. * Internal only
  17773. * @hidden
  17774. */
  17775. _getProperty(propertyPath: string): string;
  17776. /**
  17777. * Internal only
  17778. * @hidden
  17779. */
  17780. _getEffectiveTarget(target: any, propertyPath: string): any;
  17781. /**
  17782. * Serialize placeholder for child classes
  17783. * @param parent of child
  17784. * @returns the serialized object
  17785. */
  17786. serialize(parent: any): any;
  17787. /**
  17788. * Internal only called by serialize
  17789. * @hidden
  17790. */
  17791. protected _serialize(serializedAction: any, parent?: any): any;
  17792. /**
  17793. * Internal only
  17794. * @hidden
  17795. */
  17796. static _SerializeValueAsString: (value: any) => string;
  17797. /**
  17798. * Internal only
  17799. * @hidden
  17800. */
  17801. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17802. name: string;
  17803. targetType: string;
  17804. value: string;
  17805. };
  17806. }
  17807. }
  17808. declare module "babylonjs/Actions/condition" {
  17809. import { ActionManager } from "babylonjs/Actions/actionManager";
  17810. /**
  17811. * A Condition applied to an Action
  17812. */
  17813. export class Condition {
  17814. /**
  17815. * Internal only - manager for action
  17816. * @hidden
  17817. */
  17818. _actionManager: ActionManager;
  17819. /**
  17820. * Internal only
  17821. * @hidden
  17822. */
  17823. _evaluationId: number;
  17824. /**
  17825. * Internal only
  17826. * @hidden
  17827. */
  17828. _currentResult: boolean;
  17829. /**
  17830. * Creates a new Condition
  17831. * @param actionManager the manager of the action the condition is applied to
  17832. */
  17833. constructor(actionManager: ActionManager);
  17834. /**
  17835. * Check if the current condition is valid
  17836. * @returns a boolean
  17837. */
  17838. isValid(): boolean;
  17839. /**
  17840. * Internal only
  17841. * @hidden
  17842. */
  17843. _getProperty(propertyPath: string): string;
  17844. /**
  17845. * Internal only
  17846. * @hidden
  17847. */
  17848. _getEffectiveTarget(target: any, propertyPath: string): any;
  17849. /**
  17850. * Serialize placeholder for child classes
  17851. * @returns the serialized object
  17852. */
  17853. serialize(): any;
  17854. /**
  17855. * Internal only
  17856. * @hidden
  17857. */
  17858. protected _serialize(serializedCondition: any): any;
  17859. }
  17860. /**
  17861. * Defines specific conditional operators as extensions of Condition
  17862. */
  17863. export class ValueCondition extends Condition {
  17864. /** path to specify the property of the target the conditional operator uses */
  17865. propertyPath: string;
  17866. /** the value compared by the conditional operator against the current value of the property */
  17867. value: any;
  17868. /** the conditional operator, default ValueCondition.IsEqual */
  17869. operator: number;
  17870. /**
  17871. * Internal only
  17872. * @hidden
  17873. */
  17874. private static _IsEqual;
  17875. /**
  17876. * Internal only
  17877. * @hidden
  17878. */
  17879. private static _IsDifferent;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. private static _IsGreater;
  17885. /**
  17886. * Internal only
  17887. * @hidden
  17888. */
  17889. private static _IsLesser;
  17890. /**
  17891. * returns the number for IsEqual
  17892. */
  17893. static get IsEqual(): number;
  17894. /**
  17895. * Returns the number for IsDifferent
  17896. */
  17897. static get IsDifferent(): number;
  17898. /**
  17899. * Returns the number for IsGreater
  17900. */
  17901. static get IsGreater(): number;
  17902. /**
  17903. * Returns the number for IsLesser
  17904. */
  17905. static get IsLesser(): number;
  17906. /**
  17907. * Internal only The action manager for the condition
  17908. * @hidden
  17909. */
  17910. _actionManager: ActionManager;
  17911. /**
  17912. * Internal only
  17913. * @hidden
  17914. */
  17915. private _target;
  17916. /**
  17917. * Internal only
  17918. * @hidden
  17919. */
  17920. private _effectiveTarget;
  17921. /**
  17922. * Internal only
  17923. * @hidden
  17924. */
  17925. private _property;
  17926. /**
  17927. * Creates a new ValueCondition
  17928. * @param actionManager manager for the action the condition applies to
  17929. * @param target for the action
  17930. * @param propertyPath path to specify the property of the target the conditional operator uses
  17931. * @param value the value compared by the conditional operator against the current value of the property
  17932. * @param operator the conditional operator, default ValueCondition.IsEqual
  17933. */
  17934. constructor(actionManager: ActionManager, target: any,
  17935. /** path to specify the property of the target the conditional operator uses */
  17936. propertyPath: string,
  17937. /** the value compared by the conditional operator against the current value of the property */
  17938. value: any,
  17939. /** the conditional operator, default ValueCondition.IsEqual */
  17940. operator?: number);
  17941. /**
  17942. * Compares the given value with the property value for the specified conditional operator
  17943. * @returns the result of the comparison
  17944. */
  17945. isValid(): boolean;
  17946. /**
  17947. * Serialize the ValueCondition into a JSON compatible object
  17948. * @returns serialization object
  17949. */
  17950. serialize(): any;
  17951. /**
  17952. * Gets the name of the conditional operator for the ValueCondition
  17953. * @param operator the conditional operator
  17954. * @returns the name
  17955. */
  17956. static GetOperatorName(operator: number): string;
  17957. }
  17958. /**
  17959. * Defines a predicate condition as an extension of Condition
  17960. */
  17961. export class PredicateCondition extends Condition {
  17962. /** defines the predicate function used to validate the condition */
  17963. predicate: () => boolean;
  17964. /**
  17965. * Internal only - manager for action
  17966. * @hidden
  17967. */
  17968. _actionManager: ActionManager;
  17969. /**
  17970. * Creates a new PredicateCondition
  17971. * @param actionManager manager for the action the condition applies to
  17972. * @param predicate defines the predicate function used to validate the condition
  17973. */
  17974. constructor(actionManager: ActionManager,
  17975. /** defines the predicate function used to validate the condition */
  17976. predicate: () => boolean);
  17977. /**
  17978. * @returns the validity of the predicate condition
  17979. */
  17980. isValid(): boolean;
  17981. }
  17982. /**
  17983. * Defines a state condition as an extension of Condition
  17984. */
  17985. export class StateCondition extends Condition {
  17986. /** Value to compare with target state */
  17987. value: string;
  17988. /**
  17989. * Internal only - manager for action
  17990. * @hidden
  17991. */
  17992. _actionManager: ActionManager;
  17993. /**
  17994. * Internal only
  17995. * @hidden
  17996. */
  17997. private _target;
  17998. /**
  17999. * Creates a new StateCondition
  18000. * @param actionManager manager for the action the condition applies to
  18001. * @param target of the condition
  18002. * @param value to compare with target state
  18003. */
  18004. constructor(actionManager: ActionManager, target: any,
  18005. /** Value to compare with target state */
  18006. value: string);
  18007. /**
  18008. * Gets a boolean indicating if the current condition is met
  18009. * @returns the validity of the state
  18010. */
  18011. isValid(): boolean;
  18012. /**
  18013. * Serialize the StateCondition into a JSON compatible object
  18014. * @returns serialization object
  18015. */
  18016. serialize(): any;
  18017. }
  18018. }
  18019. declare module "babylonjs/Actions/directActions" {
  18020. import { Action } from "babylonjs/Actions/action";
  18021. import { Condition } from "babylonjs/Actions/condition";
  18022. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18023. /**
  18024. * This defines an action responsible to toggle a boolean once triggered.
  18025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18026. */
  18027. export class SwitchBooleanAction extends Action {
  18028. /**
  18029. * The path to the boolean property in the target object
  18030. */
  18031. propertyPath: string;
  18032. private _target;
  18033. private _effectiveTarget;
  18034. private _property;
  18035. /**
  18036. * Instantiate the action
  18037. * @param triggerOptions defines the trigger options
  18038. * @param target defines the object containing the boolean
  18039. * @param propertyPath defines the path to the boolean property in the target object
  18040. * @param condition defines the trigger related conditions
  18041. */
  18042. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18043. /** @hidden */
  18044. _prepare(): void;
  18045. /**
  18046. * Execute the action toggle the boolean value.
  18047. */
  18048. execute(): void;
  18049. /**
  18050. * Serializes the actions and its related information.
  18051. * @param parent defines the object to serialize in
  18052. * @returns the serialized object
  18053. */
  18054. serialize(parent: any): any;
  18055. }
  18056. /**
  18057. * This defines an action responsible to set a the state field of the target
  18058. * to a desired value once triggered.
  18059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18060. */
  18061. export class SetStateAction extends Action {
  18062. /**
  18063. * The value to store in the state field.
  18064. */
  18065. value: string;
  18066. private _target;
  18067. /**
  18068. * Instantiate the action
  18069. * @param triggerOptions defines the trigger options
  18070. * @param target defines the object containing the state property
  18071. * @param value defines the value to store in the state field
  18072. * @param condition defines the trigger related conditions
  18073. */
  18074. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18075. /**
  18076. * Execute the action and store the value on the target state property.
  18077. */
  18078. execute(): void;
  18079. /**
  18080. * Serializes the actions and its related information.
  18081. * @param parent defines the object to serialize in
  18082. * @returns the serialized object
  18083. */
  18084. serialize(parent: any): any;
  18085. }
  18086. /**
  18087. * This defines an action responsible to set a property of the target
  18088. * to a desired value once triggered.
  18089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18090. */
  18091. export class SetValueAction extends Action {
  18092. /**
  18093. * The path of the property to set in the target.
  18094. */
  18095. propertyPath: string;
  18096. /**
  18097. * The value to set in the property
  18098. */
  18099. value: any;
  18100. private _target;
  18101. private _effectiveTarget;
  18102. private _property;
  18103. /**
  18104. * Instantiate the action
  18105. * @param triggerOptions defines the trigger options
  18106. * @param target defines the object containing the property
  18107. * @param propertyPath defines the path of the property to set in the target
  18108. * @param value defines the value to set in the property
  18109. * @param condition defines the trigger related conditions
  18110. */
  18111. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18112. /** @hidden */
  18113. _prepare(): void;
  18114. /**
  18115. * Execute the action and set the targetted property to the desired value.
  18116. */
  18117. execute(): void;
  18118. /**
  18119. * Serializes the actions and its related information.
  18120. * @param parent defines the object to serialize in
  18121. * @returns the serialized object
  18122. */
  18123. serialize(parent: any): any;
  18124. }
  18125. /**
  18126. * This defines an action responsible to increment the target value
  18127. * to a desired value once triggered.
  18128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18129. */
  18130. export class IncrementValueAction extends Action {
  18131. /**
  18132. * The path of the property to increment in the target.
  18133. */
  18134. propertyPath: string;
  18135. /**
  18136. * The value we should increment the property by.
  18137. */
  18138. value: any;
  18139. private _target;
  18140. private _effectiveTarget;
  18141. private _property;
  18142. /**
  18143. * Instantiate the action
  18144. * @param triggerOptions defines the trigger options
  18145. * @param target defines the object containing the property
  18146. * @param propertyPath defines the path of the property to increment in the target
  18147. * @param value defines the value value we should increment the property by
  18148. * @param condition defines the trigger related conditions
  18149. */
  18150. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18151. /** @hidden */
  18152. _prepare(): void;
  18153. /**
  18154. * Execute the action and increment the target of the value amount.
  18155. */
  18156. execute(): void;
  18157. /**
  18158. * Serializes the actions and its related information.
  18159. * @param parent defines the object to serialize in
  18160. * @returns the serialized object
  18161. */
  18162. serialize(parent: any): any;
  18163. }
  18164. /**
  18165. * This defines an action responsible to start an animation once triggered.
  18166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18167. */
  18168. export class PlayAnimationAction extends Action {
  18169. /**
  18170. * Where the animation should start (animation frame)
  18171. */
  18172. from: number;
  18173. /**
  18174. * Where the animation should stop (animation frame)
  18175. */
  18176. to: number;
  18177. /**
  18178. * Define if the animation should loop or stop after the first play.
  18179. */
  18180. loop?: boolean;
  18181. private _target;
  18182. /**
  18183. * Instantiate the action
  18184. * @param triggerOptions defines the trigger options
  18185. * @param target defines the target animation or animation name
  18186. * @param from defines from where the animation should start (animation frame)
  18187. * @param end defines where the animation should stop (animation frame)
  18188. * @param loop defines if the animation should loop or stop after the first play
  18189. * @param condition defines the trigger related conditions
  18190. */
  18191. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18192. /** @hidden */
  18193. _prepare(): void;
  18194. /**
  18195. * Execute the action and play the animation.
  18196. */
  18197. execute(): void;
  18198. /**
  18199. * Serializes the actions and its related information.
  18200. * @param parent defines the object to serialize in
  18201. * @returns the serialized object
  18202. */
  18203. serialize(parent: any): any;
  18204. }
  18205. /**
  18206. * This defines an action responsible to stop an animation once triggered.
  18207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18208. */
  18209. export class StopAnimationAction extends Action {
  18210. private _target;
  18211. /**
  18212. * Instantiate the action
  18213. * @param triggerOptions defines the trigger options
  18214. * @param target defines the target animation or animation name
  18215. * @param condition defines the trigger related conditions
  18216. */
  18217. constructor(triggerOptions: any, target: any, condition?: Condition);
  18218. /** @hidden */
  18219. _prepare(): void;
  18220. /**
  18221. * Execute the action and stop the animation.
  18222. */
  18223. execute(): void;
  18224. /**
  18225. * Serializes the actions and its related information.
  18226. * @param parent defines the object to serialize in
  18227. * @returns the serialized object
  18228. */
  18229. serialize(parent: any): any;
  18230. }
  18231. /**
  18232. * This defines an action responsible that does nothing once triggered.
  18233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18234. */
  18235. export class DoNothingAction extends Action {
  18236. /**
  18237. * Instantiate the action
  18238. * @param triggerOptions defines the trigger options
  18239. * @param condition defines the trigger related conditions
  18240. */
  18241. constructor(triggerOptions?: any, condition?: Condition);
  18242. /**
  18243. * Execute the action and do nothing.
  18244. */
  18245. execute(): void;
  18246. /**
  18247. * Serializes the actions and its related information.
  18248. * @param parent defines the object to serialize in
  18249. * @returns the serialized object
  18250. */
  18251. serialize(parent: any): any;
  18252. }
  18253. /**
  18254. * This defines an action responsible to trigger several actions once triggered.
  18255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18256. */
  18257. export class CombineAction extends Action {
  18258. /**
  18259. * The list of aggregated animations to run.
  18260. */
  18261. children: Action[];
  18262. /**
  18263. * Instantiate the action
  18264. * @param triggerOptions defines the trigger options
  18265. * @param children defines the list of aggregated animations to run
  18266. * @param condition defines the trigger related conditions
  18267. */
  18268. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18269. /** @hidden */
  18270. _prepare(): void;
  18271. /**
  18272. * Execute the action and executes all the aggregated actions.
  18273. */
  18274. execute(evt: ActionEvent): void;
  18275. /**
  18276. * Serializes the actions and its related information.
  18277. * @param parent defines the object to serialize in
  18278. * @returns the serialized object
  18279. */
  18280. serialize(parent: any): any;
  18281. }
  18282. /**
  18283. * This defines an action responsible to run code (external event) once triggered.
  18284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18285. */
  18286. export class ExecuteCodeAction extends Action {
  18287. /**
  18288. * The callback function to run.
  18289. */
  18290. func: (evt: ActionEvent) => void;
  18291. /**
  18292. * Instantiate the action
  18293. * @param triggerOptions defines the trigger options
  18294. * @param func defines the callback function to run
  18295. * @param condition defines the trigger related conditions
  18296. */
  18297. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18298. /**
  18299. * Execute the action and run the attached code.
  18300. */
  18301. execute(evt: ActionEvent): void;
  18302. }
  18303. /**
  18304. * This defines an action responsible to set the parent property of the target once triggered.
  18305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18306. */
  18307. export class SetParentAction extends Action {
  18308. private _parent;
  18309. private _target;
  18310. /**
  18311. * Instantiate the action
  18312. * @param triggerOptions defines the trigger options
  18313. * @param target defines the target containing the parent property
  18314. * @param parent defines from where the animation should start (animation frame)
  18315. * @param condition defines the trigger related conditions
  18316. */
  18317. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18318. /** @hidden */
  18319. _prepare(): void;
  18320. /**
  18321. * Execute the action and set the parent property.
  18322. */
  18323. execute(): void;
  18324. /**
  18325. * Serializes the actions and its related information.
  18326. * @param parent defines the object to serialize in
  18327. * @returns the serialized object
  18328. */
  18329. serialize(parent: any): any;
  18330. }
  18331. }
  18332. declare module "babylonjs/Actions/actionManager" {
  18333. import { Nullable } from "babylonjs/types";
  18334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18335. import { Scene } from "babylonjs/scene";
  18336. import { IAction } from "babylonjs/Actions/action";
  18337. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18338. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18339. /**
  18340. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18341. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18343. */
  18344. export class ActionManager extends AbstractActionManager {
  18345. /**
  18346. * Nothing
  18347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18348. */
  18349. static readonly NothingTrigger: number;
  18350. /**
  18351. * On pick
  18352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18353. */
  18354. static readonly OnPickTrigger: number;
  18355. /**
  18356. * On left pick
  18357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18358. */
  18359. static readonly OnLeftPickTrigger: number;
  18360. /**
  18361. * On right pick
  18362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18363. */
  18364. static readonly OnRightPickTrigger: number;
  18365. /**
  18366. * On center pick
  18367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18368. */
  18369. static readonly OnCenterPickTrigger: number;
  18370. /**
  18371. * On pick down
  18372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18373. */
  18374. static readonly OnPickDownTrigger: number;
  18375. /**
  18376. * On double pick
  18377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18378. */
  18379. static readonly OnDoublePickTrigger: number;
  18380. /**
  18381. * On pick up
  18382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18383. */
  18384. static readonly OnPickUpTrigger: number;
  18385. /**
  18386. * On pick out.
  18387. * This trigger will only be raised if you also declared a OnPickDown
  18388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18389. */
  18390. static readonly OnPickOutTrigger: number;
  18391. /**
  18392. * On long press
  18393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18394. */
  18395. static readonly OnLongPressTrigger: number;
  18396. /**
  18397. * On pointer over
  18398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18399. */
  18400. static readonly OnPointerOverTrigger: number;
  18401. /**
  18402. * On pointer out
  18403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18404. */
  18405. static readonly OnPointerOutTrigger: number;
  18406. /**
  18407. * On every frame
  18408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18409. */
  18410. static readonly OnEveryFrameTrigger: number;
  18411. /**
  18412. * On intersection enter
  18413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18414. */
  18415. static readonly OnIntersectionEnterTrigger: number;
  18416. /**
  18417. * On intersection exit
  18418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18419. */
  18420. static readonly OnIntersectionExitTrigger: number;
  18421. /**
  18422. * On key down
  18423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18424. */
  18425. static readonly OnKeyDownTrigger: number;
  18426. /**
  18427. * On key up
  18428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18429. */
  18430. static readonly OnKeyUpTrigger: number;
  18431. private _scene;
  18432. /**
  18433. * Creates a new action manager
  18434. * @param scene defines the hosting scene
  18435. */
  18436. constructor(scene: Scene);
  18437. /**
  18438. * Releases all associated resources
  18439. */
  18440. dispose(): void;
  18441. /**
  18442. * Gets hosting scene
  18443. * @returns the hosting scene
  18444. */
  18445. getScene(): Scene;
  18446. /**
  18447. * Does this action manager handles actions of any of the given triggers
  18448. * @param triggers defines the triggers to be tested
  18449. * @return a boolean indicating whether one (or more) of the triggers is handled
  18450. */
  18451. hasSpecificTriggers(triggers: number[]): boolean;
  18452. /**
  18453. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18454. * speed.
  18455. * @param triggerA defines the trigger to be tested
  18456. * @param triggerB defines the trigger to be tested
  18457. * @return a boolean indicating whether one (or more) of the triggers is handled
  18458. */
  18459. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18460. /**
  18461. * Does this action manager handles actions of a given trigger
  18462. * @param trigger defines the trigger to be tested
  18463. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18464. * @return whether the trigger is handled
  18465. */
  18466. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18467. /**
  18468. * Does this action manager has pointer triggers
  18469. */
  18470. get hasPointerTriggers(): boolean;
  18471. /**
  18472. * Does this action manager has pick triggers
  18473. */
  18474. get hasPickTriggers(): boolean;
  18475. /**
  18476. * Registers an action to this action manager
  18477. * @param action defines the action to be registered
  18478. * @return the action amended (prepared) after registration
  18479. */
  18480. registerAction(action: IAction): Nullable<IAction>;
  18481. /**
  18482. * Unregisters an action to this action manager
  18483. * @param action defines the action to be unregistered
  18484. * @return a boolean indicating whether the action has been unregistered
  18485. */
  18486. unregisterAction(action: IAction): Boolean;
  18487. /**
  18488. * Process a specific trigger
  18489. * @param trigger defines the trigger to process
  18490. * @param evt defines the event details to be processed
  18491. */
  18492. processTrigger(trigger: number, evt?: IActionEvent): void;
  18493. /** @hidden */
  18494. _getEffectiveTarget(target: any, propertyPath: string): any;
  18495. /** @hidden */
  18496. _getProperty(propertyPath: string): string;
  18497. /**
  18498. * Serialize this manager to a JSON object
  18499. * @param name defines the property name to store this manager
  18500. * @returns a JSON representation of this manager
  18501. */
  18502. serialize(name: string): any;
  18503. /**
  18504. * Creates a new ActionManager from a JSON data
  18505. * @param parsedActions defines the JSON data to read from
  18506. * @param object defines the hosting mesh
  18507. * @param scene defines the hosting scene
  18508. */
  18509. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18510. /**
  18511. * Get a trigger name by index
  18512. * @param trigger defines the trigger index
  18513. * @returns a trigger name
  18514. */
  18515. static GetTriggerName(trigger: number): string;
  18516. }
  18517. }
  18518. declare module "babylonjs/Sprites/sprite" {
  18519. import { Vector3 } from "babylonjs/Maths/math.vector";
  18520. import { Nullable } from "babylonjs/types";
  18521. import { ActionManager } from "babylonjs/Actions/actionManager";
  18522. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18523. import { Color4 } from "babylonjs/Maths/math.color";
  18524. /**
  18525. * Class used to represent a sprite
  18526. * @see http://doc.babylonjs.com/babylon101/sprites
  18527. */
  18528. export class Sprite {
  18529. /** defines the name */
  18530. name: string;
  18531. /** Gets or sets the current world position */
  18532. position: Vector3;
  18533. /** Gets or sets the main color */
  18534. color: Color4;
  18535. /** Gets or sets the width */
  18536. width: number;
  18537. /** Gets or sets the height */
  18538. height: number;
  18539. /** Gets or sets rotation angle */
  18540. angle: number;
  18541. /** Gets or sets the cell index in the sprite sheet */
  18542. cellIndex: number;
  18543. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18544. cellRef: string;
  18545. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18546. invertU: number;
  18547. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18548. invertV: number;
  18549. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18550. disposeWhenFinishedAnimating: boolean;
  18551. /** Gets the list of attached animations */
  18552. animations: Animation[];
  18553. /** Gets or sets a boolean indicating if the sprite can be picked */
  18554. isPickable: boolean;
  18555. /**
  18556. * Gets or sets the associated action manager
  18557. */
  18558. actionManager: Nullable<ActionManager>;
  18559. private _animationStarted;
  18560. private _loopAnimation;
  18561. private _fromIndex;
  18562. private _toIndex;
  18563. private _delay;
  18564. private _direction;
  18565. private _manager;
  18566. private _time;
  18567. private _onAnimationEnd;
  18568. /**
  18569. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18570. */
  18571. isVisible: boolean;
  18572. /**
  18573. * Gets or sets the sprite size
  18574. */
  18575. get size(): number;
  18576. set size(value: number);
  18577. /**
  18578. * Creates a new Sprite
  18579. * @param name defines the name
  18580. * @param manager defines the manager
  18581. */
  18582. constructor(
  18583. /** defines the name */
  18584. name: string, manager: ISpriteManager);
  18585. /**
  18586. * Starts an animation
  18587. * @param from defines the initial key
  18588. * @param to defines the end key
  18589. * @param loop defines if the animation must loop
  18590. * @param delay defines the start delay (in ms)
  18591. * @param onAnimationEnd defines a callback to call when animation ends
  18592. */
  18593. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18594. /** Stops current animation (if any) */
  18595. stopAnimation(): void;
  18596. /** @hidden */
  18597. _animate(deltaTime: number): void;
  18598. /** Release associated resources */
  18599. dispose(): void;
  18600. }
  18601. }
  18602. declare module "babylonjs/Collisions/pickingInfo" {
  18603. import { Nullable } from "babylonjs/types";
  18604. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18606. import { Sprite } from "babylonjs/Sprites/sprite";
  18607. import { Ray } from "babylonjs/Culling/ray";
  18608. /**
  18609. * Information about the result of picking within a scene
  18610. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18611. */
  18612. export class PickingInfo {
  18613. /** @hidden */
  18614. _pickingUnavailable: boolean;
  18615. /**
  18616. * If the pick collided with an object
  18617. */
  18618. hit: boolean;
  18619. /**
  18620. * Distance away where the pick collided
  18621. */
  18622. distance: number;
  18623. /**
  18624. * The location of pick collision
  18625. */
  18626. pickedPoint: Nullable<Vector3>;
  18627. /**
  18628. * The mesh corresponding the the pick collision
  18629. */
  18630. pickedMesh: Nullable<AbstractMesh>;
  18631. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18632. bu: number;
  18633. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18634. bv: number;
  18635. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18636. faceId: number;
  18637. /** Id of the the submesh that was picked */
  18638. subMeshId: number;
  18639. /** If a sprite was picked, this will be the sprite the pick collided with */
  18640. pickedSprite: Nullable<Sprite>;
  18641. /**
  18642. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18643. */
  18644. originMesh: Nullable<AbstractMesh>;
  18645. /**
  18646. * The ray that was used to perform the picking.
  18647. */
  18648. ray: Nullable<Ray>;
  18649. /**
  18650. * Gets the normal correspodning to the face the pick collided with
  18651. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18652. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18653. * @returns The normal correspodning to the face the pick collided with
  18654. */
  18655. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18656. /**
  18657. * Gets the texture coordinates of where the pick occured
  18658. * @returns the vector containing the coordnates of the texture
  18659. */
  18660. getTextureCoordinates(): Nullable<Vector2>;
  18661. }
  18662. }
  18663. declare module "babylonjs/Events/pointerEvents" {
  18664. import { Nullable } from "babylonjs/types";
  18665. import { Vector2 } from "babylonjs/Maths/math.vector";
  18666. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18667. import { Ray } from "babylonjs/Culling/ray";
  18668. /**
  18669. * Gather the list of pointer event types as constants.
  18670. */
  18671. export class PointerEventTypes {
  18672. /**
  18673. * 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.
  18674. */
  18675. static readonly POINTERDOWN: number;
  18676. /**
  18677. * The pointerup event is fired when a pointer is no longer active.
  18678. */
  18679. static readonly POINTERUP: number;
  18680. /**
  18681. * The pointermove event is fired when a pointer changes coordinates.
  18682. */
  18683. static readonly POINTERMOVE: number;
  18684. /**
  18685. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18686. */
  18687. static readonly POINTERWHEEL: number;
  18688. /**
  18689. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18690. */
  18691. static readonly POINTERPICK: number;
  18692. /**
  18693. * The pointertap event is fired when a the object has been touched and released without drag.
  18694. */
  18695. static readonly POINTERTAP: number;
  18696. /**
  18697. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18698. */
  18699. static readonly POINTERDOUBLETAP: number;
  18700. }
  18701. /**
  18702. * Base class of pointer info types.
  18703. */
  18704. export class PointerInfoBase {
  18705. /**
  18706. * Defines the type of event (PointerEventTypes)
  18707. */
  18708. type: number;
  18709. /**
  18710. * Defines the related dom event
  18711. */
  18712. event: PointerEvent | MouseWheelEvent;
  18713. /**
  18714. * Instantiates the base class of pointers info.
  18715. * @param type Defines the type of event (PointerEventTypes)
  18716. * @param event Defines the related dom event
  18717. */
  18718. constructor(
  18719. /**
  18720. * Defines the type of event (PointerEventTypes)
  18721. */
  18722. type: number,
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: PointerEvent | MouseWheelEvent);
  18727. }
  18728. /**
  18729. * This class is used to store pointer related info for the onPrePointerObservable event.
  18730. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18731. */
  18732. export class PointerInfoPre extends PointerInfoBase {
  18733. /**
  18734. * Ray from a pointer if availible (eg. 6dof controller)
  18735. */
  18736. ray: Nullable<Ray>;
  18737. /**
  18738. * Defines the local position of the pointer on the canvas.
  18739. */
  18740. localPosition: Vector2;
  18741. /**
  18742. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18743. */
  18744. skipOnPointerObservable: boolean;
  18745. /**
  18746. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18747. * @param type Defines the type of event (PointerEventTypes)
  18748. * @param event Defines the related dom event
  18749. * @param localX Defines the local x coordinates of the pointer when the event occured
  18750. * @param localY Defines the local y coordinates of the pointer when the event occured
  18751. */
  18752. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18753. }
  18754. /**
  18755. * This type contains all the data related to a pointer event in Babylon.js.
  18756. * 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.
  18757. */
  18758. export class PointerInfo extends PointerInfoBase {
  18759. /**
  18760. * Defines the picking info associated to the info (if any)\
  18761. */
  18762. pickInfo: Nullable<PickingInfo>;
  18763. /**
  18764. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18765. * @param type Defines the type of event (PointerEventTypes)
  18766. * @param event Defines the related dom event
  18767. * @param pickInfo Defines the picking info associated to the info (if any)\
  18768. */
  18769. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18770. /**
  18771. * Defines the picking info associated to the info (if any)\
  18772. */
  18773. pickInfo: Nullable<PickingInfo>);
  18774. }
  18775. /**
  18776. * Data relating to a touch event on the screen.
  18777. */
  18778. export interface PointerTouch {
  18779. /**
  18780. * X coordinate of touch.
  18781. */
  18782. x: number;
  18783. /**
  18784. * Y coordinate of touch.
  18785. */
  18786. y: number;
  18787. /**
  18788. * Id of touch. Unique for each finger.
  18789. */
  18790. pointerId: number;
  18791. /**
  18792. * Event type passed from DOM.
  18793. */
  18794. type: any;
  18795. }
  18796. }
  18797. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18798. import { Observable } from "babylonjs/Misc/observable";
  18799. import { Nullable } from "babylonjs/types";
  18800. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18801. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18802. /**
  18803. * Manage the mouse inputs to control the movement of a free camera.
  18804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18805. */
  18806. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18807. /**
  18808. * Define if touch is enabled in the mouse input
  18809. */
  18810. touchEnabled: boolean;
  18811. /**
  18812. * Defines the camera the input is attached to.
  18813. */
  18814. camera: FreeCamera;
  18815. /**
  18816. * Defines the buttons associated with the input to handle camera move.
  18817. */
  18818. buttons: number[];
  18819. /**
  18820. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18821. */
  18822. angularSensibility: number;
  18823. private _pointerInput;
  18824. private _onMouseMove;
  18825. private _observer;
  18826. private previousPosition;
  18827. /**
  18828. * Observable for when a pointer move event occurs containing the move offset
  18829. */
  18830. onPointerMovedObservable: Observable<{
  18831. offsetX: number;
  18832. offsetY: number;
  18833. }>;
  18834. /**
  18835. * @hidden
  18836. * If the camera should be rotated automatically based on pointer movement
  18837. */
  18838. _allowCameraRotation: boolean;
  18839. /**
  18840. * Manage the mouse inputs to control the movement of a free camera.
  18841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18842. * @param touchEnabled Defines if touch is enabled or not
  18843. */
  18844. constructor(
  18845. /**
  18846. * Define if touch is enabled in the mouse input
  18847. */
  18848. touchEnabled?: boolean);
  18849. /**
  18850. * Attach the input controls to a specific dom element to get the input from.
  18851. * @param element Defines the element the controls should be listened from
  18852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18853. */
  18854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18855. /**
  18856. * Called on JS contextmenu event.
  18857. * Override this method to provide functionality.
  18858. */
  18859. protected onContextMenu(evt: PointerEvent): void;
  18860. /**
  18861. * Detach the current controls from the specified dom element.
  18862. * @param element Defines the element to stop listening the inputs from
  18863. */
  18864. detachControl(element: Nullable<HTMLElement>): void;
  18865. /**
  18866. * Gets the class name of the current intput.
  18867. * @returns the class name
  18868. */
  18869. getClassName(): string;
  18870. /**
  18871. * Get the friendly name associated with the input class.
  18872. * @returns the input friendly name
  18873. */
  18874. getSimpleName(): string;
  18875. }
  18876. }
  18877. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18878. import { Nullable } from "babylonjs/types";
  18879. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18880. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18881. /**
  18882. * Manage the touch inputs to control the movement of a free camera.
  18883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18884. */
  18885. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18886. /**
  18887. * Defines the camera the input is attached to.
  18888. */
  18889. camera: FreeCamera;
  18890. /**
  18891. * Defines the touch sensibility for rotation.
  18892. * The higher the faster.
  18893. */
  18894. touchAngularSensibility: number;
  18895. /**
  18896. * Defines the touch sensibility for move.
  18897. * The higher the faster.
  18898. */
  18899. touchMoveSensibility: number;
  18900. private _offsetX;
  18901. private _offsetY;
  18902. private _pointerPressed;
  18903. private _pointerInput;
  18904. private _observer;
  18905. private _onLostFocus;
  18906. /**
  18907. * Attach the input controls to a specific dom element to get the input from.
  18908. * @param element Defines the element the controls should be listened from
  18909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18910. */
  18911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18912. /**
  18913. * Detach the current controls from the specified dom element.
  18914. * @param element Defines the element to stop listening the inputs from
  18915. */
  18916. detachControl(element: Nullable<HTMLElement>): void;
  18917. /**
  18918. * Update the current camera state depending on the inputs that have been used this frame.
  18919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18920. */
  18921. checkInputs(): void;
  18922. /**
  18923. * Gets the class name of the current intput.
  18924. * @returns the class name
  18925. */
  18926. getClassName(): string;
  18927. /**
  18928. * Get the friendly name associated with the input class.
  18929. * @returns the input friendly name
  18930. */
  18931. getSimpleName(): string;
  18932. }
  18933. }
  18934. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18935. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18936. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18937. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18938. import { Nullable } from "babylonjs/types";
  18939. /**
  18940. * Default Inputs manager for the FreeCamera.
  18941. * It groups all the default supported inputs for ease of use.
  18942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18943. */
  18944. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18945. /**
  18946. * @hidden
  18947. */
  18948. _mouseInput: Nullable<FreeCameraMouseInput>;
  18949. /**
  18950. * Instantiates a new FreeCameraInputsManager.
  18951. * @param camera Defines the camera the inputs belong to
  18952. */
  18953. constructor(camera: FreeCamera);
  18954. /**
  18955. * Add keyboard input support to the input manager.
  18956. * @returns the current input manager
  18957. */
  18958. addKeyboard(): FreeCameraInputsManager;
  18959. /**
  18960. * Add mouse input support to the input manager.
  18961. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18962. * @returns the current input manager
  18963. */
  18964. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18965. /**
  18966. * Removes the mouse input support from the manager
  18967. * @returns the current input manager
  18968. */
  18969. removeMouse(): FreeCameraInputsManager;
  18970. /**
  18971. * Add touch input support to the input manager.
  18972. * @returns the current input manager
  18973. */
  18974. addTouch(): FreeCameraInputsManager;
  18975. /**
  18976. * Remove all attached input methods from a camera
  18977. */
  18978. clear(): void;
  18979. }
  18980. }
  18981. declare module "babylonjs/Cameras/freeCamera" {
  18982. import { Vector3 } from "babylonjs/Maths/math.vector";
  18983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18984. import { Scene } from "babylonjs/scene";
  18985. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18986. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18987. /**
  18988. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18989. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18990. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18991. */
  18992. export class FreeCamera extends TargetCamera {
  18993. /**
  18994. * Define the collision ellipsoid of the camera.
  18995. * This is helpful to simulate a camera body like the player body around the camera
  18996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18997. */
  18998. ellipsoid: Vector3;
  18999. /**
  19000. * Define an offset for the position of the ellipsoid around the camera.
  19001. * This can be helpful to determine the center of the body near the gravity center of the body
  19002. * instead of its head.
  19003. */
  19004. ellipsoidOffset: Vector3;
  19005. /**
  19006. * Enable or disable collisions of the camera with the rest of the scene objects.
  19007. */
  19008. checkCollisions: boolean;
  19009. /**
  19010. * Enable or disable gravity on the camera.
  19011. */
  19012. applyGravity: boolean;
  19013. /**
  19014. * Define the input manager associated to the camera.
  19015. */
  19016. inputs: FreeCameraInputsManager;
  19017. /**
  19018. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19019. * Higher values reduce sensitivity.
  19020. */
  19021. get angularSensibility(): number;
  19022. /**
  19023. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19024. * Higher values reduce sensitivity.
  19025. */
  19026. set angularSensibility(value: number);
  19027. /**
  19028. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19029. */
  19030. get keysUp(): number[];
  19031. set keysUp(value: number[]);
  19032. /**
  19033. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19034. */
  19035. get keysUpward(): number[];
  19036. set keysUpward(value: number[]);
  19037. /**
  19038. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19039. */
  19040. get keysDown(): number[];
  19041. set keysDown(value: number[]);
  19042. /**
  19043. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19044. */
  19045. get keysDownward(): number[];
  19046. set keysDownward(value: number[]);
  19047. /**
  19048. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19049. */
  19050. get keysLeft(): number[];
  19051. set keysLeft(value: number[]);
  19052. /**
  19053. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19054. */
  19055. get keysRight(): number[];
  19056. set keysRight(value: number[]);
  19057. /**
  19058. * Event raised when the camera collide with a mesh in the scene.
  19059. */
  19060. onCollide: (collidedMesh: AbstractMesh) => void;
  19061. private _collider;
  19062. private _needMoveForGravity;
  19063. private _oldPosition;
  19064. private _diffPosition;
  19065. private _newPosition;
  19066. /** @hidden */
  19067. _localDirection: Vector3;
  19068. /** @hidden */
  19069. _transformedDirection: Vector3;
  19070. /**
  19071. * Instantiates a Free Camera.
  19072. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19073. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19074. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19075. * @param name Define the name of the camera in the scene
  19076. * @param position Define the start position of the camera in the scene
  19077. * @param scene Define the scene the camera belongs to
  19078. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19079. */
  19080. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19081. /**
  19082. * Attached controls to the current camera.
  19083. * @param element Defines the element the controls should be listened from
  19084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19085. */
  19086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19087. /**
  19088. * Detach the current controls from the camera.
  19089. * The camera will stop reacting to inputs.
  19090. * @param element Defines the element to stop listening the inputs from
  19091. */
  19092. detachControl(element: HTMLElement): void;
  19093. private _collisionMask;
  19094. /**
  19095. * Define a collision mask to limit the list of object the camera can collide with
  19096. */
  19097. get collisionMask(): number;
  19098. set collisionMask(mask: number);
  19099. /** @hidden */
  19100. _collideWithWorld(displacement: Vector3): void;
  19101. private _onCollisionPositionChange;
  19102. /** @hidden */
  19103. _checkInputs(): void;
  19104. /** @hidden */
  19105. _decideIfNeedsToMove(): boolean;
  19106. /** @hidden */
  19107. _updatePosition(): void;
  19108. /**
  19109. * Destroy the camera and release the current resources hold by it.
  19110. */
  19111. dispose(): void;
  19112. /**
  19113. * Gets the current object class name.
  19114. * @return the class name
  19115. */
  19116. getClassName(): string;
  19117. }
  19118. }
  19119. declare module "babylonjs/Gamepads/gamepad" {
  19120. import { Observable } from "babylonjs/Misc/observable";
  19121. /**
  19122. * Represents a gamepad control stick position
  19123. */
  19124. export class StickValues {
  19125. /**
  19126. * The x component of the control stick
  19127. */
  19128. x: number;
  19129. /**
  19130. * The y component of the control stick
  19131. */
  19132. y: number;
  19133. /**
  19134. * Initializes the gamepad x and y control stick values
  19135. * @param x The x component of the gamepad control stick value
  19136. * @param y The y component of the gamepad control stick value
  19137. */
  19138. constructor(
  19139. /**
  19140. * The x component of the control stick
  19141. */
  19142. x: number,
  19143. /**
  19144. * The y component of the control stick
  19145. */
  19146. y: number);
  19147. }
  19148. /**
  19149. * An interface which manages callbacks for gamepad button changes
  19150. */
  19151. export interface GamepadButtonChanges {
  19152. /**
  19153. * Called when a gamepad has been changed
  19154. */
  19155. changed: boolean;
  19156. /**
  19157. * Called when a gamepad press event has been triggered
  19158. */
  19159. pressChanged: boolean;
  19160. /**
  19161. * Called when a touch event has been triggered
  19162. */
  19163. touchChanged: boolean;
  19164. /**
  19165. * Called when a value has changed
  19166. */
  19167. valueChanged: boolean;
  19168. }
  19169. /**
  19170. * Represents a gamepad
  19171. */
  19172. export class Gamepad {
  19173. /**
  19174. * The id of the gamepad
  19175. */
  19176. id: string;
  19177. /**
  19178. * The index of the gamepad
  19179. */
  19180. index: number;
  19181. /**
  19182. * The browser gamepad
  19183. */
  19184. browserGamepad: any;
  19185. /**
  19186. * Specifies what type of gamepad this represents
  19187. */
  19188. type: number;
  19189. private _leftStick;
  19190. private _rightStick;
  19191. /** @hidden */
  19192. _isConnected: boolean;
  19193. private _leftStickAxisX;
  19194. private _leftStickAxisY;
  19195. private _rightStickAxisX;
  19196. private _rightStickAxisY;
  19197. /**
  19198. * Triggered when the left control stick has been changed
  19199. */
  19200. private _onleftstickchanged;
  19201. /**
  19202. * Triggered when the right control stick has been changed
  19203. */
  19204. private _onrightstickchanged;
  19205. /**
  19206. * Represents a gamepad controller
  19207. */
  19208. static GAMEPAD: number;
  19209. /**
  19210. * Represents a generic controller
  19211. */
  19212. static GENERIC: number;
  19213. /**
  19214. * Represents an XBox controller
  19215. */
  19216. static XBOX: number;
  19217. /**
  19218. * Represents a pose-enabled controller
  19219. */
  19220. static POSE_ENABLED: number;
  19221. /**
  19222. * Represents an Dual Shock controller
  19223. */
  19224. static DUALSHOCK: number;
  19225. /**
  19226. * Specifies whether the left control stick should be Y-inverted
  19227. */
  19228. protected _invertLeftStickY: boolean;
  19229. /**
  19230. * Specifies if the gamepad has been connected
  19231. */
  19232. get isConnected(): boolean;
  19233. /**
  19234. * Initializes the gamepad
  19235. * @param id The id of the gamepad
  19236. * @param index The index of the gamepad
  19237. * @param browserGamepad The browser gamepad
  19238. * @param leftStickX The x component of the left joystick
  19239. * @param leftStickY The y component of the left joystick
  19240. * @param rightStickX The x component of the right joystick
  19241. * @param rightStickY The y component of the right joystick
  19242. */
  19243. constructor(
  19244. /**
  19245. * The id of the gamepad
  19246. */
  19247. id: string,
  19248. /**
  19249. * The index of the gamepad
  19250. */
  19251. index: number,
  19252. /**
  19253. * The browser gamepad
  19254. */
  19255. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19256. /**
  19257. * Callback triggered when the left joystick has changed
  19258. * @param callback
  19259. */
  19260. onleftstickchanged(callback: (values: StickValues) => void): void;
  19261. /**
  19262. * Callback triggered when the right joystick has changed
  19263. * @param callback
  19264. */
  19265. onrightstickchanged(callback: (values: StickValues) => void): void;
  19266. /**
  19267. * Gets the left joystick
  19268. */
  19269. get leftStick(): StickValues;
  19270. /**
  19271. * Sets the left joystick values
  19272. */
  19273. set leftStick(newValues: StickValues);
  19274. /**
  19275. * Gets the right joystick
  19276. */
  19277. get rightStick(): StickValues;
  19278. /**
  19279. * Sets the right joystick value
  19280. */
  19281. set rightStick(newValues: StickValues);
  19282. /**
  19283. * Updates the gamepad joystick positions
  19284. */
  19285. update(): void;
  19286. /**
  19287. * Disposes the gamepad
  19288. */
  19289. dispose(): void;
  19290. }
  19291. /**
  19292. * Represents a generic gamepad
  19293. */
  19294. export class GenericPad extends Gamepad {
  19295. private _buttons;
  19296. private _onbuttondown;
  19297. private _onbuttonup;
  19298. /**
  19299. * Observable triggered when a button has been pressed
  19300. */
  19301. onButtonDownObservable: Observable<number>;
  19302. /**
  19303. * Observable triggered when a button has been released
  19304. */
  19305. onButtonUpObservable: Observable<number>;
  19306. /**
  19307. * Callback triggered when a button has been pressed
  19308. * @param callback Called when a button has been pressed
  19309. */
  19310. onbuttondown(callback: (buttonPressed: number) => void): void;
  19311. /**
  19312. * Callback triggered when a button has been released
  19313. * @param callback Called when a button has been released
  19314. */
  19315. onbuttonup(callback: (buttonReleased: number) => void): void;
  19316. /**
  19317. * Initializes the generic gamepad
  19318. * @param id The id of the generic gamepad
  19319. * @param index The index of the generic gamepad
  19320. * @param browserGamepad The browser gamepad
  19321. */
  19322. constructor(id: string, index: number, browserGamepad: any);
  19323. private _setButtonValue;
  19324. /**
  19325. * Updates the generic gamepad
  19326. */
  19327. update(): void;
  19328. /**
  19329. * Disposes the generic gamepad
  19330. */
  19331. dispose(): void;
  19332. }
  19333. }
  19334. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19335. import { Observable } from "babylonjs/Misc/observable";
  19336. import { Nullable } from "babylonjs/types";
  19337. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19338. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19340. import { Ray } from "babylonjs/Culling/ray";
  19341. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19342. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19343. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19344. /**
  19345. * Defines the types of pose enabled controllers that are supported
  19346. */
  19347. export enum PoseEnabledControllerType {
  19348. /**
  19349. * HTC Vive
  19350. */
  19351. VIVE = 0,
  19352. /**
  19353. * Oculus Rift
  19354. */
  19355. OCULUS = 1,
  19356. /**
  19357. * Windows mixed reality
  19358. */
  19359. WINDOWS = 2,
  19360. /**
  19361. * Samsung gear VR
  19362. */
  19363. GEAR_VR = 3,
  19364. /**
  19365. * Google Daydream
  19366. */
  19367. DAYDREAM = 4,
  19368. /**
  19369. * Generic
  19370. */
  19371. GENERIC = 5
  19372. }
  19373. /**
  19374. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19375. */
  19376. export interface MutableGamepadButton {
  19377. /**
  19378. * Value of the button/trigger
  19379. */
  19380. value: number;
  19381. /**
  19382. * If the button/trigger is currently touched
  19383. */
  19384. touched: boolean;
  19385. /**
  19386. * If the button/trigger is currently pressed
  19387. */
  19388. pressed: boolean;
  19389. }
  19390. /**
  19391. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19392. * @hidden
  19393. */
  19394. export interface ExtendedGamepadButton extends GamepadButton {
  19395. /**
  19396. * If the button/trigger is currently pressed
  19397. */
  19398. readonly pressed: boolean;
  19399. /**
  19400. * If the button/trigger is currently touched
  19401. */
  19402. readonly touched: boolean;
  19403. /**
  19404. * Value of the button/trigger
  19405. */
  19406. readonly value: number;
  19407. }
  19408. /** @hidden */
  19409. export interface _GamePadFactory {
  19410. /**
  19411. * Returns whether or not the current gamepad can be created for this type of controller.
  19412. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19413. * @returns true if it can be created, otherwise false
  19414. */
  19415. canCreate(gamepadInfo: any): boolean;
  19416. /**
  19417. * Creates a new instance of the Gamepad.
  19418. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19419. * @returns the new gamepad instance
  19420. */
  19421. create(gamepadInfo: any): Gamepad;
  19422. }
  19423. /**
  19424. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19425. */
  19426. export class PoseEnabledControllerHelper {
  19427. /** @hidden */
  19428. static _ControllerFactories: _GamePadFactory[];
  19429. /** @hidden */
  19430. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19431. /**
  19432. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19433. * @param vrGamepad the gamepad to initialized
  19434. * @returns a vr controller of the type the gamepad identified as
  19435. */
  19436. static InitiateController(vrGamepad: any): Gamepad;
  19437. }
  19438. /**
  19439. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19440. */
  19441. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19442. /**
  19443. * If the controller is used in a webXR session
  19444. */
  19445. isXR: boolean;
  19446. private _deviceRoomPosition;
  19447. private _deviceRoomRotationQuaternion;
  19448. /**
  19449. * The device position in babylon space
  19450. */
  19451. devicePosition: Vector3;
  19452. /**
  19453. * The device rotation in babylon space
  19454. */
  19455. deviceRotationQuaternion: Quaternion;
  19456. /**
  19457. * The scale factor of the device in babylon space
  19458. */
  19459. deviceScaleFactor: number;
  19460. /**
  19461. * (Likely devicePosition should be used instead) The device position in its room space
  19462. */
  19463. position: Vector3;
  19464. /**
  19465. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19466. */
  19467. rotationQuaternion: Quaternion;
  19468. /**
  19469. * The type of controller (Eg. Windows mixed reality)
  19470. */
  19471. controllerType: PoseEnabledControllerType;
  19472. protected _calculatedPosition: Vector3;
  19473. private _calculatedRotation;
  19474. /**
  19475. * The raw pose from the device
  19476. */
  19477. rawPose: DevicePose;
  19478. private _trackPosition;
  19479. private _maxRotationDistFromHeadset;
  19480. private _draggedRoomRotation;
  19481. /**
  19482. * @hidden
  19483. */
  19484. _disableTrackPosition(fixedPosition: Vector3): void;
  19485. /**
  19486. * Internal, the mesh attached to the controller
  19487. * @hidden
  19488. */
  19489. _mesh: Nullable<AbstractMesh>;
  19490. private _poseControlledCamera;
  19491. private _leftHandSystemQuaternion;
  19492. /**
  19493. * Internal, matrix used to convert room space to babylon space
  19494. * @hidden
  19495. */
  19496. _deviceToWorld: Matrix;
  19497. /**
  19498. * Node to be used when casting a ray from the controller
  19499. * @hidden
  19500. */
  19501. _pointingPoseNode: Nullable<TransformNode>;
  19502. /**
  19503. * Name of the child mesh that can be used to cast a ray from the controller
  19504. */
  19505. static readonly POINTING_POSE: string;
  19506. /**
  19507. * Creates a new PoseEnabledController from a gamepad
  19508. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19509. */
  19510. constructor(browserGamepad: any);
  19511. private _workingMatrix;
  19512. /**
  19513. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19514. */
  19515. update(): void;
  19516. /**
  19517. * Updates only the pose device and mesh without doing any button event checking
  19518. */
  19519. protected _updatePoseAndMesh(): void;
  19520. /**
  19521. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19522. * @param poseData raw pose fromthe device
  19523. */
  19524. updateFromDevice(poseData: DevicePose): void;
  19525. /**
  19526. * @hidden
  19527. */
  19528. _meshAttachedObservable: Observable<AbstractMesh>;
  19529. /**
  19530. * Attaches a mesh to the controller
  19531. * @param mesh the mesh to be attached
  19532. */
  19533. attachToMesh(mesh: AbstractMesh): void;
  19534. /**
  19535. * Attaches the controllers mesh to a camera
  19536. * @param camera the camera the mesh should be attached to
  19537. */
  19538. attachToPoseControlledCamera(camera: TargetCamera): void;
  19539. /**
  19540. * Disposes of the controller
  19541. */
  19542. dispose(): void;
  19543. /**
  19544. * The mesh that is attached to the controller
  19545. */
  19546. get mesh(): Nullable<AbstractMesh>;
  19547. /**
  19548. * Gets the ray of the controller in the direction the controller is pointing
  19549. * @param length the length the resulting ray should be
  19550. * @returns a ray in the direction the controller is pointing
  19551. */
  19552. getForwardRay(length?: number): Ray;
  19553. }
  19554. }
  19555. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19556. import { Observable } from "babylonjs/Misc/observable";
  19557. import { Scene } from "babylonjs/scene";
  19558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19559. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19560. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19561. import { Nullable } from "babylonjs/types";
  19562. /**
  19563. * Defines the WebVRController object that represents controllers tracked in 3D space
  19564. */
  19565. export abstract class WebVRController extends PoseEnabledController {
  19566. /**
  19567. * Internal, the default controller model for the controller
  19568. */
  19569. protected _defaultModel: Nullable<AbstractMesh>;
  19570. /**
  19571. * Fired when the trigger state has changed
  19572. */
  19573. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19574. /**
  19575. * Fired when the main button state has changed
  19576. */
  19577. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19578. /**
  19579. * Fired when the secondary button state has changed
  19580. */
  19581. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19582. /**
  19583. * Fired when the pad state has changed
  19584. */
  19585. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19586. /**
  19587. * Fired when controllers stick values have changed
  19588. */
  19589. onPadValuesChangedObservable: Observable<StickValues>;
  19590. /**
  19591. * Array of button availible on the controller
  19592. */
  19593. protected _buttons: Array<MutableGamepadButton>;
  19594. private _onButtonStateChange;
  19595. /**
  19596. * Fired when a controller button's state has changed
  19597. * @param callback the callback containing the button that was modified
  19598. */
  19599. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19600. /**
  19601. * X and Y axis corresponding to the controllers joystick
  19602. */
  19603. pad: StickValues;
  19604. /**
  19605. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19606. */
  19607. hand: string;
  19608. /**
  19609. * The default controller model for the controller
  19610. */
  19611. get defaultModel(): Nullable<AbstractMesh>;
  19612. /**
  19613. * Creates a new WebVRController from a gamepad
  19614. * @param vrGamepad the gamepad that the WebVRController should be created from
  19615. */
  19616. constructor(vrGamepad: any);
  19617. /**
  19618. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19619. */
  19620. update(): void;
  19621. /**
  19622. * Function to be called when a button is modified
  19623. */
  19624. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19625. /**
  19626. * Loads a mesh and attaches it to the controller
  19627. * @param scene the scene the mesh should be added to
  19628. * @param meshLoaded callback for when the mesh has been loaded
  19629. */
  19630. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19631. private _setButtonValue;
  19632. private _changes;
  19633. private _checkChanges;
  19634. /**
  19635. * Disposes of th webVRCOntroller
  19636. */
  19637. dispose(): void;
  19638. }
  19639. }
  19640. declare module "babylonjs/Lights/hemisphericLight" {
  19641. import { Nullable } from "babylonjs/types";
  19642. import { Scene } from "babylonjs/scene";
  19643. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19644. import { Color3 } from "babylonjs/Maths/math.color";
  19645. import { Effect } from "babylonjs/Materials/effect";
  19646. import { Light } from "babylonjs/Lights/light";
  19647. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19648. /**
  19649. * The HemisphericLight simulates the ambient environment light,
  19650. * so the passed direction is the light reflection direction, not the incoming direction.
  19651. */
  19652. export class HemisphericLight extends Light {
  19653. /**
  19654. * The groundColor is the light in the opposite direction to the one specified during creation.
  19655. * 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.
  19656. */
  19657. groundColor: Color3;
  19658. /**
  19659. * The light reflection direction, not the incoming direction.
  19660. */
  19661. direction: Vector3;
  19662. /**
  19663. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19664. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19665. * The HemisphericLight can't cast shadows.
  19666. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19667. * @param name The friendly name of the light
  19668. * @param direction The direction of the light reflection
  19669. * @param scene The scene the light belongs to
  19670. */
  19671. constructor(name: string, direction: Vector3, scene: Scene);
  19672. protected _buildUniformLayout(): void;
  19673. /**
  19674. * Returns the string "HemisphericLight".
  19675. * @return The class name
  19676. */
  19677. getClassName(): string;
  19678. /**
  19679. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19680. * Returns the updated direction.
  19681. * @param target The target the direction should point to
  19682. * @return The computed direction
  19683. */
  19684. setDirectionToTarget(target: Vector3): Vector3;
  19685. /**
  19686. * Returns the shadow generator associated to the light.
  19687. * @returns Always null for hemispheric lights because it does not support shadows.
  19688. */
  19689. getShadowGenerator(): Nullable<IShadowGenerator>;
  19690. /**
  19691. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19692. * @param effect The effect to update
  19693. * @param lightIndex The index of the light in the effect to update
  19694. * @returns The hemispheric light
  19695. */
  19696. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19697. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19698. /**
  19699. * Computes the world matrix of the node
  19700. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19701. * @param useWasUpdatedFlag defines a reserved property
  19702. * @returns the world matrix
  19703. */
  19704. computeWorldMatrix(): Matrix;
  19705. /**
  19706. * Returns the integer 3.
  19707. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19708. */
  19709. getTypeID(): number;
  19710. /**
  19711. * Prepares the list of defines specific to the light type.
  19712. * @param defines the list of defines
  19713. * @param lightIndex defines the index of the light for the effect
  19714. */
  19715. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19716. }
  19717. }
  19718. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19719. /** @hidden */
  19720. export var vrMultiviewToSingleviewPixelShader: {
  19721. name: string;
  19722. shader: string;
  19723. };
  19724. }
  19725. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19727. import { Scene } from "babylonjs/scene";
  19728. /**
  19729. * Renders to multiple views with a single draw call
  19730. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19731. */
  19732. export class MultiviewRenderTarget extends RenderTargetTexture {
  19733. /**
  19734. * Creates a multiview render target
  19735. * @param scene scene used with the render target
  19736. * @param size the size of the render target (used for each view)
  19737. */
  19738. constructor(scene: Scene, size?: number | {
  19739. width: number;
  19740. height: number;
  19741. } | {
  19742. ratio: number;
  19743. });
  19744. /**
  19745. * @hidden
  19746. * @param faceIndex the face index, if its a cube texture
  19747. */
  19748. _bindFrameBuffer(faceIndex?: number): void;
  19749. /**
  19750. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19751. * @returns the view count
  19752. */
  19753. getViewCount(): number;
  19754. }
  19755. }
  19756. declare module "babylonjs/Maths/math.frustum" {
  19757. import { Matrix } from "babylonjs/Maths/math.vector";
  19758. import { DeepImmutable } from "babylonjs/types";
  19759. import { Plane } from "babylonjs/Maths/math.plane";
  19760. /**
  19761. * Represents a camera frustum
  19762. */
  19763. export class Frustum {
  19764. /**
  19765. * Gets the planes representing the frustum
  19766. * @param transform matrix to be applied to the returned planes
  19767. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19768. */
  19769. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19770. /**
  19771. * Gets the near frustum plane transformed by the transform matrix
  19772. * @param transform transformation matrix to be applied to the resulting frustum plane
  19773. * @param frustumPlane the resuling frustum plane
  19774. */
  19775. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19776. /**
  19777. * Gets the far frustum plane transformed by the transform matrix
  19778. * @param transform transformation matrix to be applied to the resulting frustum plane
  19779. * @param frustumPlane the resuling frustum plane
  19780. */
  19781. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19782. /**
  19783. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19788. /**
  19789. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19794. /**
  19795. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19800. /**
  19801. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19806. /**
  19807. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19808. * @param transform transformation matrix to be applied to the resulting frustum planes
  19809. * @param frustumPlanes the resuling frustum planes
  19810. */
  19811. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19812. }
  19813. }
  19814. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19815. import { Camera } from "babylonjs/Cameras/camera";
  19816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19817. import { Nullable } from "babylonjs/types";
  19818. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19819. import { Matrix } from "babylonjs/Maths/math.vector";
  19820. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19821. module "babylonjs/Engines/engine" {
  19822. interface Engine {
  19823. /**
  19824. * Creates a new multiview render target
  19825. * @param width defines the width of the texture
  19826. * @param height defines the height of the texture
  19827. * @returns the created multiview texture
  19828. */
  19829. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19830. /**
  19831. * Binds a multiview framebuffer to be drawn to
  19832. * @param multiviewTexture texture to bind
  19833. */
  19834. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19835. }
  19836. }
  19837. module "babylonjs/Cameras/camera" {
  19838. interface Camera {
  19839. /**
  19840. * @hidden
  19841. * 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)
  19842. */
  19843. _useMultiviewToSingleView: boolean;
  19844. /**
  19845. * @hidden
  19846. * 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)
  19847. */
  19848. _multiviewTexture: Nullable<RenderTargetTexture>;
  19849. /**
  19850. * @hidden
  19851. * ensures the multiview texture of the camera exists and has the specified width/height
  19852. * @param width height to set on the multiview texture
  19853. * @param height width to set on the multiview texture
  19854. */
  19855. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19856. }
  19857. }
  19858. module "babylonjs/scene" {
  19859. interface Scene {
  19860. /** @hidden */
  19861. _transformMatrixR: Matrix;
  19862. /** @hidden */
  19863. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19864. /** @hidden */
  19865. _createMultiviewUbo(): void;
  19866. /** @hidden */
  19867. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19868. /** @hidden */
  19869. _renderMultiviewToSingleView(camera: Camera): void;
  19870. }
  19871. }
  19872. }
  19873. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19874. import { Camera } from "babylonjs/Cameras/camera";
  19875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19876. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19877. import "babylonjs/Engines/Extensions/engine.multiview";
  19878. /**
  19879. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19880. * This will not be used for webXR as it supports displaying texture arrays directly
  19881. */
  19882. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19883. /**
  19884. * Initializes a VRMultiviewToSingleview
  19885. * @param name name of the post process
  19886. * @param camera camera to be applied to
  19887. * @param scaleFactor scaling factor to the size of the output texture
  19888. */
  19889. constructor(name: string, camera: Camera, scaleFactor: number);
  19890. }
  19891. }
  19892. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19893. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19894. import { Nullable } from "babylonjs/types";
  19895. import { Size } from "babylonjs/Maths/math.size";
  19896. import { Observable } from "babylonjs/Misc/observable";
  19897. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19898. /**
  19899. * Interface used to define additional presentation attributes
  19900. */
  19901. export interface IVRPresentationAttributes {
  19902. /**
  19903. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19904. */
  19905. highRefreshRate: boolean;
  19906. /**
  19907. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19908. */
  19909. foveationLevel: number;
  19910. }
  19911. module "babylonjs/Engines/engine" {
  19912. interface Engine {
  19913. /** @hidden */
  19914. _vrDisplay: any;
  19915. /** @hidden */
  19916. _vrSupported: boolean;
  19917. /** @hidden */
  19918. _oldSize: Size;
  19919. /** @hidden */
  19920. _oldHardwareScaleFactor: number;
  19921. /** @hidden */
  19922. _vrExclusivePointerMode: boolean;
  19923. /** @hidden */
  19924. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19925. /** @hidden */
  19926. _onVRDisplayPointerRestricted: () => void;
  19927. /** @hidden */
  19928. _onVRDisplayPointerUnrestricted: () => void;
  19929. /** @hidden */
  19930. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19931. /** @hidden */
  19932. _onVrDisplayDisconnect: Nullable<() => void>;
  19933. /** @hidden */
  19934. _onVrDisplayPresentChange: Nullable<() => void>;
  19935. /**
  19936. * Observable signaled when VR display mode changes
  19937. */
  19938. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19939. /**
  19940. * Observable signaled when VR request present is complete
  19941. */
  19942. onVRRequestPresentComplete: Observable<boolean>;
  19943. /**
  19944. * Observable signaled when VR request present starts
  19945. */
  19946. onVRRequestPresentStart: Observable<Engine>;
  19947. /**
  19948. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19949. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19950. */
  19951. isInVRExclusivePointerMode: boolean;
  19952. /**
  19953. * Gets a boolean indicating if a webVR device was detected
  19954. * @returns true if a webVR device was detected
  19955. */
  19956. isVRDevicePresent(): boolean;
  19957. /**
  19958. * Gets the current webVR device
  19959. * @returns the current webVR device (or null)
  19960. */
  19961. getVRDevice(): any;
  19962. /**
  19963. * Initializes a webVR display and starts listening to display change events
  19964. * The onVRDisplayChangedObservable will be notified upon these changes
  19965. * @returns A promise containing a VRDisplay and if vr is supported
  19966. */
  19967. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19968. /** @hidden */
  19969. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19970. /**
  19971. * Gets or sets the presentation attributes used to configure VR rendering
  19972. */
  19973. vrPresentationAttributes?: IVRPresentationAttributes;
  19974. /**
  19975. * Call this function to switch to webVR mode
  19976. * Will do nothing if webVR is not supported or if there is no webVR device
  19977. * @param options the webvr options provided to the camera. mainly used for multiview
  19978. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19979. */
  19980. enableVR(options: WebVROptions): void;
  19981. /** @hidden */
  19982. _onVRFullScreenTriggered(): void;
  19983. }
  19984. }
  19985. }
  19986. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19987. import { Nullable } from "babylonjs/types";
  19988. import { Observable } from "babylonjs/Misc/observable";
  19989. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19990. import { Scene } from "babylonjs/scene";
  19991. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19992. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19993. import { Node } from "babylonjs/node";
  19994. import { Ray } from "babylonjs/Culling/ray";
  19995. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19996. import "babylonjs/Engines/Extensions/engine.webVR";
  19997. /**
  19998. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19999. * IMPORTANT!! The data is right-hand data.
  20000. * @export
  20001. * @interface DevicePose
  20002. */
  20003. export interface DevicePose {
  20004. /**
  20005. * The position of the device, values in array are [x,y,z].
  20006. */
  20007. readonly position: Nullable<Float32Array>;
  20008. /**
  20009. * The linearVelocity of the device, values in array are [x,y,z].
  20010. */
  20011. readonly linearVelocity: Nullable<Float32Array>;
  20012. /**
  20013. * The linearAcceleration of the device, values in array are [x,y,z].
  20014. */
  20015. readonly linearAcceleration: Nullable<Float32Array>;
  20016. /**
  20017. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20018. */
  20019. readonly orientation: Nullable<Float32Array>;
  20020. /**
  20021. * The angularVelocity of the device, values in array are [x,y,z].
  20022. */
  20023. readonly angularVelocity: Nullable<Float32Array>;
  20024. /**
  20025. * The angularAcceleration of the device, values in array are [x,y,z].
  20026. */
  20027. readonly angularAcceleration: Nullable<Float32Array>;
  20028. }
  20029. /**
  20030. * Interface representing a pose controlled object in Babylon.
  20031. * A pose controlled object has both regular pose values as well as pose values
  20032. * from an external device such as a VR head mounted display
  20033. */
  20034. export interface PoseControlled {
  20035. /**
  20036. * The position of the object in babylon space.
  20037. */
  20038. position: Vector3;
  20039. /**
  20040. * The rotation quaternion of the object in babylon space.
  20041. */
  20042. rotationQuaternion: Quaternion;
  20043. /**
  20044. * The position of the device in babylon space.
  20045. */
  20046. devicePosition?: Vector3;
  20047. /**
  20048. * The rotation quaternion of the device in babylon space.
  20049. */
  20050. deviceRotationQuaternion: Quaternion;
  20051. /**
  20052. * The raw pose coming from the device.
  20053. */
  20054. rawPose: Nullable<DevicePose>;
  20055. /**
  20056. * The scale of the device to be used when translating from device space to babylon space.
  20057. */
  20058. deviceScaleFactor: number;
  20059. /**
  20060. * Updates the poseControlled values based on the input device pose.
  20061. * @param poseData the pose data to update the object with
  20062. */
  20063. updateFromDevice(poseData: DevicePose): void;
  20064. }
  20065. /**
  20066. * Set of options to customize the webVRCamera
  20067. */
  20068. export interface WebVROptions {
  20069. /**
  20070. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20071. */
  20072. trackPosition?: boolean;
  20073. /**
  20074. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20075. */
  20076. positionScale?: number;
  20077. /**
  20078. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20079. */
  20080. displayName?: string;
  20081. /**
  20082. * Should the native controller meshes be initialized. (default: true)
  20083. */
  20084. controllerMeshes?: boolean;
  20085. /**
  20086. * Creating a default HemiLight only on controllers. (default: true)
  20087. */
  20088. defaultLightingOnControllers?: boolean;
  20089. /**
  20090. * If you don't want to use the default VR button of the helper. (default: false)
  20091. */
  20092. useCustomVRButton?: boolean;
  20093. /**
  20094. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20095. */
  20096. customVRButton?: HTMLButtonElement;
  20097. /**
  20098. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20099. */
  20100. rayLength?: number;
  20101. /**
  20102. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20103. */
  20104. defaultHeight?: number;
  20105. /**
  20106. * If multiview should be used if availible (default: false)
  20107. */
  20108. useMultiview?: boolean;
  20109. }
  20110. /**
  20111. * This represents a WebVR camera.
  20112. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20113. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20114. */
  20115. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20116. private webVROptions;
  20117. /**
  20118. * @hidden
  20119. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20120. */
  20121. _vrDevice: any;
  20122. /**
  20123. * The rawPose of the vrDevice.
  20124. */
  20125. rawPose: Nullable<DevicePose>;
  20126. private _onVREnabled;
  20127. private _specsVersion;
  20128. private _attached;
  20129. private _frameData;
  20130. protected _descendants: Array<Node>;
  20131. private _deviceRoomPosition;
  20132. /** @hidden */
  20133. _deviceRoomRotationQuaternion: Quaternion;
  20134. private _standingMatrix;
  20135. /**
  20136. * Represents device position in babylon space.
  20137. */
  20138. devicePosition: Vector3;
  20139. /**
  20140. * Represents device rotation in babylon space.
  20141. */
  20142. deviceRotationQuaternion: Quaternion;
  20143. /**
  20144. * The scale of the device to be used when translating from device space to babylon space.
  20145. */
  20146. deviceScaleFactor: number;
  20147. private _deviceToWorld;
  20148. private _worldToDevice;
  20149. /**
  20150. * References to the webVR controllers for the vrDevice.
  20151. */
  20152. controllers: Array<WebVRController>;
  20153. /**
  20154. * Emits an event when a controller is attached.
  20155. */
  20156. onControllersAttachedObservable: Observable<WebVRController[]>;
  20157. /**
  20158. * Emits an event when a controller's mesh has been loaded;
  20159. */
  20160. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20161. /**
  20162. * Emits an event when the HMD's pose has been updated.
  20163. */
  20164. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20165. private _poseSet;
  20166. /**
  20167. * If the rig cameras be used as parent instead of this camera.
  20168. */
  20169. rigParenting: boolean;
  20170. private _lightOnControllers;
  20171. private _defaultHeight?;
  20172. /**
  20173. * Instantiates a WebVRFreeCamera.
  20174. * @param name The name of the WebVRFreeCamera
  20175. * @param position The starting anchor position for the camera
  20176. * @param scene The scene the camera belongs to
  20177. * @param webVROptions a set of customizable options for the webVRCamera
  20178. */
  20179. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20180. /**
  20181. * Gets the device distance from the ground in meters.
  20182. * @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.
  20183. */
  20184. deviceDistanceToRoomGround(): number;
  20185. /**
  20186. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20187. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20188. */
  20189. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20190. /**
  20191. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20192. * @returns A promise with a boolean set to if the standing matrix is supported.
  20193. */
  20194. useStandingMatrixAsync(): Promise<boolean>;
  20195. /**
  20196. * Disposes the camera
  20197. */
  20198. dispose(): void;
  20199. /**
  20200. * Gets a vrController by name.
  20201. * @param name The name of the controller to retreive
  20202. * @returns the controller matching the name specified or null if not found
  20203. */
  20204. getControllerByName(name: string): Nullable<WebVRController>;
  20205. private _leftController;
  20206. /**
  20207. * The controller corresponding to the users left hand.
  20208. */
  20209. get leftController(): Nullable<WebVRController>;
  20210. private _rightController;
  20211. /**
  20212. * The controller corresponding to the users right hand.
  20213. */
  20214. get rightController(): Nullable<WebVRController>;
  20215. /**
  20216. * Casts a ray forward from the vrCamera's gaze.
  20217. * @param length Length of the ray (default: 100)
  20218. * @returns the ray corresponding to the gaze
  20219. */
  20220. getForwardRay(length?: number): Ray;
  20221. /**
  20222. * @hidden
  20223. * Updates the camera based on device's frame data
  20224. */
  20225. _checkInputs(): void;
  20226. /**
  20227. * Updates the poseControlled values based on the input device pose.
  20228. * @param poseData Pose coming from the device
  20229. */
  20230. updateFromDevice(poseData: DevicePose): void;
  20231. private _htmlElementAttached;
  20232. private _detachIfAttached;
  20233. /**
  20234. * WebVR's attach control will start broadcasting frames to the device.
  20235. * Note that in certain browsers (chrome for example) this function must be called
  20236. * within a user-interaction callback. Example:
  20237. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20238. *
  20239. * @param element html element to attach the vrDevice to
  20240. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20241. */
  20242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20243. /**
  20244. * Detaches the camera from the html element and disables VR
  20245. *
  20246. * @param element html element to detach from
  20247. */
  20248. detachControl(element: HTMLElement): void;
  20249. /**
  20250. * @returns the name of this class
  20251. */
  20252. getClassName(): string;
  20253. /**
  20254. * Calls resetPose on the vrDisplay
  20255. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20256. */
  20257. resetToCurrentRotation(): void;
  20258. /**
  20259. * @hidden
  20260. * Updates the rig cameras (left and right eye)
  20261. */
  20262. _updateRigCameras(): void;
  20263. private _workingVector;
  20264. private _oneVector;
  20265. private _workingMatrix;
  20266. private updateCacheCalled;
  20267. private _correctPositionIfNotTrackPosition;
  20268. /**
  20269. * @hidden
  20270. * Updates the cached values of the camera
  20271. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20272. */
  20273. _updateCache(ignoreParentClass?: boolean): void;
  20274. /**
  20275. * @hidden
  20276. * Get current device position in babylon world
  20277. */
  20278. _computeDevicePosition(): void;
  20279. /**
  20280. * Updates the current device position and rotation in the babylon world
  20281. */
  20282. update(): void;
  20283. /**
  20284. * @hidden
  20285. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20286. * @returns an identity matrix
  20287. */
  20288. _getViewMatrix(): Matrix;
  20289. private _tmpMatrix;
  20290. /**
  20291. * This function is called by the two RIG cameras.
  20292. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20293. * @hidden
  20294. */
  20295. _getWebVRViewMatrix(): Matrix;
  20296. /** @hidden */
  20297. _getWebVRProjectionMatrix(): Matrix;
  20298. private _onGamepadConnectedObserver;
  20299. private _onGamepadDisconnectedObserver;
  20300. private _updateCacheWhenTrackingDisabledObserver;
  20301. /**
  20302. * Initializes the controllers and their meshes
  20303. */
  20304. initControllers(): void;
  20305. }
  20306. }
  20307. declare module "babylonjs/PostProcesses/postProcess" {
  20308. import { Nullable } from "babylonjs/types";
  20309. import { SmartArray } from "babylonjs/Misc/smartArray";
  20310. import { Observable } from "babylonjs/Misc/observable";
  20311. import { Vector2 } from "babylonjs/Maths/math.vector";
  20312. import { Camera } from "babylonjs/Cameras/camera";
  20313. import { Effect } from "babylonjs/Materials/effect";
  20314. import "babylonjs/Shaders/postprocess.vertex";
  20315. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20316. import { Engine } from "babylonjs/Engines/engine";
  20317. import { Color4 } from "babylonjs/Maths/math.color";
  20318. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20319. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20320. /**
  20321. * Size options for a post process
  20322. */
  20323. export type PostProcessOptions = {
  20324. width: number;
  20325. height: number;
  20326. };
  20327. /**
  20328. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20329. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20330. */
  20331. export class PostProcess {
  20332. /** Name of the PostProcess. */
  20333. name: string;
  20334. /**
  20335. * Gets or sets the unique id of the post process
  20336. */
  20337. uniqueId: number;
  20338. /**
  20339. * Width of the texture to apply the post process on
  20340. */
  20341. width: number;
  20342. /**
  20343. * Height of the texture to apply the post process on
  20344. */
  20345. height: number;
  20346. /**
  20347. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20348. * @hidden
  20349. */
  20350. _outputTexture: Nullable<InternalTexture>;
  20351. /**
  20352. * Sampling mode used by the shader
  20353. * See https://doc.babylonjs.com/classes/3.1/texture
  20354. */
  20355. renderTargetSamplingMode: number;
  20356. /**
  20357. * Clear color to use when screen clearing
  20358. */
  20359. clearColor: Color4;
  20360. /**
  20361. * If the buffer needs to be cleared before applying the post process. (default: true)
  20362. * Should be set to false if shader will overwrite all previous pixels.
  20363. */
  20364. autoClear: boolean;
  20365. /**
  20366. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20367. */
  20368. alphaMode: number;
  20369. /**
  20370. * Sets the setAlphaBlendConstants of the babylon engine
  20371. */
  20372. alphaConstants: Color4;
  20373. /**
  20374. * Animations to be used for the post processing
  20375. */
  20376. animations: import("babylonjs/Animations/animation").Animation[];
  20377. /**
  20378. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20379. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20380. */
  20381. enablePixelPerfectMode: boolean;
  20382. /**
  20383. * Force the postprocess to be applied without taking in account viewport
  20384. */
  20385. forceFullscreenViewport: boolean;
  20386. /**
  20387. * List of inspectable custom properties (used by the Inspector)
  20388. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20389. */
  20390. inspectableCustomProperties: IInspectable[];
  20391. /**
  20392. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20393. *
  20394. * | Value | Type | Description |
  20395. * | ----- | ----------------------------------- | ----------- |
  20396. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20397. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20398. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20399. *
  20400. */
  20401. scaleMode: number;
  20402. /**
  20403. * Force textures to be a power of two (default: false)
  20404. */
  20405. alwaysForcePOT: boolean;
  20406. private _samples;
  20407. /**
  20408. * Number of sample textures (default: 1)
  20409. */
  20410. get samples(): number;
  20411. set samples(n: number);
  20412. /**
  20413. * Modify the scale of the post process to be the same as the viewport (default: false)
  20414. */
  20415. adaptScaleToCurrentViewport: boolean;
  20416. private _camera;
  20417. private _scene;
  20418. private _engine;
  20419. private _options;
  20420. private _reusable;
  20421. private _textureType;
  20422. private _textureFormat;
  20423. /**
  20424. * Smart array of input and output textures for the post process.
  20425. * @hidden
  20426. */
  20427. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20428. /**
  20429. * The index in _textures that corresponds to the output texture.
  20430. * @hidden
  20431. */
  20432. _currentRenderTextureInd: number;
  20433. private _effect;
  20434. private _samplers;
  20435. private _fragmentUrl;
  20436. private _vertexUrl;
  20437. private _parameters;
  20438. private _scaleRatio;
  20439. protected _indexParameters: any;
  20440. private _shareOutputWithPostProcess;
  20441. private _texelSize;
  20442. private _forcedOutputTexture;
  20443. /**
  20444. * Returns the fragment url or shader name used in the post process.
  20445. * @returns the fragment url or name in the shader store.
  20446. */
  20447. getEffectName(): string;
  20448. /**
  20449. * An event triggered when the postprocess is activated.
  20450. */
  20451. onActivateObservable: Observable<Camera>;
  20452. private _onActivateObserver;
  20453. /**
  20454. * A function that is added to the onActivateObservable
  20455. */
  20456. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20457. /**
  20458. * An event triggered when the postprocess changes its size.
  20459. */
  20460. onSizeChangedObservable: Observable<PostProcess>;
  20461. private _onSizeChangedObserver;
  20462. /**
  20463. * A function that is added to the onSizeChangedObservable
  20464. */
  20465. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20466. /**
  20467. * An event triggered when the postprocess applies its effect.
  20468. */
  20469. onApplyObservable: Observable<Effect>;
  20470. private _onApplyObserver;
  20471. /**
  20472. * A function that is added to the onApplyObservable
  20473. */
  20474. set onApply(callback: (effect: Effect) => void);
  20475. /**
  20476. * An event triggered before rendering the postprocess
  20477. */
  20478. onBeforeRenderObservable: Observable<Effect>;
  20479. private _onBeforeRenderObserver;
  20480. /**
  20481. * A function that is added to the onBeforeRenderObservable
  20482. */
  20483. set onBeforeRender(callback: (effect: Effect) => void);
  20484. /**
  20485. * An event triggered after rendering the postprocess
  20486. */
  20487. onAfterRenderObservable: Observable<Effect>;
  20488. private _onAfterRenderObserver;
  20489. /**
  20490. * A function that is added to the onAfterRenderObservable
  20491. */
  20492. set onAfterRender(callback: (efect: Effect) => void);
  20493. /**
  20494. * 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
  20495. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20496. */
  20497. get inputTexture(): InternalTexture;
  20498. set inputTexture(value: InternalTexture);
  20499. /**
  20500. * Gets the camera which post process is applied to.
  20501. * @returns The camera the post process is applied to.
  20502. */
  20503. getCamera(): Camera;
  20504. /**
  20505. * Gets the texel size of the postprocess.
  20506. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20507. */
  20508. get texelSize(): Vector2;
  20509. /**
  20510. * Creates a new instance PostProcess
  20511. * @param name The name of the PostProcess.
  20512. * @param fragmentUrl The url of the fragment shader to be used.
  20513. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20514. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20515. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20516. * @param camera The camera to apply the render pass to.
  20517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20518. * @param engine The engine which the post process will be applied. (default: current engine)
  20519. * @param reusable If the post process can be reused on the same frame. (default: false)
  20520. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20521. * @param textureType Type of textures used when performing the post process. (default: 0)
  20522. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20523. * @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
  20524. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20525. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20526. */
  20527. constructor(
  20528. /** Name of the PostProcess. */
  20529. 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);
  20530. /**
  20531. * Gets a string idenfifying the name of the class
  20532. * @returns "PostProcess" string
  20533. */
  20534. getClassName(): string;
  20535. /**
  20536. * Gets the engine which this post process belongs to.
  20537. * @returns The engine the post process was enabled with.
  20538. */
  20539. getEngine(): Engine;
  20540. /**
  20541. * The effect that is created when initializing the post process.
  20542. * @returns The created effect corresponding the the postprocess.
  20543. */
  20544. getEffect(): Effect;
  20545. /**
  20546. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20547. * @param postProcess The post process to share the output with.
  20548. * @returns This post process.
  20549. */
  20550. shareOutputWith(postProcess: PostProcess): PostProcess;
  20551. /**
  20552. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20553. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20554. */
  20555. useOwnOutput(): void;
  20556. /**
  20557. * Updates the effect with the current post process compile time values and recompiles the shader.
  20558. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20559. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20560. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20561. * @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
  20562. * @param onCompiled Called when the shader has been compiled.
  20563. * @param onError Called if there is an error when compiling a shader.
  20564. */
  20565. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20566. /**
  20567. * The post process is reusable if it can be used multiple times within one frame.
  20568. * @returns If the post process is reusable
  20569. */
  20570. isReusable(): boolean;
  20571. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20572. markTextureDirty(): void;
  20573. /**
  20574. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20575. * 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.
  20576. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20577. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20578. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20579. * @returns The target texture that was bound to be written to.
  20580. */
  20581. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20582. /**
  20583. * If the post process is supported.
  20584. */
  20585. get isSupported(): boolean;
  20586. /**
  20587. * The aspect ratio of the output texture.
  20588. */
  20589. get aspectRatio(): number;
  20590. /**
  20591. * Get a value indicating if the post-process is ready to be used
  20592. * @returns true if the post-process is ready (shader is compiled)
  20593. */
  20594. isReady(): boolean;
  20595. /**
  20596. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20597. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20598. */
  20599. apply(): Nullable<Effect>;
  20600. private _disposeTextures;
  20601. /**
  20602. * Disposes the post process.
  20603. * @param camera The camera to dispose the post process on.
  20604. */
  20605. dispose(camera?: Camera): void;
  20606. }
  20607. }
  20608. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20609. /** @hidden */
  20610. export var kernelBlurVaryingDeclaration: {
  20611. name: string;
  20612. shader: string;
  20613. };
  20614. }
  20615. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20616. /** @hidden */
  20617. export var kernelBlurFragment: {
  20618. name: string;
  20619. shader: string;
  20620. };
  20621. }
  20622. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20623. /** @hidden */
  20624. export var kernelBlurFragment2: {
  20625. name: string;
  20626. shader: string;
  20627. };
  20628. }
  20629. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20630. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20631. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20632. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20633. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20634. /** @hidden */
  20635. export var kernelBlurPixelShader: {
  20636. name: string;
  20637. shader: string;
  20638. };
  20639. }
  20640. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20641. /** @hidden */
  20642. export var kernelBlurVertex: {
  20643. name: string;
  20644. shader: string;
  20645. };
  20646. }
  20647. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20648. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20649. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20650. /** @hidden */
  20651. export var kernelBlurVertexShader: {
  20652. name: string;
  20653. shader: string;
  20654. };
  20655. }
  20656. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20657. import { Vector2 } from "babylonjs/Maths/math.vector";
  20658. import { Nullable } from "babylonjs/types";
  20659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20660. import { Camera } from "babylonjs/Cameras/camera";
  20661. import { Effect } from "babylonjs/Materials/effect";
  20662. import { Engine } from "babylonjs/Engines/engine";
  20663. import "babylonjs/Shaders/kernelBlur.fragment";
  20664. import "babylonjs/Shaders/kernelBlur.vertex";
  20665. /**
  20666. * The Blur Post Process which blurs an image based on a kernel and direction.
  20667. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20668. */
  20669. export class BlurPostProcess extends PostProcess {
  20670. /** The direction in which to blur the image. */
  20671. direction: Vector2;
  20672. private blockCompilation;
  20673. protected _kernel: number;
  20674. protected _idealKernel: number;
  20675. protected _packedFloat: boolean;
  20676. private _staticDefines;
  20677. /**
  20678. * Sets the length in pixels of the blur sample region
  20679. */
  20680. set kernel(v: number);
  20681. /**
  20682. * Gets the length in pixels of the blur sample region
  20683. */
  20684. get kernel(): number;
  20685. /**
  20686. * Sets wether or not the blur needs to unpack/repack floats
  20687. */
  20688. set packedFloat(v: boolean);
  20689. /**
  20690. * Gets wether or not the blur is unpacking/repacking floats
  20691. */
  20692. get packedFloat(): boolean;
  20693. /**
  20694. * Creates a new instance BlurPostProcess
  20695. * @param name The name of the effect.
  20696. * @param direction The direction in which to blur the image.
  20697. * @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.
  20698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20699. * @param camera The camera to apply the render pass to.
  20700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20701. * @param engine The engine which the post process will be applied. (default: current engine)
  20702. * @param reusable If the post process can be reused on the same frame. (default: false)
  20703. * @param textureType Type of textures used when performing the post process. (default: 0)
  20704. * @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)
  20705. */
  20706. constructor(name: string,
  20707. /** The direction in which to blur the image. */
  20708. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20709. /**
  20710. * Updates the effect with the current post process compile time values and recompiles the shader.
  20711. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20712. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20713. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20714. * @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
  20715. * @param onCompiled Called when the shader has been compiled.
  20716. * @param onError Called if there is an error when compiling a shader.
  20717. */
  20718. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20719. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20720. /**
  20721. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20722. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20723. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20724. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20725. * The gaps between physical kernels are compensated for in the weighting of the samples
  20726. * @param idealKernel Ideal blur kernel.
  20727. * @return Nearest best kernel.
  20728. */
  20729. protected _nearestBestKernel(idealKernel: number): number;
  20730. /**
  20731. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20732. * @param x The point on the Gaussian distribution to sample.
  20733. * @return the value of the Gaussian function at x.
  20734. */
  20735. protected _gaussianWeight(x: number): number;
  20736. /**
  20737. * Generates a string that can be used as a floating point number in GLSL.
  20738. * @param x Value to print.
  20739. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20740. * @return GLSL float string.
  20741. */
  20742. protected _glslFloat(x: number, decimalFigures?: number): string;
  20743. }
  20744. }
  20745. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20746. import { Scene } from "babylonjs/scene";
  20747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20748. import { Plane } from "babylonjs/Maths/math.plane";
  20749. /**
  20750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20752. * You can then easily use it as a reflectionTexture on a flat surface.
  20753. * In case the surface is not a plane, please consider relying on reflection probes.
  20754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20755. */
  20756. export class MirrorTexture extends RenderTargetTexture {
  20757. private scene;
  20758. /**
  20759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20760. * 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.
  20761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20762. */
  20763. mirrorPlane: Plane;
  20764. /**
  20765. * Define the blur ratio used to blur the reflection if needed.
  20766. */
  20767. set blurRatio(value: number);
  20768. get blurRatio(): number;
  20769. /**
  20770. * Define the adaptive blur kernel used to blur the reflection if needed.
  20771. * This will autocompute the closest best match for the `blurKernel`
  20772. */
  20773. set adaptiveBlurKernel(value: number);
  20774. /**
  20775. * Define the blur kernel used to blur the reflection if needed.
  20776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20777. */
  20778. set blurKernel(value: number);
  20779. /**
  20780. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20781. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20782. */
  20783. set blurKernelX(value: number);
  20784. get blurKernelX(): number;
  20785. /**
  20786. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20787. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20788. */
  20789. set blurKernelY(value: number);
  20790. get blurKernelY(): number;
  20791. private _autoComputeBlurKernel;
  20792. protected _onRatioRescale(): void;
  20793. private _updateGammaSpace;
  20794. private _imageProcessingConfigChangeObserver;
  20795. private _transformMatrix;
  20796. private _mirrorMatrix;
  20797. private _savedViewMatrix;
  20798. private _blurX;
  20799. private _blurY;
  20800. private _adaptiveBlurKernel;
  20801. private _blurKernelX;
  20802. private _blurKernelY;
  20803. private _blurRatio;
  20804. /**
  20805. * Instantiates a Mirror Texture.
  20806. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20807. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20808. * You can then easily use it as a reflectionTexture on a flat surface.
  20809. * In case the surface is not a plane, please consider relying on reflection probes.
  20810. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20811. * @param name
  20812. * @param size
  20813. * @param scene
  20814. * @param generateMipMaps
  20815. * @param type
  20816. * @param samplingMode
  20817. * @param generateDepthBuffer
  20818. */
  20819. constructor(name: string, size: number | {
  20820. width: number;
  20821. height: number;
  20822. } | {
  20823. ratio: number;
  20824. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20825. private _preparePostProcesses;
  20826. /**
  20827. * Clone the mirror texture.
  20828. * @returns the cloned texture
  20829. */
  20830. clone(): MirrorTexture;
  20831. /**
  20832. * Serialize the texture to a JSON representation you could use in Parse later on
  20833. * @returns the serialized JSON representation
  20834. */
  20835. serialize(): any;
  20836. /**
  20837. * Dispose the texture and release its associated resources.
  20838. */
  20839. dispose(): void;
  20840. }
  20841. }
  20842. declare module "babylonjs/Materials/Textures/texture" {
  20843. import { Observable } from "babylonjs/Misc/observable";
  20844. import { Nullable } from "babylonjs/types";
  20845. import { Matrix } from "babylonjs/Maths/math.vector";
  20846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20847. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20848. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20849. import { Scene } from "babylonjs/scene";
  20850. /**
  20851. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20852. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20853. */
  20854. export class Texture extends BaseTexture {
  20855. /**
  20856. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20857. */
  20858. static SerializeBuffers: boolean;
  20859. /** @hidden */
  20860. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20861. /** @hidden */
  20862. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20863. /** @hidden */
  20864. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20865. /** nearest is mag = nearest and min = nearest and mip = linear */
  20866. static readonly NEAREST_SAMPLINGMODE: number;
  20867. /** nearest is mag = nearest and min = nearest and mip = linear */
  20868. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20870. static readonly BILINEAR_SAMPLINGMODE: number;
  20871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20872. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20873. /** Trilinear is mag = linear and min = linear and mip = linear */
  20874. static readonly TRILINEAR_SAMPLINGMODE: number;
  20875. /** Trilinear is mag = linear and min = linear and mip = linear */
  20876. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20877. /** mag = nearest and min = nearest and mip = nearest */
  20878. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20879. /** mag = nearest and min = linear and mip = nearest */
  20880. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20881. /** mag = nearest and min = linear and mip = linear */
  20882. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20883. /** mag = nearest and min = linear and mip = none */
  20884. static readonly NEAREST_LINEAR: number;
  20885. /** mag = nearest and min = nearest and mip = none */
  20886. static readonly NEAREST_NEAREST: number;
  20887. /** mag = linear and min = nearest and mip = nearest */
  20888. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20889. /** mag = linear and min = nearest and mip = linear */
  20890. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20891. /** mag = linear and min = linear and mip = none */
  20892. static readonly LINEAR_LINEAR: number;
  20893. /** mag = linear and min = nearest and mip = none */
  20894. static readonly LINEAR_NEAREST: number;
  20895. /** Explicit coordinates mode */
  20896. static readonly EXPLICIT_MODE: number;
  20897. /** Spherical coordinates mode */
  20898. static readonly SPHERICAL_MODE: number;
  20899. /** Planar coordinates mode */
  20900. static readonly PLANAR_MODE: number;
  20901. /** Cubic coordinates mode */
  20902. static readonly CUBIC_MODE: number;
  20903. /** Projection coordinates mode */
  20904. static readonly PROJECTION_MODE: number;
  20905. /** Inverse Cubic coordinates mode */
  20906. static readonly SKYBOX_MODE: number;
  20907. /** Inverse Cubic coordinates mode */
  20908. static readonly INVCUBIC_MODE: number;
  20909. /** Equirectangular coordinates mode */
  20910. static readonly EQUIRECTANGULAR_MODE: number;
  20911. /** Equirectangular Fixed coordinates mode */
  20912. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20913. /** Equirectangular Fixed Mirrored coordinates mode */
  20914. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20915. /** Texture is not repeating outside of 0..1 UVs */
  20916. static readonly CLAMP_ADDRESSMODE: number;
  20917. /** Texture is repeating outside of 0..1 UVs */
  20918. static readonly WRAP_ADDRESSMODE: number;
  20919. /** Texture is repeating and mirrored */
  20920. static readonly MIRROR_ADDRESSMODE: number;
  20921. /**
  20922. * 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
  20923. */
  20924. static UseSerializedUrlIfAny: boolean;
  20925. /**
  20926. * Define the url of the texture.
  20927. */
  20928. url: Nullable<string>;
  20929. /**
  20930. * Define an offset on the texture to offset the u coordinates of the UVs
  20931. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20932. */
  20933. uOffset: number;
  20934. /**
  20935. * Define an offset on the texture to offset the v coordinates of the UVs
  20936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20937. */
  20938. vOffset: number;
  20939. /**
  20940. * Define an offset on the texture to scale the u coordinates of the UVs
  20941. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20942. */
  20943. uScale: number;
  20944. /**
  20945. * Define an offset on the texture to scale the v coordinates of the UVs
  20946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20947. */
  20948. vScale: number;
  20949. /**
  20950. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20951. * @see http://doc.babylonjs.com/how_to/more_materials
  20952. */
  20953. uAng: number;
  20954. /**
  20955. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20956. * @see http://doc.babylonjs.com/how_to/more_materials
  20957. */
  20958. vAng: number;
  20959. /**
  20960. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20961. * @see http://doc.babylonjs.com/how_to/more_materials
  20962. */
  20963. wAng: number;
  20964. /**
  20965. * Defines the center of rotation (U)
  20966. */
  20967. uRotationCenter: number;
  20968. /**
  20969. * Defines the center of rotation (V)
  20970. */
  20971. vRotationCenter: number;
  20972. /**
  20973. * Defines the center of rotation (W)
  20974. */
  20975. wRotationCenter: number;
  20976. /**
  20977. * Are mip maps generated for this texture or not.
  20978. */
  20979. get noMipmap(): boolean;
  20980. /**
  20981. * List of inspectable custom properties (used by the Inspector)
  20982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20983. */
  20984. inspectableCustomProperties: Nullable<IInspectable[]>;
  20985. private _noMipmap;
  20986. /** @hidden */
  20987. _invertY: boolean;
  20988. private _rowGenerationMatrix;
  20989. private _cachedTextureMatrix;
  20990. private _projectionModeMatrix;
  20991. private _t0;
  20992. private _t1;
  20993. private _t2;
  20994. private _cachedUOffset;
  20995. private _cachedVOffset;
  20996. private _cachedUScale;
  20997. private _cachedVScale;
  20998. private _cachedUAng;
  20999. private _cachedVAng;
  21000. private _cachedWAng;
  21001. private _cachedProjectionMatrixId;
  21002. private _cachedCoordinatesMode;
  21003. /** @hidden */
  21004. protected _initialSamplingMode: number;
  21005. /** @hidden */
  21006. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21007. private _deleteBuffer;
  21008. protected _format: Nullable<number>;
  21009. private _delayedOnLoad;
  21010. private _delayedOnError;
  21011. private _mimeType?;
  21012. /**
  21013. * Observable triggered once the texture has been loaded.
  21014. */
  21015. onLoadObservable: Observable<Texture>;
  21016. protected _isBlocking: boolean;
  21017. /**
  21018. * Is the texture preventing material to render while loading.
  21019. * If false, a default texture will be used instead of the loading one during the preparation step.
  21020. */
  21021. set isBlocking(value: boolean);
  21022. get isBlocking(): boolean;
  21023. /**
  21024. * Get the current sampling mode associated with the texture.
  21025. */
  21026. get samplingMode(): number;
  21027. /**
  21028. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21029. */
  21030. get invertY(): boolean;
  21031. /**
  21032. * Instantiates a new texture.
  21033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21034. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21035. * @param url defines the url of the picture to load as a texture
  21036. * @param scene defines the scene or engine the texture will belong to
  21037. * @param noMipmap defines if the texture will require mip maps or not
  21038. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21039. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21040. * @param onLoad defines a callback triggered when the texture has been loaded
  21041. * @param onError defines a callback triggered when an error occurred during the loading session
  21042. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21043. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21044. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21045. * @param mimeType defines an optional mime type information
  21046. */
  21047. 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);
  21048. /**
  21049. * Update the url (and optional buffer) of this texture if url was null during construction.
  21050. * @param url the url of the texture
  21051. * @param buffer the buffer of the texture (defaults to null)
  21052. * @param onLoad callback called when the texture is loaded (defaults to null)
  21053. */
  21054. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21055. /**
  21056. * Finish the loading sequence of a texture flagged as delayed load.
  21057. * @hidden
  21058. */
  21059. delayLoad(): void;
  21060. private _prepareRowForTextureGeneration;
  21061. /**
  21062. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21063. * @returns the transform matrix of the texture.
  21064. */
  21065. getTextureMatrix(uBase?: number): Matrix;
  21066. /**
  21067. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21068. * @returns The reflection texture transform
  21069. */
  21070. getReflectionTextureMatrix(): Matrix;
  21071. /**
  21072. * Clones the texture.
  21073. * @returns the cloned texture
  21074. */
  21075. clone(): Texture;
  21076. /**
  21077. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21078. * @returns The JSON representation of the texture
  21079. */
  21080. serialize(): any;
  21081. /**
  21082. * Get the current class name of the texture useful for serialization or dynamic coding.
  21083. * @returns "Texture"
  21084. */
  21085. getClassName(): string;
  21086. /**
  21087. * Dispose the texture and release its associated resources.
  21088. */
  21089. dispose(): void;
  21090. /**
  21091. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21092. * @param parsedTexture Define the JSON representation of the texture
  21093. * @param scene Define the scene the parsed texture should be instantiated in
  21094. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21095. * @returns The parsed texture if successful
  21096. */
  21097. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21098. /**
  21099. * Creates a texture from its base 64 representation.
  21100. * @param data Define the base64 payload without the data: prefix
  21101. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21102. * @param scene Define the scene the texture should belong to
  21103. * @param noMipmap Forces the texture to not create mip map information if true
  21104. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21105. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21106. * @param onLoad define a callback triggered when the texture has been loaded
  21107. * @param onError define a callback triggered when an error occurred during the loading session
  21108. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21109. * @returns the created texture
  21110. */
  21111. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21112. /**
  21113. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21114. * @param data Define the base64 payload without the data: prefix
  21115. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21116. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21117. * @param scene Define the scene the texture should belong to
  21118. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21119. * @param noMipmap Forces the texture to not create mip map information if true
  21120. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21121. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21122. * @param onLoad define a callback triggered when the texture has been loaded
  21123. * @param onError define a callback triggered when an error occurred during the loading session
  21124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21125. * @returns the created texture
  21126. */
  21127. 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;
  21128. }
  21129. }
  21130. declare module "babylonjs/PostProcesses/postProcessManager" {
  21131. import { Nullable } from "babylonjs/types";
  21132. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21134. import { Scene } from "babylonjs/scene";
  21135. /**
  21136. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21137. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21138. */
  21139. export class PostProcessManager {
  21140. private _scene;
  21141. private _indexBuffer;
  21142. private _vertexBuffers;
  21143. /**
  21144. * Creates a new instance PostProcess
  21145. * @param scene The scene that the post process is associated with.
  21146. */
  21147. constructor(scene: Scene);
  21148. private _prepareBuffers;
  21149. private _buildIndexBuffer;
  21150. /**
  21151. * Rebuilds the vertex buffers of the manager.
  21152. * @hidden
  21153. */
  21154. _rebuild(): void;
  21155. /**
  21156. * Prepares a frame to be run through a post process.
  21157. * @param sourceTexture The input texture to the post procesess. (default: null)
  21158. * @param postProcesses An array of post processes to be run. (default: null)
  21159. * @returns True if the post processes were able to be run.
  21160. * @hidden
  21161. */
  21162. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21163. /**
  21164. * Manually render a set of post processes to a texture.
  21165. * @param postProcesses An array of post processes to be run.
  21166. * @param targetTexture The target texture to render to.
  21167. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21168. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21169. * @param lodLevel defines which lod of the texture to render to
  21170. */
  21171. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21172. /**
  21173. * Finalize the result of the output of the postprocesses.
  21174. * @param doNotPresent If true the result will not be displayed to the screen.
  21175. * @param targetTexture The target texture to render to.
  21176. * @param faceIndex The index of the face to bind the target texture to.
  21177. * @param postProcesses The array of post processes to render.
  21178. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21179. * @hidden
  21180. */
  21181. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21182. /**
  21183. * Disposes of the post process manager.
  21184. */
  21185. dispose(): void;
  21186. }
  21187. }
  21188. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21189. import { Observable } from "babylonjs/Misc/observable";
  21190. import { SmartArray } from "babylonjs/Misc/smartArray";
  21191. import { Nullable, Immutable } from "babylonjs/types";
  21192. import { Camera } from "babylonjs/Cameras/camera";
  21193. import { Scene } from "babylonjs/scene";
  21194. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21195. import { Color4 } from "babylonjs/Maths/math.color";
  21196. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21199. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21200. import { Texture } from "babylonjs/Materials/Textures/texture";
  21201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21202. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21203. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21204. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21205. import { Engine } from "babylonjs/Engines/engine";
  21206. /**
  21207. * This Helps creating a texture that will be created from a camera in your scene.
  21208. * It is basically a dynamic texture that could be used to create special effects for instance.
  21209. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21210. */
  21211. export class RenderTargetTexture extends Texture {
  21212. isCube: boolean;
  21213. /**
  21214. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21215. */
  21216. static readonly REFRESHRATE_RENDER_ONCE: number;
  21217. /**
  21218. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21219. */
  21220. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21221. /**
  21222. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21223. * the central point of your effect and can save a lot of performances.
  21224. */
  21225. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21226. /**
  21227. * Use this predicate to dynamically define the list of mesh you want to render.
  21228. * If set, the renderList property will be overwritten.
  21229. */
  21230. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21231. private _renderList;
  21232. /**
  21233. * Use this list to define the list of mesh you want to render.
  21234. */
  21235. get renderList(): Nullable<Array<AbstractMesh>>;
  21236. set renderList(value: Nullable<Array<AbstractMesh>>);
  21237. /**
  21238. * Use this function to overload the renderList array at rendering time.
  21239. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21240. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21241. * the cube (if the RTT is a cube, else layerOrFace=0).
  21242. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21243. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21244. * hold dummy elements!
  21245. */
  21246. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21247. private _hookArray;
  21248. /**
  21249. * Define if particles should be rendered in your texture.
  21250. */
  21251. renderParticles: boolean;
  21252. /**
  21253. * Define if sprites should be rendered in your texture.
  21254. */
  21255. renderSprites: boolean;
  21256. /**
  21257. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21258. */
  21259. coordinatesMode: number;
  21260. /**
  21261. * Define the camera used to render the texture.
  21262. */
  21263. activeCamera: Nullable<Camera>;
  21264. /**
  21265. * Override the mesh isReady function with your own one.
  21266. */
  21267. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21268. /**
  21269. * Override the render function of the texture with your own one.
  21270. */
  21271. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21272. /**
  21273. * Define if camera post processes should be use while rendering the texture.
  21274. */
  21275. useCameraPostProcesses: boolean;
  21276. /**
  21277. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21278. */
  21279. ignoreCameraViewport: boolean;
  21280. private _postProcessManager;
  21281. private _postProcesses;
  21282. private _resizeObserver;
  21283. /**
  21284. * An event triggered when the texture is unbind.
  21285. */
  21286. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21287. /**
  21288. * An event triggered when the texture is unbind.
  21289. */
  21290. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21291. private _onAfterUnbindObserver;
  21292. /**
  21293. * Set a after unbind callback in the texture.
  21294. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21295. */
  21296. set onAfterUnbind(callback: () => void);
  21297. /**
  21298. * An event triggered before rendering the texture
  21299. */
  21300. onBeforeRenderObservable: Observable<number>;
  21301. private _onBeforeRenderObserver;
  21302. /**
  21303. * Set a before render callback in the texture.
  21304. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21305. */
  21306. set onBeforeRender(callback: (faceIndex: number) => void);
  21307. /**
  21308. * An event triggered after rendering the texture
  21309. */
  21310. onAfterRenderObservable: Observable<number>;
  21311. private _onAfterRenderObserver;
  21312. /**
  21313. * Set a after render callback in the texture.
  21314. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21315. */
  21316. set onAfterRender(callback: (faceIndex: number) => void);
  21317. /**
  21318. * An event triggered after the texture clear
  21319. */
  21320. onClearObservable: Observable<Engine>;
  21321. private _onClearObserver;
  21322. /**
  21323. * Set a clear callback in the texture.
  21324. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21325. */
  21326. set onClear(callback: (Engine: Engine) => void);
  21327. /**
  21328. * An event triggered when the texture is resized.
  21329. */
  21330. onResizeObservable: Observable<RenderTargetTexture>;
  21331. /**
  21332. * Define the clear color of the Render Target if it should be different from the scene.
  21333. */
  21334. clearColor: Color4;
  21335. protected _size: number | {
  21336. width: number;
  21337. height: number;
  21338. layers?: number;
  21339. };
  21340. protected _initialSizeParameter: number | {
  21341. width: number;
  21342. height: number;
  21343. } | {
  21344. ratio: number;
  21345. };
  21346. protected _sizeRatio: Nullable<number>;
  21347. /** @hidden */
  21348. _generateMipMaps: boolean;
  21349. protected _renderingManager: RenderingManager;
  21350. /** @hidden */
  21351. _waitingRenderList: string[];
  21352. protected _doNotChangeAspectRatio: boolean;
  21353. protected _currentRefreshId: number;
  21354. protected _refreshRate: number;
  21355. protected _textureMatrix: Matrix;
  21356. protected _samples: number;
  21357. protected _renderTargetOptions: RenderTargetCreationOptions;
  21358. /**
  21359. * Gets render target creation options that were used.
  21360. */
  21361. get renderTargetOptions(): RenderTargetCreationOptions;
  21362. protected _engine: Engine;
  21363. protected _onRatioRescale(): void;
  21364. /**
  21365. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21366. * It must define where the camera used to render the texture is set
  21367. */
  21368. boundingBoxPosition: Vector3;
  21369. private _boundingBoxSize;
  21370. /**
  21371. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21372. * When defined, the cubemap will switch to local mode
  21373. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21374. * @example https://www.babylonjs-playground.com/#RNASML
  21375. */
  21376. set boundingBoxSize(value: Vector3);
  21377. get boundingBoxSize(): Vector3;
  21378. /**
  21379. * In case the RTT has been created with a depth texture, get the associated
  21380. * depth texture.
  21381. * Otherwise, return null.
  21382. */
  21383. get depthStencilTexture(): Nullable<InternalTexture>;
  21384. /**
  21385. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21386. * or used a shadow, depth texture...
  21387. * @param name The friendly name of the texture
  21388. * @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)
  21389. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21390. * @param generateMipMaps True if mip maps need to be generated after render.
  21391. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21392. * @param type The type of the buffer in the RTT (int, half float, float...)
  21393. * @param isCube True if a cube texture needs to be created
  21394. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21395. * @param generateDepthBuffer True to generate a depth buffer
  21396. * @param generateStencilBuffer True to generate a stencil buffer
  21397. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21398. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21399. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21400. */
  21401. constructor(name: string, size: number | {
  21402. width: number;
  21403. height: number;
  21404. layers?: number;
  21405. } | {
  21406. ratio: number;
  21407. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21408. /**
  21409. * Creates a depth stencil texture.
  21410. * This is only available in WebGL 2 or with the depth texture extension available.
  21411. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21412. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21413. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21414. */
  21415. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21416. private _processSizeParameter;
  21417. /**
  21418. * Define the number of samples to use in case of MSAA.
  21419. * It defaults to one meaning no MSAA has been enabled.
  21420. */
  21421. get samples(): number;
  21422. set samples(value: number);
  21423. /**
  21424. * Resets the refresh counter of the texture and start bak from scratch.
  21425. * Could be useful to regenerate the texture if it is setup to render only once.
  21426. */
  21427. resetRefreshCounter(): void;
  21428. /**
  21429. * Define the refresh rate of the texture or the rendering frequency.
  21430. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21431. */
  21432. get refreshRate(): number;
  21433. set refreshRate(value: number);
  21434. /**
  21435. * Adds a post process to the render target rendering passes.
  21436. * @param postProcess define the post process to add
  21437. */
  21438. addPostProcess(postProcess: PostProcess): void;
  21439. /**
  21440. * Clear all the post processes attached to the render target
  21441. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21442. */
  21443. clearPostProcesses(dispose?: boolean): void;
  21444. /**
  21445. * Remove one of the post process from the list of attached post processes to the texture
  21446. * @param postProcess define the post process to remove from the list
  21447. */
  21448. removePostProcess(postProcess: PostProcess): void;
  21449. /** @hidden */
  21450. _shouldRender(): boolean;
  21451. /**
  21452. * Gets the actual render size of the texture.
  21453. * @returns the width of the render size
  21454. */
  21455. getRenderSize(): number;
  21456. /**
  21457. * Gets the actual render width of the texture.
  21458. * @returns the width of the render size
  21459. */
  21460. getRenderWidth(): number;
  21461. /**
  21462. * Gets the actual render height of the texture.
  21463. * @returns the height of the render size
  21464. */
  21465. getRenderHeight(): number;
  21466. /**
  21467. * Gets the actual number of layers of the texture.
  21468. * @returns the number of layers
  21469. */
  21470. getRenderLayers(): number;
  21471. /**
  21472. * Get if the texture can be rescaled or not.
  21473. */
  21474. get canRescale(): boolean;
  21475. /**
  21476. * Resize the texture using a ratio.
  21477. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21478. */
  21479. scale(ratio: number): void;
  21480. /**
  21481. * Get the texture reflection matrix used to rotate/transform the reflection.
  21482. * @returns the reflection matrix
  21483. */
  21484. getReflectionTextureMatrix(): Matrix;
  21485. /**
  21486. * Resize the texture to a new desired size.
  21487. * Be carrefull as it will recreate all the data in the new texture.
  21488. * @param size Define the new size. It can be:
  21489. * - a number for squared texture,
  21490. * - an object containing { width: number, height: number }
  21491. * - or an object containing a ratio { ratio: number }
  21492. */
  21493. resize(size: number | {
  21494. width: number;
  21495. height: number;
  21496. } | {
  21497. ratio: number;
  21498. }): void;
  21499. private _defaultRenderListPrepared;
  21500. /**
  21501. * Renders all the objects from the render list into the texture.
  21502. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21503. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21504. */
  21505. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21506. private _bestReflectionRenderTargetDimension;
  21507. private _prepareRenderingManager;
  21508. /**
  21509. * @hidden
  21510. * @param faceIndex face index to bind to if this is a cubetexture
  21511. * @param layer defines the index of the texture to bind in the array
  21512. */
  21513. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21514. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21515. private renderToTarget;
  21516. /**
  21517. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21518. * This allowed control for front to back rendering or reversly depending of the special needs.
  21519. *
  21520. * @param renderingGroupId The rendering group id corresponding to its index
  21521. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21522. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21523. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21524. */
  21525. 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;
  21526. /**
  21527. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21528. *
  21529. * @param renderingGroupId The rendering group id corresponding to its index
  21530. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21531. */
  21532. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21533. /**
  21534. * Clones the texture.
  21535. * @returns the cloned texture
  21536. */
  21537. clone(): RenderTargetTexture;
  21538. /**
  21539. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21540. * @returns The JSON representation of the texture
  21541. */
  21542. serialize(): any;
  21543. /**
  21544. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21545. */
  21546. disposeFramebufferObjects(): void;
  21547. /**
  21548. * Dispose the texture and release its associated resources.
  21549. */
  21550. dispose(): void;
  21551. /** @hidden */
  21552. _rebuild(): void;
  21553. /**
  21554. * Clear the info related to rendering groups preventing retention point in material dispose.
  21555. */
  21556. freeRenderingGroups(): void;
  21557. /**
  21558. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21559. * @returns the view count
  21560. */
  21561. getViewCount(): number;
  21562. }
  21563. }
  21564. declare module "babylonjs/Materials/material" {
  21565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21566. import { SmartArray } from "babylonjs/Misc/smartArray";
  21567. import { Observable } from "babylonjs/Misc/observable";
  21568. import { Nullable } from "babylonjs/types";
  21569. import { Scene } from "babylonjs/scene";
  21570. import { Matrix } from "babylonjs/Maths/math.vector";
  21571. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21573. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21574. import { Effect } from "babylonjs/Materials/effect";
  21575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21577. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21578. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21579. import { Mesh } from "babylonjs/Meshes/mesh";
  21580. import { Animation } from "babylonjs/Animations/animation";
  21581. /**
  21582. * Options for compiling materials.
  21583. */
  21584. export interface IMaterialCompilationOptions {
  21585. /**
  21586. * Defines whether clip planes are enabled.
  21587. */
  21588. clipPlane: boolean;
  21589. /**
  21590. * Defines whether instances are enabled.
  21591. */
  21592. useInstances: boolean;
  21593. }
  21594. /**
  21595. * Base class for the main features of a material in Babylon.js
  21596. */
  21597. export class Material implements IAnimatable {
  21598. /**
  21599. * Returns the triangle fill mode
  21600. */
  21601. static readonly TriangleFillMode: number;
  21602. /**
  21603. * Returns the wireframe mode
  21604. */
  21605. static readonly WireFrameFillMode: number;
  21606. /**
  21607. * Returns the point fill mode
  21608. */
  21609. static readonly PointFillMode: number;
  21610. /**
  21611. * Returns the point list draw mode
  21612. */
  21613. static readonly PointListDrawMode: number;
  21614. /**
  21615. * Returns the line list draw mode
  21616. */
  21617. static readonly LineListDrawMode: number;
  21618. /**
  21619. * Returns the line loop draw mode
  21620. */
  21621. static readonly LineLoopDrawMode: number;
  21622. /**
  21623. * Returns the line strip draw mode
  21624. */
  21625. static readonly LineStripDrawMode: number;
  21626. /**
  21627. * Returns the triangle strip draw mode
  21628. */
  21629. static readonly TriangleStripDrawMode: number;
  21630. /**
  21631. * Returns the triangle fan draw mode
  21632. */
  21633. static readonly TriangleFanDrawMode: number;
  21634. /**
  21635. * Stores the clock-wise side orientation
  21636. */
  21637. static readonly ClockWiseSideOrientation: number;
  21638. /**
  21639. * Stores the counter clock-wise side orientation
  21640. */
  21641. static readonly CounterClockWiseSideOrientation: number;
  21642. /**
  21643. * The dirty texture flag value
  21644. */
  21645. static readonly TextureDirtyFlag: number;
  21646. /**
  21647. * The dirty light flag value
  21648. */
  21649. static readonly LightDirtyFlag: number;
  21650. /**
  21651. * The dirty fresnel flag value
  21652. */
  21653. static readonly FresnelDirtyFlag: number;
  21654. /**
  21655. * The dirty attribute flag value
  21656. */
  21657. static readonly AttributesDirtyFlag: number;
  21658. /**
  21659. * The dirty misc flag value
  21660. */
  21661. static readonly MiscDirtyFlag: number;
  21662. /**
  21663. * The all dirty flag value
  21664. */
  21665. static readonly AllDirtyFlag: number;
  21666. /**
  21667. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21668. */
  21669. static readonly MATERIAL_OPAQUE: number;
  21670. /**
  21671. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21672. */
  21673. static readonly MATERIAL_ALPHATEST: number;
  21674. /**
  21675. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21676. */
  21677. static readonly MATERIAL_ALPHABLEND: number;
  21678. /**
  21679. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21680. * They are also discarded below the alpha cutoff threshold to improve performances.
  21681. */
  21682. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21683. /**
  21684. * The ID of the material
  21685. */
  21686. id: string;
  21687. /**
  21688. * Gets or sets the unique id of the material
  21689. */
  21690. uniqueId: number;
  21691. /**
  21692. * The name of the material
  21693. */
  21694. name: string;
  21695. /**
  21696. * Gets or sets user defined metadata
  21697. */
  21698. metadata: any;
  21699. /**
  21700. * For internal use only. Please do not use.
  21701. */
  21702. reservedDataStore: any;
  21703. /**
  21704. * Specifies if the ready state should be checked on each call
  21705. */
  21706. checkReadyOnEveryCall: boolean;
  21707. /**
  21708. * Specifies if the ready state should be checked once
  21709. */
  21710. checkReadyOnlyOnce: boolean;
  21711. /**
  21712. * The state of the material
  21713. */
  21714. state: string;
  21715. /**
  21716. * The alpha value of the material
  21717. */
  21718. protected _alpha: number;
  21719. /**
  21720. * List of inspectable custom properties (used by the Inspector)
  21721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21722. */
  21723. inspectableCustomProperties: IInspectable[];
  21724. /**
  21725. * Sets the alpha value of the material
  21726. */
  21727. set alpha(value: number);
  21728. /**
  21729. * Gets the alpha value of the material
  21730. */
  21731. get alpha(): number;
  21732. /**
  21733. * Specifies if back face culling is enabled
  21734. */
  21735. protected _backFaceCulling: boolean;
  21736. /**
  21737. * Sets the back-face culling state
  21738. */
  21739. set backFaceCulling(value: boolean);
  21740. /**
  21741. * Gets the back-face culling state
  21742. */
  21743. get backFaceCulling(): boolean;
  21744. /**
  21745. * Stores the value for side orientation
  21746. */
  21747. sideOrientation: number;
  21748. /**
  21749. * Callback triggered when the material is compiled
  21750. */
  21751. onCompiled: Nullable<(effect: Effect) => void>;
  21752. /**
  21753. * Callback triggered when an error occurs
  21754. */
  21755. onError: Nullable<(effect: Effect, errors: string) => void>;
  21756. /**
  21757. * Callback triggered to get the render target textures
  21758. */
  21759. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21760. /**
  21761. * Gets a boolean indicating that current material needs to register RTT
  21762. */
  21763. get hasRenderTargetTextures(): boolean;
  21764. /**
  21765. * Specifies if the material should be serialized
  21766. */
  21767. doNotSerialize: boolean;
  21768. /**
  21769. * @hidden
  21770. */
  21771. _storeEffectOnSubMeshes: boolean;
  21772. /**
  21773. * Stores the animations for the material
  21774. */
  21775. animations: Nullable<Array<Animation>>;
  21776. /**
  21777. * An event triggered when the material is disposed
  21778. */
  21779. onDisposeObservable: Observable<Material>;
  21780. /**
  21781. * An observer which watches for dispose events
  21782. */
  21783. private _onDisposeObserver;
  21784. private _onUnBindObservable;
  21785. /**
  21786. * Called during a dispose event
  21787. */
  21788. set onDispose(callback: () => void);
  21789. private _onBindObservable;
  21790. /**
  21791. * An event triggered when the material is bound
  21792. */
  21793. get onBindObservable(): Observable<AbstractMesh>;
  21794. /**
  21795. * An observer which watches for bind events
  21796. */
  21797. private _onBindObserver;
  21798. /**
  21799. * Called during a bind event
  21800. */
  21801. set onBind(callback: (Mesh: AbstractMesh) => void);
  21802. /**
  21803. * An event triggered when the material is unbound
  21804. */
  21805. get onUnBindObservable(): Observable<Material>;
  21806. /**
  21807. * Stores the value of the alpha mode
  21808. */
  21809. private _alphaMode;
  21810. /**
  21811. * Sets the value of the alpha mode.
  21812. *
  21813. * | Value | Type | Description |
  21814. * | --- | --- | --- |
  21815. * | 0 | ALPHA_DISABLE | |
  21816. * | 1 | ALPHA_ADD | |
  21817. * | 2 | ALPHA_COMBINE | |
  21818. * | 3 | ALPHA_SUBTRACT | |
  21819. * | 4 | ALPHA_MULTIPLY | |
  21820. * | 5 | ALPHA_MAXIMIZED | |
  21821. * | 6 | ALPHA_ONEONE | |
  21822. * | 7 | ALPHA_PREMULTIPLIED | |
  21823. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21824. * | 9 | ALPHA_INTERPOLATE | |
  21825. * | 10 | ALPHA_SCREENMODE | |
  21826. *
  21827. */
  21828. set alphaMode(value: number);
  21829. /**
  21830. * Gets the value of the alpha mode
  21831. */
  21832. get alphaMode(): number;
  21833. /**
  21834. * Stores the state of the need depth pre-pass value
  21835. */
  21836. private _needDepthPrePass;
  21837. /**
  21838. * Sets the need depth pre-pass value
  21839. */
  21840. set needDepthPrePass(value: boolean);
  21841. /**
  21842. * Gets the depth pre-pass value
  21843. */
  21844. get needDepthPrePass(): boolean;
  21845. /**
  21846. * Specifies if depth writing should be disabled
  21847. */
  21848. disableDepthWrite: boolean;
  21849. /**
  21850. * Specifies if depth writing should be forced
  21851. */
  21852. forceDepthWrite: boolean;
  21853. /**
  21854. * Specifies the depth function that should be used. 0 means the default engine function
  21855. */
  21856. depthFunction: number;
  21857. /**
  21858. * Specifies if there should be a separate pass for culling
  21859. */
  21860. separateCullingPass: boolean;
  21861. /**
  21862. * Stores the state specifing if fog should be enabled
  21863. */
  21864. private _fogEnabled;
  21865. /**
  21866. * Sets the state for enabling fog
  21867. */
  21868. set fogEnabled(value: boolean);
  21869. /**
  21870. * Gets the value of the fog enabled state
  21871. */
  21872. get fogEnabled(): boolean;
  21873. /**
  21874. * Stores the size of points
  21875. */
  21876. pointSize: number;
  21877. /**
  21878. * Stores the z offset value
  21879. */
  21880. zOffset: number;
  21881. /**
  21882. * Gets a value specifying if wireframe mode is enabled
  21883. */
  21884. get wireframe(): boolean;
  21885. /**
  21886. * Sets the state of wireframe mode
  21887. */
  21888. set wireframe(value: boolean);
  21889. /**
  21890. * Gets the value specifying if point clouds are enabled
  21891. */
  21892. get pointsCloud(): boolean;
  21893. /**
  21894. * Sets the state of point cloud mode
  21895. */
  21896. set pointsCloud(value: boolean);
  21897. /**
  21898. * Gets the material fill mode
  21899. */
  21900. get fillMode(): number;
  21901. /**
  21902. * Sets the material fill mode
  21903. */
  21904. set fillMode(value: number);
  21905. /**
  21906. * @hidden
  21907. * Stores the effects for the material
  21908. */
  21909. _effect: Nullable<Effect>;
  21910. /**
  21911. * Specifies if uniform buffers should be used
  21912. */
  21913. private _useUBO;
  21914. /**
  21915. * Stores a reference to the scene
  21916. */
  21917. private _scene;
  21918. /**
  21919. * Stores the fill mode state
  21920. */
  21921. private _fillMode;
  21922. /**
  21923. * Specifies if the depth write state should be cached
  21924. */
  21925. private _cachedDepthWriteState;
  21926. /**
  21927. * Specifies if the depth function state should be cached
  21928. */
  21929. private _cachedDepthFunctionState;
  21930. /**
  21931. * Stores the uniform buffer
  21932. */
  21933. protected _uniformBuffer: UniformBuffer;
  21934. /** @hidden */
  21935. _indexInSceneMaterialArray: number;
  21936. /** @hidden */
  21937. meshMap: Nullable<{
  21938. [id: string]: AbstractMesh | undefined;
  21939. }>;
  21940. /**
  21941. * Creates a material instance
  21942. * @param name defines the name of the material
  21943. * @param scene defines the scene to reference
  21944. * @param doNotAdd specifies if the material should be added to the scene
  21945. */
  21946. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21947. /**
  21948. * Returns a string representation of the current material
  21949. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21950. * @returns a string with material information
  21951. */
  21952. toString(fullDetails?: boolean): string;
  21953. /**
  21954. * Gets the class name of the material
  21955. * @returns a string with the class name of the material
  21956. */
  21957. getClassName(): string;
  21958. /**
  21959. * Specifies if updates for the material been locked
  21960. */
  21961. get isFrozen(): boolean;
  21962. /**
  21963. * Locks updates for the material
  21964. */
  21965. freeze(): void;
  21966. /**
  21967. * Unlocks updates for the material
  21968. */
  21969. unfreeze(): void;
  21970. /**
  21971. * Specifies if the material is ready to be used
  21972. * @param mesh defines the mesh to check
  21973. * @param useInstances specifies if instances should be used
  21974. * @returns a boolean indicating if the material is ready to be used
  21975. */
  21976. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21977. /**
  21978. * Specifies that the submesh is ready to be used
  21979. * @param mesh defines the mesh to check
  21980. * @param subMesh defines which submesh to check
  21981. * @param useInstances specifies that instances should be used
  21982. * @returns a boolean indicating that the submesh is ready or not
  21983. */
  21984. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21985. /**
  21986. * Returns the material effect
  21987. * @returns the effect associated with the material
  21988. */
  21989. getEffect(): Nullable<Effect>;
  21990. /**
  21991. * Returns the current scene
  21992. * @returns a Scene
  21993. */
  21994. getScene(): Scene;
  21995. /**
  21996. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21997. */
  21998. protected _forceAlphaTest: boolean;
  21999. /**
  22000. * The transparency mode of the material.
  22001. */
  22002. protected _transparencyMode: Nullable<number>;
  22003. /**
  22004. * Gets the current transparency mode.
  22005. */
  22006. get transparencyMode(): Nullable<number>;
  22007. /**
  22008. * Sets the transparency mode of the material.
  22009. *
  22010. * | Value | Type | Description |
  22011. * | ----- | ----------------------------------- | ----------- |
  22012. * | 0 | OPAQUE | |
  22013. * | 1 | ALPHATEST | |
  22014. * | 2 | ALPHABLEND | |
  22015. * | 3 | ALPHATESTANDBLEND | |
  22016. *
  22017. */
  22018. set transparencyMode(value: Nullable<number>);
  22019. /**
  22020. * Returns true if alpha blending should be disabled.
  22021. */
  22022. protected get _disableAlphaBlending(): boolean;
  22023. /**
  22024. * Specifies whether or not this material should be rendered in alpha blend mode.
  22025. * @returns a boolean specifying if alpha blending is needed
  22026. */
  22027. needAlphaBlending(): boolean;
  22028. /**
  22029. * Specifies if the mesh will require alpha blending
  22030. * @param mesh defines the mesh to check
  22031. * @returns a boolean specifying if alpha blending is needed for the mesh
  22032. */
  22033. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22034. /**
  22035. * Specifies whether or not this material should be rendered in alpha test mode.
  22036. * @returns a boolean specifying if an alpha test is needed.
  22037. */
  22038. needAlphaTesting(): boolean;
  22039. /**
  22040. * Specifies if material alpha testing should be turned on for the mesh
  22041. * @param mesh defines the mesh to check
  22042. */
  22043. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22044. /**
  22045. * Gets the texture used for the alpha test
  22046. * @returns the texture to use for alpha testing
  22047. */
  22048. getAlphaTestTexture(): Nullable<BaseTexture>;
  22049. /**
  22050. * Marks the material to indicate that it needs to be re-calculated
  22051. */
  22052. markDirty(): void;
  22053. /** @hidden */
  22054. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22055. /**
  22056. * Binds the material to the mesh
  22057. * @param world defines the world transformation matrix
  22058. * @param mesh defines the mesh to bind the material to
  22059. */
  22060. bind(world: Matrix, mesh?: Mesh): void;
  22061. /**
  22062. * Binds the submesh to the material
  22063. * @param world defines the world transformation matrix
  22064. * @param mesh defines the mesh containing the submesh
  22065. * @param subMesh defines the submesh to bind the material to
  22066. */
  22067. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22068. /**
  22069. * Binds the world matrix to the material
  22070. * @param world defines the world transformation matrix
  22071. */
  22072. bindOnlyWorldMatrix(world: Matrix): void;
  22073. /**
  22074. * Binds the scene's uniform buffer to the effect.
  22075. * @param effect defines the effect to bind to the scene uniform buffer
  22076. * @param sceneUbo defines the uniform buffer storing scene data
  22077. */
  22078. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22079. /**
  22080. * Binds the view matrix to the effect
  22081. * @param effect defines the effect to bind the view matrix to
  22082. */
  22083. bindView(effect: Effect): void;
  22084. /**
  22085. * Binds the view projection matrix to the effect
  22086. * @param effect defines the effect to bind the view projection matrix to
  22087. */
  22088. bindViewProjection(effect: Effect): void;
  22089. /**
  22090. * Processes to execute after binding the material to a mesh
  22091. * @param mesh defines the rendered mesh
  22092. */
  22093. protected _afterBind(mesh?: Mesh): void;
  22094. /**
  22095. * Unbinds the material from the mesh
  22096. */
  22097. unbind(): void;
  22098. /**
  22099. * Gets the active textures from the material
  22100. * @returns an array of textures
  22101. */
  22102. getActiveTextures(): BaseTexture[];
  22103. /**
  22104. * Specifies if the material uses a texture
  22105. * @param texture defines the texture to check against the material
  22106. * @returns a boolean specifying if the material uses the texture
  22107. */
  22108. hasTexture(texture: BaseTexture): boolean;
  22109. /**
  22110. * Makes a duplicate of the material, and gives it a new name
  22111. * @param name defines the new name for the duplicated material
  22112. * @returns the cloned material
  22113. */
  22114. clone(name: string): Nullable<Material>;
  22115. /**
  22116. * Gets the meshes bound to the material
  22117. * @returns an array of meshes bound to the material
  22118. */
  22119. getBindedMeshes(): AbstractMesh[];
  22120. /**
  22121. * Force shader compilation
  22122. * @param mesh defines the mesh associated with this material
  22123. * @param onCompiled defines a function to execute once the material is compiled
  22124. * @param options defines the options to configure the compilation
  22125. * @param onError defines a function to execute if the material fails compiling
  22126. */
  22127. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22128. /**
  22129. * Force shader compilation
  22130. * @param mesh defines the mesh that will use this material
  22131. * @param options defines additional options for compiling the shaders
  22132. * @returns a promise that resolves when the compilation completes
  22133. */
  22134. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22135. private static readonly _AllDirtyCallBack;
  22136. private static readonly _ImageProcessingDirtyCallBack;
  22137. private static readonly _TextureDirtyCallBack;
  22138. private static readonly _FresnelDirtyCallBack;
  22139. private static readonly _MiscDirtyCallBack;
  22140. private static readonly _LightsDirtyCallBack;
  22141. private static readonly _AttributeDirtyCallBack;
  22142. private static _FresnelAndMiscDirtyCallBack;
  22143. private static _TextureAndMiscDirtyCallBack;
  22144. private static readonly _DirtyCallbackArray;
  22145. private static readonly _RunDirtyCallBacks;
  22146. /**
  22147. * Marks a define in the material to indicate that it needs to be re-computed
  22148. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22149. */
  22150. markAsDirty(flag: number): void;
  22151. /**
  22152. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22153. * @param func defines a function which checks material defines against the submeshes
  22154. */
  22155. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22156. /**
  22157. * Indicates that we need to re-calculated for all submeshes
  22158. */
  22159. protected _markAllSubMeshesAsAllDirty(): void;
  22160. /**
  22161. * Indicates that image processing needs to be re-calculated for all submeshes
  22162. */
  22163. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22164. /**
  22165. * Indicates that textures need to be re-calculated for all submeshes
  22166. */
  22167. protected _markAllSubMeshesAsTexturesDirty(): void;
  22168. /**
  22169. * Indicates that fresnel needs to be re-calculated for all submeshes
  22170. */
  22171. protected _markAllSubMeshesAsFresnelDirty(): void;
  22172. /**
  22173. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22174. */
  22175. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22176. /**
  22177. * Indicates that lights need to be re-calculated for all submeshes
  22178. */
  22179. protected _markAllSubMeshesAsLightsDirty(): void;
  22180. /**
  22181. * Indicates that attributes need to be re-calculated for all submeshes
  22182. */
  22183. protected _markAllSubMeshesAsAttributesDirty(): void;
  22184. /**
  22185. * Indicates that misc needs to be re-calculated for all submeshes
  22186. */
  22187. protected _markAllSubMeshesAsMiscDirty(): void;
  22188. /**
  22189. * Indicates that textures and misc need to be re-calculated for all submeshes
  22190. */
  22191. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22192. /**
  22193. * Disposes the material
  22194. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22195. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22196. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22197. */
  22198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22199. /** @hidden */
  22200. private releaseVertexArrayObject;
  22201. /**
  22202. * Serializes this material
  22203. * @returns the serialized material object
  22204. */
  22205. serialize(): any;
  22206. /**
  22207. * Creates a material from parsed material data
  22208. * @param parsedMaterial defines parsed material data
  22209. * @param scene defines the hosting scene
  22210. * @param rootUrl defines the root URL to use to load textures
  22211. * @returns a new material
  22212. */
  22213. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22214. }
  22215. }
  22216. declare module "babylonjs/Materials/multiMaterial" {
  22217. import { Nullable } from "babylonjs/types";
  22218. import { Scene } from "babylonjs/scene";
  22219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22220. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22222. import { Material } from "babylonjs/Materials/material";
  22223. /**
  22224. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22225. * separate meshes. This can be use to improve performances.
  22226. * @see http://doc.babylonjs.com/how_to/multi_materials
  22227. */
  22228. export class MultiMaterial extends Material {
  22229. private _subMaterials;
  22230. /**
  22231. * Gets or Sets the list of Materials used within the multi material.
  22232. * They need to be ordered according to the submeshes order in the associated mesh
  22233. */
  22234. get subMaterials(): Nullable<Material>[];
  22235. set subMaterials(value: Nullable<Material>[]);
  22236. /**
  22237. * Function used to align with Node.getChildren()
  22238. * @returns the list of Materials used within the multi material
  22239. */
  22240. getChildren(): Nullable<Material>[];
  22241. /**
  22242. * Instantiates a new Multi Material
  22243. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22244. * separate meshes. This can be use to improve performances.
  22245. * @see http://doc.babylonjs.com/how_to/multi_materials
  22246. * @param name Define the name in the scene
  22247. * @param scene Define the scene the material belongs to
  22248. */
  22249. constructor(name: string, scene: Scene);
  22250. private _hookArray;
  22251. /**
  22252. * Get one of the submaterial by its index in the submaterials array
  22253. * @param index The index to look the sub material at
  22254. * @returns The Material if the index has been defined
  22255. */
  22256. getSubMaterial(index: number): Nullable<Material>;
  22257. /**
  22258. * Get the list of active textures for the whole sub materials list.
  22259. * @returns All the textures that will be used during the rendering
  22260. */
  22261. getActiveTextures(): BaseTexture[];
  22262. /**
  22263. * Gets the current class name of the material e.g. "MultiMaterial"
  22264. * Mainly use in serialization.
  22265. * @returns the class name
  22266. */
  22267. getClassName(): string;
  22268. /**
  22269. * Checks if the material is ready to render the requested sub mesh
  22270. * @param mesh Define the mesh the submesh belongs to
  22271. * @param subMesh Define the sub mesh to look readyness for
  22272. * @param useInstances Define whether or not the material is used with instances
  22273. * @returns true if ready, otherwise false
  22274. */
  22275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22276. /**
  22277. * Clones the current material and its related sub materials
  22278. * @param name Define the name of the newly cloned material
  22279. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22280. * @returns the cloned material
  22281. */
  22282. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22283. /**
  22284. * Serializes the materials into a JSON representation.
  22285. * @returns the JSON representation
  22286. */
  22287. serialize(): any;
  22288. /**
  22289. * Dispose the material and release its associated resources
  22290. * @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)
  22291. * @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)
  22292. * @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)
  22293. */
  22294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22295. /**
  22296. * Creates a MultiMaterial from parsed MultiMaterial data.
  22297. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22298. * @param scene defines the hosting scene
  22299. * @returns a new MultiMaterial
  22300. */
  22301. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22302. }
  22303. }
  22304. declare module "babylonjs/Meshes/subMesh" {
  22305. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22306. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22307. import { Engine } from "babylonjs/Engines/engine";
  22308. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22309. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22310. import { Effect } from "babylonjs/Materials/effect";
  22311. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22312. import { Plane } from "babylonjs/Maths/math.plane";
  22313. import { Collider } from "babylonjs/Collisions/collider";
  22314. import { Material } from "babylonjs/Materials/material";
  22315. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22317. import { Mesh } from "babylonjs/Meshes/mesh";
  22318. import { Ray } from "babylonjs/Culling/ray";
  22319. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22320. /**
  22321. * Base class for submeshes
  22322. */
  22323. export class BaseSubMesh {
  22324. /** @hidden */
  22325. _materialDefines: Nullable<MaterialDefines>;
  22326. /** @hidden */
  22327. _materialEffect: Nullable<Effect>;
  22328. /**
  22329. * Gets material defines used by the effect associated to the sub mesh
  22330. */
  22331. get materialDefines(): Nullable<MaterialDefines>;
  22332. /**
  22333. * Sets material defines used by the effect associated to the sub mesh
  22334. */
  22335. set materialDefines(defines: Nullable<MaterialDefines>);
  22336. /**
  22337. * Gets associated effect
  22338. */
  22339. get effect(): Nullable<Effect>;
  22340. /**
  22341. * Sets associated effect (effect used to render this submesh)
  22342. * @param effect defines the effect to associate with
  22343. * @param defines defines the set of defines used to compile this effect
  22344. */
  22345. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22346. }
  22347. /**
  22348. * Defines a subdivision inside a mesh
  22349. */
  22350. export class SubMesh extends BaseSubMesh implements ICullable {
  22351. /** the material index to use */
  22352. materialIndex: number;
  22353. /** vertex index start */
  22354. verticesStart: number;
  22355. /** vertices count */
  22356. verticesCount: number;
  22357. /** index start */
  22358. indexStart: number;
  22359. /** indices count */
  22360. indexCount: number;
  22361. /** @hidden */
  22362. _linesIndexCount: number;
  22363. private _mesh;
  22364. private _renderingMesh;
  22365. private _boundingInfo;
  22366. private _linesIndexBuffer;
  22367. /** @hidden */
  22368. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22369. /** @hidden */
  22370. _trianglePlanes: Plane[];
  22371. /** @hidden */
  22372. _lastColliderTransformMatrix: Nullable<Matrix>;
  22373. /** @hidden */
  22374. _renderId: number;
  22375. /** @hidden */
  22376. _alphaIndex: number;
  22377. /** @hidden */
  22378. _distanceToCamera: number;
  22379. /** @hidden */
  22380. _id: number;
  22381. private _currentMaterial;
  22382. /**
  22383. * Add a new submesh to a mesh
  22384. * @param materialIndex defines the material index to use
  22385. * @param verticesStart defines vertex index start
  22386. * @param verticesCount defines vertices count
  22387. * @param indexStart defines index start
  22388. * @param indexCount defines indices count
  22389. * @param mesh defines the parent mesh
  22390. * @param renderingMesh defines an optional rendering mesh
  22391. * @param createBoundingBox defines if bounding box should be created for this submesh
  22392. * @returns the new submesh
  22393. */
  22394. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22395. /**
  22396. * Creates a new submesh
  22397. * @param materialIndex defines the material index to use
  22398. * @param verticesStart defines vertex index start
  22399. * @param verticesCount defines vertices count
  22400. * @param indexStart defines index start
  22401. * @param indexCount defines indices count
  22402. * @param mesh defines the parent mesh
  22403. * @param renderingMesh defines an optional rendering mesh
  22404. * @param createBoundingBox defines if bounding box should be created for this submesh
  22405. */
  22406. constructor(
  22407. /** the material index to use */
  22408. materialIndex: number,
  22409. /** vertex index start */
  22410. verticesStart: number,
  22411. /** vertices count */
  22412. verticesCount: number,
  22413. /** index start */
  22414. indexStart: number,
  22415. /** indices count */
  22416. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22417. /**
  22418. * Returns true if this submesh covers the entire parent mesh
  22419. * @ignorenaming
  22420. */
  22421. get IsGlobal(): boolean;
  22422. /**
  22423. * Returns the submesh BoudingInfo object
  22424. * @returns current bounding info (or mesh's one if the submesh is global)
  22425. */
  22426. getBoundingInfo(): BoundingInfo;
  22427. /**
  22428. * Sets the submesh BoundingInfo
  22429. * @param boundingInfo defines the new bounding info to use
  22430. * @returns the SubMesh
  22431. */
  22432. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22433. /**
  22434. * Returns the mesh of the current submesh
  22435. * @return the parent mesh
  22436. */
  22437. getMesh(): AbstractMesh;
  22438. /**
  22439. * Returns the rendering mesh of the submesh
  22440. * @returns the rendering mesh (could be different from parent mesh)
  22441. */
  22442. getRenderingMesh(): Mesh;
  22443. /**
  22444. * Returns the submesh material
  22445. * @returns null or the current material
  22446. */
  22447. getMaterial(): Nullable<Material>;
  22448. /**
  22449. * Sets a new updated BoundingInfo object to the submesh
  22450. * @param data defines an optional position array to use to determine the bounding info
  22451. * @returns the SubMesh
  22452. */
  22453. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22454. /** @hidden */
  22455. _checkCollision(collider: Collider): boolean;
  22456. /**
  22457. * Updates the submesh BoundingInfo
  22458. * @param world defines the world matrix to use to update the bounding info
  22459. * @returns the submesh
  22460. */
  22461. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22462. /**
  22463. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22464. * @param frustumPlanes defines the frustum planes
  22465. * @returns true if the submesh is intersecting with the frustum
  22466. */
  22467. isInFrustum(frustumPlanes: Plane[]): boolean;
  22468. /**
  22469. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22470. * @param frustumPlanes defines the frustum planes
  22471. * @returns true if the submesh is inside the frustum
  22472. */
  22473. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22474. /**
  22475. * Renders the submesh
  22476. * @param enableAlphaMode defines if alpha needs to be used
  22477. * @returns the submesh
  22478. */
  22479. render(enableAlphaMode: boolean): SubMesh;
  22480. /**
  22481. * @hidden
  22482. */
  22483. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22484. /**
  22485. * Checks if the submesh intersects with a ray
  22486. * @param ray defines the ray to test
  22487. * @returns true is the passed ray intersects the submesh bounding box
  22488. */
  22489. canIntersects(ray: Ray): boolean;
  22490. /**
  22491. * Intersects current submesh with a ray
  22492. * @param ray defines the ray to test
  22493. * @param positions defines mesh's positions array
  22494. * @param indices defines mesh's indices array
  22495. * @param fastCheck defines if only bounding info should be used
  22496. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22497. * @returns intersection info or null if no intersection
  22498. */
  22499. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22500. /** @hidden */
  22501. private _intersectLines;
  22502. /** @hidden */
  22503. private _intersectUnIndexedLines;
  22504. /** @hidden */
  22505. private _intersectTriangles;
  22506. /** @hidden */
  22507. private _intersectUnIndexedTriangles;
  22508. /** @hidden */
  22509. _rebuild(): void;
  22510. /**
  22511. * Creates a new submesh from the passed mesh
  22512. * @param newMesh defines the new hosting mesh
  22513. * @param newRenderingMesh defines an optional rendering mesh
  22514. * @returns the new submesh
  22515. */
  22516. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22517. /**
  22518. * Release associated resources
  22519. */
  22520. dispose(): void;
  22521. /**
  22522. * Gets the class name
  22523. * @returns the string "SubMesh".
  22524. */
  22525. getClassName(): string;
  22526. /**
  22527. * Creates a new submesh from indices data
  22528. * @param materialIndex the index of the main mesh material
  22529. * @param startIndex the index where to start the copy in the mesh indices array
  22530. * @param indexCount the number of indices to copy then from the startIndex
  22531. * @param mesh the main mesh to create the submesh from
  22532. * @param renderingMesh the optional rendering mesh
  22533. * @returns a new submesh
  22534. */
  22535. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22536. }
  22537. }
  22538. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22539. /**
  22540. * Class used to represent data loading progression
  22541. */
  22542. export class SceneLoaderFlags {
  22543. private static _ForceFullSceneLoadingForIncremental;
  22544. private static _ShowLoadingScreen;
  22545. private static _CleanBoneMatrixWeights;
  22546. private static _loggingLevel;
  22547. /**
  22548. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22549. */
  22550. static get ForceFullSceneLoadingForIncremental(): boolean;
  22551. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22552. /**
  22553. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22554. */
  22555. static get ShowLoadingScreen(): boolean;
  22556. static set ShowLoadingScreen(value: boolean);
  22557. /**
  22558. * Defines the current logging level (while loading the scene)
  22559. * @ignorenaming
  22560. */
  22561. static get loggingLevel(): number;
  22562. static set loggingLevel(value: number);
  22563. /**
  22564. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22565. */
  22566. static get CleanBoneMatrixWeights(): boolean;
  22567. static set CleanBoneMatrixWeights(value: boolean);
  22568. }
  22569. }
  22570. declare module "babylonjs/Meshes/geometry" {
  22571. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22572. import { Scene } from "babylonjs/scene";
  22573. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22574. import { Engine } from "babylonjs/Engines/engine";
  22575. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22576. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22577. import { Effect } from "babylonjs/Materials/effect";
  22578. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22579. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22580. import { Mesh } from "babylonjs/Meshes/mesh";
  22581. /**
  22582. * Class used to store geometry data (vertex buffers + index buffer)
  22583. */
  22584. export class Geometry implements IGetSetVerticesData {
  22585. /**
  22586. * Gets or sets the ID of the geometry
  22587. */
  22588. id: string;
  22589. /**
  22590. * Gets or sets the unique ID of the geometry
  22591. */
  22592. uniqueId: number;
  22593. /**
  22594. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22595. */
  22596. delayLoadState: number;
  22597. /**
  22598. * Gets the file containing the data to load when running in delay load state
  22599. */
  22600. delayLoadingFile: Nullable<string>;
  22601. /**
  22602. * Callback called when the geometry is updated
  22603. */
  22604. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22605. private _scene;
  22606. private _engine;
  22607. private _meshes;
  22608. private _totalVertices;
  22609. /** @hidden */
  22610. _indices: IndicesArray;
  22611. /** @hidden */
  22612. _vertexBuffers: {
  22613. [key: string]: VertexBuffer;
  22614. };
  22615. private _isDisposed;
  22616. private _extend;
  22617. private _boundingBias;
  22618. /** @hidden */
  22619. _delayInfo: Array<string>;
  22620. private _indexBuffer;
  22621. private _indexBufferIsUpdatable;
  22622. /** @hidden */
  22623. _boundingInfo: Nullable<BoundingInfo>;
  22624. /** @hidden */
  22625. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22626. /** @hidden */
  22627. _softwareSkinningFrameId: number;
  22628. private _vertexArrayObjects;
  22629. private _updatable;
  22630. /** @hidden */
  22631. _positions: Nullable<Vector3[]>;
  22632. /**
  22633. * 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
  22634. */
  22635. get boundingBias(): Vector2;
  22636. /**
  22637. * 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
  22638. */
  22639. set boundingBias(value: Vector2);
  22640. /**
  22641. * Static function used to attach a new empty geometry to a mesh
  22642. * @param mesh defines the mesh to attach the geometry to
  22643. * @returns the new Geometry
  22644. */
  22645. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22646. /**
  22647. * Creates a new geometry
  22648. * @param id defines the unique ID
  22649. * @param scene defines the hosting scene
  22650. * @param vertexData defines the VertexData used to get geometry data
  22651. * @param updatable defines if geometry must be updatable (false by default)
  22652. * @param mesh defines the mesh that will be associated with the geometry
  22653. */
  22654. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22655. /**
  22656. * Gets the current extend of the geometry
  22657. */
  22658. get extend(): {
  22659. minimum: Vector3;
  22660. maximum: Vector3;
  22661. };
  22662. /**
  22663. * Gets the hosting scene
  22664. * @returns the hosting Scene
  22665. */
  22666. getScene(): Scene;
  22667. /**
  22668. * Gets the hosting engine
  22669. * @returns the hosting Engine
  22670. */
  22671. getEngine(): Engine;
  22672. /**
  22673. * Defines if the geometry is ready to use
  22674. * @returns true if the geometry is ready to be used
  22675. */
  22676. isReady(): boolean;
  22677. /**
  22678. * Gets a value indicating that the geometry should not be serialized
  22679. */
  22680. get doNotSerialize(): boolean;
  22681. /** @hidden */
  22682. _rebuild(): void;
  22683. /**
  22684. * Affects all geometry data in one call
  22685. * @param vertexData defines the geometry data
  22686. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22687. */
  22688. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22689. /**
  22690. * Set specific vertex data
  22691. * @param kind defines the data kind (Position, normal, etc...)
  22692. * @param data defines the vertex data to use
  22693. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22694. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22695. */
  22696. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22697. /**
  22698. * Removes a specific vertex data
  22699. * @param kind defines the data kind (Position, normal, etc...)
  22700. */
  22701. removeVerticesData(kind: string): void;
  22702. /**
  22703. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22704. * @param buffer defines the vertex buffer to use
  22705. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22706. */
  22707. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22708. /**
  22709. * Update a specific vertex buffer
  22710. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22711. * It will do nothing if the buffer is not updatable
  22712. * @param kind defines the data kind (Position, normal, etc...)
  22713. * @param data defines the data to use
  22714. * @param offset defines the offset in the target buffer where to store the data
  22715. * @param useBytes set to true if the offset is in bytes
  22716. */
  22717. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22718. /**
  22719. * Update a specific vertex buffer
  22720. * This function will create a new buffer if the current one is not updatable
  22721. * @param kind defines the data kind (Position, normal, etc...)
  22722. * @param data defines the data to use
  22723. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22724. */
  22725. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22726. private _updateBoundingInfo;
  22727. /** @hidden */
  22728. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22729. /**
  22730. * Gets total number of vertices
  22731. * @returns the total number of vertices
  22732. */
  22733. getTotalVertices(): number;
  22734. /**
  22735. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22736. * @param kind defines the data kind (Position, normal, etc...)
  22737. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22738. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22739. * @returns a float array containing vertex data
  22740. */
  22741. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22742. /**
  22743. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22744. * @param kind defines the data kind (Position, normal, etc...)
  22745. * @returns true if the vertex buffer with the specified kind is updatable
  22746. */
  22747. isVertexBufferUpdatable(kind: string): boolean;
  22748. /**
  22749. * Gets a specific vertex buffer
  22750. * @param kind defines the data kind (Position, normal, etc...)
  22751. * @returns a VertexBuffer
  22752. */
  22753. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22754. /**
  22755. * Returns all vertex buffers
  22756. * @return an object holding all vertex buffers indexed by kind
  22757. */
  22758. getVertexBuffers(): Nullable<{
  22759. [key: string]: VertexBuffer;
  22760. }>;
  22761. /**
  22762. * Gets a boolean indicating if specific vertex buffer is present
  22763. * @param kind defines the data kind (Position, normal, etc...)
  22764. * @returns true if data is present
  22765. */
  22766. isVerticesDataPresent(kind: string): boolean;
  22767. /**
  22768. * Gets a list of all attached data kinds (Position, normal, etc...)
  22769. * @returns a list of string containing all kinds
  22770. */
  22771. getVerticesDataKinds(): string[];
  22772. /**
  22773. * Update index buffer
  22774. * @param indices defines the indices to store in the index buffer
  22775. * @param offset defines the offset in the target buffer where to store the data
  22776. * @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)
  22777. */
  22778. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22779. /**
  22780. * Creates a new index buffer
  22781. * @param indices defines the indices to store in the index buffer
  22782. * @param totalVertices defines the total number of vertices (could be null)
  22783. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22784. */
  22785. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22786. /**
  22787. * Return the total number of indices
  22788. * @returns the total number of indices
  22789. */
  22790. getTotalIndices(): number;
  22791. /**
  22792. * Gets the index buffer array
  22793. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22795. * @returns the index buffer array
  22796. */
  22797. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22798. /**
  22799. * Gets the index buffer
  22800. * @return the index buffer
  22801. */
  22802. getIndexBuffer(): Nullable<DataBuffer>;
  22803. /** @hidden */
  22804. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22805. /**
  22806. * Release the associated resources for a specific mesh
  22807. * @param mesh defines the source mesh
  22808. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22809. */
  22810. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22811. /**
  22812. * Apply current geometry to a given mesh
  22813. * @param mesh defines the mesh to apply geometry to
  22814. */
  22815. applyToMesh(mesh: Mesh): void;
  22816. private _updateExtend;
  22817. private _applyToMesh;
  22818. private notifyUpdate;
  22819. /**
  22820. * Load the geometry if it was flagged as delay loaded
  22821. * @param scene defines the hosting scene
  22822. * @param onLoaded defines a callback called when the geometry is loaded
  22823. */
  22824. load(scene: Scene, onLoaded?: () => void): void;
  22825. private _queueLoad;
  22826. /**
  22827. * Invert the geometry to move from a right handed system to a left handed one.
  22828. */
  22829. toLeftHanded(): void;
  22830. /** @hidden */
  22831. _resetPointsArrayCache(): void;
  22832. /** @hidden */
  22833. _generatePointsArray(): boolean;
  22834. /**
  22835. * Gets a value indicating if the geometry is disposed
  22836. * @returns true if the geometry was disposed
  22837. */
  22838. isDisposed(): boolean;
  22839. private _disposeVertexArrayObjects;
  22840. /**
  22841. * Free all associated resources
  22842. */
  22843. dispose(): void;
  22844. /**
  22845. * Clone the current geometry into a new geometry
  22846. * @param id defines the unique ID of the new geometry
  22847. * @returns a new geometry object
  22848. */
  22849. copy(id: string): Geometry;
  22850. /**
  22851. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22852. * @return a JSON representation of the current geometry data (without the vertices data)
  22853. */
  22854. serialize(): any;
  22855. private toNumberArray;
  22856. /**
  22857. * Serialize all vertices data into a JSON oject
  22858. * @returns a JSON representation of the current geometry data
  22859. */
  22860. serializeVerticeData(): any;
  22861. /**
  22862. * Extracts a clone of a mesh geometry
  22863. * @param mesh defines the source mesh
  22864. * @param id defines the unique ID of the new geometry object
  22865. * @returns the new geometry object
  22866. */
  22867. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22868. /**
  22869. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22870. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22871. * Be aware Math.random() could cause collisions, but:
  22872. * "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"
  22873. * @returns a string containing a new GUID
  22874. */
  22875. static RandomId(): string;
  22876. /** @hidden */
  22877. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22878. private static _CleanMatricesWeights;
  22879. /**
  22880. * Create a new geometry from persisted data (Using .babylon file format)
  22881. * @param parsedVertexData defines the persisted data
  22882. * @param scene defines the hosting scene
  22883. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22884. * @returns the new geometry object
  22885. */
  22886. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22887. }
  22888. }
  22889. declare module "babylonjs/Meshes/mesh.vertexData" {
  22890. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22891. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22892. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22893. import { Geometry } from "babylonjs/Meshes/geometry";
  22894. import { Mesh } from "babylonjs/Meshes/mesh";
  22895. /**
  22896. * Define an interface for all classes that will get and set the data on vertices
  22897. */
  22898. export interface IGetSetVerticesData {
  22899. /**
  22900. * Gets a boolean indicating if specific vertex data is present
  22901. * @param kind defines the vertex data kind to use
  22902. * @returns true is data kind is present
  22903. */
  22904. isVerticesDataPresent(kind: string): boolean;
  22905. /**
  22906. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22907. * @param kind defines the data kind (Position, normal, etc...)
  22908. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22910. * @returns a float array containing vertex data
  22911. */
  22912. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22913. /**
  22914. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22915. * @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.
  22916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22917. * @returns the indices array or an empty array if the mesh has no geometry
  22918. */
  22919. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22920. /**
  22921. * Set specific vertex data
  22922. * @param kind defines the data kind (Position, normal, etc...)
  22923. * @param data defines the vertex data to use
  22924. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22925. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22926. */
  22927. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22928. /**
  22929. * Update a specific associated vertex buffer
  22930. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22931. * - VertexBuffer.PositionKind
  22932. * - VertexBuffer.UVKind
  22933. * - VertexBuffer.UV2Kind
  22934. * - VertexBuffer.UV3Kind
  22935. * - VertexBuffer.UV4Kind
  22936. * - VertexBuffer.UV5Kind
  22937. * - VertexBuffer.UV6Kind
  22938. * - VertexBuffer.ColorKind
  22939. * - VertexBuffer.MatricesIndicesKind
  22940. * - VertexBuffer.MatricesIndicesExtraKind
  22941. * - VertexBuffer.MatricesWeightsKind
  22942. * - VertexBuffer.MatricesWeightsExtraKind
  22943. * @param data defines the data source
  22944. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22945. * @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)
  22946. */
  22947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22948. /**
  22949. * Creates a new index buffer
  22950. * @param indices defines the indices to store in the index buffer
  22951. * @param totalVertices defines the total number of vertices (could be null)
  22952. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22953. */
  22954. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22955. }
  22956. /**
  22957. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22958. */
  22959. export class VertexData {
  22960. /**
  22961. * Mesh side orientation : usually the external or front surface
  22962. */
  22963. static readonly FRONTSIDE: number;
  22964. /**
  22965. * Mesh side orientation : usually the internal or back surface
  22966. */
  22967. static readonly BACKSIDE: number;
  22968. /**
  22969. * Mesh side orientation : both internal and external or front and back surfaces
  22970. */
  22971. static readonly DOUBLESIDE: number;
  22972. /**
  22973. * Mesh side orientation : by default, `FRONTSIDE`
  22974. */
  22975. static readonly DEFAULTSIDE: number;
  22976. /**
  22977. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22978. */
  22979. positions: Nullable<FloatArray>;
  22980. /**
  22981. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22982. */
  22983. normals: Nullable<FloatArray>;
  22984. /**
  22985. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22986. */
  22987. tangents: Nullable<FloatArray>;
  22988. /**
  22989. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22990. */
  22991. uvs: Nullable<FloatArray>;
  22992. /**
  22993. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22994. */
  22995. uvs2: Nullable<FloatArray>;
  22996. /**
  22997. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22998. */
  22999. uvs3: Nullable<FloatArray>;
  23000. /**
  23001. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23002. */
  23003. uvs4: Nullable<FloatArray>;
  23004. /**
  23005. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23006. */
  23007. uvs5: Nullable<FloatArray>;
  23008. /**
  23009. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23010. */
  23011. uvs6: Nullable<FloatArray>;
  23012. /**
  23013. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23014. */
  23015. colors: Nullable<FloatArray>;
  23016. /**
  23017. * 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).
  23018. */
  23019. matricesIndices: Nullable<FloatArray>;
  23020. /**
  23021. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23022. */
  23023. matricesWeights: Nullable<FloatArray>;
  23024. /**
  23025. * An array extending the number of possible indices
  23026. */
  23027. matricesIndicesExtra: Nullable<FloatArray>;
  23028. /**
  23029. * An array extending the number of possible weights when the number of indices is extended
  23030. */
  23031. matricesWeightsExtra: Nullable<FloatArray>;
  23032. /**
  23033. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23034. */
  23035. indices: Nullable<IndicesArray>;
  23036. /**
  23037. * Uses the passed data array to set the set the values for the specified kind of data
  23038. * @param data a linear array of floating numbers
  23039. * @param kind the type of data that is being set, eg positions, colors etc
  23040. */
  23041. set(data: FloatArray, kind: string): void;
  23042. /**
  23043. * Associates the vertexData to the passed Mesh.
  23044. * Sets it as updatable or not (default `false`)
  23045. * @param mesh the mesh the vertexData is applied to
  23046. * @param updatable when used and having the value true allows new data to update the vertexData
  23047. * @returns the VertexData
  23048. */
  23049. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23050. /**
  23051. * Associates the vertexData to the passed Geometry.
  23052. * Sets it as updatable or not (default `false`)
  23053. * @param geometry the geometry the vertexData is applied to
  23054. * @param updatable when used and having the value true allows new data to update the vertexData
  23055. * @returns VertexData
  23056. */
  23057. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23058. /**
  23059. * Updates the associated mesh
  23060. * @param mesh the mesh to be updated
  23061. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23062. * @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
  23063. * @returns VertexData
  23064. */
  23065. updateMesh(mesh: Mesh): VertexData;
  23066. /**
  23067. * Updates the associated geometry
  23068. * @param geometry the geometry to be updated
  23069. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23070. * @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
  23071. * @returns VertexData.
  23072. */
  23073. updateGeometry(geometry: Geometry): VertexData;
  23074. private _applyTo;
  23075. private _update;
  23076. /**
  23077. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23078. * @param matrix the transforming matrix
  23079. * @returns the VertexData
  23080. */
  23081. transform(matrix: Matrix): VertexData;
  23082. /**
  23083. * Merges the passed VertexData into the current one
  23084. * @param other the VertexData to be merged into the current one
  23085. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23086. * @returns the modified VertexData
  23087. */
  23088. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23089. private _mergeElement;
  23090. private _validate;
  23091. /**
  23092. * Serializes the VertexData
  23093. * @returns a serialized object
  23094. */
  23095. serialize(): any;
  23096. /**
  23097. * Extracts the vertexData from a mesh
  23098. * @param mesh the mesh from which to extract the VertexData
  23099. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23100. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23101. * @returns the object VertexData associated to the passed mesh
  23102. */
  23103. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23104. /**
  23105. * Extracts the vertexData from the geometry
  23106. * @param geometry the geometry from which to extract the VertexData
  23107. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23108. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23109. * @returns the object VertexData associated to the passed mesh
  23110. */
  23111. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23112. private static _ExtractFrom;
  23113. /**
  23114. * Creates the VertexData for a Ribbon
  23115. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23116. * * pathArray array of paths, each of which an array of successive Vector3
  23117. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23118. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23119. * * 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
  23120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23121. * * 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)
  23122. * * 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)
  23123. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23124. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23125. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23126. * @returns the VertexData of the ribbon
  23127. */
  23128. static CreateRibbon(options: {
  23129. pathArray: Vector3[][];
  23130. closeArray?: boolean;
  23131. closePath?: boolean;
  23132. offset?: number;
  23133. sideOrientation?: number;
  23134. frontUVs?: Vector4;
  23135. backUVs?: Vector4;
  23136. invertUV?: boolean;
  23137. uvs?: Vector2[];
  23138. colors?: Color4[];
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for a box
  23142. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23143. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23144. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23145. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23146. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23147. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23148. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * 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)
  23151. * * 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)
  23152. * @returns the VertexData of the box
  23153. */
  23154. static CreateBox(options: {
  23155. size?: number;
  23156. width?: number;
  23157. height?: number;
  23158. depth?: number;
  23159. faceUV?: Vector4[];
  23160. faceColors?: Color4[];
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }): VertexData;
  23165. /**
  23166. * Creates the VertexData for a tiled box
  23167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23168. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23169. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23170. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23172. * @returns the VertexData of the box
  23173. */
  23174. static CreateTiledBox(options: {
  23175. pattern?: number;
  23176. width?: number;
  23177. height?: number;
  23178. depth?: number;
  23179. tileSize?: number;
  23180. tileWidth?: number;
  23181. tileHeight?: number;
  23182. alignHorizontal?: number;
  23183. alignVertical?: number;
  23184. faceUV?: Vector4[];
  23185. faceColors?: Color4[];
  23186. sideOrientation?: number;
  23187. }): VertexData;
  23188. /**
  23189. * Creates the VertexData for a tiled plane
  23190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23191. * * pattern a limited pattern arrangement depending on the number
  23192. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23193. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23194. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23196. * * 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)
  23197. * * 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)
  23198. * @returns the VertexData of the tiled plane
  23199. */
  23200. static CreateTiledPlane(options: {
  23201. pattern?: number;
  23202. tileSize?: number;
  23203. tileWidth?: number;
  23204. tileHeight?: number;
  23205. size?: number;
  23206. width?: number;
  23207. height?: number;
  23208. alignHorizontal?: number;
  23209. alignVertical?: number;
  23210. sideOrientation?: number;
  23211. frontUVs?: Vector4;
  23212. backUVs?: Vector4;
  23213. }): VertexData;
  23214. /**
  23215. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23217. * * segments sets the number of horizontal strips optional, default 32
  23218. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23219. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23220. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23221. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23222. * * 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
  23223. * * 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
  23224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23225. * * 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)
  23226. * * 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)
  23227. * @returns the VertexData of the ellipsoid
  23228. */
  23229. static CreateSphere(options: {
  23230. segments?: number;
  23231. diameter?: number;
  23232. diameterX?: number;
  23233. diameterY?: number;
  23234. diameterZ?: number;
  23235. arc?: number;
  23236. slice?: number;
  23237. sideOrientation?: number;
  23238. frontUVs?: Vector4;
  23239. backUVs?: Vector4;
  23240. }): VertexData;
  23241. /**
  23242. * Creates the VertexData for a cylinder, cone or prism
  23243. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23244. * * height sets the height (y direction) of the cylinder, optional, default 2
  23245. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23246. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23247. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23248. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23249. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23250. * * 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
  23251. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23252. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23253. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23254. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23256. * * 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)
  23257. * * 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)
  23258. * @returns the VertexData of the cylinder, cone or prism
  23259. */
  23260. static CreateCylinder(options: {
  23261. height?: number;
  23262. diameterTop?: number;
  23263. diameterBottom?: number;
  23264. diameter?: number;
  23265. tessellation?: number;
  23266. subdivisions?: number;
  23267. arc?: number;
  23268. faceColors?: Color4[];
  23269. faceUV?: Vector4[];
  23270. hasRings?: boolean;
  23271. enclose?: boolean;
  23272. sideOrientation?: number;
  23273. frontUVs?: Vector4;
  23274. backUVs?: Vector4;
  23275. }): VertexData;
  23276. /**
  23277. * Creates the VertexData for a torus
  23278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23279. * * diameter the diameter of the torus, optional default 1
  23280. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23281. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23283. * * 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)
  23284. * * 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)
  23285. * @returns the VertexData of the torus
  23286. */
  23287. static CreateTorus(options: {
  23288. diameter?: number;
  23289. thickness?: number;
  23290. tessellation?: number;
  23291. sideOrientation?: number;
  23292. frontUVs?: Vector4;
  23293. backUVs?: Vector4;
  23294. }): VertexData;
  23295. /**
  23296. * Creates the VertexData of the LineSystem
  23297. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23298. * - lines an array of lines, each line being an array of successive Vector3
  23299. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23300. * @returns the VertexData of the LineSystem
  23301. */
  23302. static CreateLineSystem(options: {
  23303. lines: Vector3[][];
  23304. colors?: Nullable<Color4[][]>;
  23305. }): VertexData;
  23306. /**
  23307. * Create the VertexData for a DashedLines
  23308. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23309. * - points an array successive Vector3
  23310. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23311. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23312. * - dashNb the intended total number of dashes, optional, default 200
  23313. * @returns the VertexData for the DashedLines
  23314. */
  23315. static CreateDashedLines(options: {
  23316. points: Vector3[];
  23317. dashSize?: number;
  23318. gapSize?: number;
  23319. dashNb?: number;
  23320. }): VertexData;
  23321. /**
  23322. * Creates the VertexData for a Ground
  23323. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23324. * - width the width (x direction) of the ground, optional, default 1
  23325. * - height the height (z direction) of the ground, optional, default 1
  23326. * - subdivisions the number of subdivisions per side, optional, default 1
  23327. * @returns the VertexData of the Ground
  23328. */
  23329. static CreateGround(options: {
  23330. width?: number;
  23331. height?: number;
  23332. subdivisions?: number;
  23333. subdivisionsX?: number;
  23334. subdivisionsY?: number;
  23335. }): VertexData;
  23336. /**
  23337. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23338. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23339. * * xmin the ground minimum X coordinate, optional, default -1
  23340. * * zmin the ground minimum Z coordinate, optional, default -1
  23341. * * xmax the ground maximum X coordinate, optional, default 1
  23342. * * zmax the ground maximum Z coordinate, optional, default 1
  23343. * * 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}
  23344. * * 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}
  23345. * @returns the VertexData of the TiledGround
  23346. */
  23347. static CreateTiledGround(options: {
  23348. xmin: number;
  23349. zmin: number;
  23350. xmax: number;
  23351. zmax: number;
  23352. subdivisions?: {
  23353. w: number;
  23354. h: number;
  23355. };
  23356. precision?: {
  23357. w: number;
  23358. h: number;
  23359. };
  23360. }): VertexData;
  23361. /**
  23362. * Creates the VertexData of the Ground designed from a heightmap
  23363. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23364. * * width the width (x direction) of the ground
  23365. * * height the height (z direction) of the ground
  23366. * * subdivisions the number of subdivisions per side
  23367. * * minHeight the minimum altitude on the ground, optional, default 0
  23368. * * maxHeight the maximum altitude on the ground, optional default 1
  23369. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23370. * * buffer the array holding the image color data
  23371. * * bufferWidth the width of image
  23372. * * bufferHeight the height of image
  23373. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23374. * @returns the VertexData of the Ground designed from a heightmap
  23375. */
  23376. static CreateGroundFromHeightMap(options: {
  23377. width: number;
  23378. height: number;
  23379. subdivisions: number;
  23380. minHeight: number;
  23381. maxHeight: number;
  23382. colorFilter: Color3;
  23383. buffer: Uint8Array;
  23384. bufferWidth: number;
  23385. bufferHeight: number;
  23386. alphaFilter: number;
  23387. }): VertexData;
  23388. /**
  23389. * Creates the VertexData for a Plane
  23390. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23391. * * size sets the width and height of the plane to the value of size, optional default 1
  23392. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23393. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23395. * * 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)
  23396. * * 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)
  23397. * @returns the VertexData of the box
  23398. */
  23399. static CreatePlane(options: {
  23400. size?: number;
  23401. width?: number;
  23402. height?: number;
  23403. sideOrientation?: number;
  23404. frontUVs?: Vector4;
  23405. backUVs?: Vector4;
  23406. }): VertexData;
  23407. /**
  23408. * Creates the VertexData of the Disc or regular Polygon
  23409. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23410. * * radius the radius of the disc, optional default 0.5
  23411. * * tessellation the number of polygon sides, optional, default 64
  23412. * * 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
  23413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23414. * * 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)
  23415. * * 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)
  23416. * @returns the VertexData of the box
  23417. */
  23418. static CreateDisc(options: {
  23419. radius?: number;
  23420. tessellation?: number;
  23421. arc?: number;
  23422. sideOrientation?: number;
  23423. frontUVs?: Vector4;
  23424. backUVs?: Vector4;
  23425. }): VertexData;
  23426. /**
  23427. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23428. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23429. * @param polygon a mesh built from polygonTriangulation.build()
  23430. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23431. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23432. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23433. * @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)
  23434. * @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)
  23435. * @returns the VertexData of the Polygon
  23436. */
  23437. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23438. /**
  23439. * Creates the VertexData of the IcoSphere
  23440. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23441. * * radius the radius of the IcoSphere, optional default 1
  23442. * * radiusX allows stretching in the x direction, optional, default radius
  23443. * * radiusY allows stretching in the y direction, optional, default radius
  23444. * * radiusZ allows stretching in the z direction, optional, default radius
  23445. * * flat when true creates a flat shaded mesh, optional, default true
  23446. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23448. * * 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)
  23449. * * 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)
  23450. * @returns the VertexData of the IcoSphere
  23451. */
  23452. static CreateIcoSphere(options: {
  23453. radius?: number;
  23454. radiusX?: number;
  23455. radiusY?: number;
  23456. radiusZ?: number;
  23457. flat?: boolean;
  23458. subdivisions?: number;
  23459. sideOrientation?: number;
  23460. frontUVs?: Vector4;
  23461. backUVs?: Vector4;
  23462. }): VertexData;
  23463. /**
  23464. * Creates the VertexData for a Polyhedron
  23465. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23466. * * type provided types are:
  23467. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23468. * * 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)
  23469. * * size the size of the IcoSphere, optional default 1
  23470. * * sizeX allows stretching in the x direction, optional, default size
  23471. * * sizeY allows stretching in the y direction, optional, default size
  23472. * * sizeZ allows stretching in the z direction, optional, default size
  23473. * * 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
  23474. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23475. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23476. * * flat when true creates a flat shaded mesh, optional, default true
  23477. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23479. * * 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)
  23480. * * 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)
  23481. * @returns the VertexData of the Polyhedron
  23482. */
  23483. static CreatePolyhedron(options: {
  23484. type?: number;
  23485. size?: number;
  23486. sizeX?: number;
  23487. sizeY?: number;
  23488. sizeZ?: number;
  23489. custom?: any;
  23490. faceUV?: Vector4[];
  23491. faceColors?: Color4[];
  23492. flat?: boolean;
  23493. sideOrientation?: number;
  23494. frontUVs?: Vector4;
  23495. backUVs?: Vector4;
  23496. }): VertexData;
  23497. /**
  23498. * Creates the VertexData for a TorusKnot
  23499. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23500. * * radius the radius of the torus knot, optional, default 2
  23501. * * tube the thickness of the tube, optional, default 0.5
  23502. * * radialSegments the number of sides on each tube segments, optional, default 32
  23503. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23504. * * p the number of windings around the z axis, optional, default 2
  23505. * * q the number of windings around the x axis, optional, default 3
  23506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23507. * * 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)
  23508. * * 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)
  23509. * @returns the VertexData of the Torus Knot
  23510. */
  23511. static CreateTorusKnot(options: {
  23512. radius?: number;
  23513. tube?: number;
  23514. radialSegments?: number;
  23515. tubularSegments?: number;
  23516. p?: number;
  23517. q?: number;
  23518. sideOrientation?: number;
  23519. frontUVs?: Vector4;
  23520. backUVs?: Vector4;
  23521. }): VertexData;
  23522. /**
  23523. * Compute normals for given positions and indices
  23524. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23525. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23526. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23527. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23528. * * facetNormals : optional array of facet normals (vector3)
  23529. * * facetPositions : optional array of facet positions (vector3)
  23530. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23531. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23532. * * bInfo : optional bounding info, required for facetPartitioning computation
  23533. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23534. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23535. * * useRightHandedSystem: optional boolean to for right handed system computation
  23536. * * depthSort : optional boolean to enable the facet depth sort computation
  23537. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23538. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23539. */
  23540. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23541. facetNormals?: any;
  23542. facetPositions?: any;
  23543. facetPartitioning?: any;
  23544. ratio?: number;
  23545. bInfo?: any;
  23546. bbSize?: Vector3;
  23547. subDiv?: any;
  23548. useRightHandedSystem?: boolean;
  23549. depthSort?: boolean;
  23550. distanceTo?: Vector3;
  23551. depthSortedFacets?: any;
  23552. }): void;
  23553. /** @hidden */
  23554. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23555. /**
  23556. * Applies VertexData created from the imported parameters to the geometry
  23557. * @param parsedVertexData the parsed data from an imported file
  23558. * @param geometry the geometry to apply the VertexData to
  23559. */
  23560. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23561. }
  23562. }
  23563. declare module "babylonjs/Morph/morphTarget" {
  23564. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23565. import { Observable } from "babylonjs/Misc/observable";
  23566. import { Nullable, FloatArray } from "babylonjs/types";
  23567. import { Scene } from "babylonjs/scene";
  23568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23569. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23570. /**
  23571. * Defines a target to use with MorphTargetManager
  23572. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23573. */
  23574. export class MorphTarget implements IAnimatable {
  23575. /** defines the name of the target */
  23576. name: string;
  23577. /**
  23578. * Gets or sets the list of animations
  23579. */
  23580. animations: import("babylonjs/Animations/animation").Animation[];
  23581. private _scene;
  23582. private _positions;
  23583. private _normals;
  23584. private _tangents;
  23585. private _uvs;
  23586. private _influence;
  23587. private _uniqueId;
  23588. /**
  23589. * Observable raised when the influence changes
  23590. */
  23591. onInfluenceChanged: Observable<boolean>;
  23592. /** @hidden */
  23593. _onDataLayoutChanged: Observable<void>;
  23594. /**
  23595. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23596. */
  23597. get influence(): number;
  23598. set influence(influence: number);
  23599. /**
  23600. * Gets or sets the id of the morph Target
  23601. */
  23602. id: string;
  23603. private _animationPropertiesOverride;
  23604. /**
  23605. * Gets or sets the animation properties override
  23606. */
  23607. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23608. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23609. /**
  23610. * Creates a new MorphTarget
  23611. * @param name defines the name of the target
  23612. * @param influence defines the influence to use
  23613. * @param scene defines the scene the morphtarget belongs to
  23614. */
  23615. constructor(
  23616. /** defines the name of the target */
  23617. name: string, influence?: number, scene?: Nullable<Scene>);
  23618. /**
  23619. * Gets the unique ID of this manager
  23620. */
  23621. get uniqueId(): number;
  23622. /**
  23623. * Gets a boolean defining if the target contains position data
  23624. */
  23625. get hasPositions(): boolean;
  23626. /**
  23627. * Gets a boolean defining if the target contains normal data
  23628. */
  23629. get hasNormals(): boolean;
  23630. /**
  23631. * Gets a boolean defining if the target contains tangent data
  23632. */
  23633. get hasTangents(): boolean;
  23634. /**
  23635. * Gets a boolean defining if the target contains texture coordinates data
  23636. */
  23637. get hasUVs(): boolean;
  23638. /**
  23639. * Affects position data to this target
  23640. * @param data defines the position data to use
  23641. */
  23642. setPositions(data: Nullable<FloatArray>): void;
  23643. /**
  23644. * Gets the position data stored in this target
  23645. * @returns a FloatArray containing the position data (or null if not present)
  23646. */
  23647. getPositions(): Nullable<FloatArray>;
  23648. /**
  23649. * Affects normal data to this target
  23650. * @param data defines the normal data to use
  23651. */
  23652. setNormals(data: Nullable<FloatArray>): void;
  23653. /**
  23654. * Gets the normal data stored in this target
  23655. * @returns a FloatArray containing the normal data (or null if not present)
  23656. */
  23657. getNormals(): Nullable<FloatArray>;
  23658. /**
  23659. * Affects tangent data to this target
  23660. * @param data defines the tangent data to use
  23661. */
  23662. setTangents(data: Nullable<FloatArray>): void;
  23663. /**
  23664. * Gets the tangent data stored in this target
  23665. * @returns a FloatArray containing the tangent data (or null if not present)
  23666. */
  23667. getTangents(): Nullable<FloatArray>;
  23668. /**
  23669. * Affects texture coordinates data to this target
  23670. * @param data defines the texture coordinates data to use
  23671. */
  23672. setUVs(data: Nullable<FloatArray>): void;
  23673. /**
  23674. * Gets the texture coordinates data stored in this target
  23675. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23676. */
  23677. getUVs(): Nullable<FloatArray>;
  23678. /**
  23679. * Clone the current target
  23680. * @returns a new MorphTarget
  23681. */
  23682. clone(): MorphTarget;
  23683. /**
  23684. * Serializes the current target into a Serialization object
  23685. * @returns the serialized object
  23686. */
  23687. serialize(): any;
  23688. /**
  23689. * Returns the string "MorphTarget"
  23690. * @returns "MorphTarget"
  23691. */
  23692. getClassName(): string;
  23693. /**
  23694. * Creates a new target from serialized data
  23695. * @param serializationObject defines the serialized data to use
  23696. * @returns a new MorphTarget
  23697. */
  23698. static Parse(serializationObject: any): MorphTarget;
  23699. /**
  23700. * Creates a MorphTarget from mesh data
  23701. * @param mesh defines the source mesh
  23702. * @param name defines the name to use for the new target
  23703. * @param influence defines the influence to attach to the target
  23704. * @returns a new MorphTarget
  23705. */
  23706. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23707. }
  23708. }
  23709. declare module "babylonjs/Morph/morphTargetManager" {
  23710. import { Nullable } from "babylonjs/types";
  23711. import { Scene } from "babylonjs/scene";
  23712. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23713. /**
  23714. * This class is used to deform meshes using morphing between different targets
  23715. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23716. */
  23717. export class MorphTargetManager {
  23718. private _targets;
  23719. private _targetInfluenceChangedObservers;
  23720. private _targetDataLayoutChangedObservers;
  23721. private _activeTargets;
  23722. private _scene;
  23723. private _influences;
  23724. private _supportsNormals;
  23725. private _supportsTangents;
  23726. private _supportsUVs;
  23727. private _vertexCount;
  23728. private _uniqueId;
  23729. private _tempInfluences;
  23730. /**
  23731. * Gets or sets a boolean indicating if normals must be morphed
  23732. */
  23733. enableNormalMorphing: boolean;
  23734. /**
  23735. * Gets or sets a boolean indicating if tangents must be morphed
  23736. */
  23737. enableTangentMorphing: boolean;
  23738. /**
  23739. * Gets or sets a boolean indicating if UV must be morphed
  23740. */
  23741. enableUVMorphing: boolean;
  23742. /**
  23743. * Creates a new MorphTargetManager
  23744. * @param scene defines the current scene
  23745. */
  23746. constructor(scene?: Nullable<Scene>);
  23747. /**
  23748. * Gets the unique ID of this manager
  23749. */
  23750. get uniqueId(): number;
  23751. /**
  23752. * Gets the number of vertices handled by this manager
  23753. */
  23754. get vertexCount(): number;
  23755. /**
  23756. * Gets a boolean indicating if this manager supports morphing of normals
  23757. */
  23758. get supportsNormals(): boolean;
  23759. /**
  23760. * Gets a boolean indicating if this manager supports morphing of tangents
  23761. */
  23762. get supportsTangents(): boolean;
  23763. /**
  23764. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23765. */
  23766. get supportsUVs(): boolean;
  23767. /**
  23768. * Gets the number of targets stored in this manager
  23769. */
  23770. get numTargets(): number;
  23771. /**
  23772. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23773. */
  23774. get numInfluencers(): number;
  23775. /**
  23776. * Gets the list of influences (one per target)
  23777. */
  23778. get influences(): Float32Array;
  23779. /**
  23780. * Gets the active target at specified index. An active target is a target with an influence > 0
  23781. * @param index defines the index to check
  23782. * @returns the requested target
  23783. */
  23784. getActiveTarget(index: number): MorphTarget;
  23785. /**
  23786. * Gets the target at specified index
  23787. * @param index defines the index to check
  23788. * @returns the requested target
  23789. */
  23790. getTarget(index: number): MorphTarget;
  23791. /**
  23792. * Add a new target to this manager
  23793. * @param target defines the target to add
  23794. */
  23795. addTarget(target: MorphTarget): void;
  23796. /**
  23797. * Removes a target from the manager
  23798. * @param target defines the target to remove
  23799. */
  23800. removeTarget(target: MorphTarget): void;
  23801. /**
  23802. * Clone the current manager
  23803. * @returns a new MorphTargetManager
  23804. */
  23805. clone(): MorphTargetManager;
  23806. /**
  23807. * Serializes the current manager into a Serialization object
  23808. * @returns the serialized object
  23809. */
  23810. serialize(): any;
  23811. private _syncActiveTargets;
  23812. /**
  23813. * Syncrhonize the targets with all the meshes using this morph target manager
  23814. */
  23815. synchronize(): void;
  23816. /**
  23817. * Creates a new MorphTargetManager from serialized data
  23818. * @param serializationObject defines the serialized data
  23819. * @param scene defines the hosting scene
  23820. * @returns the new MorphTargetManager
  23821. */
  23822. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23823. }
  23824. }
  23825. declare module "babylonjs/Meshes/meshLODLevel" {
  23826. import { Mesh } from "babylonjs/Meshes/mesh";
  23827. import { Nullable } from "babylonjs/types";
  23828. /**
  23829. * Class used to represent a specific level of detail of a mesh
  23830. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23831. */
  23832. export class MeshLODLevel {
  23833. /** Defines the distance where this level should start being displayed */
  23834. distance: number;
  23835. /** Defines the mesh to use to render this level */
  23836. mesh: Nullable<Mesh>;
  23837. /**
  23838. * Creates a new LOD level
  23839. * @param distance defines the distance where this level should star being displayed
  23840. * @param mesh defines the mesh to use to render this level
  23841. */
  23842. constructor(
  23843. /** Defines the distance where this level should start being displayed */
  23844. distance: number,
  23845. /** Defines the mesh to use to render this level */
  23846. mesh: Nullable<Mesh>);
  23847. }
  23848. }
  23849. declare module "babylonjs/Meshes/groundMesh" {
  23850. import { Scene } from "babylonjs/scene";
  23851. import { Vector3 } from "babylonjs/Maths/math.vector";
  23852. import { Mesh } from "babylonjs/Meshes/mesh";
  23853. /**
  23854. * Mesh representing the gorund
  23855. */
  23856. export class GroundMesh extends Mesh {
  23857. /** If octree should be generated */
  23858. generateOctree: boolean;
  23859. private _heightQuads;
  23860. /** @hidden */
  23861. _subdivisionsX: number;
  23862. /** @hidden */
  23863. _subdivisionsY: number;
  23864. /** @hidden */
  23865. _width: number;
  23866. /** @hidden */
  23867. _height: number;
  23868. /** @hidden */
  23869. _minX: number;
  23870. /** @hidden */
  23871. _maxX: number;
  23872. /** @hidden */
  23873. _minZ: number;
  23874. /** @hidden */
  23875. _maxZ: number;
  23876. constructor(name: string, scene: Scene);
  23877. /**
  23878. * "GroundMesh"
  23879. * @returns "GroundMesh"
  23880. */
  23881. getClassName(): string;
  23882. /**
  23883. * The minimum of x and y subdivisions
  23884. */
  23885. get subdivisions(): number;
  23886. /**
  23887. * X subdivisions
  23888. */
  23889. get subdivisionsX(): number;
  23890. /**
  23891. * Y subdivisions
  23892. */
  23893. get subdivisionsY(): number;
  23894. /**
  23895. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23896. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23897. * @param chunksCount the number of subdivisions for x and y
  23898. * @param octreeBlocksSize (Default: 32)
  23899. */
  23900. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23901. /**
  23902. * Returns a height (y) value in the Worl system :
  23903. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23904. * @param x x coordinate
  23905. * @param z z coordinate
  23906. * @returns the ground y position if (x, z) are outside the ground surface.
  23907. */
  23908. getHeightAtCoordinates(x: number, z: number): number;
  23909. /**
  23910. * Returns a normalized vector (Vector3) orthogonal to the ground
  23911. * at the ground coordinates (x, z) expressed in the World system.
  23912. * @param x x coordinate
  23913. * @param z z coordinate
  23914. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23915. */
  23916. getNormalAtCoordinates(x: number, z: number): Vector3;
  23917. /**
  23918. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23919. * at the ground coordinates (x, z) expressed in the World system.
  23920. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23921. * @param x x coordinate
  23922. * @param z z coordinate
  23923. * @param ref vector to store the result
  23924. * @returns the GroundMesh.
  23925. */
  23926. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23927. /**
  23928. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23929. * if the ground has been updated.
  23930. * This can be used in the render loop.
  23931. * @returns the GroundMesh.
  23932. */
  23933. updateCoordinateHeights(): GroundMesh;
  23934. private _getFacetAt;
  23935. private _initHeightQuads;
  23936. private _computeHeightQuads;
  23937. /**
  23938. * Serializes this ground mesh
  23939. * @param serializationObject object to write serialization to
  23940. */
  23941. serialize(serializationObject: any): void;
  23942. /**
  23943. * Parses a serialized ground mesh
  23944. * @param parsedMesh the serialized mesh
  23945. * @param scene the scene to create the ground mesh in
  23946. * @returns the created ground mesh
  23947. */
  23948. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23949. }
  23950. }
  23951. declare module "babylonjs/Physics/physicsJoint" {
  23952. import { Vector3 } from "babylonjs/Maths/math.vector";
  23953. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23954. /**
  23955. * Interface for Physics-Joint data
  23956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23957. */
  23958. export interface PhysicsJointData {
  23959. /**
  23960. * The main pivot of the joint
  23961. */
  23962. mainPivot?: Vector3;
  23963. /**
  23964. * The connected pivot of the joint
  23965. */
  23966. connectedPivot?: Vector3;
  23967. /**
  23968. * The main axis of the joint
  23969. */
  23970. mainAxis?: Vector3;
  23971. /**
  23972. * The connected axis of the joint
  23973. */
  23974. connectedAxis?: Vector3;
  23975. /**
  23976. * The collision of the joint
  23977. */
  23978. collision?: boolean;
  23979. /**
  23980. * Native Oimo/Cannon/Energy data
  23981. */
  23982. nativeParams?: any;
  23983. }
  23984. /**
  23985. * This is a holder class for the physics joint created by the physics plugin
  23986. * It holds a set of functions to control the underlying joint
  23987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23988. */
  23989. export class PhysicsJoint {
  23990. /**
  23991. * The type of the physics joint
  23992. */
  23993. type: number;
  23994. /**
  23995. * The data for the physics joint
  23996. */
  23997. jointData: PhysicsJointData;
  23998. private _physicsJoint;
  23999. protected _physicsPlugin: IPhysicsEnginePlugin;
  24000. /**
  24001. * Initializes the physics joint
  24002. * @param type The type of the physics joint
  24003. * @param jointData The data for the physics joint
  24004. */
  24005. constructor(
  24006. /**
  24007. * The type of the physics joint
  24008. */
  24009. type: number,
  24010. /**
  24011. * The data for the physics joint
  24012. */
  24013. jointData: PhysicsJointData);
  24014. /**
  24015. * Gets the physics joint
  24016. */
  24017. get physicsJoint(): any;
  24018. /**
  24019. * Sets the physics joint
  24020. */
  24021. set physicsJoint(newJoint: any);
  24022. /**
  24023. * Sets the physics plugin
  24024. */
  24025. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24026. /**
  24027. * Execute a function that is physics-plugin specific.
  24028. * @param {Function} func the function that will be executed.
  24029. * It accepts two parameters: the physics world and the physics joint
  24030. */
  24031. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24032. /**
  24033. * Distance-Joint type
  24034. */
  24035. static DistanceJoint: number;
  24036. /**
  24037. * Hinge-Joint type
  24038. */
  24039. static HingeJoint: number;
  24040. /**
  24041. * Ball-and-Socket joint type
  24042. */
  24043. static BallAndSocketJoint: number;
  24044. /**
  24045. * Wheel-Joint type
  24046. */
  24047. static WheelJoint: number;
  24048. /**
  24049. * Slider-Joint type
  24050. */
  24051. static SliderJoint: number;
  24052. /**
  24053. * Prismatic-Joint type
  24054. */
  24055. static PrismaticJoint: number;
  24056. /**
  24057. * Universal-Joint type
  24058. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24059. */
  24060. static UniversalJoint: number;
  24061. /**
  24062. * Hinge-Joint 2 type
  24063. */
  24064. static Hinge2Joint: number;
  24065. /**
  24066. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24067. */
  24068. static PointToPointJoint: number;
  24069. /**
  24070. * Spring-Joint type
  24071. */
  24072. static SpringJoint: number;
  24073. /**
  24074. * Lock-Joint type
  24075. */
  24076. static LockJoint: number;
  24077. }
  24078. /**
  24079. * A class representing a physics distance joint
  24080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24081. */
  24082. export class DistanceJoint extends PhysicsJoint {
  24083. /**
  24084. *
  24085. * @param jointData The data for the Distance-Joint
  24086. */
  24087. constructor(jointData: DistanceJointData);
  24088. /**
  24089. * Update the predefined distance.
  24090. * @param maxDistance The maximum preferred distance
  24091. * @param minDistance The minimum preferred distance
  24092. */
  24093. updateDistance(maxDistance: number, minDistance?: number): void;
  24094. }
  24095. /**
  24096. * Represents a Motor-Enabled Joint
  24097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24098. */
  24099. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24100. /**
  24101. * Initializes the Motor-Enabled Joint
  24102. * @param type The type of the joint
  24103. * @param jointData The physica joint data for the joint
  24104. */
  24105. constructor(type: number, jointData: PhysicsJointData);
  24106. /**
  24107. * Set the motor values.
  24108. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24109. * @param force the force to apply
  24110. * @param maxForce max force for this motor.
  24111. */
  24112. setMotor(force?: number, maxForce?: number): void;
  24113. /**
  24114. * Set the motor's limits.
  24115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24116. * @param upperLimit The upper limit of the motor
  24117. * @param lowerLimit The lower limit of the motor
  24118. */
  24119. setLimit(upperLimit: number, lowerLimit?: number): void;
  24120. }
  24121. /**
  24122. * This class represents a single physics Hinge-Joint
  24123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24124. */
  24125. export class HingeJoint extends MotorEnabledJoint {
  24126. /**
  24127. * Initializes the Hinge-Joint
  24128. * @param jointData The joint data for the Hinge-Joint
  24129. */
  24130. constructor(jointData: PhysicsJointData);
  24131. /**
  24132. * Set the motor values.
  24133. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24134. * @param {number} force the force to apply
  24135. * @param {number} maxForce max force for this motor.
  24136. */
  24137. setMotor(force?: number, maxForce?: number): void;
  24138. /**
  24139. * Set the motor's limits.
  24140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24141. * @param upperLimit The upper limit of the motor
  24142. * @param lowerLimit The lower limit of the motor
  24143. */
  24144. setLimit(upperLimit: number, lowerLimit?: number): void;
  24145. }
  24146. /**
  24147. * This class represents a dual hinge physics joint (same as wheel joint)
  24148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24149. */
  24150. export class Hinge2Joint extends MotorEnabledJoint {
  24151. /**
  24152. * Initializes the Hinge2-Joint
  24153. * @param jointData The joint data for the Hinge2-Joint
  24154. */
  24155. constructor(jointData: PhysicsJointData);
  24156. /**
  24157. * Set the motor values.
  24158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24159. * @param {number} targetSpeed the speed the motor is to reach
  24160. * @param {number} maxForce max force for this motor.
  24161. * @param {motorIndex} the motor's index, 0 or 1.
  24162. */
  24163. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24164. /**
  24165. * Set the motor limits.
  24166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24167. * @param {number} upperLimit the upper limit
  24168. * @param {number} lowerLimit lower limit
  24169. * @param {motorIndex} the motor's index, 0 or 1.
  24170. */
  24171. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24172. }
  24173. /**
  24174. * Interface for a motor enabled joint
  24175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24176. */
  24177. export interface IMotorEnabledJoint {
  24178. /**
  24179. * Physics joint
  24180. */
  24181. physicsJoint: any;
  24182. /**
  24183. * Sets the motor of the motor-enabled joint
  24184. * @param force The force of the motor
  24185. * @param maxForce The maximum force of the motor
  24186. * @param motorIndex The index of the motor
  24187. */
  24188. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24189. /**
  24190. * Sets the limit of the motor
  24191. * @param upperLimit The upper limit of the motor
  24192. * @param lowerLimit The lower limit of the motor
  24193. * @param motorIndex The index of the motor
  24194. */
  24195. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24196. }
  24197. /**
  24198. * Joint data for a Distance-Joint
  24199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24200. */
  24201. export interface DistanceJointData extends PhysicsJointData {
  24202. /**
  24203. * Max distance the 2 joint objects can be apart
  24204. */
  24205. maxDistance: number;
  24206. }
  24207. /**
  24208. * Joint data from a spring joint
  24209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24210. */
  24211. export interface SpringJointData extends PhysicsJointData {
  24212. /**
  24213. * Length of the spring
  24214. */
  24215. length: number;
  24216. /**
  24217. * Stiffness of the spring
  24218. */
  24219. stiffness: number;
  24220. /**
  24221. * Damping of the spring
  24222. */
  24223. damping: number;
  24224. /** this callback will be called when applying the force to the impostors. */
  24225. forceApplicationCallback: () => void;
  24226. }
  24227. }
  24228. declare module "babylonjs/Physics/physicsRaycastResult" {
  24229. import { Vector3 } from "babylonjs/Maths/math.vector";
  24230. /**
  24231. * Holds the data for the raycast result
  24232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24233. */
  24234. export class PhysicsRaycastResult {
  24235. private _hasHit;
  24236. private _hitDistance;
  24237. private _hitNormalWorld;
  24238. private _hitPointWorld;
  24239. private _rayFromWorld;
  24240. private _rayToWorld;
  24241. /**
  24242. * Gets if there was a hit
  24243. */
  24244. get hasHit(): boolean;
  24245. /**
  24246. * Gets the distance from the hit
  24247. */
  24248. get hitDistance(): number;
  24249. /**
  24250. * Gets the hit normal/direction in the world
  24251. */
  24252. get hitNormalWorld(): Vector3;
  24253. /**
  24254. * Gets the hit point in the world
  24255. */
  24256. get hitPointWorld(): Vector3;
  24257. /**
  24258. * Gets the ray "start point" of the ray in the world
  24259. */
  24260. get rayFromWorld(): Vector3;
  24261. /**
  24262. * Gets the ray "end point" of the ray in the world
  24263. */
  24264. get rayToWorld(): Vector3;
  24265. /**
  24266. * Sets the hit data (normal & point in world space)
  24267. * @param hitNormalWorld defines the normal in world space
  24268. * @param hitPointWorld defines the point in world space
  24269. */
  24270. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24271. /**
  24272. * Sets the distance from the start point to the hit point
  24273. * @param distance
  24274. */
  24275. setHitDistance(distance: number): void;
  24276. /**
  24277. * Calculates the distance manually
  24278. */
  24279. calculateHitDistance(): void;
  24280. /**
  24281. * Resets all the values to default
  24282. * @param from The from point on world space
  24283. * @param to The to point on world space
  24284. */
  24285. reset(from?: Vector3, to?: Vector3): void;
  24286. }
  24287. /**
  24288. * Interface for the size containing width and height
  24289. */
  24290. interface IXYZ {
  24291. /**
  24292. * X
  24293. */
  24294. x: number;
  24295. /**
  24296. * Y
  24297. */
  24298. y: number;
  24299. /**
  24300. * Z
  24301. */
  24302. z: number;
  24303. }
  24304. }
  24305. declare module "babylonjs/Physics/IPhysicsEngine" {
  24306. import { Nullable } from "babylonjs/types";
  24307. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24309. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24310. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24311. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24312. /**
  24313. * Interface used to describe a physics joint
  24314. */
  24315. export interface PhysicsImpostorJoint {
  24316. /** Defines the main impostor to which the joint is linked */
  24317. mainImpostor: PhysicsImpostor;
  24318. /** Defines the impostor that is connected to the main impostor using this joint */
  24319. connectedImpostor: PhysicsImpostor;
  24320. /** Defines the joint itself */
  24321. joint: PhysicsJoint;
  24322. }
  24323. /** @hidden */
  24324. export interface IPhysicsEnginePlugin {
  24325. world: any;
  24326. name: string;
  24327. setGravity(gravity: Vector3): void;
  24328. setTimeStep(timeStep: number): void;
  24329. getTimeStep(): number;
  24330. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24334. removePhysicsBody(impostor: PhysicsImpostor): void;
  24335. generateJoint(joint: PhysicsImpostorJoint): void;
  24336. removeJoint(joint: PhysicsImpostorJoint): void;
  24337. isSupported(): boolean;
  24338. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24339. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24340. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24341. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24342. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24343. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24344. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24345. getBodyMass(impostor: PhysicsImpostor): number;
  24346. getBodyFriction(impostor: PhysicsImpostor): number;
  24347. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24348. getBodyRestitution(impostor: PhysicsImpostor): number;
  24349. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24350. getBodyPressure?(impostor: PhysicsImpostor): number;
  24351. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24352. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24353. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24354. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24355. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24356. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24357. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24358. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24359. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24360. sleepBody(impostor: PhysicsImpostor): void;
  24361. wakeUpBody(impostor: PhysicsImpostor): void;
  24362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24364. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24366. getRadius(impostor: PhysicsImpostor): number;
  24367. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24368. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24369. dispose(): void;
  24370. }
  24371. /**
  24372. * Interface used to define a physics engine
  24373. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24374. */
  24375. export interface IPhysicsEngine {
  24376. /**
  24377. * Gets the gravity vector used by the simulation
  24378. */
  24379. gravity: Vector3;
  24380. /**
  24381. * Sets the gravity vector used by the simulation
  24382. * @param gravity defines the gravity vector to use
  24383. */
  24384. setGravity(gravity: Vector3): void;
  24385. /**
  24386. * Set the time step of the physics engine.
  24387. * Default is 1/60.
  24388. * To slow it down, enter 1/600 for example.
  24389. * To speed it up, 1/30
  24390. * @param newTimeStep the new timestep to apply to this world.
  24391. */
  24392. setTimeStep(newTimeStep: number): void;
  24393. /**
  24394. * Get the time step of the physics engine.
  24395. * @returns the current time step
  24396. */
  24397. getTimeStep(): number;
  24398. /**
  24399. * Set the sub time step of the physics engine.
  24400. * Default is 0 meaning there is no sub steps
  24401. * To increase physics resolution precision, set a small value (like 1 ms)
  24402. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24403. */
  24404. setSubTimeStep(subTimeStep: number): void;
  24405. /**
  24406. * Get the sub time step of the physics engine.
  24407. * @returns the current sub time step
  24408. */
  24409. getSubTimeStep(): number;
  24410. /**
  24411. * Release all resources
  24412. */
  24413. dispose(): void;
  24414. /**
  24415. * Gets the name of the current physics plugin
  24416. * @returns the name of the plugin
  24417. */
  24418. getPhysicsPluginName(): string;
  24419. /**
  24420. * Adding a new impostor for the impostor tracking.
  24421. * This will be done by the impostor itself.
  24422. * @param impostor the impostor to add
  24423. */
  24424. addImpostor(impostor: PhysicsImpostor): void;
  24425. /**
  24426. * Remove an impostor from the engine.
  24427. * This impostor and its mesh will not longer be updated by the physics engine.
  24428. * @param impostor the impostor to remove
  24429. */
  24430. removeImpostor(impostor: PhysicsImpostor): void;
  24431. /**
  24432. * Add a joint to the physics engine
  24433. * @param mainImpostor defines the main impostor to which the joint is added.
  24434. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24435. * @param joint defines the joint that will connect both impostors.
  24436. */
  24437. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24438. /**
  24439. * Removes a joint from the simulation
  24440. * @param mainImpostor defines the impostor used with the joint
  24441. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24442. * @param joint defines the joint to remove
  24443. */
  24444. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24445. /**
  24446. * Gets the current plugin used to run the simulation
  24447. * @returns current plugin
  24448. */
  24449. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24450. /**
  24451. * Gets the list of physic impostors
  24452. * @returns an array of PhysicsImpostor
  24453. */
  24454. getImpostors(): Array<PhysicsImpostor>;
  24455. /**
  24456. * Gets the impostor for a physics enabled object
  24457. * @param object defines the object impersonated by the impostor
  24458. * @returns the PhysicsImpostor or null if not found
  24459. */
  24460. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24461. /**
  24462. * Gets the impostor for a physics body object
  24463. * @param body defines physics body used by the impostor
  24464. * @returns the PhysicsImpostor or null if not found
  24465. */
  24466. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24467. /**
  24468. * Does a raycast in the physics world
  24469. * @param from when should the ray start?
  24470. * @param to when should the ray end?
  24471. * @returns PhysicsRaycastResult
  24472. */
  24473. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24474. /**
  24475. * Called by the scene. No need to call it.
  24476. * @param delta defines the timespam between frames
  24477. */
  24478. _step(delta: number): void;
  24479. }
  24480. }
  24481. declare module "babylonjs/Physics/physicsImpostor" {
  24482. import { Nullable, IndicesArray } from "babylonjs/types";
  24483. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24484. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24486. import { Scene } from "babylonjs/scene";
  24487. import { Bone } from "babylonjs/Bones/bone";
  24488. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24489. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24490. import { Space } from "babylonjs/Maths/math.axis";
  24491. /**
  24492. * The interface for the physics imposter parameters
  24493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24494. */
  24495. export interface PhysicsImpostorParameters {
  24496. /**
  24497. * The mass of the physics imposter
  24498. */
  24499. mass: number;
  24500. /**
  24501. * The friction of the physics imposter
  24502. */
  24503. friction?: number;
  24504. /**
  24505. * The coefficient of restitution of the physics imposter
  24506. */
  24507. restitution?: number;
  24508. /**
  24509. * The native options of the physics imposter
  24510. */
  24511. nativeOptions?: any;
  24512. /**
  24513. * Specifies if the parent should be ignored
  24514. */
  24515. ignoreParent?: boolean;
  24516. /**
  24517. * Specifies if bi-directional transformations should be disabled
  24518. */
  24519. disableBidirectionalTransformation?: boolean;
  24520. /**
  24521. * The pressure inside the physics imposter, soft object only
  24522. */
  24523. pressure?: number;
  24524. /**
  24525. * The stiffness the physics imposter, soft object only
  24526. */
  24527. stiffness?: number;
  24528. /**
  24529. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24530. */
  24531. velocityIterations?: number;
  24532. /**
  24533. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24534. */
  24535. positionIterations?: number;
  24536. /**
  24537. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24538. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24539. * Add to fix multiple points
  24540. */
  24541. fixedPoints?: number;
  24542. /**
  24543. * The collision margin around a soft object
  24544. */
  24545. margin?: number;
  24546. /**
  24547. * The collision margin around a soft object
  24548. */
  24549. damping?: number;
  24550. /**
  24551. * The path for a rope based on an extrusion
  24552. */
  24553. path?: any;
  24554. /**
  24555. * The shape of an extrusion used for a rope based on an extrusion
  24556. */
  24557. shape?: any;
  24558. }
  24559. /**
  24560. * Interface for a physics-enabled object
  24561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24562. */
  24563. export interface IPhysicsEnabledObject {
  24564. /**
  24565. * The position of the physics-enabled object
  24566. */
  24567. position: Vector3;
  24568. /**
  24569. * The rotation of the physics-enabled object
  24570. */
  24571. rotationQuaternion: Nullable<Quaternion>;
  24572. /**
  24573. * The scale of the physics-enabled object
  24574. */
  24575. scaling: Vector3;
  24576. /**
  24577. * The rotation of the physics-enabled object
  24578. */
  24579. rotation?: Vector3;
  24580. /**
  24581. * The parent of the physics-enabled object
  24582. */
  24583. parent?: any;
  24584. /**
  24585. * The bounding info of the physics-enabled object
  24586. * @returns The bounding info of the physics-enabled object
  24587. */
  24588. getBoundingInfo(): BoundingInfo;
  24589. /**
  24590. * Computes the world matrix
  24591. * @param force Specifies if the world matrix should be computed by force
  24592. * @returns A world matrix
  24593. */
  24594. computeWorldMatrix(force: boolean): Matrix;
  24595. /**
  24596. * Gets the world matrix
  24597. * @returns A world matrix
  24598. */
  24599. getWorldMatrix?(): Matrix;
  24600. /**
  24601. * Gets the child meshes
  24602. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24603. * @returns An array of abstract meshes
  24604. */
  24605. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24606. /**
  24607. * Gets the vertex data
  24608. * @param kind The type of vertex data
  24609. * @returns A nullable array of numbers, or a float32 array
  24610. */
  24611. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24612. /**
  24613. * Gets the indices from the mesh
  24614. * @returns A nullable array of index arrays
  24615. */
  24616. getIndices?(): Nullable<IndicesArray>;
  24617. /**
  24618. * Gets the scene from the mesh
  24619. * @returns the indices array or null
  24620. */
  24621. getScene?(): Scene;
  24622. /**
  24623. * Gets the absolute position from the mesh
  24624. * @returns the absolute position
  24625. */
  24626. getAbsolutePosition(): Vector3;
  24627. /**
  24628. * Gets the absolute pivot point from the mesh
  24629. * @returns the absolute pivot point
  24630. */
  24631. getAbsolutePivotPoint(): Vector3;
  24632. /**
  24633. * Rotates the mesh
  24634. * @param axis The axis of rotation
  24635. * @param amount The amount of rotation
  24636. * @param space The space of the rotation
  24637. * @returns The rotation transform node
  24638. */
  24639. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24640. /**
  24641. * Translates the mesh
  24642. * @param axis The axis of translation
  24643. * @param distance The distance of translation
  24644. * @param space The space of the translation
  24645. * @returns The transform node
  24646. */
  24647. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24648. /**
  24649. * Sets the absolute position of the mesh
  24650. * @param absolutePosition The absolute position of the mesh
  24651. * @returns The transform node
  24652. */
  24653. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24654. /**
  24655. * Gets the class name of the mesh
  24656. * @returns The class name
  24657. */
  24658. getClassName(): string;
  24659. }
  24660. /**
  24661. * Represents a physics imposter
  24662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24663. */
  24664. export class PhysicsImpostor {
  24665. /**
  24666. * The physics-enabled object used as the physics imposter
  24667. */
  24668. object: IPhysicsEnabledObject;
  24669. /**
  24670. * The type of the physics imposter
  24671. */
  24672. type: number;
  24673. private _options;
  24674. private _scene?;
  24675. /**
  24676. * The default object size of the imposter
  24677. */
  24678. static DEFAULT_OBJECT_SIZE: Vector3;
  24679. /**
  24680. * The identity quaternion of the imposter
  24681. */
  24682. static IDENTITY_QUATERNION: Quaternion;
  24683. /** @hidden */
  24684. _pluginData: any;
  24685. private _physicsEngine;
  24686. private _physicsBody;
  24687. private _bodyUpdateRequired;
  24688. private _onBeforePhysicsStepCallbacks;
  24689. private _onAfterPhysicsStepCallbacks;
  24690. /** @hidden */
  24691. _onPhysicsCollideCallbacks: Array<{
  24692. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24693. otherImpostors: Array<PhysicsImpostor>;
  24694. }>;
  24695. private _deltaPosition;
  24696. private _deltaRotation;
  24697. private _deltaRotationConjugated;
  24698. /** @hidden */
  24699. _isFromLine: boolean;
  24700. private _parent;
  24701. private _isDisposed;
  24702. private static _tmpVecs;
  24703. private static _tmpQuat;
  24704. /**
  24705. * Specifies if the physics imposter is disposed
  24706. */
  24707. get isDisposed(): boolean;
  24708. /**
  24709. * Gets the mass of the physics imposter
  24710. */
  24711. get mass(): number;
  24712. set mass(value: number);
  24713. /**
  24714. * Gets the coefficient of friction
  24715. */
  24716. get friction(): number;
  24717. /**
  24718. * Sets the coefficient of friction
  24719. */
  24720. set friction(value: number);
  24721. /**
  24722. * Gets the coefficient of restitution
  24723. */
  24724. get restitution(): number;
  24725. /**
  24726. * Sets the coefficient of restitution
  24727. */
  24728. set restitution(value: number);
  24729. /**
  24730. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24731. */
  24732. get pressure(): number;
  24733. /**
  24734. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24735. */
  24736. set pressure(value: number);
  24737. /**
  24738. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24739. */
  24740. get stiffness(): number;
  24741. /**
  24742. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24743. */
  24744. set stiffness(value: number);
  24745. /**
  24746. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24747. */
  24748. get velocityIterations(): number;
  24749. /**
  24750. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24751. */
  24752. set velocityIterations(value: number);
  24753. /**
  24754. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24755. */
  24756. get positionIterations(): number;
  24757. /**
  24758. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24759. */
  24760. set positionIterations(value: number);
  24761. /**
  24762. * The unique id of the physics imposter
  24763. * set by the physics engine when adding this impostor to the array
  24764. */
  24765. uniqueId: number;
  24766. /**
  24767. * @hidden
  24768. */
  24769. soft: boolean;
  24770. /**
  24771. * @hidden
  24772. */
  24773. segments: number;
  24774. private _joints;
  24775. /**
  24776. * Initializes the physics imposter
  24777. * @param object The physics-enabled object used as the physics imposter
  24778. * @param type The type of the physics imposter
  24779. * @param _options The options for the physics imposter
  24780. * @param _scene The Babylon scene
  24781. */
  24782. constructor(
  24783. /**
  24784. * The physics-enabled object used as the physics imposter
  24785. */
  24786. object: IPhysicsEnabledObject,
  24787. /**
  24788. * The type of the physics imposter
  24789. */
  24790. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24791. /**
  24792. * This function will completly initialize this impostor.
  24793. * It will create a new body - but only if this mesh has no parent.
  24794. * If it has, this impostor will not be used other than to define the impostor
  24795. * of the child mesh.
  24796. * @hidden
  24797. */
  24798. _init(): void;
  24799. private _getPhysicsParent;
  24800. /**
  24801. * Should a new body be generated.
  24802. * @returns boolean specifying if body initialization is required
  24803. */
  24804. isBodyInitRequired(): boolean;
  24805. /**
  24806. * Sets the updated scaling
  24807. * @param updated Specifies if the scaling is updated
  24808. */
  24809. setScalingUpdated(): void;
  24810. /**
  24811. * Force a regeneration of this or the parent's impostor's body.
  24812. * Use under cautious - This will remove all joints already implemented.
  24813. */
  24814. forceUpdate(): void;
  24815. /**
  24816. * Gets the body that holds this impostor. Either its own, or its parent.
  24817. */
  24818. get physicsBody(): any;
  24819. /**
  24820. * Get the parent of the physics imposter
  24821. * @returns Physics imposter or null
  24822. */
  24823. get parent(): Nullable<PhysicsImpostor>;
  24824. /**
  24825. * Sets the parent of the physics imposter
  24826. */
  24827. set parent(value: Nullable<PhysicsImpostor>);
  24828. /**
  24829. * Set the physics body. Used mainly by the physics engine/plugin
  24830. */
  24831. set physicsBody(physicsBody: any);
  24832. /**
  24833. * Resets the update flags
  24834. */
  24835. resetUpdateFlags(): void;
  24836. /**
  24837. * Gets the object extend size
  24838. * @returns the object extend size
  24839. */
  24840. getObjectExtendSize(): Vector3;
  24841. /**
  24842. * Gets the object center
  24843. * @returns The object center
  24844. */
  24845. getObjectCenter(): Vector3;
  24846. /**
  24847. * Get a specific parameter from the options parameters
  24848. * @param paramName The object parameter name
  24849. * @returns The object parameter
  24850. */
  24851. getParam(paramName: string): any;
  24852. /**
  24853. * Sets a specific parameter in the options given to the physics plugin
  24854. * @param paramName The parameter name
  24855. * @param value The value of the parameter
  24856. */
  24857. setParam(paramName: string, value: number): void;
  24858. /**
  24859. * Specifically change the body's mass option. Won't recreate the physics body object
  24860. * @param mass The mass of the physics imposter
  24861. */
  24862. setMass(mass: number): void;
  24863. /**
  24864. * Gets the linear velocity
  24865. * @returns linear velocity or null
  24866. */
  24867. getLinearVelocity(): Nullable<Vector3>;
  24868. /**
  24869. * Sets the linear velocity
  24870. * @param velocity linear velocity or null
  24871. */
  24872. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24873. /**
  24874. * Gets the angular velocity
  24875. * @returns angular velocity or null
  24876. */
  24877. getAngularVelocity(): Nullable<Vector3>;
  24878. /**
  24879. * Sets the angular velocity
  24880. * @param velocity The velocity or null
  24881. */
  24882. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24883. /**
  24884. * Execute a function with the physics plugin native code
  24885. * Provide a function the will have two variables - the world object and the physics body object
  24886. * @param func The function to execute with the physics plugin native code
  24887. */
  24888. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24889. /**
  24890. * Register a function that will be executed before the physics world is stepping forward
  24891. * @param func The function to execute before the physics world is stepped forward
  24892. */
  24893. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24894. /**
  24895. * Unregister a function that will be executed before the physics world is stepping forward
  24896. * @param func The function to execute before the physics world is stepped forward
  24897. */
  24898. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24899. /**
  24900. * Register a function that will be executed after the physics step
  24901. * @param func The function to execute after physics step
  24902. */
  24903. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24904. /**
  24905. * Unregisters a function that will be executed after the physics step
  24906. * @param func The function to execute after physics step
  24907. */
  24908. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24909. /**
  24910. * register a function that will be executed when this impostor collides against a different body
  24911. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24912. * @param func Callback that is executed on collision
  24913. */
  24914. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24915. /**
  24916. * Unregisters the physics imposter on contact
  24917. * @param collideAgainst The physics object to collide against
  24918. * @param func Callback to execute on collision
  24919. */
  24920. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24921. private _tmpQuat;
  24922. private _tmpQuat2;
  24923. /**
  24924. * Get the parent rotation
  24925. * @returns The parent rotation
  24926. */
  24927. getParentsRotation(): Quaternion;
  24928. /**
  24929. * this function is executed by the physics engine.
  24930. */
  24931. beforeStep: () => void;
  24932. /**
  24933. * this function is executed by the physics engine
  24934. */
  24935. afterStep: () => void;
  24936. /**
  24937. * Legacy collision detection event support
  24938. */
  24939. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24940. /**
  24941. * event and body object due to cannon's event-based architecture.
  24942. */
  24943. onCollide: (e: {
  24944. body: any;
  24945. }) => void;
  24946. /**
  24947. * Apply a force
  24948. * @param force The force to apply
  24949. * @param contactPoint The contact point for the force
  24950. * @returns The physics imposter
  24951. */
  24952. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24953. /**
  24954. * Apply an impulse
  24955. * @param force The impulse force
  24956. * @param contactPoint The contact point for the impulse force
  24957. * @returns The physics imposter
  24958. */
  24959. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24960. /**
  24961. * A help function to create a joint
  24962. * @param otherImpostor A physics imposter used to create a joint
  24963. * @param jointType The type of joint
  24964. * @param jointData The data for the joint
  24965. * @returns The physics imposter
  24966. */
  24967. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24968. /**
  24969. * Add a joint to this impostor with a different impostor
  24970. * @param otherImpostor A physics imposter used to add a joint
  24971. * @param joint The joint to add
  24972. * @returns The physics imposter
  24973. */
  24974. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24975. /**
  24976. * Add an anchor to a cloth impostor
  24977. * @param otherImpostor rigid impostor to anchor to
  24978. * @param width ratio across width from 0 to 1
  24979. * @param height ratio up height from 0 to 1
  24980. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24981. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24982. * @returns impostor the soft imposter
  24983. */
  24984. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24985. /**
  24986. * Add a hook to a rope impostor
  24987. * @param otherImpostor rigid impostor to anchor to
  24988. * @param length ratio across rope from 0 to 1
  24989. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24990. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24991. * @returns impostor the rope imposter
  24992. */
  24993. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24994. /**
  24995. * Will keep this body still, in a sleep mode.
  24996. * @returns the physics imposter
  24997. */
  24998. sleep(): PhysicsImpostor;
  24999. /**
  25000. * Wake the body up.
  25001. * @returns The physics imposter
  25002. */
  25003. wakeUp(): PhysicsImpostor;
  25004. /**
  25005. * Clones the physics imposter
  25006. * @param newObject The physics imposter clones to this physics-enabled object
  25007. * @returns A nullable physics imposter
  25008. */
  25009. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25010. /**
  25011. * Disposes the physics imposter
  25012. */
  25013. dispose(): void;
  25014. /**
  25015. * Sets the delta position
  25016. * @param position The delta position amount
  25017. */
  25018. setDeltaPosition(position: Vector3): void;
  25019. /**
  25020. * Sets the delta rotation
  25021. * @param rotation The delta rotation amount
  25022. */
  25023. setDeltaRotation(rotation: Quaternion): void;
  25024. /**
  25025. * Gets the box size of the physics imposter and stores the result in the input parameter
  25026. * @param result Stores the box size
  25027. * @returns The physics imposter
  25028. */
  25029. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25030. /**
  25031. * Gets the radius of the physics imposter
  25032. * @returns Radius of the physics imposter
  25033. */
  25034. getRadius(): number;
  25035. /**
  25036. * Sync a bone with this impostor
  25037. * @param bone The bone to sync to the impostor.
  25038. * @param boneMesh The mesh that the bone is influencing.
  25039. * @param jointPivot The pivot of the joint / bone in local space.
  25040. * @param distToJoint Optional distance from the impostor to the joint.
  25041. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25042. */
  25043. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25044. /**
  25045. * Sync impostor to a bone
  25046. * @param bone The bone that the impostor will be synced to.
  25047. * @param boneMesh The mesh that the bone is influencing.
  25048. * @param jointPivot The pivot of the joint / bone in local space.
  25049. * @param distToJoint Optional distance from the impostor to the joint.
  25050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25051. * @param boneAxis Optional vector3 axis the bone is aligned with
  25052. */
  25053. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25054. /**
  25055. * No-Imposter type
  25056. */
  25057. static NoImpostor: number;
  25058. /**
  25059. * Sphere-Imposter type
  25060. */
  25061. static SphereImpostor: number;
  25062. /**
  25063. * Box-Imposter type
  25064. */
  25065. static BoxImpostor: number;
  25066. /**
  25067. * Plane-Imposter type
  25068. */
  25069. static PlaneImpostor: number;
  25070. /**
  25071. * Mesh-imposter type
  25072. */
  25073. static MeshImpostor: number;
  25074. /**
  25075. * Capsule-Impostor type (Ammo.js plugin only)
  25076. */
  25077. static CapsuleImpostor: number;
  25078. /**
  25079. * Cylinder-Imposter type
  25080. */
  25081. static CylinderImpostor: number;
  25082. /**
  25083. * Particle-Imposter type
  25084. */
  25085. static ParticleImpostor: number;
  25086. /**
  25087. * Heightmap-Imposter type
  25088. */
  25089. static HeightmapImpostor: number;
  25090. /**
  25091. * ConvexHull-Impostor type (Ammo.js plugin only)
  25092. */
  25093. static ConvexHullImpostor: number;
  25094. /**
  25095. * Custom-Imposter type (Ammo.js plugin only)
  25096. */
  25097. static CustomImpostor: number;
  25098. /**
  25099. * Rope-Imposter type
  25100. */
  25101. static RopeImpostor: number;
  25102. /**
  25103. * Cloth-Imposter type
  25104. */
  25105. static ClothImpostor: number;
  25106. /**
  25107. * Softbody-Imposter type
  25108. */
  25109. static SoftbodyImpostor: number;
  25110. }
  25111. }
  25112. declare module "babylonjs/Meshes/mesh" {
  25113. import { Observable } from "babylonjs/Misc/observable";
  25114. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25115. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25116. import { Camera } from "babylonjs/Cameras/camera";
  25117. import { Scene } from "babylonjs/scene";
  25118. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25119. import { Color4 } from "babylonjs/Maths/math.color";
  25120. import { Engine } from "babylonjs/Engines/engine";
  25121. import { Node } from "babylonjs/node";
  25122. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25123. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25124. import { Buffer } from "babylonjs/Meshes/buffer";
  25125. import { Geometry } from "babylonjs/Meshes/geometry";
  25126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25128. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25129. import { Effect } from "babylonjs/Materials/effect";
  25130. import { Material } from "babylonjs/Materials/material";
  25131. import { Skeleton } from "babylonjs/Bones/skeleton";
  25132. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25133. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25134. import { Path3D } from "babylonjs/Maths/math.path";
  25135. import { Plane } from "babylonjs/Maths/math.plane";
  25136. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25137. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25138. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25139. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25140. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25141. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25142. /**
  25143. * @hidden
  25144. **/
  25145. export class _CreationDataStorage {
  25146. closePath?: boolean;
  25147. closeArray?: boolean;
  25148. idx: number[];
  25149. dashSize: number;
  25150. gapSize: number;
  25151. path3D: Path3D;
  25152. pathArray: Vector3[][];
  25153. arc: number;
  25154. radius: number;
  25155. cap: number;
  25156. tessellation: number;
  25157. }
  25158. /**
  25159. * @hidden
  25160. **/
  25161. class _InstanceDataStorage {
  25162. visibleInstances: any;
  25163. batchCache: _InstancesBatch;
  25164. instancesBufferSize: number;
  25165. instancesBuffer: Nullable<Buffer>;
  25166. instancesData: Float32Array;
  25167. overridenInstanceCount: number;
  25168. isFrozen: boolean;
  25169. previousBatch: Nullable<_InstancesBatch>;
  25170. hardwareInstancedRendering: boolean;
  25171. sideOrientation: number;
  25172. manualUpdate: boolean;
  25173. }
  25174. /**
  25175. * @hidden
  25176. **/
  25177. export class _InstancesBatch {
  25178. mustReturn: boolean;
  25179. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25180. renderSelf: boolean[];
  25181. hardwareInstancedRendering: boolean[];
  25182. }
  25183. /**
  25184. * Class used to represent renderable models
  25185. */
  25186. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25187. /**
  25188. * Mesh side orientation : usually the external or front surface
  25189. */
  25190. static readonly FRONTSIDE: number;
  25191. /**
  25192. * Mesh side orientation : usually the internal or back surface
  25193. */
  25194. static readonly BACKSIDE: number;
  25195. /**
  25196. * Mesh side orientation : both internal and external or front and back surfaces
  25197. */
  25198. static readonly DOUBLESIDE: number;
  25199. /**
  25200. * Mesh side orientation : by default, `FRONTSIDE`
  25201. */
  25202. static readonly DEFAULTSIDE: number;
  25203. /**
  25204. * Mesh cap setting : no cap
  25205. */
  25206. static readonly NO_CAP: number;
  25207. /**
  25208. * Mesh cap setting : one cap at the beginning of the mesh
  25209. */
  25210. static readonly CAP_START: number;
  25211. /**
  25212. * Mesh cap setting : one cap at the end of the mesh
  25213. */
  25214. static readonly CAP_END: number;
  25215. /**
  25216. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25217. */
  25218. static readonly CAP_ALL: number;
  25219. /**
  25220. * Mesh pattern setting : no flip or rotate
  25221. */
  25222. static readonly NO_FLIP: number;
  25223. /**
  25224. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25225. */
  25226. static readonly FLIP_TILE: number;
  25227. /**
  25228. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25229. */
  25230. static readonly ROTATE_TILE: number;
  25231. /**
  25232. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25233. */
  25234. static readonly FLIP_ROW: number;
  25235. /**
  25236. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25237. */
  25238. static readonly ROTATE_ROW: number;
  25239. /**
  25240. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25241. */
  25242. static readonly FLIP_N_ROTATE_TILE: number;
  25243. /**
  25244. * Mesh pattern setting : rotate pattern and rotate
  25245. */
  25246. static readonly FLIP_N_ROTATE_ROW: number;
  25247. /**
  25248. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25249. */
  25250. static readonly CENTER: number;
  25251. /**
  25252. * Mesh tile positioning : part tiles on left
  25253. */
  25254. static readonly LEFT: number;
  25255. /**
  25256. * Mesh tile positioning : part tiles on right
  25257. */
  25258. static readonly RIGHT: number;
  25259. /**
  25260. * Mesh tile positioning : part tiles on top
  25261. */
  25262. static readonly TOP: number;
  25263. /**
  25264. * Mesh tile positioning : part tiles on bottom
  25265. */
  25266. static readonly BOTTOM: number;
  25267. /**
  25268. * Gets the default side orientation.
  25269. * @param orientation the orientation to value to attempt to get
  25270. * @returns the default orientation
  25271. * @hidden
  25272. */
  25273. static _GetDefaultSideOrientation(orientation?: number): number;
  25274. private _internalMeshDataInfo;
  25275. /**
  25276. * An event triggered before rendering the mesh
  25277. */
  25278. get onBeforeRenderObservable(): Observable<Mesh>;
  25279. /**
  25280. * An event triggered before binding the mesh
  25281. */
  25282. get onBeforeBindObservable(): Observable<Mesh>;
  25283. /**
  25284. * An event triggered after rendering the mesh
  25285. */
  25286. get onAfterRenderObservable(): Observable<Mesh>;
  25287. /**
  25288. * An event triggered before drawing the mesh
  25289. */
  25290. get onBeforeDrawObservable(): Observable<Mesh>;
  25291. private _onBeforeDrawObserver;
  25292. /**
  25293. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25294. */
  25295. set onBeforeDraw(callback: () => void);
  25296. get hasInstances(): boolean;
  25297. /**
  25298. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25299. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25300. */
  25301. delayLoadState: number;
  25302. /**
  25303. * Gets the list of instances created from this mesh
  25304. * it is not supposed to be modified manually.
  25305. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25306. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25307. */
  25308. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25309. /**
  25310. * Gets the file containing delay loading data for this mesh
  25311. */
  25312. delayLoadingFile: string;
  25313. /** @hidden */
  25314. _binaryInfo: any;
  25315. /**
  25316. * User defined function used to change how LOD level selection is done
  25317. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25318. */
  25319. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25320. /**
  25321. * Gets or sets the morph target manager
  25322. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25323. */
  25324. get morphTargetManager(): Nullable<MorphTargetManager>;
  25325. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25326. /** @hidden */
  25327. _creationDataStorage: Nullable<_CreationDataStorage>;
  25328. /** @hidden */
  25329. _geometry: Nullable<Geometry>;
  25330. /** @hidden */
  25331. _delayInfo: Array<string>;
  25332. /** @hidden */
  25333. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25334. /** @hidden */
  25335. _instanceDataStorage: _InstanceDataStorage;
  25336. private _effectiveMaterial;
  25337. /** @hidden */
  25338. _shouldGenerateFlatShading: boolean;
  25339. /** @hidden */
  25340. _originalBuilderSideOrientation: number;
  25341. /**
  25342. * Use this property to change the original side orientation defined at construction time
  25343. */
  25344. overrideMaterialSideOrientation: Nullable<number>;
  25345. /**
  25346. * Gets the source mesh (the one used to clone this one from)
  25347. */
  25348. get source(): Nullable<Mesh>;
  25349. /**
  25350. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25351. */
  25352. get isUnIndexed(): boolean;
  25353. set isUnIndexed(value: boolean);
  25354. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25355. get worldMatrixInstancedBuffer(): Float32Array;
  25356. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25357. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25358. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25359. /**
  25360. * @constructor
  25361. * @param name The value used by scene.getMeshByName() to do a lookup.
  25362. * @param scene The scene to add this mesh to.
  25363. * @param parent The parent of this mesh, if it has one
  25364. * @param source An optional Mesh from which geometry is shared, cloned.
  25365. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25366. * When false, achieved by calling a clone(), also passing False.
  25367. * This will make creation of children, recursive.
  25368. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25369. */
  25370. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25371. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25372. doNotInstantiate: boolean;
  25373. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25374. /**
  25375. * Gets the class name
  25376. * @returns the string "Mesh".
  25377. */
  25378. getClassName(): string;
  25379. /** @hidden */
  25380. get _isMesh(): boolean;
  25381. /**
  25382. * Returns a description of this mesh
  25383. * @param fullDetails define if full details about this mesh must be used
  25384. * @returns a descriptive string representing this mesh
  25385. */
  25386. toString(fullDetails?: boolean): string;
  25387. /** @hidden */
  25388. _unBindEffect(): void;
  25389. /**
  25390. * Gets a boolean indicating if this mesh has LOD
  25391. */
  25392. get hasLODLevels(): boolean;
  25393. /**
  25394. * Gets the list of MeshLODLevel associated with the current mesh
  25395. * @returns an array of MeshLODLevel
  25396. */
  25397. getLODLevels(): MeshLODLevel[];
  25398. private _sortLODLevels;
  25399. /**
  25400. * Add a mesh as LOD level triggered at the given distance.
  25401. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25402. * @param distance The distance from the center of the object to show this level
  25403. * @param mesh The mesh to be added as LOD level (can be null)
  25404. * @return This mesh (for chaining)
  25405. */
  25406. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25407. /**
  25408. * Returns the LOD level mesh at the passed distance or null if not found.
  25409. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25410. * @param distance The distance from the center of the object to show this level
  25411. * @returns a Mesh or `null`
  25412. */
  25413. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25414. /**
  25415. * Remove a mesh from the LOD array
  25416. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25417. * @param mesh defines the mesh to be removed
  25418. * @return This mesh (for chaining)
  25419. */
  25420. removeLODLevel(mesh: Mesh): Mesh;
  25421. /**
  25422. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25424. * @param camera defines the camera to use to compute distance
  25425. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25426. * @return This mesh (for chaining)
  25427. */
  25428. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25429. /**
  25430. * Gets the mesh internal Geometry object
  25431. */
  25432. get geometry(): Nullable<Geometry>;
  25433. /**
  25434. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25435. * @returns the total number of vertices
  25436. */
  25437. getTotalVertices(): number;
  25438. /**
  25439. * Returns the content of an associated vertex buffer
  25440. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25441. * - VertexBuffer.PositionKind
  25442. * - VertexBuffer.UVKind
  25443. * - VertexBuffer.UV2Kind
  25444. * - VertexBuffer.UV3Kind
  25445. * - VertexBuffer.UV4Kind
  25446. * - VertexBuffer.UV5Kind
  25447. * - VertexBuffer.UV6Kind
  25448. * - VertexBuffer.ColorKind
  25449. * - VertexBuffer.MatricesIndicesKind
  25450. * - VertexBuffer.MatricesIndicesExtraKind
  25451. * - VertexBuffer.MatricesWeightsKind
  25452. * - VertexBuffer.MatricesWeightsExtraKind
  25453. * @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
  25454. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25455. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25456. */
  25457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25458. /**
  25459. * Returns the mesh VertexBuffer object from the requested `kind`
  25460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25461. * - VertexBuffer.PositionKind
  25462. * - VertexBuffer.NormalKind
  25463. * - VertexBuffer.UVKind
  25464. * - VertexBuffer.UV2Kind
  25465. * - VertexBuffer.UV3Kind
  25466. * - VertexBuffer.UV4Kind
  25467. * - VertexBuffer.UV5Kind
  25468. * - VertexBuffer.UV6Kind
  25469. * - VertexBuffer.ColorKind
  25470. * - VertexBuffer.MatricesIndicesKind
  25471. * - VertexBuffer.MatricesIndicesExtraKind
  25472. * - VertexBuffer.MatricesWeightsKind
  25473. * - VertexBuffer.MatricesWeightsExtraKind
  25474. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25475. */
  25476. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25477. /**
  25478. * Tests if a specific vertex buffer is associated with this mesh
  25479. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25480. * - VertexBuffer.PositionKind
  25481. * - VertexBuffer.NormalKind
  25482. * - VertexBuffer.UVKind
  25483. * - VertexBuffer.UV2Kind
  25484. * - VertexBuffer.UV3Kind
  25485. * - VertexBuffer.UV4Kind
  25486. * - VertexBuffer.UV5Kind
  25487. * - VertexBuffer.UV6Kind
  25488. * - VertexBuffer.ColorKind
  25489. * - VertexBuffer.MatricesIndicesKind
  25490. * - VertexBuffer.MatricesIndicesExtraKind
  25491. * - VertexBuffer.MatricesWeightsKind
  25492. * - VertexBuffer.MatricesWeightsExtraKind
  25493. * @returns a boolean
  25494. */
  25495. isVerticesDataPresent(kind: string): boolean;
  25496. /**
  25497. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25498. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25499. * - VertexBuffer.PositionKind
  25500. * - VertexBuffer.UVKind
  25501. * - VertexBuffer.UV2Kind
  25502. * - VertexBuffer.UV3Kind
  25503. * - VertexBuffer.UV4Kind
  25504. * - VertexBuffer.UV5Kind
  25505. * - VertexBuffer.UV6Kind
  25506. * - VertexBuffer.ColorKind
  25507. * - VertexBuffer.MatricesIndicesKind
  25508. * - VertexBuffer.MatricesIndicesExtraKind
  25509. * - VertexBuffer.MatricesWeightsKind
  25510. * - VertexBuffer.MatricesWeightsExtraKind
  25511. * @returns a boolean
  25512. */
  25513. isVertexBufferUpdatable(kind: string): boolean;
  25514. /**
  25515. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25516. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25517. * - VertexBuffer.PositionKind
  25518. * - VertexBuffer.NormalKind
  25519. * - VertexBuffer.UVKind
  25520. * - VertexBuffer.UV2Kind
  25521. * - VertexBuffer.UV3Kind
  25522. * - VertexBuffer.UV4Kind
  25523. * - VertexBuffer.UV5Kind
  25524. * - VertexBuffer.UV6Kind
  25525. * - VertexBuffer.ColorKind
  25526. * - VertexBuffer.MatricesIndicesKind
  25527. * - VertexBuffer.MatricesIndicesExtraKind
  25528. * - VertexBuffer.MatricesWeightsKind
  25529. * - VertexBuffer.MatricesWeightsExtraKind
  25530. * @returns an array of strings
  25531. */
  25532. getVerticesDataKinds(): string[];
  25533. /**
  25534. * Returns a positive integer : the total number of indices in this mesh geometry.
  25535. * @returns the numner of indices or zero if the mesh has no geometry.
  25536. */
  25537. getTotalIndices(): number;
  25538. /**
  25539. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25540. * @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.
  25541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25542. * @returns the indices array or an empty array if the mesh has no geometry
  25543. */
  25544. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25545. get isBlocked(): boolean;
  25546. /**
  25547. * Determine if the current mesh is ready to be rendered
  25548. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25549. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25550. * @returns true if all associated assets are ready (material, textures, shaders)
  25551. */
  25552. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25553. /**
  25554. * 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.
  25555. */
  25556. get areNormalsFrozen(): boolean;
  25557. /**
  25558. * 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.
  25559. * @returns the current mesh
  25560. */
  25561. freezeNormals(): Mesh;
  25562. /**
  25563. * 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
  25564. * @returns the current mesh
  25565. */
  25566. unfreezeNormals(): Mesh;
  25567. /**
  25568. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25569. */
  25570. set overridenInstanceCount(count: number);
  25571. /** @hidden */
  25572. _preActivate(): Mesh;
  25573. /** @hidden */
  25574. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25575. /** @hidden */
  25576. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25577. /**
  25578. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25579. * This means the mesh underlying bounding box and sphere are recomputed.
  25580. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25581. * @returns the current mesh
  25582. */
  25583. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25584. /** @hidden */
  25585. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25586. /**
  25587. * This function will subdivide the mesh into multiple submeshes
  25588. * @param count defines the expected number of submeshes
  25589. */
  25590. subdivide(count: number): void;
  25591. /**
  25592. * Copy a FloatArray into a specific associated vertex buffer
  25593. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25594. * - VertexBuffer.PositionKind
  25595. * - VertexBuffer.UVKind
  25596. * - VertexBuffer.UV2Kind
  25597. * - VertexBuffer.UV3Kind
  25598. * - VertexBuffer.UV4Kind
  25599. * - VertexBuffer.UV5Kind
  25600. * - VertexBuffer.UV6Kind
  25601. * - VertexBuffer.ColorKind
  25602. * - VertexBuffer.MatricesIndicesKind
  25603. * - VertexBuffer.MatricesIndicesExtraKind
  25604. * - VertexBuffer.MatricesWeightsKind
  25605. * - VertexBuffer.MatricesWeightsExtraKind
  25606. * @param data defines the data source
  25607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25608. * @param stride defines the data stride size (can be null)
  25609. * @returns the current mesh
  25610. */
  25611. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25612. /**
  25613. * Delete a vertex buffer associated with this mesh
  25614. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25615. * - VertexBuffer.PositionKind
  25616. * - VertexBuffer.UVKind
  25617. * - VertexBuffer.UV2Kind
  25618. * - VertexBuffer.UV3Kind
  25619. * - VertexBuffer.UV4Kind
  25620. * - VertexBuffer.UV5Kind
  25621. * - VertexBuffer.UV6Kind
  25622. * - VertexBuffer.ColorKind
  25623. * - VertexBuffer.MatricesIndicesKind
  25624. * - VertexBuffer.MatricesIndicesExtraKind
  25625. * - VertexBuffer.MatricesWeightsKind
  25626. * - VertexBuffer.MatricesWeightsExtraKind
  25627. */
  25628. removeVerticesData(kind: string): void;
  25629. /**
  25630. * Flags an associated vertex buffer as updatable
  25631. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25632. * - VertexBuffer.PositionKind
  25633. * - VertexBuffer.UVKind
  25634. * - VertexBuffer.UV2Kind
  25635. * - VertexBuffer.UV3Kind
  25636. * - VertexBuffer.UV4Kind
  25637. * - VertexBuffer.UV5Kind
  25638. * - VertexBuffer.UV6Kind
  25639. * - VertexBuffer.ColorKind
  25640. * - VertexBuffer.MatricesIndicesKind
  25641. * - VertexBuffer.MatricesIndicesExtraKind
  25642. * - VertexBuffer.MatricesWeightsKind
  25643. * - VertexBuffer.MatricesWeightsExtraKind
  25644. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25645. */
  25646. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25647. /**
  25648. * Sets the mesh global Vertex Buffer
  25649. * @param buffer defines the buffer to use
  25650. * @returns the current mesh
  25651. */
  25652. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25653. /**
  25654. * Update a specific associated vertex buffer
  25655. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25656. * - VertexBuffer.PositionKind
  25657. * - VertexBuffer.UVKind
  25658. * - VertexBuffer.UV2Kind
  25659. * - VertexBuffer.UV3Kind
  25660. * - VertexBuffer.UV4Kind
  25661. * - VertexBuffer.UV5Kind
  25662. * - VertexBuffer.UV6Kind
  25663. * - VertexBuffer.ColorKind
  25664. * - VertexBuffer.MatricesIndicesKind
  25665. * - VertexBuffer.MatricesIndicesExtraKind
  25666. * - VertexBuffer.MatricesWeightsKind
  25667. * - VertexBuffer.MatricesWeightsExtraKind
  25668. * @param data defines the data source
  25669. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25670. * @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)
  25671. * @returns the current mesh
  25672. */
  25673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25674. /**
  25675. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25676. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25677. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25678. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25679. * @returns the current mesh
  25680. */
  25681. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25682. /**
  25683. * Creates a un-shared specific occurence of the geometry for the mesh.
  25684. * @returns the current mesh
  25685. */
  25686. makeGeometryUnique(): Mesh;
  25687. /**
  25688. * Set the index buffer of this mesh
  25689. * @param indices defines the source data
  25690. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25691. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25692. * @returns the current mesh
  25693. */
  25694. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25695. /**
  25696. * Update the current index buffer
  25697. * @param indices defines the source data
  25698. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25699. * @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)
  25700. * @returns the current mesh
  25701. */
  25702. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25703. /**
  25704. * Invert the geometry to move from a right handed system to a left handed one.
  25705. * @returns the current mesh
  25706. */
  25707. toLeftHanded(): Mesh;
  25708. /** @hidden */
  25709. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25710. /** @hidden */
  25711. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25712. /**
  25713. * Registers for this mesh a javascript function called just before the rendering process
  25714. * @param func defines the function to call before rendering this mesh
  25715. * @returns the current mesh
  25716. */
  25717. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25718. /**
  25719. * Disposes a previously registered javascript function called before the rendering
  25720. * @param func defines the function to remove
  25721. * @returns the current mesh
  25722. */
  25723. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25724. /**
  25725. * Registers for this mesh a javascript function called just after the rendering is complete
  25726. * @param func defines the function to call after rendering this mesh
  25727. * @returns the current mesh
  25728. */
  25729. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25730. /**
  25731. * Disposes a previously registered javascript function called after the rendering.
  25732. * @param func defines the function to remove
  25733. * @returns the current mesh
  25734. */
  25735. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25736. /** @hidden */
  25737. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25738. /** @hidden */
  25739. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25740. /** @hidden */
  25741. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25742. /** @hidden */
  25743. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25744. /** @hidden */
  25745. _rebuild(): void;
  25746. /** @hidden */
  25747. _freeze(): void;
  25748. /** @hidden */
  25749. _unFreeze(): void;
  25750. /**
  25751. * 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
  25752. * @param subMesh defines the subMesh to render
  25753. * @param enableAlphaMode defines if alpha mode can be changed
  25754. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25755. * @returns the current mesh
  25756. */
  25757. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25758. private _onBeforeDraw;
  25759. /**
  25760. * Renormalize the mesh and patch it up if there are no weights
  25761. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25762. * However in the case of zero weights then we set just a single influence to 1.
  25763. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25764. */
  25765. cleanMatrixWeights(): void;
  25766. private normalizeSkinFourWeights;
  25767. private normalizeSkinWeightsAndExtra;
  25768. /**
  25769. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25770. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25771. * the user know there was an issue with importing the mesh
  25772. * @returns a validation object with skinned, valid and report string
  25773. */
  25774. validateSkinning(): {
  25775. skinned: boolean;
  25776. valid: boolean;
  25777. report: string;
  25778. };
  25779. /** @hidden */
  25780. _checkDelayState(): Mesh;
  25781. private _queueLoad;
  25782. /**
  25783. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25784. * A mesh is in the frustum if its bounding box intersects the frustum
  25785. * @param frustumPlanes defines the frustum to test
  25786. * @returns true if the mesh is in the frustum planes
  25787. */
  25788. isInFrustum(frustumPlanes: Plane[]): boolean;
  25789. /**
  25790. * Sets the mesh material by the material or multiMaterial `id` property
  25791. * @param id is a string identifying the material or the multiMaterial
  25792. * @returns the current mesh
  25793. */
  25794. setMaterialByID(id: string): Mesh;
  25795. /**
  25796. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25797. * @returns an array of IAnimatable
  25798. */
  25799. getAnimatables(): IAnimatable[];
  25800. /**
  25801. * Modifies the mesh geometry according to the passed transformation matrix.
  25802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25803. * The mesh normals are modified using the same transformation.
  25804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25805. * @param transform defines the transform matrix to use
  25806. * @see http://doc.babylonjs.com/resources/baking_transformations
  25807. * @returns the current mesh
  25808. */
  25809. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25810. /**
  25811. * Modifies the mesh geometry according to its own current World Matrix.
  25812. * The mesh World Matrix is then reset.
  25813. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25815. * @see http://doc.babylonjs.com/resources/baking_transformations
  25816. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25817. * @returns the current mesh
  25818. */
  25819. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25820. /** @hidden */
  25821. get _positions(): Nullable<Vector3[]>;
  25822. /** @hidden */
  25823. _resetPointsArrayCache(): Mesh;
  25824. /** @hidden */
  25825. _generatePointsArray(): boolean;
  25826. /**
  25827. * Returns a new Mesh object generated from the current mesh properties.
  25828. * This method must not get confused with createInstance()
  25829. * @param name is a string, the name given to the new mesh
  25830. * @param newParent can be any Node object (default `null`)
  25831. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25832. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25833. * @returns a new mesh
  25834. */
  25835. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25836. /**
  25837. * Releases resources associated with this mesh.
  25838. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25839. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25840. */
  25841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25842. /** @hidden */
  25843. _disposeInstanceSpecificData(): void;
  25844. /**
  25845. * Modifies the mesh geometry according to a displacement map.
  25846. * 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.
  25847. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25848. * @param url is a string, the URL from the image file is to be downloaded.
  25849. * @param minHeight is the lower limit of the displacement.
  25850. * @param maxHeight is the upper limit of the displacement.
  25851. * @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.
  25852. * @param uvOffset is an optional vector2 used to offset UV.
  25853. * @param uvScale is an optional vector2 used to scale UV.
  25854. * @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.
  25855. * @returns the Mesh.
  25856. */
  25857. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25858. /**
  25859. * Modifies the mesh geometry according to a displacementMap buffer.
  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 buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25863. * @param heightMapWidth is the width of the buffer image.
  25864. * @param heightMapHeight is the height of the buffer image.
  25865. * @param minHeight is the lower limit of the displacement.
  25866. * @param maxHeight is the upper limit of the displacement.
  25867. * @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.
  25868. * @param uvOffset is an optional vector2 used to offset UV.
  25869. * @param uvScale is an optional vector2 used to scale UV.
  25870. * @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.
  25871. * @returns the Mesh.
  25872. */
  25873. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25874. /**
  25875. * Modify the mesh to get a flat shading rendering.
  25876. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25877. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25878. * @returns current mesh
  25879. */
  25880. convertToFlatShadedMesh(): Mesh;
  25881. /**
  25882. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25883. * In other words, more vertices, no more indices and a single bigger VBO.
  25884. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25885. * @returns current mesh
  25886. */
  25887. convertToUnIndexedMesh(): Mesh;
  25888. /**
  25889. * Inverses facet orientations.
  25890. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25891. * @param flipNormals will also inverts the normals
  25892. * @returns current mesh
  25893. */
  25894. flipFaces(flipNormals?: boolean): Mesh;
  25895. /**
  25896. * Increase the number of facets and hence vertices in a mesh
  25897. * Vertex normals are interpolated from existing vertex normals
  25898. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25899. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25900. */
  25901. increaseVertices(numberPerEdge: number): void;
  25902. /**
  25903. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25904. * This will undo any application of covertToFlatShadedMesh
  25905. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25906. */
  25907. forceSharedVertices(): void;
  25908. /** @hidden */
  25909. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25910. /** @hidden */
  25911. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25912. /**
  25913. * Creates a new InstancedMesh object from the mesh model.
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25915. * @param name defines the name of the new instance
  25916. * @returns a new InstancedMesh
  25917. */
  25918. createInstance(name: string): InstancedMesh;
  25919. /**
  25920. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25921. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25922. * @returns the current mesh
  25923. */
  25924. synchronizeInstances(): Mesh;
  25925. /**
  25926. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25927. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25928. * This should be used together with the simplification to avoid disappearing triangles.
  25929. * @param successCallback an optional success callback to be called after the optimization finished.
  25930. * @returns the current mesh
  25931. */
  25932. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25933. /**
  25934. * Serialize current mesh
  25935. * @param serializationObject defines the object which will receive the serialization data
  25936. */
  25937. serialize(serializationObject: any): void;
  25938. /** @hidden */
  25939. _syncGeometryWithMorphTargetManager(): void;
  25940. /** @hidden */
  25941. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25942. /**
  25943. * Returns a new Mesh object parsed from the source provided.
  25944. * @param parsedMesh is the source
  25945. * @param scene defines the hosting scene
  25946. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25947. * @returns a new Mesh
  25948. */
  25949. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25950. /**
  25951. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25952. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25953. * @param name defines the name of the mesh to create
  25954. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25955. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25956. * @param closePath creates a seam between the first and the last points of each path of the path array
  25957. * @param offset is taken in account only if the `pathArray` is containing a single path
  25958. * @param scene defines the hosting scene
  25959. * @param updatable defines if the mesh must be flagged as updatable
  25960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25961. * @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)
  25962. * @returns a new Mesh
  25963. */
  25964. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25965. /**
  25966. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25967. * @param name defines the name of the mesh to create
  25968. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25969. * @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
  25970. * @param scene defines the hosting scene
  25971. * @param updatable defines if the mesh must be flagged as updatable
  25972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25973. * @returns a new Mesh
  25974. */
  25975. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25976. /**
  25977. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25978. * @param name defines the name of the mesh to create
  25979. * @param size sets the size (float) of each box side (default 1)
  25980. * @param scene defines the hosting scene
  25981. * @param updatable defines if the mesh must be flagged as updatable
  25982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25983. * @returns a new Mesh
  25984. */
  25985. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25986. /**
  25987. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25988. * @param name defines the name of the mesh to create
  25989. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25990. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25991. * @param scene defines the hosting scene
  25992. * @param updatable defines if the mesh must be flagged as updatable
  25993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25994. * @returns a new Mesh
  25995. */
  25996. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25997. /**
  25998. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25999. * @param name defines the name of the mesh to create
  26000. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26001. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26002. * @param scene defines the hosting scene
  26003. * @returns a new Mesh
  26004. */
  26005. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26006. /**
  26007. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26008. * @param name defines the name of the mesh to create
  26009. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26010. * @param diameterTop set the top cap diameter (floats, default 1)
  26011. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26012. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26013. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26014. * @param scene defines the hosting scene
  26015. * @param updatable defines if the mesh must be flagged as updatable
  26016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26020. /**
  26021. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  26024. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26025. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26026. * @param scene defines the hosting scene
  26027. * @param updatable defines if the mesh must be flagged as updatable
  26028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26029. * @returns a new Mesh
  26030. */
  26031. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26032. /**
  26033. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26034. * @param name defines the name of the mesh to create
  26035. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26036. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26037. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26038. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26039. * @param p the number of windings on X axis (positive integers, default 2)
  26040. * @param q the number of windings on Y axis (positive integers, default 3)
  26041. * @param scene defines the hosting scene
  26042. * @param updatable defines if the mesh must be flagged as updatable
  26043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26044. * @returns a new Mesh
  26045. */
  26046. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26047. /**
  26048. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26049. * @param name defines the name of the mesh to create
  26050. * @param points is an array successive Vector3
  26051. * @param scene defines the hosting scene
  26052. * @param updatable defines if the mesh must be flagged as updatable
  26053. * @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).
  26054. * @returns a new Mesh
  26055. */
  26056. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26057. /**
  26058. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26059. * @param name defines the name of the mesh to create
  26060. * @param points is an array successive Vector3
  26061. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26062. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26063. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26064. * @param scene defines the hosting scene
  26065. * @param updatable defines if the mesh must be flagged as updatable
  26066. * @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)
  26067. * @returns a new Mesh
  26068. */
  26069. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26070. /**
  26071. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26073. * 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.
  26074. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26075. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26076. * Remember you can only change the shape positions, not their number when updating a polygon.
  26077. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26078. * @param name defines the name of the mesh to create
  26079. * @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
  26080. * @param scene defines the hosting scene
  26081. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26082. * @param updatable defines if the mesh must be flagged as updatable
  26083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26084. * @param earcutInjection can be used to inject your own earcut reference
  26085. * @returns a new Mesh
  26086. */
  26087. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26088. /**
  26089. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26091. * @param name defines the name of the mesh to create
  26092. * @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
  26093. * @param depth defines the height of extrusion
  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 ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26102. /**
  26103. * Creates an extruded shape mesh.
  26104. * 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
  26105. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26107. * @param name defines the name of the mesh to create
  26108. * @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
  26109. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26110. * @param scale is the value to scale the shape
  26111. * @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
  26112. * @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
  26113. * @param scene defines the hosting scene
  26114. * @param updatable defines if the mesh must be flagged as updatable
  26115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26116. * @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)
  26117. * @returns a new Mesh
  26118. */
  26119. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26120. /**
  26121. * Creates an custom extruded shape mesh.
  26122. * The custom extrusion is a parametric shape.
  26123. * It has no predefined shape. Its final shape will depend on the input parameters.
  26124. * Please consider using the same method from the MeshBuilder class instead
  26125. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26126. * @param name defines the name of the mesh to create
  26127. * @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
  26128. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26129. * @param scaleFunction is a custom Javascript function called on each path point
  26130. * @param rotationFunction is a custom Javascript function called on each path point
  26131. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26132. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26133. * @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
  26134. * @param scene defines the hosting scene
  26135. * @param updatable defines if the mesh must be flagged as updatable
  26136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26137. * @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)
  26138. * @returns a new Mesh
  26139. */
  26140. 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;
  26141. /**
  26142. * Creates lathe mesh.
  26143. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26144. * Please consider using the same method from the MeshBuilder class instead
  26145. * @param name defines the name of the mesh to create
  26146. * @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
  26147. * @param radius is the radius value of the lathe
  26148. * @param tessellation is the side number of the lathe.
  26149. * @param scene defines the hosting scene
  26150. * @param updatable defines if the mesh must be flagged as updatable
  26151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26152. * @returns a new Mesh
  26153. */
  26154. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26155. /**
  26156. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26157. * @param name defines the name of the mesh to create
  26158. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26159. * @param scene defines the hosting scene
  26160. * @param updatable defines if the mesh must be flagged as updatable
  26161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26162. * @returns a new Mesh
  26163. */
  26164. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26165. /**
  26166. * Creates a ground mesh.
  26167. * Please consider using the same method from the MeshBuilder class instead
  26168. * @param name defines the name of the mesh to create
  26169. * @param width set the width of the ground
  26170. * @param height set the height of the ground
  26171. * @param subdivisions sets the number of subdivisions per side
  26172. * @param scene defines the hosting scene
  26173. * @param updatable defines if the mesh must be flagged as updatable
  26174. * @returns a new Mesh
  26175. */
  26176. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26177. /**
  26178. * Creates a tiled ground mesh.
  26179. * Please consider using the same method from the MeshBuilder class instead
  26180. * @param name defines the name of the mesh to create
  26181. * @param xmin set the ground minimum X coordinate
  26182. * @param zmin set the ground minimum Y coordinate
  26183. * @param xmax set the ground maximum X coordinate
  26184. * @param zmax set the ground maximum Z coordinate
  26185. * @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
  26186. * @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
  26187. * @param scene defines the hosting scene
  26188. * @param updatable defines if the mesh must be flagged as updatable
  26189. * @returns a new Mesh
  26190. */
  26191. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26192. w: number;
  26193. h: number;
  26194. }, precision: {
  26195. w: number;
  26196. h: number;
  26197. }, scene: Scene, updatable?: boolean): Mesh;
  26198. /**
  26199. * Creates a ground mesh from a height map.
  26200. * Please consider using the same method from the MeshBuilder class instead
  26201. * @see http://doc.babylonjs.com/babylon101/height_map
  26202. * @param name defines the name of the mesh to create
  26203. * @param url sets the URL of the height map image resource
  26204. * @param width set the ground width size
  26205. * @param height set the ground height size
  26206. * @param subdivisions sets the number of subdivision per side
  26207. * @param minHeight is the minimum altitude on the ground
  26208. * @param maxHeight is the maximum altitude on the ground
  26209. * @param scene defines the hosting scene
  26210. * @param updatable defines if the mesh must be flagged as updatable
  26211. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26212. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26213. * @returns a new Mesh
  26214. */
  26215. 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;
  26216. /**
  26217. * Creates a tube mesh.
  26218. * The tube is a parametric shape.
  26219. * It has no predefined shape. Its final shape will depend on the input parameters.
  26220. * Please consider using the same method from the MeshBuilder class instead
  26221. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26222. * @param name defines the name of the mesh to create
  26223. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26224. * @param radius sets the tube radius size
  26225. * @param tessellation is the number of sides on the tubular surface
  26226. * @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
  26227. * @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
  26228. * @param scene defines the hosting scene
  26229. * @param updatable defines if the mesh must be flagged as updatable
  26230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26231. * @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)
  26232. * @returns a new Mesh
  26233. */
  26234. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26235. (i: number, distance: number): number;
  26236. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26237. /**
  26238. * Creates a polyhedron mesh.
  26239. * Please consider using the same method from the MeshBuilder class instead.
  26240. * * 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
  26241. * * The parameter `size` (positive float, default 1) sets the polygon size
  26242. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26243. * * 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`
  26244. * * 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
  26245. * * 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)`)
  26246. * * 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
  26247. * * 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
  26248. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26249. * * If you create a double-sided mesh, you can choose what parts of 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
  26250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26251. * @param name defines the name of the mesh to create
  26252. * @param options defines the options used to create the mesh
  26253. * @param scene defines the hosting scene
  26254. * @returns a new Mesh
  26255. */
  26256. static CreatePolyhedron(name: string, options: {
  26257. type?: number;
  26258. size?: number;
  26259. sizeX?: number;
  26260. sizeY?: number;
  26261. sizeZ?: number;
  26262. custom?: any;
  26263. faceUV?: Vector4[];
  26264. faceColors?: Color4[];
  26265. updatable?: boolean;
  26266. sideOrientation?: number;
  26267. }, scene: Scene): Mesh;
  26268. /**
  26269. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26270. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26271. * * 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`)
  26272. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26273. * * 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
  26274. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26275. * * If you create a double-sided mesh, you can choose what parts of 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
  26276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26277. * @param name defines the name of the mesh
  26278. * @param options defines the options used to create the mesh
  26279. * @param scene defines the hosting scene
  26280. * @returns a new Mesh
  26281. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26282. */
  26283. static CreateIcoSphere(name: string, options: {
  26284. radius?: number;
  26285. flat?: boolean;
  26286. subdivisions?: number;
  26287. sideOrientation?: number;
  26288. updatable?: boolean;
  26289. }, scene: Scene): Mesh;
  26290. /**
  26291. * Creates a decal mesh.
  26292. * Please consider using the same method from the MeshBuilder class instead.
  26293. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26294. * @param name defines the name of the mesh
  26295. * @param sourceMesh defines the mesh receiving the decal
  26296. * @param position sets the position of the decal in world coordinates
  26297. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26298. * @param size sets the decal scaling
  26299. * @param angle sets the angle to rotate the decal
  26300. * @returns a new Mesh
  26301. */
  26302. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26303. /**
  26304. * Prepare internal position array for software CPU skinning
  26305. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26306. */
  26307. setPositionsForCPUSkinning(): Float32Array;
  26308. /**
  26309. * Prepare internal normal array for software CPU skinning
  26310. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26311. */
  26312. setNormalsForCPUSkinning(): Float32Array;
  26313. /**
  26314. * Updates the vertex buffer by applying transformation from the bones
  26315. * @param skeleton defines the skeleton to apply to current mesh
  26316. * @returns the current mesh
  26317. */
  26318. applySkeleton(skeleton: Skeleton): Mesh;
  26319. /**
  26320. * 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
  26321. * @param meshes defines the list of meshes to scan
  26322. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26323. */
  26324. static MinMax(meshes: AbstractMesh[]): {
  26325. min: Vector3;
  26326. max: Vector3;
  26327. };
  26328. /**
  26329. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26330. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26331. * @returns a vector3
  26332. */
  26333. static Center(meshesOrMinMaxVector: {
  26334. min: Vector3;
  26335. max: Vector3;
  26336. } | AbstractMesh[]): Vector3;
  26337. /**
  26338. * Merge the array of meshes into a single mesh for performance reasons.
  26339. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26340. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26341. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26342. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26343. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26344. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26345. * @returns a new mesh
  26346. */
  26347. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26348. /** @hidden */
  26349. addInstance(instance: InstancedMesh): void;
  26350. /** @hidden */
  26351. removeInstance(instance: InstancedMesh): void;
  26352. }
  26353. }
  26354. declare module "babylonjs/Cameras/camera" {
  26355. import { SmartArray } from "babylonjs/Misc/smartArray";
  26356. import { Observable } from "babylonjs/Misc/observable";
  26357. import { Nullable } from "babylonjs/types";
  26358. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26359. import { Scene } from "babylonjs/scene";
  26360. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26361. import { Node } from "babylonjs/node";
  26362. import { Mesh } from "babylonjs/Meshes/mesh";
  26363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26364. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26365. import { Viewport } from "babylonjs/Maths/math.viewport";
  26366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26367. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26368. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26369. import { Ray } from "babylonjs/Culling/ray";
  26370. /**
  26371. * This is the base class of all the camera used in the application.
  26372. * @see http://doc.babylonjs.com/features/cameras
  26373. */
  26374. export class Camera extends Node {
  26375. /** @hidden */
  26376. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26377. /**
  26378. * This is the default projection mode used by the cameras.
  26379. * It helps recreating a feeling of perspective and better appreciate depth.
  26380. * This is the best way to simulate real life cameras.
  26381. */
  26382. static readonly PERSPECTIVE_CAMERA: number;
  26383. /**
  26384. * This helps creating camera with an orthographic mode.
  26385. * 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.
  26386. */
  26387. static readonly ORTHOGRAPHIC_CAMERA: number;
  26388. /**
  26389. * This is the default FOV mode for perspective cameras.
  26390. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26391. */
  26392. static readonly FOVMODE_VERTICAL_FIXED: number;
  26393. /**
  26394. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26395. */
  26396. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26397. /**
  26398. * This specifies ther is no need for a camera rig.
  26399. * Basically only one eye is rendered corresponding to the camera.
  26400. */
  26401. static readonly RIG_MODE_NONE: number;
  26402. /**
  26403. * Simulates a camera Rig with one blue eye and one red eye.
  26404. * This can be use with 3d blue and red glasses.
  26405. */
  26406. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26407. /**
  26408. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26409. */
  26410. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26411. /**
  26412. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26413. */
  26414. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26415. /**
  26416. * Defines that both eyes of the camera will be rendered over under each other.
  26417. */
  26418. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26419. /**
  26420. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26421. */
  26422. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26423. /**
  26424. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26425. */
  26426. static readonly RIG_MODE_VR: number;
  26427. /**
  26428. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26429. */
  26430. static readonly RIG_MODE_WEBVR: number;
  26431. /**
  26432. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26433. */
  26434. static readonly RIG_MODE_CUSTOM: number;
  26435. /**
  26436. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26437. */
  26438. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26439. /**
  26440. * Define the input manager associated with the camera.
  26441. */
  26442. inputs: CameraInputsManager<Camera>;
  26443. /** @hidden */
  26444. _position: Vector3;
  26445. /**
  26446. * Define the current local position of the camera in the scene
  26447. */
  26448. get position(): Vector3;
  26449. set position(newPosition: Vector3);
  26450. /**
  26451. * The vector the camera should consider as up.
  26452. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26453. */
  26454. upVector: Vector3;
  26455. /**
  26456. * Define the current limit on the left side for an orthographic camera
  26457. * In scene unit
  26458. */
  26459. orthoLeft: Nullable<number>;
  26460. /**
  26461. * Define the current limit on the right side for an orthographic camera
  26462. * In scene unit
  26463. */
  26464. orthoRight: Nullable<number>;
  26465. /**
  26466. * Define the current limit on the bottom side for an orthographic camera
  26467. * In scene unit
  26468. */
  26469. orthoBottom: Nullable<number>;
  26470. /**
  26471. * Define the current limit on the top side for an orthographic camera
  26472. * In scene unit
  26473. */
  26474. orthoTop: Nullable<number>;
  26475. /**
  26476. * Field Of View is set in Radians. (default is 0.8)
  26477. */
  26478. fov: number;
  26479. /**
  26480. * Define the minimum distance the camera can see from.
  26481. * This is important to note that the depth buffer are not infinite and the closer it starts
  26482. * the more your scene might encounter depth fighting issue.
  26483. */
  26484. minZ: number;
  26485. /**
  26486. * Define the maximum distance the camera can see to.
  26487. * This is important to note that the depth buffer are not infinite and the further it end
  26488. * the more your scene might encounter depth fighting issue.
  26489. */
  26490. maxZ: number;
  26491. /**
  26492. * Define the default inertia of the camera.
  26493. * This helps giving a smooth feeling to the camera movement.
  26494. */
  26495. inertia: number;
  26496. /**
  26497. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26498. */
  26499. mode: number;
  26500. /**
  26501. * Define whether the camera is intermediate.
  26502. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26503. */
  26504. isIntermediate: boolean;
  26505. /**
  26506. * Define the viewport of the camera.
  26507. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26508. */
  26509. viewport: Viewport;
  26510. /**
  26511. * Restricts the camera to viewing objects with the same layerMask.
  26512. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26513. */
  26514. layerMask: number;
  26515. /**
  26516. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26517. */
  26518. fovMode: number;
  26519. /**
  26520. * Rig mode of the camera.
  26521. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26522. * This is normally controlled byt the camera themselves as internal use.
  26523. */
  26524. cameraRigMode: number;
  26525. /**
  26526. * Defines the distance between both "eyes" in case of a RIG
  26527. */
  26528. interaxialDistance: number;
  26529. /**
  26530. * Defines if stereoscopic rendering is done side by side or over under.
  26531. */
  26532. isStereoscopicSideBySide: boolean;
  26533. /**
  26534. * 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
  26535. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26536. * else in the scene. (Eg. security camera)
  26537. *
  26538. * 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)
  26539. */
  26540. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26541. /**
  26542. * When set, the camera will render to this render target instead of the default canvas
  26543. *
  26544. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26545. */
  26546. outputRenderTarget: Nullable<RenderTargetTexture>;
  26547. /**
  26548. * Observable triggered when the camera view matrix has changed.
  26549. */
  26550. onViewMatrixChangedObservable: Observable<Camera>;
  26551. /**
  26552. * Observable triggered when the camera Projection matrix has changed.
  26553. */
  26554. onProjectionMatrixChangedObservable: Observable<Camera>;
  26555. /**
  26556. * Observable triggered when the inputs have been processed.
  26557. */
  26558. onAfterCheckInputsObservable: Observable<Camera>;
  26559. /**
  26560. * Observable triggered when reset has been called and applied to the camera.
  26561. */
  26562. onRestoreStateObservable: Observable<Camera>;
  26563. /**
  26564. * Is this camera a part of a rig system?
  26565. */
  26566. isRigCamera: boolean;
  26567. /**
  26568. * If isRigCamera set to true this will be set with the parent camera.
  26569. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26570. */
  26571. rigParent?: Camera;
  26572. /** @hidden */
  26573. _cameraRigParams: any;
  26574. /** @hidden */
  26575. _rigCameras: Camera[];
  26576. /** @hidden */
  26577. _rigPostProcess: Nullable<PostProcess>;
  26578. protected _webvrViewMatrix: Matrix;
  26579. /** @hidden */
  26580. _skipRendering: boolean;
  26581. /** @hidden */
  26582. _projectionMatrix: Matrix;
  26583. /** @hidden */
  26584. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26585. /** @hidden */
  26586. _activeMeshes: SmartArray<AbstractMesh>;
  26587. protected _globalPosition: Vector3;
  26588. /** @hidden */
  26589. _computedViewMatrix: Matrix;
  26590. private _doNotComputeProjectionMatrix;
  26591. private _transformMatrix;
  26592. private _frustumPlanes;
  26593. private _refreshFrustumPlanes;
  26594. private _storedFov;
  26595. private _stateStored;
  26596. /**
  26597. * Instantiates a new camera object.
  26598. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26599. * @see http://doc.babylonjs.com/features/cameras
  26600. * @param name Defines the name of the camera in the scene
  26601. * @param position Defines the position of the camera
  26602. * @param scene Defines the scene the camera belongs too
  26603. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26604. */
  26605. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26606. /**
  26607. * Store current camera state (fov, position, etc..)
  26608. * @returns the camera
  26609. */
  26610. storeState(): Camera;
  26611. /**
  26612. * Restores the camera state values if it has been stored. You must call storeState() first
  26613. */
  26614. protected _restoreStateValues(): boolean;
  26615. /**
  26616. * Restored camera state. You must call storeState() first.
  26617. * @returns true if restored and false otherwise
  26618. */
  26619. restoreState(): boolean;
  26620. /**
  26621. * Gets the class name of the camera.
  26622. * @returns the class name
  26623. */
  26624. getClassName(): string;
  26625. /** @hidden */
  26626. readonly _isCamera: boolean;
  26627. /**
  26628. * Gets a string representation of the camera useful for debug purpose.
  26629. * @param fullDetails Defines that a more verboe level of logging is required
  26630. * @returns the string representation
  26631. */
  26632. toString(fullDetails?: boolean): string;
  26633. /**
  26634. * Gets the current world space position of the camera.
  26635. */
  26636. get globalPosition(): Vector3;
  26637. /**
  26638. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26639. * @returns the active meshe list
  26640. */
  26641. getActiveMeshes(): SmartArray<AbstractMesh>;
  26642. /**
  26643. * Check whether a mesh is part of the current active mesh list of the camera
  26644. * @param mesh Defines the mesh to check
  26645. * @returns true if active, false otherwise
  26646. */
  26647. isActiveMesh(mesh: Mesh): boolean;
  26648. /**
  26649. * Is this camera ready to be used/rendered
  26650. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26651. * @return true if the camera is ready
  26652. */
  26653. isReady(completeCheck?: boolean): boolean;
  26654. /** @hidden */
  26655. _initCache(): void;
  26656. /** @hidden */
  26657. _updateCache(ignoreParentClass?: boolean): void;
  26658. /** @hidden */
  26659. _isSynchronized(): boolean;
  26660. /** @hidden */
  26661. _isSynchronizedViewMatrix(): boolean;
  26662. /** @hidden */
  26663. _isSynchronizedProjectionMatrix(): boolean;
  26664. /**
  26665. * Attach the input controls to a specific dom element to get the input from.
  26666. * @param element Defines the element the controls should be listened from
  26667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26668. */
  26669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26670. /**
  26671. * Detach the current controls from the specified dom element.
  26672. * @param element Defines the element to stop listening the inputs from
  26673. */
  26674. detachControl(element: HTMLElement): void;
  26675. /**
  26676. * Update the camera state according to the different inputs gathered during the frame.
  26677. */
  26678. update(): void;
  26679. /** @hidden */
  26680. _checkInputs(): void;
  26681. /** @hidden */
  26682. get rigCameras(): Camera[];
  26683. /**
  26684. * Gets the post process used by the rig cameras
  26685. */
  26686. get rigPostProcess(): Nullable<PostProcess>;
  26687. /**
  26688. * Internal, gets the first post proces.
  26689. * @returns the first post process to be run on this camera.
  26690. */
  26691. _getFirstPostProcess(): Nullable<PostProcess>;
  26692. private _cascadePostProcessesToRigCams;
  26693. /**
  26694. * Attach a post process to the camera.
  26695. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26696. * @param postProcess The post process to attach to the camera
  26697. * @param insertAt The position of the post process in case several of them are in use in the scene
  26698. * @returns the position the post process has been inserted at
  26699. */
  26700. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26701. /**
  26702. * Detach a post process to the camera.
  26703. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26704. * @param postProcess The post process to detach from the camera
  26705. */
  26706. detachPostProcess(postProcess: PostProcess): void;
  26707. /**
  26708. * Gets the current world matrix of the camera
  26709. */
  26710. getWorldMatrix(): Matrix;
  26711. /** @hidden */
  26712. _getViewMatrix(): Matrix;
  26713. /**
  26714. * Gets the current view matrix of the camera.
  26715. * @param force forces the camera to recompute the matrix without looking at the cached state
  26716. * @returns the view matrix
  26717. */
  26718. getViewMatrix(force?: boolean): Matrix;
  26719. /**
  26720. * Freeze the projection matrix.
  26721. * It will prevent the cache check of the camera projection compute and can speed up perf
  26722. * if no parameter of the camera are meant to change
  26723. * @param projection Defines manually a projection if necessary
  26724. */
  26725. freezeProjectionMatrix(projection?: Matrix): void;
  26726. /**
  26727. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26728. */
  26729. unfreezeProjectionMatrix(): void;
  26730. /**
  26731. * Gets the current projection matrix of the camera.
  26732. * @param force forces the camera to recompute the matrix without looking at the cached state
  26733. * @returns the projection matrix
  26734. */
  26735. getProjectionMatrix(force?: boolean): Matrix;
  26736. /**
  26737. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26738. * @returns a Matrix
  26739. */
  26740. getTransformationMatrix(): Matrix;
  26741. private _updateFrustumPlanes;
  26742. /**
  26743. * Checks if a cullable object (mesh...) is in the camera frustum
  26744. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26745. * @param target The object to check
  26746. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26747. * @returns true if the object is in frustum otherwise false
  26748. */
  26749. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26750. /**
  26751. * Checks if a cullable object (mesh...) is in the camera frustum
  26752. * Unlike isInFrustum this cheks the full bounding box
  26753. * @param target The object to check
  26754. * @returns true if the object is in frustum otherwise false
  26755. */
  26756. isCompletelyInFrustum(target: ICullable): boolean;
  26757. /**
  26758. * Gets a ray in the forward direction from the camera.
  26759. * @param length Defines the length of the ray to create
  26760. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26761. * @param origin Defines the start point of the ray which defaults to the camera position
  26762. * @returns the forward ray
  26763. */
  26764. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26765. /**
  26766. * Releases resources associated with this node.
  26767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26769. */
  26770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26771. /** @hidden */
  26772. _isLeftCamera: boolean;
  26773. /**
  26774. * Gets the left camera of a rig setup in case of Rigged Camera
  26775. */
  26776. get isLeftCamera(): boolean;
  26777. /** @hidden */
  26778. _isRightCamera: boolean;
  26779. /**
  26780. * Gets the right camera of a rig setup in case of Rigged Camera
  26781. */
  26782. get isRightCamera(): boolean;
  26783. /**
  26784. * Gets the left camera of a rig setup in case of Rigged Camera
  26785. */
  26786. get leftCamera(): Nullable<FreeCamera>;
  26787. /**
  26788. * Gets the right camera of a rig setup in case of Rigged Camera
  26789. */
  26790. get rightCamera(): Nullable<FreeCamera>;
  26791. /**
  26792. * Gets the left camera target of a rig setup in case of Rigged Camera
  26793. * @returns the target position
  26794. */
  26795. getLeftTarget(): Nullable<Vector3>;
  26796. /**
  26797. * Gets the right camera target of a rig setup in case of Rigged Camera
  26798. * @returns the target position
  26799. */
  26800. getRightTarget(): Nullable<Vector3>;
  26801. /**
  26802. * @hidden
  26803. */
  26804. setCameraRigMode(mode: number, rigParams: any): void;
  26805. /** @hidden */
  26806. static _setStereoscopicRigMode(camera: Camera): void;
  26807. /** @hidden */
  26808. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26809. /** @hidden */
  26810. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26811. /** @hidden */
  26812. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26813. /** @hidden */
  26814. _getVRProjectionMatrix(): Matrix;
  26815. protected _updateCameraRotationMatrix(): void;
  26816. protected _updateWebVRCameraRotationMatrix(): void;
  26817. /**
  26818. * This function MUST be overwritten by the different WebVR cameras available.
  26819. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26820. * @hidden
  26821. */
  26822. _getWebVRProjectionMatrix(): Matrix;
  26823. /**
  26824. * This function MUST be overwritten by the different WebVR cameras available.
  26825. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26826. * @hidden
  26827. */
  26828. _getWebVRViewMatrix(): Matrix;
  26829. /** @hidden */
  26830. setCameraRigParameter(name: string, value: any): void;
  26831. /**
  26832. * needs to be overridden by children so sub has required properties to be copied
  26833. * @hidden
  26834. */
  26835. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26836. /**
  26837. * May need to be overridden by children
  26838. * @hidden
  26839. */
  26840. _updateRigCameras(): void;
  26841. /** @hidden */
  26842. _setupInputs(): void;
  26843. /**
  26844. * Serialiaze the camera setup to a json represention
  26845. * @returns the JSON representation
  26846. */
  26847. serialize(): any;
  26848. /**
  26849. * Clones the current camera.
  26850. * @param name The cloned camera name
  26851. * @returns the cloned camera
  26852. */
  26853. clone(name: string): Camera;
  26854. /**
  26855. * Gets the direction of the camera relative to a given local axis.
  26856. * @param localAxis Defines the reference axis to provide a relative direction.
  26857. * @return the direction
  26858. */
  26859. getDirection(localAxis: Vector3): Vector3;
  26860. /**
  26861. * Returns the current camera absolute rotation
  26862. */
  26863. get absoluteRotation(): Quaternion;
  26864. /**
  26865. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26866. * @param localAxis Defines the reference axis to provide a relative direction.
  26867. * @param result Defines the vector to store the result in
  26868. */
  26869. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26870. /**
  26871. * Gets a camera constructor for a given camera type
  26872. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26873. * @param name The name of the camera the result will be able to instantiate
  26874. * @param scene The scene the result will construct the camera in
  26875. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26876. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26877. * @returns a factory method to construc the camera
  26878. */
  26879. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26880. /**
  26881. * Compute the world matrix of the camera.
  26882. * @returns the camera world matrix
  26883. */
  26884. computeWorldMatrix(): Matrix;
  26885. /**
  26886. * Parse a JSON and creates the camera from the parsed information
  26887. * @param parsedCamera The JSON to parse
  26888. * @param scene The scene to instantiate the camera in
  26889. * @returns the newly constructed camera
  26890. */
  26891. static Parse(parsedCamera: any, scene: Scene): Camera;
  26892. }
  26893. }
  26894. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26895. import { Nullable } from "babylonjs/types";
  26896. import { Scene } from "babylonjs/scene";
  26897. import { Vector4 } from "babylonjs/Maths/math.vector";
  26898. import { Mesh } from "babylonjs/Meshes/mesh";
  26899. /**
  26900. * Class containing static functions to help procedurally build meshes
  26901. */
  26902. export class DiscBuilder {
  26903. /**
  26904. * Creates a plane polygonal mesh. By default, this is a disc
  26905. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26906. * * 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
  26907. * * 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
  26908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26911. * @param name defines the name of the mesh
  26912. * @param options defines the options used to create the mesh
  26913. * @param scene defines the hosting scene
  26914. * @returns the plane polygonal mesh
  26915. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26916. */
  26917. static CreateDisc(name: string, options: {
  26918. radius?: number;
  26919. tessellation?: number;
  26920. arc?: number;
  26921. updatable?: boolean;
  26922. sideOrientation?: number;
  26923. frontUVs?: Vector4;
  26924. backUVs?: Vector4;
  26925. }, scene?: Nullable<Scene>): Mesh;
  26926. }
  26927. }
  26928. declare module "babylonjs/Materials/fresnelParameters" {
  26929. import { DeepImmutable } from "babylonjs/types";
  26930. import { Color3 } from "babylonjs/Maths/math.color";
  26931. /**
  26932. * Options to be used when creating a FresnelParameters.
  26933. */
  26934. export type IFresnelParametersCreationOptions = {
  26935. /**
  26936. * Define the color used on edges (grazing angle)
  26937. */
  26938. leftColor?: Color3;
  26939. /**
  26940. * Define the color used on center
  26941. */
  26942. rightColor?: Color3;
  26943. /**
  26944. * Define bias applied to computed fresnel term
  26945. */
  26946. bias?: number;
  26947. /**
  26948. * Defined the power exponent applied to fresnel term
  26949. */
  26950. power?: number;
  26951. /**
  26952. * Define if the fresnel effect is enable or not.
  26953. */
  26954. isEnabled?: boolean;
  26955. };
  26956. /**
  26957. * Serialized format for FresnelParameters.
  26958. */
  26959. export type IFresnelParametersSerialized = {
  26960. /**
  26961. * Define the color used on edges (grazing angle) [as an array]
  26962. */
  26963. leftColor: number[];
  26964. /**
  26965. * Define the color used on center [as an array]
  26966. */
  26967. rightColor: number[];
  26968. /**
  26969. * Define bias applied to computed fresnel term
  26970. */
  26971. bias: number;
  26972. /**
  26973. * Defined the power exponent applied to fresnel term
  26974. */
  26975. power?: number;
  26976. /**
  26977. * Define if the fresnel effect is enable or not.
  26978. */
  26979. isEnabled: boolean;
  26980. };
  26981. /**
  26982. * This represents all the required information to add a fresnel effect on a material:
  26983. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26984. */
  26985. export class FresnelParameters {
  26986. private _isEnabled;
  26987. /**
  26988. * Define if the fresnel effect is enable or not.
  26989. */
  26990. get isEnabled(): boolean;
  26991. set isEnabled(value: boolean);
  26992. /**
  26993. * Define the color used on edges (grazing angle)
  26994. */
  26995. leftColor: Color3;
  26996. /**
  26997. * Define the color used on center
  26998. */
  26999. rightColor: Color3;
  27000. /**
  27001. * Define bias applied to computed fresnel term
  27002. */
  27003. bias: number;
  27004. /**
  27005. * Defined the power exponent applied to fresnel term
  27006. */
  27007. power: number;
  27008. /**
  27009. * Creates a new FresnelParameters object.
  27010. *
  27011. * @param options provide your own settings to optionally to override defaults
  27012. */
  27013. constructor(options?: IFresnelParametersCreationOptions);
  27014. /**
  27015. * Clones the current fresnel and its valuues
  27016. * @returns a clone fresnel configuration
  27017. */
  27018. clone(): FresnelParameters;
  27019. /**
  27020. * Determines equality between FresnelParameters objects
  27021. * @param otherFresnelParameters defines the second operand
  27022. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27023. */
  27024. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27025. /**
  27026. * Serializes the current fresnel parameters to a JSON representation.
  27027. * @return the JSON serialization
  27028. */
  27029. serialize(): IFresnelParametersSerialized;
  27030. /**
  27031. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27032. * @param parsedFresnelParameters Define the JSON representation
  27033. * @returns the parsed parameters
  27034. */
  27035. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27036. }
  27037. }
  27038. declare module "babylonjs/Materials/pushMaterial" {
  27039. import { Nullable } from "babylonjs/types";
  27040. import { Scene } from "babylonjs/scene";
  27041. import { Matrix } from "babylonjs/Maths/math.vector";
  27042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27043. import { Mesh } from "babylonjs/Meshes/mesh";
  27044. import { Material } from "babylonjs/Materials/material";
  27045. import { Effect } from "babylonjs/Materials/effect";
  27046. /**
  27047. * Base class of materials working in push mode in babylon JS
  27048. * @hidden
  27049. */
  27050. export class PushMaterial extends Material {
  27051. protected _activeEffect: Effect;
  27052. protected _normalMatrix: Matrix;
  27053. /**
  27054. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27055. * This means that the material can keep using a previous shader while a new one is being compiled.
  27056. * This is mostly used when shader parallel compilation is supported (true by default)
  27057. */
  27058. allowShaderHotSwapping: boolean;
  27059. constructor(name: string, scene: Scene);
  27060. getEffect(): Effect;
  27061. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27062. /**
  27063. * Binds the given world matrix to the active effect
  27064. *
  27065. * @param world the matrix to bind
  27066. */
  27067. bindOnlyWorldMatrix(world: Matrix): void;
  27068. /**
  27069. * Binds the given normal matrix to the active effect
  27070. *
  27071. * @param normalMatrix the matrix to bind
  27072. */
  27073. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27074. bind(world: Matrix, mesh?: Mesh): void;
  27075. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27076. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27077. }
  27078. }
  27079. declare module "babylonjs/Materials/materialFlags" {
  27080. /**
  27081. * This groups all the flags used to control the materials channel.
  27082. */
  27083. export class MaterialFlags {
  27084. private static _DiffuseTextureEnabled;
  27085. /**
  27086. * Are diffuse textures enabled in the application.
  27087. */
  27088. static get DiffuseTextureEnabled(): boolean;
  27089. static set DiffuseTextureEnabled(value: boolean);
  27090. private static _AmbientTextureEnabled;
  27091. /**
  27092. * Are ambient textures enabled in the application.
  27093. */
  27094. static get AmbientTextureEnabled(): boolean;
  27095. static set AmbientTextureEnabled(value: boolean);
  27096. private static _OpacityTextureEnabled;
  27097. /**
  27098. * Are opacity textures enabled in the application.
  27099. */
  27100. static get OpacityTextureEnabled(): boolean;
  27101. static set OpacityTextureEnabled(value: boolean);
  27102. private static _ReflectionTextureEnabled;
  27103. /**
  27104. * Are reflection textures enabled in the application.
  27105. */
  27106. static get ReflectionTextureEnabled(): boolean;
  27107. static set ReflectionTextureEnabled(value: boolean);
  27108. private static _EmissiveTextureEnabled;
  27109. /**
  27110. * Are emissive textures enabled in the application.
  27111. */
  27112. static get EmissiveTextureEnabled(): boolean;
  27113. static set EmissiveTextureEnabled(value: boolean);
  27114. private static _SpecularTextureEnabled;
  27115. /**
  27116. * Are specular textures enabled in the application.
  27117. */
  27118. static get SpecularTextureEnabled(): boolean;
  27119. static set SpecularTextureEnabled(value: boolean);
  27120. private static _BumpTextureEnabled;
  27121. /**
  27122. * Are bump textures enabled in the application.
  27123. */
  27124. static get BumpTextureEnabled(): boolean;
  27125. static set BumpTextureEnabled(value: boolean);
  27126. private static _LightmapTextureEnabled;
  27127. /**
  27128. * Are lightmap textures enabled in the application.
  27129. */
  27130. static get LightmapTextureEnabled(): boolean;
  27131. static set LightmapTextureEnabled(value: boolean);
  27132. private static _RefractionTextureEnabled;
  27133. /**
  27134. * Are refraction textures enabled in the application.
  27135. */
  27136. static get RefractionTextureEnabled(): boolean;
  27137. static set RefractionTextureEnabled(value: boolean);
  27138. private static _ColorGradingTextureEnabled;
  27139. /**
  27140. * Are color grading textures enabled in the application.
  27141. */
  27142. static get ColorGradingTextureEnabled(): boolean;
  27143. static set ColorGradingTextureEnabled(value: boolean);
  27144. private static _FresnelEnabled;
  27145. /**
  27146. * Are fresnels enabled in the application.
  27147. */
  27148. static get FresnelEnabled(): boolean;
  27149. static set FresnelEnabled(value: boolean);
  27150. private static _ClearCoatTextureEnabled;
  27151. /**
  27152. * Are clear coat textures enabled in the application.
  27153. */
  27154. static get ClearCoatTextureEnabled(): boolean;
  27155. static set ClearCoatTextureEnabled(value: boolean);
  27156. private static _ClearCoatBumpTextureEnabled;
  27157. /**
  27158. * Are clear coat bump textures enabled in the application.
  27159. */
  27160. static get ClearCoatBumpTextureEnabled(): boolean;
  27161. static set ClearCoatBumpTextureEnabled(value: boolean);
  27162. private static _ClearCoatTintTextureEnabled;
  27163. /**
  27164. * Are clear coat tint textures enabled in the application.
  27165. */
  27166. static get ClearCoatTintTextureEnabled(): boolean;
  27167. static set ClearCoatTintTextureEnabled(value: boolean);
  27168. private static _SheenTextureEnabled;
  27169. /**
  27170. * Are sheen textures enabled in the application.
  27171. */
  27172. static get SheenTextureEnabled(): boolean;
  27173. static set SheenTextureEnabled(value: boolean);
  27174. private static _AnisotropicTextureEnabled;
  27175. /**
  27176. * Are anisotropic textures enabled in the application.
  27177. */
  27178. static get AnisotropicTextureEnabled(): boolean;
  27179. static set AnisotropicTextureEnabled(value: boolean);
  27180. private static _ThicknessTextureEnabled;
  27181. /**
  27182. * Are thickness textures enabled in the application.
  27183. */
  27184. static get ThicknessTextureEnabled(): boolean;
  27185. static set ThicknessTextureEnabled(value: boolean);
  27186. }
  27187. }
  27188. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27189. /** @hidden */
  27190. export var defaultFragmentDeclaration: {
  27191. name: string;
  27192. shader: string;
  27193. };
  27194. }
  27195. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27196. /** @hidden */
  27197. export var defaultUboDeclaration: {
  27198. name: string;
  27199. shader: string;
  27200. };
  27201. }
  27202. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27203. /** @hidden */
  27204. export var lightFragmentDeclaration: {
  27205. name: string;
  27206. shader: string;
  27207. };
  27208. }
  27209. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27210. /** @hidden */
  27211. export var lightUboDeclaration: {
  27212. name: string;
  27213. shader: string;
  27214. };
  27215. }
  27216. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27217. /** @hidden */
  27218. export var lightsFragmentFunctions: {
  27219. name: string;
  27220. shader: string;
  27221. };
  27222. }
  27223. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27224. /** @hidden */
  27225. export var shadowsFragmentFunctions: {
  27226. name: string;
  27227. shader: string;
  27228. };
  27229. }
  27230. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27231. /** @hidden */
  27232. export var fresnelFunction: {
  27233. name: string;
  27234. shader: string;
  27235. };
  27236. }
  27237. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27238. /** @hidden */
  27239. export var reflectionFunction: {
  27240. name: string;
  27241. shader: string;
  27242. };
  27243. }
  27244. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27245. /** @hidden */
  27246. export var bumpFragmentFunctions: {
  27247. name: string;
  27248. shader: string;
  27249. };
  27250. }
  27251. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27252. /** @hidden */
  27253. export var logDepthDeclaration: {
  27254. name: string;
  27255. shader: string;
  27256. };
  27257. }
  27258. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27259. /** @hidden */
  27260. export var bumpFragment: {
  27261. name: string;
  27262. shader: string;
  27263. };
  27264. }
  27265. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27266. /** @hidden */
  27267. export var depthPrePass: {
  27268. name: string;
  27269. shader: string;
  27270. };
  27271. }
  27272. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27273. /** @hidden */
  27274. export var lightFragment: {
  27275. name: string;
  27276. shader: string;
  27277. };
  27278. }
  27279. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27280. /** @hidden */
  27281. export var logDepthFragment: {
  27282. name: string;
  27283. shader: string;
  27284. };
  27285. }
  27286. declare module "babylonjs/Shaders/default.fragment" {
  27287. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27288. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27289. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27290. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27291. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27292. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27293. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27294. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27295. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27296. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27297. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27298. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27299. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27300. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27301. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27302. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27303. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27304. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27305. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27306. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27307. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27308. /** @hidden */
  27309. export var defaultPixelShader: {
  27310. name: string;
  27311. shader: string;
  27312. };
  27313. }
  27314. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27315. /** @hidden */
  27316. export var defaultVertexDeclaration: {
  27317. name: string;
  27318. shader: string;
  27319. };
  27320. }
  27321. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27322. /** @hidden */
  27323. export var bumpVertexDeclaration: {
  27324. name: string;
  27325. shader: string;
  27326. };
  27327. }
  27328. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27329. /** @hidden */
  27330. export var bumpVertex: {
  27331. name: string;
  27332. shader: string;
  27333. };
  27334. }
  27335. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27336. /** @hidden */
  27337. export var fogVertex: {
  27338. name: string;
  27339. shader: string;
  27340. };
  27341. }
  27342. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27343. /** @hidden */
  27344. export var shadowsVertex: {
  27345. name: string;
  27346. shader: string;
  27347. };
  27348. }
  27349. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27350. /** @hidden */
  27351. export var pointCloudVertex: {
  27352. name: string;
  27353. shader: string;
  27354. };
  27355. }
  27356. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27357. /** @hidden */
  27358. export var logDepthVertex: {
  27359. name: string;
  27360. shader: string;
  27361. };
  27362. }
  27363. declare module "babylonjs/Shaders/default.vertex" {
  27364. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27365. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27366. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27367. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27369. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27371. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27372. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27373. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27376. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27378. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27379. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27380. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27382. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27383. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27384. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27385. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27386. /** @hidden */
  27387. export var defaultVertexShader: {
  27388. name: string;
  27389. shader: string;
  27390. };
  27391. }
  27392. declare module "babylonjs/Materials/standardMaterial" {
  27393. import { SmartArray } from "babylonjs/Misc/smartArray";
  27394. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27395. import { Nullable } from "babylonjs/types";
  27396. import { Scene } from "babylonjs/scene";
  27397. import { Matrix } from "babylonjs/Maths/math.vector";
  27398. import { Color3 } from "babylonjs/Maths/math.color";
  27399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27401. import { Mesh } from "babylonjs/Meshes/mesh";
  27402. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27403. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27404. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27405. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27406. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27409. import "babylonjs/Shaders/default.fragment";
  27410. import "babylonjs/Shaders/default.vertex";
  27411. /** @hidden */
  27412. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27413. MAINUV1: boolean;
  27414. MAINUV2: boolean;
  27415. DIFFUSE: boolean;
  27416. DIFFUSEDIRECTUV: number;
  27417. AMBIENT: boolean;
  27418. AMBIENTDIRECTUV: number;
  27419. OPACITY: boolean;
  27420. OPACITYDIRECTUV: number;
  27421. OPACITYRGB: boolean;
  27422. REFLECTION: boolean;
  27423. EMISSIVE: boolean;
  27424. EMISSIVEDIRECTUV: number;
  27425. SPECULAR: boolean;
  27426. SPECULARDIRECTUV: number;
  27427. BUMP: boolean;
  27428. BUMPDIRECTUV: number;
  27429. PARALLAX: boolean;
  27430. PARALLAXOCCLUSION: boolean;
  27431. SPECULAROVERALPHA: boolean;
  27432. CLIPPLANE: boolean;
  27433. CLIPPLANE2: boolean;
  27434. CLIPPLANE3: boolean;
  27435. CLIPPLANE4: boolean;
  27436. CLIPPLANE5: boolean;
  27437. CLIPPLANE6: boolean;
  27438. ALPHATEST: boolean;
  27439. DEPTHPREPASS: boolean;
  27440. ALPHAFROMDIFFUSE: boolean;
  27441. POINTSIZE: boolean;
  27442. FOG: boolean;
  27443. SPECULARTERM: boolean;
  27444. DIFFUSEFRESNEL: boolean;
  27445. OPACITYFRESNEL: boolean;
  27446. REFLECTIONFRESNEL: boolean;
  27447. REFRACTIONFRESNEL: boolean;
  27448. EMISSIVEFRESNEL: boolean;
  27449. FRESNEL: boolean;
  27450. NORMAL: boolean;
  27451. UV1: boolean;
  27452. UV2: boolean;
  27453. VERTEXCOLOR: boolean;
  27454. VERTEXALPHA: boolean;
  27455. NUM_BONE_INFLUENCERS: number;
  27456. BonesPerMesh: number;
  27457. BONETEXTURE: boolean;
  27458. INSTANCES: boolean;
  27459. GLOSSINESS: boolean;
  27460. ROUGHNESS: boolean;
  27461. EMISSIVEASILLUMINATION: boolean;
  27462. LINKEMISSIVEWITHDIFFUSE: boolean;
  27463. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27464. LIGHTMAP: boolean;
  27465. LIGHTMAPDIRECTUV: number;
  27466. OBJECTSPACE_NORMALMAP: boolean;
  27467. USELIGHTMAPASSHADOWMAP: boolean;
  27468. REFLECTIONMAP_3D: boolean;
  27469. REFLECTIONMAP_SPHERICAL: boolean;
  27470. REFLECTIONMAP_PLANAR: boolean;
  27471. REFLECTIONMAP_CUBIC: boolean;
  27472. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27473. REFLECTIONMAP_PROJECTION: boolean;
  27474. REFLECTIONMAP_SKYBOX: boolean;
  27475. REFLECTIONMAP_EXPLICIT: boolean;
  27476. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27477. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27478. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27479. INVERTCUBICMAP: boolean;
  27480. LOGARITHMICDEPTH: boolean;
  27481. REFRACTION: boolean;
  27482. REFRACTIONMAP_3D: boolean;
  27483. REFLECTIONOVERALPHA: boolean;
  27484. TWOSIDEDLIGHTING: boolean;
  27485. SHADOWFLOAT: boolean;
  27486. MORPHTARGETS: boolean;
  27487. MORPHTARGETS_NORMAL: boolean;
  27488. MORPHTARGETS_TANGENT: boolean;
  27489. MORPHTARGETS_UV: boolean;
  27490. NUM_MORPH_INFLUENCERS: number;
  27491. NONUNIFORMSCALING: boolean;
  27492. PREMULTIPLYALPHA: boolean;
  27493. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27494. ALPHABLEND: boolean;
  27495. IMAGEPROCESSING: boolean;
  27496. VIGNETTE: boolean;
  27497. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27498. VIGNETTEBLENDMODEOPAQUE: boolean;
  27499. TONEMAPPING: boolean;
  27500. TONEMAPPING_ACES: boolean;
  27501. CONTRAST: boolean;
  27502. COLORCURVES: boolean;
  27503. COLORGRADING: boolean;
  27504. COLORGRADING3D: boolean;
  27505. SAMPLER3DGREENDEPTH: boolean;
  27506. SAMPLER3DBGRMAP: boolean;
  27507. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27508. MULTIVIEW: boolean;
  27509. /**
  27510. * If the reflection texture on this material is in linear color space
  27511. * @hidden
  27512. */
  27513. IS_REFLECTION_LINEAR: boolean;
  27514. /**
  27515. * If the refraction texture on this material is in linear color space
  27516. * @hidden
  27517. */
  27518. IS_REFRACTION_LINEAR: boolean;
  27519. EXPOSURE: boolean;
  27520. constructor();
  27521. setReflectionMode(modeToEnable: string): void;
  27522. }
  27523. /**
  27524. * This is the default material used in Babylon. It is the best trade off between quality
  27525. * and performances.
  27526. * @see http://doc.babylonjs.com/babylon101/materials
  27527. */
  27528. export class StandardMaterial extends PushMaterial {
  27529. private _diffuseTexture;
  27530. /**
  27531. * The basic texture of the material as viewed under a light.
  27532. */
  27533. diffuseTexture: Nullable<BaseTexture>;
  27534. private _ambientTexture;
  27535. /**
  27536. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27537. */
  27538. ambientTexture: Nullable<BaseTexture>;
  27539. private _opacityTexture;
  27540. /**
  27541. * Define the transparency of the material from a texture.
  27542. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27543. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27544. */
  27545. opacityTexture: Nullable<BaseTexture>;
  27546. private _reflectionTexture;
  27547. /**
  27548. * Define the texture used to display the reflection.
  27549. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27550. */
  27551. reflectionTexture: Nullable<BaseTexture>;
  27552. private _emissiveTexture;
  27553. /**
  27554. * Define texture of the material as if self lit.
  27555. * This will be mixed in the final result even in the absence of light.
  27556. */
  27557. emissiveTexture: Nullable<BaseTexture>;
  27558. private _specularTexture;
  27559. /**
  27560. * Define how the color and intensity of the highlight given by the light in the material.
  27561. */
  27562. specularTexture: Nullable<BaseTexture>;
  27563. private _bumpTexture;
  27564. /**
  27565. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27566. * 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.
  27567. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27568. */
  27569. bumpTexture: Nullable<BaseTexture>;
  27570. private _lightmapTexture;
  27571. /**
  27572. * Complex lighting can be computationally expensive to compute at runtime.
  27573. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27574. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27575. */
  27576. lightmapTexture: Nullable<BaseTexture>;
  27577. private _refractionTexture;
  27578. /**
  27579. * Define the texture used to display the refraction.
  27580. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27581. */
  27582. refractionTexture: Nullable<BaseTexture>;
  27583. /**
  27584. * The color of the material lit by the environmental background lighting.
  27585. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27586. */
  27587. ambientColor: Color3;
  27588. /**
  27589. * The basic color of the material as viewed under a light.
  27590. */
  27591. diffuseColor: Color3;
  27592. /**
  27593. * Define how the color and intensity of the highlight given by the light in the material.
  27594. */
  27595. specularColor: Color3;
  27596. /**
  27597. * Define the color of the material as if self lit.
  27598. * This will be mixed in the final result even in the absence of light.
  27599. */
  27600. emissiveColor: Color3;
  27601. /**
  27602. * Defines how sharp are the highlights in the material.
  27603. * The bigger the value the sharper giving a more glossy feeling to the result.
  27604. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27605. */
  27606. specularPower: number;
  27607. private _useAlphaFromDiffuseTexture;
  27608. /**
  27609. * Does the transparency come from the diffuse texture alpha channel.
  27610. */
  27611. useAlphaFromDiffuseTexture: boolean;
  27612. private _useEmissiveAsIllumination;
  27613. /**
  27614. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27615. */
  27616. useEmissiveAsIllumination: boolean;
  27617. private _linkEmissiveWithDiffuse;
  27618. /**
  27619. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27620. * the emissive level when the final color is close to one.
  27621. */
  27622. linkEmissiveWithDiffuse: boolean;
  27623. private _useSpecularOverAlpha;
  27624. /**
  27625. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27626. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27627. */
  27628. useSpecularOverAlpha: boolean;
  27629. private _useReflectionOverAlpha;
  27630. /**
  27631. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27632. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27633. */
  27634. useReflectionOverAlpha: boolean;
  27635. private _disableLighting;
  27636. /**
  27637. * Does lights from the scene impacts this material.
  27638. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27639. */
  27640. disableLighting: boolean;
  27641. private _useObjectSpaceNormalMap;
  27642. /**
  27643. * Allows using an object space normal map (instead of tangent space).
  27644. */
  27645. useObjectSpaceNormalMap: boolean;
  27646. private _useParallax;
  27647. /**
  27648. * Is parallax enabled or not.
  27649. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27650. */
  27651. useParallax: boolean;
  27652. private _useParallaxOcclusion;
  27653. /**
  27654. * Is parallax occlusion enabled or not.
  27655. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27656. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27657. */
  27658. useParallaxOcclusion: boolean;
  27659. /**
  27660. * 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.
  27661. */
  27662. parallaxScaleBias: number;
  27663. private _roughness;
  27664. /**
  27665. * Helps to define how blurry the reflections should appears in the material.
  27666. */
  27667. roughness: number;
  27668. /**
  27669. * In case of refraction, define the value of the index of refraction.
  27670. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27671. */
  27672. indexOfRefraction: number;
  27673. /**
  27674. * Invert the refraction texture alongside the y axis.
  27675. * It can be useful with procedural textures or probe for instance.
  27676. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27677. */
  27678. invertRefractionY: boolean;
  27679. /**
  27680. * Defines the alpha limits in alpha test mode.
  27681. */
  27682. alphaCutOff: number;
  27683. private _useLightmapAsShadowmap;
  27684. /**
  27685. * In case of light mapping, define whether the map contains light or shadow informations.
  27686. */
  27687. useLightmapAsShadowmap: boolean;
  27688. private _diffuseFresnelParameters;
  27689. /**
  27690. * Define the diffuse fresnel parameters of the material.
  27691. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27692. */
  27693. diffuseFresnelParameters: FresnelParameters;
  27694. private _opacityFresnelParameters;
  27695. /**
  27696. * Define the opacity fresnel parameters of the material.
  27697. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27698. */
  27699. opacityFresnelParameters: FresnelParameters;
  27700. private _reflectionFresnelParameters;
  27701. /**
  27702. * Define the reflection fresnel parameters of the material.
  27703. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27704. */
  27705. reflectionFresnelParameters: FresnelParameters;
  27706. private _refractionFresnelParameters;
  27707. /**
  27708. * Define the refraction fresnel parameters of the material.
  27709. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27710. */
  27711. refractionFresnelParameters: FresnelParameters;
  27712. private _emissiveFresnelParameters;
  27713. /**
  27714. * Define the emissive fresnel parameters of the material.
  27715. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27716. */
  27717. emissiveFresnelParameters: FresnelParameters;
  27718. private _useReflectionFresnelFromSpecular;
  27719. /**
  27720. * If true automatically deducts the fresnels values from the material specularity.
  27721. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27722. */
  27723. useReflectionFresnelFromSpecular: boolean;
  27724. private _useGlossinessFromSpecularMapAlpha;
  27725. /**
  27726. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27727. */
  27728. useGlossinessFromSpecularMapAlpha: boolean;
  27729. private _maxSimultaneousLights;
  27730. /**
  27731. * Defines the maximum number of lights that can be used in the material
  27732. */
  27733. maxSimultaneousLights: number;
  27734. private _invertNormalMapX;
  27735. /**
  27736. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27737. */
  27738. invertNormalMapX: boolean;
  27739. private _invertNormalMapY;
  27740. /**
  27741. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27742. */
  27743. invertNormalMapY: boolean;
  27744. private _twoSidedLighting;
  27745. /**
  27746. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27747. */
  27748. twoSidedLighting: boolean;
  27749. /**
  27750. * Default configuration related to image processing available in the standard Material.
  27751. */
  27752. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27753. /**
  27754. * Gets the image processing configuration used either in this material.
  27755. */
  27756. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27757. /**
  27758. * Sets the Default image processing configuration used either in the this material.
  27759. *
  27760. * If sets to null, the scene one is in use.
  27761. */
  27762. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27763. /**
  27764. * Keep track of the image processing observer to allow dispose and replace.
  27765. */
  27766. private _imageProcessingObserver;
  27767. /**
  27768. * Attaches a new image processing configuration to the Standard Material.
  27769. * @param configuration
  27770. */
  27771. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27772. /**
  27773. * Gets wether the color curves effect is enabled.
  27774. */
  27775. get cameraColorCurvesEnabled(): boolean;
  27776. /**
  27777. * Sets wether the color curves effect is enabled.
  27778. */
  27779. set cameraColorCurvesEnabled(value: boolean);
  27780. /**
  27781. * Gets wether the color grading effect is enabled.
  27782. */
  27783. get cameraColorGradingEnabled(): boolean;
  27784. /**
  27785. * Gets wether the color grading effect is enabled.
  27786. */
  27787. set cameraColorGradingEnabled(value: boolean);
  27788. /**
  27789. * Gets wether tonemapping is enabled or not.
  27790. */
  27791. get cameraToneMappingEnabled(): boolean;
  27792. /**
  27793. * Sets wether tonemapping is enabled or not
  27794. */
  27795. set cameraToneMappingEnabled(value: boolean);
  27796. /**
  27797. * The camera exposure used on this material.
  27798. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27799. * This corresponds to a photographic exposure.
  27800. */
  27801. get cameraExposure(): number;
  27802. /**
  27803. * The camera exposure used on this material.
  27804. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27805. * This corresponds to a photographic exposure.
  27806. */
  27807. set cameraExposure(value: number);
  27808. /**
  27809. * Gets The camera contrast used on this material.
  27810. */
  27811. get cameraContrast(): number;
  27812. /**
  27813. * Sets The camera contrast used on this material.
  27814. */
  27815. set cameraContrast(value: number);
  27816. /**
  27817. * Gets the Color Grading 2D Lookup Texture.
  27818. */
  27819. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27820. /**
  27821. * Sets the Color Grading 2D Lookup Texture.
  27822. */
  27823. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27824. /**
  27825. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27826. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27827. * 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;
  27828. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27829. */
  27830. get cameraColorCurves(): Nullable<ColorCurves>;
  27831. /**
  27832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27834. * 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;
  27835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27836. */
  27837. set cameraColorCurves(value: Nullable<ColorCurves>);
  27838. /**
  27839. * Custom callback helping to override the default shader used in the material.
  27840. */
  27841. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27842. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27843. protected _worldViewProjectionMatrix: Matrix;
  27844. protected _globalAmbientColor: Color3;
  27845. protected _useLogarithmicDepth: boolean;
  27846. protected _rebuildInParallel: boolean;
  27847. /**
  27848. * Instantiates a new standard material.
  27849. * This is the default material used in Babylon. It is the best trade off between quality
  27850. * and performances.
  27851. * @see http://doc.babylonjs.com/babylon101/materials
  27852. * @param name Define the name of the material in the scene
  27853. * @param scene Define the scene the material belong to
  27854. */
  27855. constructor(name: string, scene: Scene);
  27856. /**
  27857. * Gets a boolean indicating that current material needs to register RTT
  27858. */
  27859. get hasRenderTargetTextures(): boolean;
  27860. /**
  27861. * Gets the current class name of the material e.g. "StandardMaterial"
  27862. * Mainly use in serialization.
  27863. * @returns the class name
  27864. */
  27865. getClassName(): string;
  27866. /**
  27867. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27868. * You can try switching to logarithmic depth.
  27869. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27870. */
  27871. get useLogarithmicDepth(): boolean;
  27872. set useLogarithmicDepth(value: boolean);
  27873. /**
  27874. * Specifies if the material will require alpha blending
  27875. * @returns a boolean specifying if alpha blending is needed
  27876. */
  27877. needAlphaBlending(): boolean;
  27878. /**
  27879. * Specifies if this material should be rendered in alpha test mode
  27880. * @returns a boolean specifying if an alpha test is needed.
  27881. */
  27882. needAlphaTesting(): boolean;
  27883. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27884. /**
  27885. * Get the texture used for alpha test purpose.
  27886. * @returns the diffuse texture in case of the standard material.
  27887. */
  27888. getAlphaTestTexture(): Nullable<BaseTexture>;
  27889. /**
  27890. * Get if the submesh is ready to be used and all its information available.
  27891. * Child classes can use it to update shaders
  27892. * @param mesh defines the mesh to check
  27893. * @param subMesh defines which submesh to check
  27894. * @param useInstances specifies that instances should be used
  27895. * @returns a boolean indicating that the submesh is ready or not
  27896. */
  27897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27898. /**
  27899. * Builds the material UBO layouts.
  27900. * Used internally during the effect preparation.
  27901. */
  27902. buildUniformLayout(): void;
  27903. /**
  27904. * Unbinds the material from the mesh
  27905. */
  27906. unbind(): void;
  27907. /**
  27908. * Binds the submesh to this material by preparing the effect and shader to draw
  27909. * @param world defines the world transformation matrix
  27910. * @param mesh defines the mesh containing the submesh
  27911. * @param subMesh defines the submesh to bind the material to
  27912. */
  27913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27914. /**
  27915. * Get the list of animatables in the material.
  27916. * @returns the list of animatables object used in the material
  27917. */
  27918. getAnimatables(): IAnimatable[];
  27919. /**
  27920. * Gets the active textures from the material
  27921. * @returns an array of textures
  27922. */
  27923. getActiveTextures(): BaseTexture[];
  27924. /**
  27925. * Specifies if the material uses a texture
  27926. * @param texture defines the texture to check against the material
  27927. * @returns a boolean specifying if the material uses the texture
  27928. */
  27929. hasTexture(texture: BaseTexture): boolean;
  27930. /**
  27931. * Disposes the material
  27932. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27933. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27934. */
  27935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27936. /**
  27937. * Makes a duplicate of the material, and gives it a new name
  27938. * @param name defines the new name for the duplicated material
  27939. * @returns the cloned material
  27940. */
  27941. clone(name: string): StandardMaterial;
  27942. /**
  27943. * Serializes this material in a JSON representation
  27944. * @returns the serialized material object
  27945. */
  27946. serialize(): any;
  27947. /**
  27948. * Creates a standard material from parsed material data
  27949. * @param source defines the JSON representation of the material
  27950. * @param scene defines the hosting scene
  27951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27952. * @returns a new standard material
  27953. */
  27954. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27955. /**
  27956. * Are diffuse textures enabled in the application.
  27957. */
  27958. static get DiffuseTextureEnabled(): boolean;
  27959. static set DiffuseTextureEnabled(value: boolean);
  27960. /**
  27961. * Are ambient textures enabled in the application.
  27962. */
  27963. static get AmbientTextureEnabled(): boolean;
  27964. static set AmbientTextureEnabled(value: boolean);
  27965. /**
  27966. * Are opacity textures enabled in the application.
  27967. */
  27968. static get OpacityTextureEnabled(): boolean;
  27969. static set OpacityTextureEnabled(value: boolean);
  27970. /**
  27971. * Are reflection textures enabled in the application.
  27972. */
  27973. static get ReflectionTextureEnabled(): boolean;
  27974. static set ReflectionTextureEnabled(value: boolean);
  27975. /**
  27976. * Are emissive textures enabled in the application.
  27977. */
  27978. static get EmissiveTextureEnabled(): boolean;
  27979. static set EmissiveTextureEnabled(value: boolean);
  27980. /**
  27981. * Are specular textures enabled in the application.
  27982. */
  27983. static get SpecularTextureEnabled(): boolean;
  27984. static set SpecularTextureEnabled(value: boolean);
  27985. /**
  27986. * Are bump textures enabled in the application.
  27987. */
  27988. static get BumpTextureEnabled(): boolean;
  27989. static set BumpTextureEnabled(value: boolean);
  27990. /**
  27991. * Are lightmap textures enabled in the application.
  27992. */
  27993. static get LightmapTextureEnabled(): boolean;
  27994. static set LightmapTextureEnabled(value: boolean);
  27995. /**
  27996. * Are refraction textures enabled in the application.
  27997. */
  27998. static get RefractionTextureEnabled(): boolean;
  27999. static set RefractionTextureEnabled(value: boolean);
  28000. /**
  28001. * Are color grading textures enabled in the application.
  28002. */
  28003. static get ColorGradingTextureEnabled(): boolean;
  28004. static set ColorGradingTextureEnabled(value: boolean);
  28005. /**
  28006. * Are fresnels enabled in the application.
  28007. */
  28008. static get FresnelEnabled(): boolean;
  28009. static set FresnelEnabled(value: boolean);
  28010. }
  28011. }
  28012. declare module "babylonjs/Particles/solidParticleSystem" {
  28013. import { Nullable } from "babylonjs/types";
  28014. import { Vector3 } from "babylonjs/Maths/math.vector";
  28015. import { Mesh } from "babylonjs/Meshes/mesh";
  28016. import { Scene, IDisposable } from "babylonjs/scene";
  28017. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28018. import { Material } from "babylonjs/Materials/material";
  28019. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28020. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28021. /**
  28022. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28023. *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.
  28024. * The SPS is also a particle system. It provides some methods to manage the particles.
  28025. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28026. *
  28027. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28028. */
  28029. export class SolidParticleSystem implements IDisposable {
  28030. /**
  28031. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28032. * Example : var p = SPS.particles[i];
  28033. */
  28034. particles: SolidParticle[];
  28035. /**
  28036. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28037. */
  28038. nbParticles: number;
  28039. /**
  28040. * If the particles must ever face the camera (default false). Useful for planar particles.
  28041. */
  28042. billboard: boolean;
  28043. /**
  28044. * Recompute normals when adding a shape
  28045. */
  28046. recomputeNormals: boolean;
  28047. /**
  28048. * This a counter ofr your own usage. It's not set by any SPS functions.
  28049. */
  28050. counter: number;
  28051. /**
  28052. * The SPS name. This name is also given to the underlying mesh.
  28053. */
  28054. name: string;
  28055. /**
  28056. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28057. */
  28058. mesh: Mesh;
  28059. /**
  28060. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28061. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28062. */
  28063. vars: any;
  28064. /**
  28065. * This array is populated when the SPS is set as 'pickable'.
  28066. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28067. * Each element of this array is an object `{idx: int, faceId: int}`.
  28068. * `idx` is the picked particle index in the `SPS.particles` array
  28069. * `faceId` is the picked face index counted within this particle.
  28070. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28071. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28072. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28073. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28074. */
  28075. pickedParticles: {
  28076. idx: number;
  28077. faceId: number;
  28078. }[];
  28079. /**
  28080. * This array is populated when the SPS is set as 'pickable'
  28081. * Each key of this array is a submesh index.
  28082. * Each element of this array is a second array defined like this :
  28083. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28084. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28085. * `idx` is the picked particle index in the `SPS.particles` array
  28086. * `faceId` is the picked face index counted within this particle.
  28087. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28088. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28089. */
  28090. pickedBySubMesh: {
  28091. idx: number;
  28092. faceId: number;
  28093. }[][];
  28094. /**
  28095. * This array is populated when `enableDepthSort` is set to true.
  28096. * Each element of this array is an instance of the class DepthSortedParticle.
  28097. */
  28098. depthSortedParticles: DepthSortedParticle[];
  28099. /**
  28100. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28101. * @hidden
  28102. */
  28103. _bSphereOnly: boolean;
  28104. /**
  28105. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28106. * @hidden
  28107. */
  28108. _bSphereRadiusFactor: number;
  28109. private _scene;
  28110. private _positions;
  28111. private _indices;
  28112. private _normals;
  28113. private _colors;
  28114. private _uvs;
  28115. private _indices32;
  28116. private _positions32;
  28117. private _normals32;
  28118. private _fixedNormal32;
  28119. private _colors32;
  28120. private _uvs32;
  28121. private _index;
  28122. private _updatable;
  28123. private _pickable;
  28124. private _isVisibilityBoxLocked;
  28125. private _alwaysVisible;
  28126. private _depthSort;
  28127. private _expandable;
  28128. private _shapeCounter;
  28129. private _copy;
  28130. private _color;
  28131. private _computeParticleColor;
  28132. private _computeParticleTexture;
  28133. private _computeParticleRotation;
  28134. private _computeParticleVertex;
  28135. private _computeBoundingBox;
  28136. private _depthSortParticles;
  28137. private _camera;
  28138. private _mustUnrotateFixedNormals;
  28139. private _particlesIntersect;
  28140. private _needs32Bits;
  28141. private _isNotBuilt;
  28142. private _lastParticleId;
  28143. private _idxOfId;
  28144. private _multimaterialEnabled;
  28145. private _useModelMaterial;
  28146. private _indicesByMaterial;
  28147. private _materialIndexes;
  28148. private _depthSortFunction;
  28149. private _materialSortFunction;
  28150. private _materials;
  28151. private _multimaterial;
  28152. private _materialIndexesById;
  28153. private _defaultMaterial;
  28154. private _autoUpdateSubMeshes;
  28155. /**
  28156. * Creates a SPS (Solid Particle System) object.
  28157. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28158. * @param scene (Scene) is the scene in which the SPS is added.
  28159. * @param options defines the options of the sps e.g.
  28160. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28161. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28162. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28163. * * 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.
  28164. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28165. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28166. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28167. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28168. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28169. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28170. */
  28171. constructor(name: string, scene: Scene, options?: {
  28172. updatable?: boolean;
  28173. isPickable?: boolean;
  28174. enableDepthSort?: boolean;
  28175. particleIntersection?: boolean;
  28176. boundingSphereOnly?: boolean;
  28177. bSphereRadiusFactor?: number;
  28178. expandable?: boolean;
  28179. useModelMaterial?: boolean;
  28180. enableMultiMaterial?: boolean;
  28181. });
  28182. /**
  28183. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28184. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28185. * @returns the created mesh
  28186. */
  28187. buildMesh(): Mesh;
  28188. /**
  28189. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28190. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28191. * Thus the particles generated from `digest()` have their property `position` set yet.
  28192. * @param mesh ( Mesh ) is the mesh to be digested
  28193. * @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
  28194. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28195. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28197. * @returns the current SPS
  28198. */
  28199. digest(mesh: Mesh, options?: {
  28200. facetNb?: number;
  28201. number?: number;
  28202. delta?: number;
  28203. storage?: [];
  28204. }): SolidParticleSystem;
  28205. /**
  28206. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28207. * @hidden
  28208. */
  28209. private _unrotateFixedNormals;
  28210. /**
  28211. * Resets the temporary working copy particle
  28212. * @hidden
  28213. */
  28214. private _resetCopy;
  28215. /**
  28216. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28217. * @param p the current index in the positions array to be updated
  28218. * @param ind the current index in the indices array
  28219. * @param shape a Vector3 array, the shape geometry
  28220. * @param positions the positions array to be updated
  28221. * @param meshInd the shape indices array
  28222. * @param indices the indices array to be updated
  28223. * @param meshUV the shape uv array
  28224. * @param uvs the uv array to be updated
  28225. * @param meshCol the shape color array
  28226. * @param colors the color array to be updated
  28227. * @param meshNor the shape normals array
  28228. * @param normals the normals array to be updated
  28229. * @param idx the particle index
  28230. * @param idxInShape the particle index in its shape
  28231. * @param options the addShape() method passed options
  28232. * @model the particle model
  28233. * @hidden
  28234. */
  28235. private _meshBuilder;
  28236. /**
  28237. * Returns a shape Vector3 array from positions float array
  28238. * @param positions float array
  28239. * @returns a vector3 array
  28240. * @hidden
  28241. */
  28242. private _posToShape;
  28243. /**
  28244. * Returns a shapeUV array from a float uvs (array deep copy)
  28245. * @param uvs as a float array
  28246. * @returns a shapeUV array
  28247. * @hidden
  28248. */
  28249. private _uvsToShapeUV;
  28250. /**
  28251. * Adds a new particle object in the particles array
  28252. * @param idx particle index in particles array
  28253. * @param id particle id
  28254. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28255. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28256. * @param model particle ModelShape object
  28257. * @param shapeId model shape identifier
  28258. * @param idxInShape index of the particle in the current model
  28259. * @param bInfo model bounding info object
  28260. * @param storage target storage array, if any
  28261. * @hidden
  28262. */
  28263. private _addParticle;
  28264. /**
  28265. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28266. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28267. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28268. * @param nb (positive integer) the number of particles to be created from this model
  28269. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28270. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28271. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28272. * @returns the number of shapes in the system
  28273. */
  28274. addShape(mesh: Mesh, nb: number, options?: {
  28275. positionFunction?: any;
  28276. vertexFunction?: any;
  28277. storage?: [];
  28278. }): number;
  28279. /**
  28280. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28281. * @hidden
  28282. */
  28283. private _rebuildParticle;
  28284. /**
  28285. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28286. * @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.
  28287. * @returns the SPS.
  28288. */
  28289. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28290. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28291. * Returns an array with the removed particles.
  28292. * 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.
  28293. * The SPS can't be empty so at least one particle needs to remain in place.
  28294. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28295. * @param start index of the first particle to remove
  28296. * @param end index of the last particle to remove (included)
  28297. * @returns an array populated with the removed particles
  28298. */
  28299. removeParticles(start: number, end: number): SolidParticle[];
  28300. /**
  28301. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28302. * @param solidParticleArray an array populated with Solid Particles objects
  28303. * @returns the SPS
  28304. */
  28305. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28306. /**
  28307. * Creates a new particle and modifies the SPS mesh geometry :
  28308. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28309. * - calls _addParticle() to populate the particle array
  28310. * factorized code from addShape() and insertParticlesFromArray()
  28311. * @param idx particle index in the particles array
  28312. * @param i particle index in its shape
  28313. * @param modelShape particle ModelShape object
  28314. * @param shape shape vertex array
  28315. * @param meshInd shape indices array
  28316. * @param meshUV shape uv array
  28317. * @param meshCol shape color array
  28318. * @param meshNor shape normals array
  28319. * @param bbInfo shape bounding info
  28320. * @param storage target particle storage
  28321. * @options addShape() passed options
  28322. * @hidden
  28323. */
  28324. private _insertNewParticle;
  28325. /**
  28326. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28327. * This method calls `updateParticle()` for each particle of the SPS.
  28328. * For an animated SPS, it is usually called within the render loop.
  28329. * 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.
  28330. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28331. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28332. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28333. * @returns the SPS.
  28334. */
  28335. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28336. /**
  28337. * Disposes the SPS.
  28338. */
  28339. dispose(): void;
  28340. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28341. * idx is the particle index in the SPS
  28342. * faceId is the picked face index counted within this particle.
  28343. * Returns null if the pickInfo can't identify a picked particle.
  28344. * @param pickingInfo (PickingInfo object)
  28345. * @returns {idx: number, faceId: number} or null
  28346. */
  28347. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28348. idx: number;
  28349. faceId: number;
  28350. }>;
  28351. /**
  28352. * Returns a SolidParticle object from its identifier : particle.id
  28353. * @param id (integer) the particle Id
  28354. * @returns the searched particle or null if not found in the SPS.
  28355. */
  28356. getParticleById(id: number): Nullable<SolidParticle>;
  28357. /**
  28358. * Returns a new array populated with the particles having the passed shapeId.
  28359. * @param shapeId (integer) the shape identifier
  28360. * @returns a new solid particle array
  28361. */
  28362. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28363. /**
  28364. * Populates the passed array "ref" with the particles having the passed shapeId.
  28365. * @param shapeId the shape identifier
  28366. * @returns the SPS
  28367. * @param ref
  28368. */
  28369. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28370. /**
  28371. * Computes the required SubMeshes according the materials assigned to the particles.
  28372. * @returns the solid particle system.
  28373. * Does nothing if called before the SPS mesh is built.
  28374. */
  28375. computeSubMeshes(): SolidParticleSystem;
  28376. /**
  28377. * Sorts the solid particles by material when MultiMaterial is enabled.
  28378. * Updates the indices32 array.
  28379. * Updates the indicesByMaterial array.
  28380. * Updates the mesh indices array.
  28381. * @returns the SPS
  28382. * @hidden
  28383. */
  28384. private _sortParticlesByMaterial;
  28385. /**
  28386. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28387. * @hidden
  28388. */
  28389. private _setMaterialIndexesById;
  28390. /**
  28391. * Returns an array with unique values of Materials from the passed array
  28392. * @param array the material array to be checked and filtered
  28393. * @hidden
  28394. */
  28395. private _filterUniqueMaterialId;
  28396. /**
  28397. * Sets a new Standard Material as _defaultMaterial if not already set.
  28398. * @hidden
  28399. */
  28400. private _setDefaultMaterial;
  28401. /**
  28402. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28403. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28404. * @returns the SPS.
  28405. */
  28406. refreshVisibleSize(): SolidParticleSystem;
  28407. /**
  28408. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28409. * @param size the size (float) of the visibility box
  28410. * note : this doesn't lock the SPS mesh bounding box.
  28411. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28412. */
  28413. setVisibilityBox(size: number): void;
  28414. /**
  28415. * Gets whether the SPS as always visible or not
  28416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28417. */
  28418. get isAlwaysVisible(): boolean;
  28419. /**
  28420. * Sets the SPS as always visible or not
  28421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28422. */
  28423. set isAlwaysVisible(val: boolean);
  28424. /**
  28425. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28426. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28427. */
  28428. set isVisibilityBoxLocked(val: boolean);
  28429. /**
  28430. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28431. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28432. */
  28433. get isVisibilityBoxLocked(): boolean;
  28434. /**
  28435. * Tells to `setParticles()` to compute the particle rotations or not.
  28436. * Default value : true. The SPS is faster when it's set to false.
  28437. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28438. */
  28439. set computeParticleRotation(val: boolean);
  28440. /**
  28441. * Tells to `setParticles()` to compute the particle colors or not.
  28442. * Default value : true. The SPS is faster when it's set to false.
  28443. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28444. */
  28445. set computeParticleColor(val: boolean);
  28446. set computeParticleTexture(val: boolean);
  28447. /**
  28448. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28449. * Default value : false. The SPS is faster when it's set to false.
  28450. * Note : the particle custom vertex positions aren't stored values.
  28451. */
  28452. set computeParticleVertex(val: boolean);
  28453. /**
  28454. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28455. */
  28456. set computeBoundingBox(val: boolean);
  28457. /**
  28458. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28459. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28460. * Default : `true`
  28461. */
  28462. set depthSortParticles(val: boolean);
  28463. /**
  28464. * Gets if `setParticles()` computes the particle rotations or not.
  28465. * Default value : true. The SPS is faster when it's set to false.
  28466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28467. */
  28468. get computeParticleRotation(): boolean;
  28469. /**
  28470. * Gets if `setParticles()` computes the particle colors or not.
  28471. * Default value : true. The SPS is faster when it's set to false.
  28472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28473. */
  28474. get computeParticleColor(): boolean;
  28475. /**
  28476. * Gets if `setParticles()` computes the particle textures or not.
  28477. * Default value : true. The SPS is faster when it's set to false.
  28478. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28479. */
  28480. get computeParticleTexture(): boolean;
  28481. /**
  28482. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28483. * Default value : false. The SPS is faster when it's set to false.
  28484. * Note : the particle custom vertex positions aren't stored values.
  28485. */
  28486. get computeParticleVertex(): boolean;
  28487. /**
  28488. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28489. */
  28490. get computeBoundingBox(): boolean;
  28491. /**
  28492. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28493. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28494. * Default : `true`
  28495. */
  28496. get depthSortParticles(): boolean;
  28497. /**
  28498. * Gets if the SPS is created as expandable at construction time.
  28499. * Default : `false`
  28500. */
  28501. get expandable(): boolean;
  28502. /**
  28503. * Gets if the SPS supports the Multi Materials
  28504. */
  28505. get multimaterialEnabled(): boolean;
  28506. /**
  28507. * Gets if the SPS uses the model materials for its own multimaterial.
  28508. */
  28509. get useModelMaterial(): boolean;
  28510. /**
  28511. * The SPS used material array.
  28512. */
  28513. get materials(): Material[];
  28514. /**
  28515. * Sets the SPS MultiMaterial from the passed materials.
  28516. * Note : the passed array is internally copied and not used then by reference.
  28517. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28518. */
  28519. setMultiMaterial(materials: Material[]): void;
  28520. /**
  28521. * The SPS computed multimaterial object
  28522. */
  28523. get multimaterial(): MultiMaterial;
  28524. set multimaterial(mm: MultiMaterial);
  28525. /**
  28526. * If the subMeshes must be updated on the next call to setParticles()
  28527. */
  28528. get autoUpdateSubMeshes(): boolean;
  28529. set autoUpdateSubMeshes(val: boolean);
  28530. /**
  28531. * This function does nothing. It may be overwritten to set all the particle first values.
  28532. * The SPS doesn't call this function, you may have to call it by your own.
  28533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28534. */
  28535. initParticles(): void;
  28536. /**
  28537. * This function does nothing. It may be overwritten to recycle a particle.
  28538. * The SPS doesn't call this function, you may have to call it by your own.
  28539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28540. * @param particle The particle to recycle
  28541. * @returns the recycled particle
  28542. */
  28543. recycleParticle(particle: SolidParticle): SolidParticle;
  28544. /**
  28545. * Updates a particle : this function should be overwritten by the user.
  28546. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28548. * @example : just set a particle position or velocity and recycle conditions
  28549. * @param particle The particle to update
  28550. * @returns the updated particle
  28551. */
  28552. updateParticle(particle: SolidParticle): SolidParticle;
  28553. /**
  28554. * Updates a vertex of a particle : it can be overwritten by the user.
  28555. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28556. * @param particle the current particle
  28557. * @param vertex the current index of the current particle
  28558. * @param pt the index of the current vertex in the particle shape
  28559. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28560. * @example : just set a vertex particle position
  28561. * @returns the updated vertex
  28562. */
  28563. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28564. /**
  28565. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28566. * This does nothing and may be overwritten by the user.
  28567. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28569. * @param update the boolean update value actually passed to setParticles()
  28570. */
  28571. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28572. /**
  28573. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28574. * This will be passed three parameters.
  28575. * This does nothing and may be overwritten by the user.
  28576. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28577. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28578. * @param update the boolean update value actually passed to setParticles()
  28579. */
  28580. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28581. }
  28582. }
  28583. declare module "babylonjs/Particles/solidParticle" {
  28584. import { Nullable } from "babylonjs/types";
  28585. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28586. import { Color4 } from "babylonjs/Maths/math.color";
  28587. import { Mesh } from "babylonjs/Meshes/mesh";
  28588. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28589. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28590. import { Plane } from "babylonjs/Maths/math.plane";
  28591. import { Material } from "babylonjs/Materials/material";
  28592. /**
  28593. * Represents one particle of a solid particle system.
  28594. */
  28595. export class SolidParticle {
  28596. /**
  28597. * particle global index
  28598. */
  28599. idx: number;
  28600. /**
  28601. * particle identifier
  28602. */
  28603. id: number;
  28604. /**
  28605. * The color of the particle
  28606. */
  28607. color: Nullable<Color4>;
  28608. /**
  28609. * The world space position of the particle.
  28610. */
  28611. position: Vector3;
  28612. /**
  28613. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28614. */
  28615. rotation: Vector3;
  28616. /**
  28617. * The world space rotation quaternion of the particle.
  28618. */
  28619. rotationQuaternion: Nullable<Quaternion>;
  28620. /**
  28621. * The scaling of the particle.
  28622. */
  28623. scaling: Vector3;
  28624. /**
  28625. * The uvs of the particle.
  28626. */
  28627. uvs: Vector4;
  28628. /**
  28629. * The current speed of the particle.
  28630. */
  28631. velocity: Vector3;
  28632. /**
  28633. * The pivot point in the particle local space.
  28634. */
  28635. pivot: Vector3;
  28636. /**
  28637. * Must the particle be translated from its pivot point in its local space ?
  28638. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28639. * Default : false
  28640. */
  28641. translateFromPivot: boolean;
  28642. /**
  28643. * Is the particle active or not ?
  28644. */
  28645. alive: boolean;
  28646. /**
  28647. * Is the particle visible or not ?
  28648. */
  28649. isVisible: boolean;
  28650. /**
  28651. * Index of this particle in the global "positions" array (Internal use)
  28652. * @hidden
  28653. */
  28654. _pos: number;
  28655. /**
  28656. * @hidden Index of this particle in the global "indices" array (Internal use)
  28657. */
  28658. _ind: number;
  28659. /**
  28660. * @hidden ModelShape of this particle (Internal use)
  28661. */
  28662. _model: ModelShape;
  28663. /**
  28664. * ModelShape id of this particle
  28665. */
  28666. shapeId: number;
  28667. /**
  28668. * Index of the particle in its shape id
  28669. */
  28670. idxInShape: number;
  28671. /**
  28672. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28673. */
  28674. _modelBoundingInfo: BoundingInfo;
  28675. /**
  28676. * @hidden Particle BoundingInfo object (Internal use)
  28677. */
  28678. _boundingInfo: BoundingInfo;
  28679. /**
  28680. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28681. */
  28682. _sps: SolidParticleSystem;
  28683. /**
  28684. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28685. */
  28686. _stillInvisible: boolean;
  28687. /**
  28688. * @hidden Last computed particle rotation matrix
  28689. */
  28690. _rotationMatrix: number[];
  28691. /**
  28692. * Parent particle Id, if any.
  28693. * Default null.
  28694. */
  28695. parentId: Nullable<number>;
  28696. /**
  28697. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28698. */
  28699. materialIndex: Nullable<number>;
  28700. /**
  28701. * Custom object or properties.
  28702. */
  28703. props: Nullable<any>;
  28704. /**
  28705. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28706. * The possible values are :
  28707. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28708. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28709. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28710. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28711. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28712. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28713. * */
  28714. cullingStrategy: number;
  28715. /**
  28716. * @hidden Internal global position in the SPS.
  28717. */
  28718. _globalPosition: Vector3;
  28719. /**
  28720. * Creates a Solid Particle object.
  28721. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28722. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28723. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28724. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28725. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28726. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28727. * @param shapeId (integer) is the model shape identifier in the SPS.
  28728. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28729. * @param sps defines the sps it is associated to
  28730. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28731. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28732. */
  28733. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28734. /**
  28735. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28736. * @param target the particle target
  28737. * @returns the current particle
  28738. */
  28739. copyToRef(target: SolidParticle): SolidParticle;
  28740. /**
  28741. * Legacy support, changed scale to scaling
  28742. */
  28743. get scale(): Vector3;
  28744. /**
  28745. * Legacy support, changed scale to scaling
  28746. */
  28747. set scale(scale: Vector3);
  28748. /**
  28749. * Legacy support, changed quaternion to rotationQuaternion
  28750. */
  28751. get quaternion(): Nullable<Quaternion>;
  28752. /**
  28753. * Legacy support, changed quaternion to rotationQuaternion
  28754. */
  28755. set quaternion(q: Nullable<Quaternion>);
  28756. /**
  28757. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28758. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28759. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28760. * @returns true if it intersects
  28761. */
  28762. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28763. /**
  28764. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28765. * A particle is in the frustum if its bounding box intersects the frustum
  28766. * @param frustumPlanes defines the frustum to test
  28767. * @returns true if the particle is in the frustum planes
  28768. */
  28769. isInFrustum(frustumPlanes: Plane[]): boolean;
  28770. /**
  28771. * get the rotation matrix of the particle
  28772. * @hidden
  28773. */
  28774. getRotationMatrix(m: Matrix): void;
  28775. }
  28776. /**
  28777. * Represents the shape of the model used by one particle of a solid particle system.
  28778. * SPS internal tool, don't use it manually.
  28779. */
  28780. export class ModelShape {
  28781. /**
  28782. * The shape id
  28783. * @hidden
  28784. */
  28785. shapeID: number;
  28786. /**
  28787. * flat array of model positions (internal use)
  28788. * @hidden
  28789. */
  28790. _shape: Vector3[];
  28791. /**
  28792. * flat array of model UVs (internal use)
  28793. * @hidden
  28794. */
  28795. _shapeUV: number[];
  28796. /**
  28797. * color array of the model
  28798. * @hidden
  28799. */
  28800. _shapeColors: number[];
  28801. /**
  28802. * indices array of the model
  28803. * @hidden
  28804. */
  28805. _indices: number[];
  28806. /**
  28807. * normals array of the model
  28808. * @hidden
  28809. */
  28810. _normals: number[];
  28811. /**
  28812. * length of the shape in the model indices array (internal use)
  28813. * @hidden
  28814. */
  28815. _indicesLength: number;
  28816. /**
  28817. * Custom position function (internal use)
  28818. * @hidden
  28819. */
  28820. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28821. /**
  28822. * Custom vertex function (internal use)
  28823. * @hidden
  28824. */
  28825. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28826. /**
  28827. * Model material (internal use)
  28828. * @hidden
  28829. */
  28830. _material: Nullable<Material>;
  28831. /**
  28832. * 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.
  28833. * SPS internal tool, don't use it manually.
  28834. * @hidden
  28835. */
  28836. 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>);
  28837. }
  28838. /**
  28839. * Represents a Depth Sorted Particle in the solid particle system.
  28840. * @hidden
  28841. */
  28842. export class DepthSortedParticle {
  28843. /**
  28844. * Particle index
  28845. */
  28846. idx: number;
  28847. /**
  28848. * Index of the particle in the "indices" array
  28849. */
  28850. ind: number;
  28851. /**
  28852. * Length of the particle shape in the "indices" array
  28853. */
  28854. indicesLength: number;
  28855. /**
  28856. * Squared distance from the particle to the camera
  28857. */
  28858. sqDistance: number;
  28859. /**
  28860. * Material index when used with MultiMaterials
  28861. */
  28862. materialIndex: number;
  28863. /**
  28864. * Creates a new sorted particle
  28865. * @param materialIndex
  28866. */
  28867. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28868. }
  28869. }
  28870. declare module "babylonjs/Collisions/meshCollisionData" {
  28871. import { Collider } from "babylonjs/Collisions/collider";
  28872. import { Vector3 } from "babylonjs/Maths/math.vector";
  28873. import { Nullable } from "babylonjs/types";
  28874. import { Observer } from "babylonjs/Misc/observable";
  28875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28876. /**
  28877. * @hidden
  28878. */
  28879. export class _MeshCollisionData {
  28880. _checkCollisions: boolean;
  28881. _collisionMask: number;
  28882. _collisionGroup: number;
  28883. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28884. _collider: Nullable<Collider>;
  28885. _oldPositionForCollisions: Vector3;
  28886. _diffPositionForCollisions: Vector3;
  28887. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28888. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28889. }
  28890. }
  28891. declare module "babylonjs/Meshes/abstractMesh" {
  28892. import { Observable } from "babylonjs/Misc/observable";
  28893. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28894. import { Camera } from "babylonjs/Cameras/camera";
  28895. import { Scene, IDisposable } from "babylonjs/scene";
  28896. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28897. import { Node } from "babylonjs/node";
  28898. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28899. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28901. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28902. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28903. import { Material } from "babylonjs/Materials/material";
  28904. import { Light } from "babylonjs/Lights/light";
  28905. import { Skeleton } from "babylonjs/Bones/skeleton";
  28906. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28907. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28908. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28909. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28910. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28911. import { Plane } from "babylonjs/Maths/math.plane";
  28912. import { Ray } from "babylonjs/Culling/ray";
  28913. import { Collider } from "babylonjs/Collisions/collider";
  28914. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28915. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28916. /** @hidden */
  28917. class _FacetDataStorage {
  28918. facetPositions: Vector3[];
  28919. facetNormals: Vector3[];
  28920. facetPartitioning: number[][];
  28921. facetNb: number;
  28922. partitioningSubdivisions: number;
  28923. partitioningBBoxRatio: number;
  28924. facetDataEnabled: boolean;
  28925. facetParameters: any;
  28926. bbSize: Vector3;
  28927. subDiv: {
  28928. max: number;
  28929. X: number;
  28930. Y: number;
  28931. Z: number;
  28932. };
  28933. facetDepthSort: boolean;
  28934. facetDepthSortEnabled: boolean;
  28935. depthSortedIndices: IndicesArray;
  28936. depthSortedFacets: {
  28937. ind: number;
  28938. sqDistance: number;
  28939. }[];
  28940. facetDepthSortFunction: (f1: {
  28941. ind: number;
  28942. sqDistance: number;
  28943. }, f2: {
  28944. ind: number;
  28945. sqDistance: number;
  28946. }) => number;
  28947. facetDepthSortFrom: Vector3;
  28948. facetDepthSortOrigin: Vector3;
  28949. invertedMatrix: Matrix;
  28950. }
  28951. /**
  28952. * @hidden
  28953. **/
  28954. class _InternalAbstractMeshDataInfo {
  28955. _hasVertexAlpha: boolean;
  28956. _useVertexColors: boolean;
  28957. _numBoneInfluencers: number;
  28958. _applyFog: boolean;
  28959. _receiveShadows: boolean;
  28960. _facetData: _FacetDataStorage;
  28961. _visibility: number;
  28962. _skeleton: Nullable<Skeleton>;
  28963. _layerMask: number;
  28964. _computeBonesUsingShaders: boolean;
  28965. _isActive: boolean;
  28966. _onlyForInstances: boolean;
  28967. _isActiveIntermediate: boolean;
  28968. _onlyForInstancesIntermediate: boolean;
  28969. _actAsRegularMesh: boolean;
  28970. }
  28971. /**
  28972. * Class used to store all common mesh properties
  28973. */
  28974. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28975. /** No occlusion */
  28976. static OCCLUSION_TYPE_NONE: number;
  28977. /** Occlusion set to optimisitic */
  28978. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28979. /** Occlusion set to strict */
  28980. static OCCLUSION_TYPE_STRICT: number;
  28981. /** Use an accurante occlusion algorithm */
  28982. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28983. /** Use a conservative occlusion algorithm */
  28984. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28985. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28986. * Test order :
  28987. * Is the bounding sphere outside the frustum ?
  28988. * If not, are the bounding box vertices outside the frustum ?
  28989. * It not, then the cullable object is in the frustum.
  28990. */
  28991. static readonly CULLINGSTRATEGY_STANDARD: number;
  28992. /** Culling strategy : Bounding Sphere Only.
  28993. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28994. * It's also less accurate than the standard because some not visible objects can still be selected.
  28995. * Test : is the bounding sphere outside the frustum ?
  28996. * If not, then the cullable object is in the frustum.
  28997. */
  28998. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28999. /** Culling strategy : Optimistic Inclusion.
  29000. * This in an inclusion test first, then the standard exclusion test.
  29001. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29002. * 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.
  29003. * Anyway, it's as accurate as the standard strategy.
  29004. * Test :
  29005. * Is the cullable object bounding sphere center in the frustum ?
  29006. * If not, apply the default culling strategy.
  29007. */
  29008. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29009. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29010. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29011. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29012. * 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.
  29013. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29014. * Test :
  29015. * Is the cullable object bounding sphere center in the frustum ?
  29016. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29017. */
  29018. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29019. /**
  29020. * No billboard
  29021. */
  29022. static get BILLBOARDMODE_NONE(): number;
  29023. /** Billboard on X axis */
  29024. static get BILLBOARDMODE_X(): number;
  29025. /** Billboard on Y axis */
  29026. static get BILLBOARDMODE_Y(): number;
  29027. /** Billboard on Z axis */
  29028. static get BILLBOARDMODE_Z(): number;
  29029. /** Billboard on all axes */
  29030. static get BILLBOARDMODE_ALL(): number;
  29031. /** Billboard on using position instead of orientation */
  29032. static get BILLBOARDMODE_USE_POSITION(): number;
  29033. /** @hidden */
  29034. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29035. /**
  29036. * The culling strategy to use to check whether the mesh must be rendered or not.
  29037. * This value can be changed at any time and will be used on the next render mesh selection.
  29038. * The possible values are :
  29039. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29040. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29041. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29042. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29043. * Please read each static variable documentation to get details about the culling process.
  29044. * */
  29045. cullingStrategy: number;
  29046. /**
  29047. * Gets the number of facets in the mesh
  29048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29049. */
  29050. get facetNb(): number;
  29051. /**
  29052. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29054. */
  29055. get partitioningSubdivisions(): number;
  29056. set partitioningSubdivisions(nb: number);
  29057. /**
  29058. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29059. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29061. */
  29062. get partitioningBBoxRatio(): number;
  29063. set partitioningBBoxRatio(ratio: number);
  29064. /**
  29065. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29066. * Works only for updatable meshes.
  29067. * Doesn't work with multi-materials
  29068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29069. */
  29070. get mustDepthSortFacets(): boolean;
  29071. set mustDepthSortFacets(sort: boolean);
  29072. /**
  29073. * The location (Vector3) where the facet depth sort must be computed from.
  29074. * By default, the active camera position.
  29075. * Used only when facet depth sort is enabled
  29076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29077. */
  29078. get facetDepthSortFrom(): Vector3;
  29079. set facetDepthSortFrom(location: Vector3);
  29080. /**
  29081. * gets a boolean indicating if facetData is enabled
  29082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29083. */
  29084. get isFacetDataEnabled(): boolean;
  29085. /** @hidden */
  29086. _updateNonUniformScalingState(value: boolean): boolean;
  29087. /**
  29088. * An event triggered when this mesh collides with another one
  29089. */
  29090. onCollideObservable: Observable<AbstractMesh>;
  29091. /** Set a function to call when this mesh collides with another one */
  29092. set onCollide(callback: () => void);
  29093. /**
  29094. * An event triggered when the collision's position changes
  29095. */
  29096. onCollisionPositionChangeObservable: Observable<Vector3>;
  29097. /** Set a function to call when the collision's position changes */
  29098. set onCollisionPositionChange(callback: () => void);
  29099. /**
  29100. * An event triggered when material is changed
  29101. */
  29102. onMaterialChangedObservable: Observable<AbstractMesh>;
  29103. /**
  29104. * Gets or sets the orientation for POV movement & rotation
  29105. */
  29106. definedFacingForward: boolean;
  29107. /** @hidden */
  29108. _occlusionQuery: Nullable<WebGLQuery>;
  29109. /** @hidden */
  29110. _renderingGroup: Nullable<RenderingGroup>;
  29111. /**
  29112. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29113. */
  29114. get visibility(): number;
  29115. /**
  29116. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29117. */
  29118. set visibility(value: number);
  29119. /** Gets or sets the alpha index used to sort transparent meshes
  29120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29121. */
  29122. alphaIndex: number;
  29123. /**
  29124. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29125. */
  29126. isVisible: boolean;
  29127. /**
  29128. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29129. */
  29130. isPickable: boolean;
  29131. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29132. showSubMeshesBoundingBox: boolean;
  29133. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29134. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29135. */
  29136. isBlocker: boolean;
  29137. /**
  29138. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29139. */
  29140. enablePointerMoveEvents: boolean;
  29141. /**
  29142. * Specifies the rendering group id for this mesh (0 by default)
  29143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29144. */
  29145. renderingGroupId: number;
  29146. private _material;
  29147. /** Gets or sets current material */
  29148. get material(): Nullable<Material>;
  29149. set material(value: Nullable<Material>);
  29150. /**
  29151. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29152. * @see http://doc.babylonjs.com/babylon101/shadows
  29153. */
  29154. get receiveShadows(): boolean;
  29155. set receiveShadows(value: boolean);
  29156. /** Defines color to use when rendering outline */
  29157. outlineColor: Color3;
  29158. /** Define width to use when rendering outline */
  29159. outlineWidth: number;
  29160. /** Defines color to use when rendering overlay */
  29161. overlayColor: Color3;
  29162. /** Defines alpha to use when rendering overlay */
  29163. overlayAlpha: number;
  29164. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29165. get hasVertexAlpha(): boolean;
  29166. set hasVertexAlpha(value: boolean);
  29167. /** 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) */
  29168. get useVertexColors(): boolean;
  29169. set useVertexColors(value: boolean);
  29170. /**
  29171. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29172. */
  29173. get computeBonesUsingShaders(): boolean;
  29174. set computeBonesUsingShaders(value: boolean);
  29175. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29176. get numBoneInfluencers(): number;
  29177. set numBoneInfluencers(value: number);
  29178. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29179. get applyFog(): boolean;
  29180. set applyFog(value: boolean);
  29181. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29182. useOctreeForRenderingSelection: boolean;
  29183. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29184. useOctreeForPicking: boolean;
  29185. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29186. useOctreeForCollisions: boolean;
  29187. /**
  29188. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29189. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29190. */
  29191. get layerMask(): number;
  29192. set layerMask(value: number);
  29193. /**
  29194. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29195. */
  29196. alwaysSelectAsActiveMesh: boolean;
  29197. /**
  29198. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29199. */
  29200. doNotSyncBoundingInfo: boolean;
  29201. /**
  29202. * Gets or sets the current action manager
  29203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29204. */
  29205. actionManager: Nullable<AbstractActionManager>;
  29206. private _meshCollisionData;
  29207. /**
  29208. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29210. */
  29211. ellipsoid: Vector3;
  29212. /**
  29213. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29215. */
  29216. ellipsoidOffset: Vector3;
  29217. /**
  29218. * Gets or sets a collision mask used to mask collisions (default is -1).
  29219. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29220. */
  29221. get collisionMask(): number;
  29222. set collisionMask(mask: number);
  29223. /**
  29224. * Gets or sets the current collision group mask (-1 by default).
  29225. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29226. */
  29227. get collisionGroup(): number;
  29228. set collisionGroup(mask: number);
  29229. /**
  29230. * Gets or sets current surrounding meshes (null by default).
  29231. *
  29232. * By default collision detection is tested against every mesh in the scene.
  29233. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29234. * meshes will be tested for the collision.
  29235. *
  29236. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29237. */
  29238. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29239. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29240. /**
  29241. * Defines edge width used when edgesRenderer is enabled
  29242. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29243. */
  29244. edgesWidth: number;
  29245. /**
  29246. * Defines edge color used when edgesRenderer is enabled
  29247. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29248. */
  29249. edgesColor: Color4;
  29250. /** @hidden */
  29251. _edgesRenderer: Nullable<IEdgesRenderer>;
  29252. /** @hidden */
  29253. _masterMesh: Nullable<AbstractMesh>;
  29254. /** @hidden */
  29255. _boundingInfo: Nullable<BoundingInfo>;
  29256. /** @hidden */
  29257. _renderId: number;
  29258. /**
  29259. * Gets or sets the list of subMeshes
  29260. * @see http://doc.babylonjs.com/how_to/multi_materials
  29261. */
  29262. subMeshes: SubMesh[];
  29263. /** @hidden */
  29264. _intersectionsInProgress: AbstractMesh[];
  29265. /** @hidden */
  29266. _unIndexed: boolean;
  29267. /** @hidden */
  29268. _lightSources: Light[];
  29269. /** Gets the list of lights affecting that mesh */
  29270. get lightSources(): Light[];
  29271. /** @hidden */
  29272. get _positions(): Nullable<Vector3[]>;
  29273. /** @hidden */
  29274. _waitingData: {
  29275. lods: Nullable<any>;
  29276. actions: Nullable<any>;
  29277. freezeWorldMatrix: Nullable<boolean>;
  29278. };
  29279. /** @hidden */
  29280. _bonesTransformMatrices: Nullable<Float32Array>;
  29281. /** @hidden */
  29282. _transformMatrixTexture: Nullable<RawTexture>;
  29283. /**
  29284. * Gets or sets a skeleton to apply skining transformations
  29285. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29286. */
  29287. set skeleton(value: Nullable<Skeleton>);
  29288. get skeleton(): Nullable<Skeleton>;
  29289. /**
  29290. * An event triggered when the mesh is rebuilt.
  29291. */
  29292. onRebuildObservable: Observable<AbstractMesh>;
  29293. /**
  29294. * Creates a new AbstractMesh
  29295. * @param name defines the name of the mesh
  29296. * @param scene defines the hosting scene
  29297. */
  29298. constructor(name: string, scene?: Nullable<Scene>);
  29299. /**
  29300. * Returns the string "AbstractMesh"
  29301. * @returns "AbstractMesh"
  29302. */
  29303. getClassName(): string;
  29304. /**
  29305. * Gets a string representation of the current mesh
  29306. * @param fullDetails defines a boolean indicating if full details must be included
  29307. * @returns a string representation of the current mesh
  29308. */
  29309. toString(fullDetails?: boolean): string;
  29310. /**
  29311. * @hidden
  29312. */
  29313. protected _getEffectiveParent(): Nullable<Node>;
  29314. /** @hidden */
  29315. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29316. /** @hidden */
  29317. _rebuild(): void;
  29318. /** @hidden */
  29319. _resyncLightSources(): void;
  29320. /** @hidden */
  29321. _resyncLightSource(light: Light): void;
  29322. /** @hidden */
  29323. _unBindEffect(): void;
  29324. /** @hidden */
  29325. _removeLightSource(light: Light, dispose: boolean): void;
  29326. private _markSubMeshesAsDirty;
  29327. /** @hidden */
  29328. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29329. /** @hidden */
  29330. _markSubMeshesAsAttributesDirty(): void;
  29331. /** @hidden */
  29332. _markSubMeshesAsMiscDirty(): void;
  29333. /**
  29334. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29335. */
  29336. get scaling(): Vector3;
  29337. set scaling(newScaling: Vector3);
  29338. /**
  29339. * Returns true if the mesh is blocked. Implemented by child classes
  29340. */
  29341. get isBlocked(): boolean;
  29342. /**
  29343. * Returns the mesh itself by default. Implemented by child classes
  29344. * @param camera defines the camera to use to pick the right LOD level
  29345. * @returns the currentAbstractMesh
  29346. */
  29347. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29348. /**
  29349. * Returns 0 by default. Implemented by child classes
  29350. * @returns an integer
  29351. */
  29352. getTotalVertices(): number;
  29353. /**
  29354. * Returns a positive integer : the total number of indices in this mesh geometry.
  29355. * @returns the numner of indices or zero if the mesh has no geometry.
  29356. */
  29357. getTotalIndices(): number;
  29358. /**
  29359. * Returns null by default. Implemented by child classes
  29360. * @returns null
  29361. */
  29362. getIndices(): Nullable<IndicesArray>;
  29363. /**
  29364. * Returns the array of the requested vertex data kind. Implemented by child classes
  29365. * @param kind defines the vertex data kind to use
  29366. * @returns null
  29367. */
  29368. getVerticesData(kind: string): Nullable<FloatArray>;
  29369. /**
  29370. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29371. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29372. * Note that a new underlying VertexBuffer object is created each call.
  29373. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29374. * @param kind defines vertex data kind:
  29375. * * VertexBuffer.PositionKind
  29376. * * VertexBuffer.UVKind
  29377. * * VertexBuffer.UV2Kind
  29378. * * VertexBuffer.UV3Kind
  29379. * * VertexBuffer.UV4Kind
  29380. * * VertexBuffer.UV5Kind
  29381. * * VertexBuffer.UV6Kind
  29382. * * VertexBuffer.ColorKind
  29383. * * VertexBuffer.MatricesIndicesKind
  29384. * * VertexBuffer.MatricesIndicesExtraKind
  29385. * * VertexBuffer.MatricesWeightsKind
  29386. * * VertexBuffer.MatricesWeightsExtraKind
  29387. * @param data defines the data source
  29388. * @param updatable defines if the data must be flagged as updatable (or static)
  29389. * @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
  29390. * @returns the current mesh
  29391. */
  29392. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29393. /**
  29394. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29395. * If the mesh has no geometry, it is simply returned as it is.
  29396. * @param kind defines vertex data kind:
  29397. * * VertexBuffer.PositionKind
  29398. * * VertexBuffer.UVKind
  29399. * * VertexBuffer.UV2Kind
  29400. * * VertexBuffer.UV3Kind
  29401. * * VertexBuffer.UV4Kind
  29402. * * VertexBuffer.UV5Kind
  29403. * * VertexBuffer.UV6Kind
  29404. * * VertexBuffer.ColorKind
  29405. * * VertexBuffer.MatricesIndicesKind
  29406. * * VertexBuffer.MatricesIndicesExtraKind
  29407. * * VertexBuffer.MatricesWeightsKind
  29408. * * VertexBuffer.MatricesWeightsExtraKind
  29409. * @param data defines the data source
  29410. * @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
  29411. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29412. * @returns the current mesh
  29413. */
  29414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29415. /**
  29416. * Sets the mesh indices,
  29417. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29418. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29419. * @param totalVertices Defines the total number of vertices
  29420. * @returns the current mesh
  29421. */
  29422. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29423. /**
  29424. * Gets a boolean indicating if specific vertex data is present
  29425. * @param kind defines the vertex data kind to use
  29426. * @returns true is data kind is present
  29427. */
  29428. isVerticesDataPresent(kind: string): boolean;
  29429. /**
  29430. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29431. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29432. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29433. * @returns a BoundingInfo
  29434. */
  29435. getBoundingInfo(): BoundingInfo;
  29436. /**
  29437. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29438. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29439. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29440. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29441. * @returns the current mesh
  29442. */
  29443. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29444. /**
  29445. * Overwrite the current bounding info
  29446. * @param boundingInfo defines the new bounding info
  29447. * @returns the current mesh
  29448. */
  29449. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29450. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29451. get useBones(): boolean;
  29452. /** @hidden */
  29453. _preActivate(): void;
  29454. /** @hidden */
  29455. _preActivateForIntermediateRendering(renderId: number): void;
  29456. /** @hidden */
  29457. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29458. /** @hidden */
  29459. _postActivate(): void;
  29460. /** @hidden */
  29461. _freeze(): void;
  29462. /** @hidden */
  29463. _unFreeze(): void;
  29464. /**
  29465. * Gets the current world matrix
  29466. * @returns a Matrix
  29467. */
  29468. getWorldMatrix(): Matrix;
  29469. /** @hidden */
  29470. _getWorldMatrixDeterminant(): number;
  29471. /**
  29472. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29473. */
  29474. get isAnInstance(): boolean;
  29475. /**
  29476. * Gets a boolean indicating if this mesh has instances
  29477. */
  29478. get hasInstances(): boolean;
  29479. /**
  29480. * Perform relative position change from the point of view of behind the front of the mesh.
  29481. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29482. * Supports definition of mesh facing forward or backward
  29483. * @param amountRight defines the distance on the right axis
  29484. * @param amountUp defines the distance on the up axis
  29485. * @param amountForward defines the distance on the forward axis
  29486. * @returns the current mesh
  29487. */
  29488. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29489. /**
  29490. * Calculate relative position change from the point of view of behind the front of the mesh.
  29491. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29492. * Supports definition of mesh facing forward or backward
  29493. * @param amountRight defines the distance on the right axis
  29494. * @param amountUp defines the distance on the up axis
  29495. * @param amountForward defines the distance on the forward axis
  29496. * @returns the new displacement vector
  29497. */
  29498. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29499. /**
  29500. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29501. * Supports definition of mesh facing forward or backward
  29502. * @param flipBack defines the flip
  29503. * @param twirlClockwise defines the twirl
  29504. * @param tiltRight defines the tilt
  29505. * @returns the current mesh
  29506. */
  29507. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29508. /**
  29509. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29510. * Supports definition of mesh facing forward or backward.
  29511. * @param flipBack defines the flip
  29512. * @param twirlClockwise defines the twirl
  29513. * @param tiltRight defines the tilt
  29514. * @returns the new rotation vector
  29515. */
  29516. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29517. /**
  29518. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29519. * This means the mesh underlying bounding box and sphere are recomputed.
  29520. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29521. * @returns the current mesh
  29522. */
  29523. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29524. /** @hidden */
  29525. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29526. /** @hidden */
  29527. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29528. /** @hidden */
  29529. _updateBoundingInfo(): AbstractMesh;
  29530. /** @hidden */
  29531. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29532. /** @hidden */
  29533. protected _afterComputeWorldMatrix(): void;
  29534. /** @hidden */
  29535. get _effectiveMesh(): AbstractMesh;
  29536. /**
  29537. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29538. * A mesh is in the frustum if its bounding box intersects the frustum
  29539. * @param frustumPlanes defines the frustum to test
  29540. * @returns true if the mesh is in the frustum planes
  29541. */
  29542. isInFrustum(frustumPlanes: Plane[]): boolean;
  29543. /**
  29544. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29545. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29546. * @param frustumPlanes defines the frustum to test
  29547. * @returns true if the mesh is completely in the frustum planes
  29548. */
  29549. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29550. /**
  29551. * True if the mesh intersects another mesh or a SolidParticle object
  29552. * @param mesh defines a target mesh or SolidParticle to test
  29553. * @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)
  29554. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29555. * @returns true if there is an intersection
  29556. */
  29557. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29558. /**
  29559. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29560. * @param point defines the point to test
  29561. * @returns true if there is an intersection
  29562. */
  29563. intersectsPoint(point: Vector3): boolean;
  29564. /**
  29565. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29567. */
  29568. get checkCollisions(): boolean;
  29569. set checkCollisions(collisionEnabled: boolean);
  29570. /**
  29571. * Gets Collider object used to compute collisions (not physics)
  29572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29573. */
  29574. get collider(): Nullable<Collider>;
  29575. /**
  29576. * Move the mesh using collision engine
  29577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29578. * @param displacement defines the requested displacement vector
  29579. * @returns the current mesh
  29580. */
  29581. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29582. private _onCollisionPositionChange;
  29583. /** @hidden */
  29584. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29585. /** @hidden */
  29586. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29587. /** @hidden */
  29588. _checkCollision(collider: Collider): AbstractMesh;
  29589. /** @hidden */
  29590. _generatePointsArray(): boolean;
  29591. /**
  29592. * Checks if the passed Ray intersects with the mesh
  29593. * @param ray defines the ray to use
  29594. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29596. * @returns the picking info
  29597. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29598. */
  29599. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29600. /**
  29601. * Clones the current mesh
  29602. * @param name defines the mesh name
  29603. * @param newParent defines the new mesh parent
  29604. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29605. * @returns the new mesh
  29606. */
  29607. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29608. /**
  29609. * Disposes all the submeshes of the current meshnp
  29610. * @returns the current mesh
  29611. */
  29612. releaseSubMeshes(): AbstractMesh;
  29613. /**
  29614. * Releases resources associated with this abstract mesh.
  29615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29617. */
  29618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29619. /**
  29620. * Adds the passed mesh as a child to the current mesh
  29621. * @param mesh defines the child mesh
  29622. * @returns the current mesh
  29623. */
  29624. addChild(mesh: AbstractMesh): AbstractMesh;
  29625. /**
  29626. * Removes the passed mesh from the current mesh children list
  29627. * @param mesh defines the child mesh
  29628. * @returns the current mesh
  29629. */
  29630. removeChild(mesh: AbstractMesh): AbstractMesh;
  29631. /** @hidden */
  29632. private _initFacetData;
  29633. /**
  29634. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29635. * This method can be called within the render loop.
  29636. * 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
  29637. * @returns the current mesh
  29638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29639. */
  29640. updateFacetData(): AbstractMesh;
  29641. /**
  29642. * Returns the facetLocalNormals array.
  29643. * The normals are expressed in the mesh local spac
  29644. * @returns an array of Vector3
  29645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29646. */
  29647. getFacetLocalNormals(): Vector3[];
  29648. /**
  29649. * Returns the facetLocalPositions array.
  29650. * The facet positions are expressed in the mesh local space
  29651. * @returns an array of Vector3
  29652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29653. */
  29654. getFacetLocalPositions(): Vector3[];
  29655. /**
  29656. * Returns the facetLocalPartioning array
  29657. * @returns an array of array of numbers
  29658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29659. */
  29660. getFacetLocalPartitioning(): number[][];
  29661. /**
  29662. * Returns the i-th facet position in the world system.
  29663. * This method allocates a new Vector3 per call
  29664. * @param i defines the facet index
  29665. * @returns a new Vector3
  29666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29667. */
  29668. getFacetPosition(i: number): Vector3;
  29669. /**
  29670. * Sets the reference Vector3 with the i-th facet position in the world system
  29671. * @param i defines the facet index
  29672. * @param ref defines the target vector
  29673. * @returns the current mesh
  29674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29675. */
  29676. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29677. /**
  29678. * Returns the i-th facet normal 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. getFacetNormal(i: number): Vector3;
  29685. /**
  29686. * Sets the reference Vector3 with the i-th facet normal 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. getFacetNormalToRef(i: number, ref: Vector3): this;
  29693. /**
  29694. * 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)
  29695. * @param x defines x coordinate
  29696. * @param y defines y coordinate
  29697. * @param z defines z coordinate
  29698. * @returns the array of facet indexes
  29699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29700. */
  29701. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29702. /**
  29703. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29704. * @param projected sets as the (x,y,z) world projection on the facet
  29705. * @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
  29706. * @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
  29707. * @param x defines x coordinate
  29708. * @param y defines y coordinate
  29709. * @param z defines z coordinate
  29710. * @returns the face index if found (or null instead)
  29711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29712. */
  29713. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29714. /**
  29715. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29716. * @param projected sets as the (x,y,z) local projection on the facet
  29717. * @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
  29718. * @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
  29719. * @param x defines x coordinate
  29720. * @param y defines y coordinate
  29721. * @param z defines z coordinate
  29722. * @returns the face index if found (or null instead)
  29723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29724. */
  29725. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29726. /**
  29727. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29728. * @returns the parameters
  29729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29730. */
  29731. getFacetDataParameters(): any;
  29732. /**
  29733. * Disables the feature FacetData and frees the related memory
  29734. * @returns the current mesh
  29735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29736. */
  29737. disableFacetData(): AbstractMesh;
  29738. /**
  29739. * Updates the AbstractMesh indices array
  29740. * @param indices defines the data source
  29741. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29742. * @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)
  29743. * @returns the current mesh
  29744. */
  29745. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29746. /**
  29747. * Creates new normals data for the mesh
  29748. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29749. * @returns the current mesh
  29750. */
  29751. createNormals(updatable: boolean): AbstractMesh;
  29752. /**
  29753. * Align the mesh with a normal
  29754. * @param normal defines the normal to use
  29755. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29756. * @returns the current mesh
  29757. */
  29758. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29759. /** @hidden */
  29760. _checkOcclusionQuery(): boolean;
  29761. /**
  29762. * Disables the mesh edge rendering mode
  29763. * @returns the currentAbstractMesh
  29764. */
  29765. disableEdgesRendering(): AbstractMesh;
  29766. /**
  29767. * Enables the edge rendering mode on the mesh.
  29768. * This mode makes the mesh edges visible
  29769. * @param epsilon defines the maximal distance between two angles to detect a face
  29770. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29771. * @returns the currentAbstractMesh
  29772. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29773. */
  29774. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29775. }
  29776. }
  29777. declare module "babylonjs/Actions/actionEvent" {
  29778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29779. import { Nullable } from "babylonjs/types";
  29780. import { Sprite } from "babylonjs/Sprites/sprite";
  29781. import { Scene } from "babylonjs/scene";
  29782. import { Vector2 } from "babylonjs/Maths/math.vector";
  29783. /**
  29784. * Interface used to define ActionEvent
  29785. */
  29786. export interface IActionEvent {
  29787. /** The mesh or sprite that triggered the action */
  29788. source: any;
  29789. /** The X mouse cursor position at the time of the event */
  29790. pointerX: number;
  29791. /** The Y mouse cursor position at the time of the event */
  29792. pointerY: number;
  29793. /** The mesh that is currently pointed at (can be null) */
  29794. meshUnderPointer: Nullable<AbstractMesh>;
  29795. /** the original (browser) event that triggered the ActionEvent */
  29796. sourceEvent?: any;
  29797. /** additional data for the event */
  29798. additionalData?: any;
  29799. }
  29800. /**
  29801. * ActionEvent is the event being sent when an action is triggered.
  29802. */
  29803. export class ActionEvent implements IActionEvent {
  29804. /** The mesh or sprite that triggered the action */
  29805. source: any;
  29806. /** The X mouse cursor position at the time of the event */
  29807. pointerX: number;
  29808. /** The Y mouse cursor position at the time of the event */
  29809. pointerY: number;
  29810. /** The mesh that is currently pointed at (can be null) */
  29811. meshUnderPointer: Nullable<AbstractMesh>;
  29812. /** the original (browser) event that triggered the ActionEvent */
  29813. sourceEvent?: any;
  29814. /** additional data for the event */
  29815. additionalData?: any;
  29816. /**
  29817. * Creates a new ActionEvent
  29818. * @param source The mesh or sprite that triggered the action
  29819. * @param pointerX The X mouse cursor position at the time of the event
  29820. * @param pointerY The Y mouse cursor position at the time of the event
  29821. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29822. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29823. * @param additionalData additional data for the event
  29824. */
  29825. constructor(
  29826. /** The mesh or sprite that triggered the action */
  29827. source: any,
  29828. /** The X mouse cursor position at the time of the event */
  29829. pointerX: number,
  29830. /** The Y mouse cursor position at the time of the event */
  29831. pointerY: number,
  29832. /** The mesh that is currently pointed at (can be null) */
  29833. meshUnderPointer: Nullable<AbstractMesh>,
  29834. /** the original (browser) event that triggered the ActionEvent */
  29835. sourceEvent?: any,
  29836. /** additional data for the event */
  29837. additionalData?: any);
  29838. /**
  29839. * Helper function to auto-create an ActionEvent from a source mesh.
  29840. * @param source The source mesh that triggered the event
  29841. * @param evt The original (browser) event
  29842. * @param additionalData additional data for the event
  29843. * @returns the new ActionEvent
  29844. */
  29845. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29846. /**
  29847. * Helper function to auto-create an ActionEvent from a source sprite
  29848. * @param source The source sprite that triggered the event
  29849. * @param scene Scene associated with the sprite
  29850. * @param evt The original (browser) event
  29851. * @param additionalData additional data for the event
  29852. * @returns the new ActionEvent
  29853. */
  29854. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29855. /**
  29856. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29857. * @param scene the scene where the event occurred
  29858. * @param evt The original (browser) event
  29859. * @returns the new ActionEvent
  29860. */
  29861. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29862. /**
  29863. * Helper function to auto-create an ActionEvent from a primitive
  29864. * @param prim defines the target primitive
  29865. * @param pointerPos defines the pointer position
  29866. * @param evt The original (browser) event
  29867. * @param additionalData additional data for the event
  29868. * @returns the new ActionEvent
  29869. */
  29870. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29871. }
  29872. }
  29873. declare module "babylonjs/Actions/abstractActionManager" {
  29874. import { IDisposable } from "babylonjs/scene";
  29875. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29876. import { IAction } from "babylonjs/Actions/action";
  29877. import { Nullable } from "babylonjs/types";
  29878. /**
  29879. * Abstract class used to decouple action Manager from scene and meshes.
  29880. * Do not instantiate.
  29881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29882. */
  29883. export abstract class AbstractActionManager implements IDisposable {
  29884. /** Gets the list of active triggers */
  29885. static Triggers: {
  29886. [key: string]: number;
  29887. };
  29888. /** Gets the cursor to use when hovering items */
  29889. hoverCursor: string;
  29890. /** Gets the list of actions */
  29891. actions: IAction[];
  29892. /**
  29893. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29894. */
  29895. isRecursive: boolean;
  29896. /**
  29897. * Releases all associated resources
  29898. */
  29899. abstract dispose(): void;
  29900. /**
  29901. * Does this action manager has pointer triggers
  29902. */
  29903. abstract get hasPointerTriggers(): boolean;
  29904. /**
  29905. * Does this action manager has pick triggers
  29906. */
  29907. abstract get hasPickTriggers(): boolean;
  29908. /**
  29909. * Process a specific trigger
  29910. * @param trigger defines the trigger to process
  29911. * @param evt defines the event details to be processed
  29912. */
  29913. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29914. /**
  29915. * Does this action manager handles actions of any of the given triggers
  29916. * @param triggers defines the triggers to be tested
  29917. * @return a boolean indicating whether one (or more) of the triggers is handled
  29918. */
  29919. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29920. /**
  29921. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29922. * speed.
  29923. * @param triggerA defines the trigger to be tested
  29924. * @param triggerB defines the trigger to be tested
  29925. * @return a boolean indicating whether one (or more) of the triggers is handled
  29926. */
  29927. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29928. /**
  29929. * Does this action manager handles actions of a given trigger
  29930. * @param trigger defines the trigger to be tested
  29931. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29932. * @return whether the trigger is handled
  29933. */
  29934. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29935. /**
  29936. * Serialize this manager to a JSON object
  29937. * @param name defines the property name to store this manager
  29938. * @returns a JSON representation of this manager
  29939. */
  29940. abstract serialize(name: string): any;
  29941. /**
  29942. * Registers an action to this action manager
  29943. * @param action defines the action to be registered
  29944. * @return the action amended (prepared) after registration
  29945. */
  29946. abstract registerAction(action: IAction): Nullable<IAction>;
  29947. /**
  29948. * Unregisters an action to this action manager
  29949. * @param action defines the action to be unregistered
  29950. * @return a boolean indicating whether the action has been unregistered
  29951. */
  29952. abstract unregisterAction(action: IAction): Boolean;
  29953. /**
  29954. * Does exist one action manager with at least one trigger
  29955. **/
  29956. static get HasTriggers(): boolean;
  29957. /**
  29958. * Does exist one action manager with at least one pick trigger
  29959. **/
  29960. static get HasPickTriggers(): boolean;
  29961. /**
  29962. * Does exist one action manager that handles actions of a given trigger
  29963. * @param trigger defines the trigger to be tested
  29964. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29965. **/
  29966. static HasSpecificTrigger(trigger: number): boolean;
  29967. }
  29968. }
  29969. declare module "babylonjs/node" {
  29970. import { Scene } from "babylonjs/scene";
  29971. import { Nullable } from "babylonjs/types";
  29972. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29973. import { Engine } from "babylonjs/Engines/engine";
  29974. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29975. import { Observable } from "babylonjs/Misc/observable";
  29976. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29977. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29978. import { Animatable } from "babylonjs/Animations/animatable";
  29979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29980. import { Animation } from "babylonjs/Animations/animation";
  29981. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29983. /**
  29984. * Defines how a node can be built from a string name.
  29985. */
  29986. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29987. /**
  29988. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29989. */
  29990. export class Node implements IBehaviorAware<Node> {
  29991. /** @hidden */
  29992. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29993. private static _NodeConstructors;
  29994. /**
  29995. * Add a new node constructor
  29996. * @param type defines the type name of the node to construct
  29997. * @param constructorFunc defines the constructor function
  29998. */
  29999. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30000. /**
  30001. * Returns a node constructor based on type name
  30002. * @param type defines the type name
  30003. * @param name defines the new node name
  30004. * @param scene defines the hosting scene
  30005. * @param options defines optional options to transmit to constructors
  30006. * @returns the new constructor or null
  30007. */
  30008. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30009. /**
  30010. * Gets or sets the name of the node
  30011. */
  30012. name: string;
  30013. /**
  30014. * Gets or sets the id of the node
  30015. */
  30016. id: string;
  30017. /**
  30018. * Gets or sets the unique id of the node
  30019. */
  30020. uniqueId: number;
  30021. /**
  30022. * Gets or sets a string used to store user defined state for the node
  30023. */
  30024. state: string;
  30025. /**
  30026. * Gets or sets an object used to store user defined information for the node
  30027. */
  30028. metadata: any;
  30029. /**
  30030. * For internal use only. Please do not use.
  30031. */
  30032. reservedDataStore: any;
  30033. /**
  30034. * List of inspectable custom properties (used by the Inspector)
  30035. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30036. */
  30037. inspectableCustomProperties: IInspectable[];
  30038. private _doNotSerialize;
  30039. /**
  30040. * Gets or sets a boolean used to define if the node must be serialized
  30041. */
  30042. get doNotSerialize(): boolean;
  30043. set doNotSerialize(value: boolean);
  30044. /** @hidden */
  30045. _isDisposed: boolean;
  30046. /**
  30047. * Gets a list of Animations associated with the node
  30048. */
  30049. animations: import("babylonjs/Animations/animation").Animation[];
  30050. protected _ranges: {
  30051. [name: string]: Nullable<AnimationRange>;
  30052. };
  30053. /**
  30054. * Callback raised when the node is ready to be used
  30055. */
  30056. onReady: Nullable<(node: Node) => void>;
  30057. private _isEnabled;
  30058. private _isParentEnabled;
  30059. private _isReady;
  30060. /** @hidden */
  30061. _currentRenderId: number;
  30062. private _parentUpdateId;
  30063. /** @hidden */
  30064. _childUpdateId: number;
  30065. /** @hidden */
  30066. _waitingParentId: Nullable<string>;
  30067. /** @hidden */
  30068. _scene: Scene;
  30069. /** @hidden */
  30070. _cache: any;
  30071. private _parentNode;
  30072. private _children;
  30073. /** @hidden */
  30074. _worldMatrix: Matrix;
  30075. /** @hidden */
  30076. _worldMatrixDeterminant: number;
  30077. /** @hidden */
  30078. _worldMatrixDeterminantIsDirty: boolean;
  30079. /** @hidden */
  30080. private _sceneRootNodesIndex;
  30081. /**
  30082. * Gets a boolean indicating if the node has been disposed
  30083. * @returns true if the node was disposed
  30084. */
  30085. isDisposed(): boolean;
  30086. /**
  30087. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30088. * @see https://doc.babylonjs.com/how_to/parenting
  30089. */
  30090. set parent(parent: Nullable<Node>);
  30091. get parent(): Nullable<Node>;
  30092. /** @hidden */
  30093. _addToSceneRootNodes(): void;
  30094. /** @hidden */
  30095. _removeFromSceneRootNodes(): void;
  30096. private _animationPropertiesOverride;
  30097. /**
  30098. * Gets or sets the animation properties override
  30099. */
  30100. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30101. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30102. /**
  30103. * Gets a string idenfifying the name of the class
  30104. * @returns "Node" string
  30105. */
  30106. getClassName(): string;
  30107. /** @hidden */
  30108. readonly _isNode: boolean;
  30109. /**
  30110. * An event triggered when the mesh is disposed
  30111. */
  30112. onDisposeObservable: Observable<Node>;
  30113. private _onDisposeObserver;
  30114. /**
  30115. * Sets a callback that will be raised when the node will be disposed
  30116. */
  30117. set onDispose(callback: () => void);
  30118. /**
  30119. * Creates a new Node
  30120. * @param name the name and id to be given to this node
  30121. * @param scene the scene this node will be added to
  30122. */
  30123. constructor(name: string, scene?: Nullable<Scene>);
  30124. /**
  30125. * Gets the scene of the node
  30126. * @returns a scene
  30127. */
  30128. getScene(): Scene;
  30129. /**
  30130. * Gets the engine of the node
  30131. * @returns a Engine
  30132. */
  30133. getEngine(): Engine;
  30134. private _behaviors;
  30135. /**
  30136. * Attach a behavior to the node
  30137. * @see http://doc.babylonjs.com/features/behaviour
  30138. * @param behavior defines the behavior to attach
  30139. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30140. * @returns the current Node
  30141. */
  30142. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30143. /**
  30144. * Remove an attached behavior
  30145. * @see http://doc.babylonjs.com/features/behaviour
  30146. * @param behavior defines the behavior to attach
  30147. * @returns the current Node
  30148. */
  30149. removeBehavior(behavior: Behavior<Node>): Node;
  30150. /**
  30151. * Gets the list of attached behaviors
  30152. * @see http://doc.babylonjs.com/features/behaviour
  30153. */
  30154. get behaviors(): Behavior<Node>[];
  30155. /**
  30156. * Gets an attached behavior by name
  30157. * @param name defines the name of the behavior to look for
  30158. * @see http://doc.babylonjs.com/features/behaviour
  30159. * @returns null if behavior was not found else the requested behavior
  30160. */
  30161. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30162. /**
  30163. * Returns the latest update of the World matrix
  30164. * @returns a Matrix
  30165. */
  30166. getWorldMatrix(): Matrix;
  30167. /** @hidden */
  30168. _getWorldMatrixDeterminant(): number;
  30169. /**
  30170. * Returns directly the latest state of the mesh World matrix.
  30171. * A Matrix is returned.
  30172. */
  30173. get worldMatrixFromCache(): Matrix;
  30174. /** @hidden */
  30175. _initCache(): void;
  30176. /** @hidden */
  30177. updateCache(force?: boolean): void;
  30178. /** @hidden */
  30179. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30180. /** @hidden */
  30181. _updateCache(ignoreParentClass?: boolean): void;
  30182. /** @hidden */
  30183. _isSynchronized(): boolean;
  30184. /** @hidden */
  30185. _markSyncedWithParent(): void;
  30186. /** @hidden */
  30187. isSynchronizedWithParent(): boolean;
  30188. /** @hidden */
  30189. isSynchronized(): boolean;
  30190. /**
  30191. * Is this node ready to be used/rendered
  30192. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30193. * @return true if the node is ready
  30194. */
  30195. isReady(completeCheck?: boolean): boolean;
  30196. /**
  30197. * Is this node enabled?
  30198. * 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
  30199. * @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
  30200. * @return whether this node (and its parent) is enabled
  30201. */
  30202. isEnabled(checkAncestors?: boolean): boolean;
  30203. /** @hidden */
  30204. protected _syncParentEnabledState(): void;
  30205. /**
  30206. * Set the enabled state of this node
  30207. * @param value defines the new enabled state
  30208. */
  30209. setEnabled(value: boolean): void;
  30210. /**
  30211. * Is this node a descendant of the given node?
  30212. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30213. * @param ancestor defines the parent node to inspect
  30214. * @returns a boolean indicating if this node is a descendant of the given node
  30215. */
  30216. isDescendantOf(ancestor: Node): boolean;
  30217. /** @hidden */
  30218. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30219. /**
  30220. * Will return all nodes that have this node as ascendant
  30221. * @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
  30222. * @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
  30223. * @return all children nodes of all types
  30224. */
  30225. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30226. /**
  30227. * Get all child-meshes of this node
  30228. * @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)
  30229. * @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
  30230. * @returns an array of AbstractMesh
  30231. */
  30232. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30233. /**
  30234. * Get all direct children of this node
  30235. * @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
  30236. * @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)
  30237. * @returns an array of Node
  30238. */
  30239. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30240. /** @hidden */
  30241. _setReady(state: boolean): void;
  30242. /**
  30243. * Get an animation by name
  30244. * @param name defines the name of the animation to look for
  30245. * @returns null if not found else the requested animation
  30246. */
  30247. getAnimationByName(name: string): Nullable<Animation>;
  30248. /**
  30249. * Creates an animation range for this node
  30250. * @param name defines the name of the range
  30251. * @param from defines the starting key
  30252. * @param to defines the end key
  30253. */
  30254. createAnimationRange(name: string, from: number, to: number): void;
  30255. /**
  30256. * Delete a specific animation range
  30257. * @param name defines the name of the range to delete
  30258. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30259. */
  30260. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30261. /**
  30262. * Get an animation range by name
  30263. * @param name defines the name of the animation range to look for
  30264. * @returns null if not found else the requested animation range
  30265. */
  30266. getAnimationRange(name: string): Nullable<AnimationRange>;
  30267. /**
  30268. * Gets the list of all animation ranges defined on this node
  30269. * @returns an array
  30270. */
  30271. getAnimationRanges(): Nullable<AnimationRange>[];
  30272. /**
  30273. * Will start the animation sequence
  30274. * @param name defines the range frames for animation sequence
  30275. * @param loop defines if the animation should loop (false by default)
  30276. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30277. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30278. * @returns the object created for this animation. If range does not exist, it will return null
  30279. */
  30280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30281. /**
  30282. * Serialize animation ranges into a JSON compatible object
  30283. * @returns serialization object
  30284. */
  30285. serializeAnimationRanges(): any;
  30286. /**
  30287. * Computes the world matrix of the node
  30288. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30289. * @returns the world matrix
  30290. */
  30291. computeWorldMatrix(force?: boolean): Matrix;
  30292. /**
  30293. * Releases resources associated with this node.
  30294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30296. */
  30297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30298. /**
  30299. * Parse animation range data from a serialization object and store them into a given node
  30300. * @param node defines where to store the animation ranges
  30301. * @param parsedNode defines the serialization object to read data from
  30302. * @param scene defines the hosting scene
  30303. */
  30304. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30305. /**
  30306. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30307. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30308. * @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
  30309. * @returns the new bounding vectors
  30310. */
  30311. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30312. min: Vector3;
  30313. max: Vector3;
  30314. };
  30315. }
  30316. }
  30317. declare module "babylonjs/Animations/animation" {
  30318. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30319. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30320. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30321. import { Nullable } from "babylonjs/types";
  30322. import { Scene } from "babylonjs/scene";
  30323. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30324. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30325. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30326. import { Node } from "babylonjs/node";
  30327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30328. import { Size } from "babylonjs/Maths/math.size";
  30329. import { Animatable } from "babylonjs/Animations/animatable";
  30330. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30331. /**
  30332. * @hidden
  30333. */
  30334. export class _IAnimationState {
  30335. key: number;
  30336. repeatCount: number;
  30337. workValue?: any;
  30338. loopMode?: number;
  30339. offsetValue?: any;
  30340. highLimitValue?: any;
  30341. }
  30342. /**
  30343. * Class used to store any kind of animation
  30344. */
  30345. export class Animation {
  30346. /**Name of the animation */
  30347. name: string;
  30348. /**Property to animate */
  30349. targetProperty: string;
  30350. /**The frames per second of the animation */
  30351. framePerSecond: number;
  30352. /**The data type of the animation */
  30353. dataType: number;
  30354. /**The loop mode of the animation */
  30355. loopMode?: number | undefined;
  30356. /**Specifies if blending should be enabled */
  30357. enableBlending?: boolean | undefined;
  30358. /**
  30359. * Use matrix interpolation instead of using direct key value when animating matrices
  30360. */
  30361. static AllowMatricesInterpolation: boolean;
  30362. /**
  30363. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30364. */
  30365. static AllowMatrixDecomposeForInterpolation: boolean;
  30366. /**
  30367. * Stores the key frames of the animation
  30368. */
  30369. private _keys;
  30370. /**
  30371. * Stores the easing function of the animation
  30372. */
  30373. private _easingFunction;
  30374. /**
  30375. * @hidden Internal use only
  30376. */
  30377. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30378. /**
  30379. * The set of event that will be linked to this animation
  30380. */
  30381. private _events;
  30382. /**
  30383. * Stores an array of target property paths
  30384. */
  30385. targetPropertyPath: string[];
  30386. /**
  30387. * Stores the blending speed of the animation
  30388. */
  30389. blendingSpeed: number;
  30390. /**
  30391. * Stores the animation ranges for the animation
  30392. */
  30393. private _ranges;
  30394. /**
  30395. * @hidden Internal use
  30396. */
  30397. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30398. /**
  30399. * Sets up an animation
  30400. * @param property The property to animate
  30401. * @param animationType The animation type to apply
  30402. * @param framePerSecond The frames per second of the animation
  30403. * @param easingFunction The easing function used in the animation
  30404. * @returns The created animation
  30405. */
  30406. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30407. /**
  30408. * Create and start an animation on a node
  30409. * @param name defines the name of the global animation that will be run on all nodes
  30410. * @param node defines the root node where the animation will take place
  30411. * @param targetProperty defines property to animate
  30412. * @param framePerSecond defines the number of frame per second yo use
  30413. * @param totalFrame defines the number of frames in total
  30414. * @param from defines the initial value
  30415. * @param to defines the final value
  30416. * @param loopMode defines which loop mode you want to use (off by default)
  30417. * @param easingFunction defines the easing function to use (linear by default)
  30418. * @param onAnimationEnd defines the callback to call when animation end
  30419. * @returns the animatable created for this animation
  30420. */
  30421. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30422. /**
  30423. * Create and start an animation on a node and its descendants
  30424. * @param name defines the name of the global animation that will be run on all nodes
  30425. * @param node defines the root node where the animation will take place
  30426. * @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
  30427. * @param targetProperty defines property to animate
  30428. * @param framePerSecond defines the number of frame per second to 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 an animation ends (will be called once per node)
  30435. * @returns the list of animatables created for all nodes
  30436. * @example https://www.babylonjs-playground.com/#MH0VLI
  30437. */
  30438. 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[]>;
  30439. /**
  30440. * Creates a new animation, merges it with the existing animations and starts it
  30441. * @param name Name of the animation
  30442. * @param node Node which contains the scene that begins the animations
  30443. * @param targetProperty Specifies which property to animate
  30444. * @param framePerSecond The frames per second of the animation
  30445. * @param totalFrame The total number of frames
  30446. * @param from The frame at the beginning of the animation
  30447. * @param to The frame at the end of the animation
  30448. * @param loopMode Specifies the loop mode of the animation
  30449. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30450. * @param onAnimationEnd Callback to run once the animation is complete
  30451. * @returns Nullable animation
  30452. */
  30453. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30454. /**
  30455. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30456. * @param sourceAnimation defines the Animation containing keyframes to convert
  30457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30458. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30459. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30460. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30461. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30462. */
  30463. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30464. /**
  30465. * Transition property of an host to the target Value
  30466. * @param property The property to transition
  30467. * @param targetValue The target Value of the property
  30468. * @param host The object where the property to animate belongs
  30469. * @param scene Scene used to run the animation
  30470. * @param frameRate Framerate (in frame/s) to use
  30471. * @param transition The transition type we want to use
  30472. * @param duration The duration of the animation, in milliseconds
  30473. * @param onAnimationEnd Callback trigger at the end of the animation
  30474. * @returns Nullable animation
  30475. */
  30476. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30477. /**
  30478. * Return the array of runtime animations currently using this animation
  30479. */
  30480. get runtimeAnimations(): RuntimeAnimation[];
  30481. /**
  30482. * Specifies if any of the runtime animations are currently running
  30483. */
  30484. get hasRunningRuntimeAnimations(): boolean;
  30485. /**
  30486. * Initializes the animation
  30487. * @param name Name of the animation
  30488. * @param targetProperty Property to animate
  30489. * @param framePerSecond The frames per second of the animation
  30490. * @param dataType The data type of the animation
  30491. * @param loopMode The loop mode of the animation
  30492. * @param enableBlending Specifies if blending should be enabled
  30493. */
  30494. constructor(
  30495. /**Name of the animation */
  30496. name: string,
  30497. /**Property to animate */
  30498. targetProperty: string,
  30499. /**The frames per second of the animation */
  30500. framePerSecond: number,
  30501. /**The data type of the animation */
  30502. dataType: number,
  30503. /**The loop mode of the animation */
  30504. loopMode?: number | undefined,
  30505. /**Specifies if blending should be enabled */
  30506. enableBlending?: boolean | undefined);
  30507. /**
  30508. * Converts the animation to a string
  30509. * @param fullDetails support for multiple levels of logging within scene loading
  30510. * @returns String form of the animation
  30511. */
  30512. toString(fullDetails?: boolean): string;
  30513. /**
  30514. * Add an event to this animation
  30515. * @param event Event to add
  30516. */
  30517. addEvent(event: AnimationEvent): void;
  30518. /**
  30519. * Remove all events found at the given frame
  30520. * @param frame The frame to remove events from
  30521. */
  30522. removeEvents(frame: number): void;
  30523. /**
  30524. * Retrieves all the events from the animation
  30525. * @returns Events from the animation
  30526. */
  30527. getEvents(): AnimationEvent[];
  30528. /**
  30529. * Creates an animation range
  30530. * @param name Name of the animation range
  30531. * @param from Starting frame of the animation range
  30532. * @param to Ending frame of the animation
  30533. */
  30534. createRange(name: string, from: number, to: number): void;
  30535. /**
  30536. * Deletes an animation range by name
  30537. * @param name Name of the animation range to delete
  30538. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30539. */
  30540. deleteRange(name: string, deleteFrames?: boolean): void;
  30541. /**
  30542. * Gets the animation range by name, or null if not defined
  30543. * @param name Name of the animation range
  30544. * @returns Nullable animation range
  30545. */
  30546. getRange(name: string): Nullable<AnimationRange>;
  30547. /**
  30548. * Gets the key frames from the animation
  30549. * @returns The key frames of the animation
  30550. */
  30551. getKeys(): Array<IAnimationKey>;
  30552. /**
  30553. * Gets the highest frame rate of the animation
  30554. * @returns Highest frame rate of the animation
  30555. */
  30556. getHighestFrame(): number;
  30557. /**
  30558. * Gets the easing function of the animation
  30559. * @returns Easing function of the animation
  30560. */
  30561. getEasingFunction(): IEasingFunction;
  30562. /**
  30563. * Sets the easing function of the animation
  30564. * @param easingFunction A custom mathematical formula for animation
  30565. */
  30566. setEasingFunction(easingFunction: EasingFunction): void;
  30567. /**
  30568. * Interpolates a scalar linearly
  30569. * @param startValue Start value of the animation curve
  30570. * @param endValue End value of the animation curve
  30571. * @param gradient Scalar amount to interpolate
  30572. * @returns Interpolated scalar value
  30573. */
  30574. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30575. /**
  30576. * Interpolates a scalar cubically
  30577. * @param startValue Start value of the animation curve
  30578. * @param outTangent End tangent of the animation
  30579. * @param endValue End value of the animation curve
  30580. * @param inTangent Start tangent of the animation curve
  30581. * @param gradient Scalar amount to interpolate
  30582. * @returns Interpolated scalar value
  30583. */
  30584. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30585. /**
  30586. * Interpolates a quaternion using a spherical linear interpolation
  30587. * @param startValue Start value of the animation curve
  30588. * @param endValue End value of the animation curve
  30589. * @param gradient Scalar amount to interpolate
  30590. * @returns Interpolated quaternion value
  30591. */
  30592. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30593. /**
  30594. * Interpolates a quaternion cubically
  30595. * @param startValue Start value of the animation curve
  30596. * @param outTangent End tangent of the animation curve
  30597. * @param endValue End value of the animation curve
  30598. * @param inTangent Start tangent of the animation curve
  30599. * @param gradient Scalar amount to interpolate
  30600. * @returns Interpolated quaternion value
  30601. */
  30602. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30603. /**
  30604. * Interpolates a Vector3 linearl
  30605. * @param startValue Start value of the animation curve
  30606. * @param endValue End value of the animation curve
  30607. * @param gradient Scalar amount to interpolate
  30608. * @returns Interpolated scalar value
  30609. */
  30610. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30611. /**
  30612. * Interpolates a Vector3 cubically
  30613. * @param startValue Start value of the animation curve
  30614. * @param outTangent End tangent of the animation
  30615. * @param endValue End value of the animation curve
  30616. * @param inTangent Start tangent of the animation curve
  30617. * @param gradient Scalar amount to interpolate
  30618. * @returns InterpolatedVector3 value
  30619. */
  30620. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30621. /**
  30622. * Interpolates a Vector2 linearly
  30623. * @param startValue Start value of the animation curve
  30624. * @param endValue End value of the animation curve
  30625. * @param gradient Scalar amount to interpolate
  30626. * @returns Interpolated Vector2 value
  30627. */
  30628. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30629. /**
  30630. * Interpolates a Vector2 cubically
  30631. * @param startValue Start value of the animation curve
  30632. * @param outTangent End tangent of the animation
  30633. * @param endValue End value of the animation curve
  30634. * @param inTangent Start tangent of the animation curve
  30635. * @param gradient Scalar amount to interpolate
  30636. * @returns Interpolated Vector2 value
  30637. */
  30638. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30639. /**
  30640. * Interpolates a size linearly
  30641. * @param startValue Start value of the animation curve
  30642. * @param endValue End value of the animation curve
  30643. * @param gradient Scalar amount to interpolate
  30644. * @returns Interpolated Size value
  30645. */
  30646. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30647. /**
  30648. * Interpolates a Color3 linearly
  30649. * @param startValue Start value of the animation curve
  30650. * @param endValue End value of the animation curve
  30651. * @param gradient Scalar amount to interpolate
  30652. * @returns Interpolated Color3 value
  30653. */
  30654. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30655. /**
  30656. * Interpolates a Color4 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 Color3 value
  30661. */
  30662. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30663. /**
  30664. * @hidden Internal use only
  30665. */
  30666. _getKeyValue(value: any): any;
  30667. /**
  30668. * @hidden Internal use only
  30669. */
  30670. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30671. /**
  30672. * Defines the function to use to interpolate matrices
  30673. * @param startValue defines the start matrix
  30674. * @param endValue defines the end matrix
  30675. * @param gradient defines the gradient between both matrices
  30676. * @param result defines an optional target matrix where to store the interpolation
  30677. * @returns the interpolated matrix
  30678. */
  30679. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30680. /**
  30681. * Makes a copy of the animation
  30682. * @returns Cloned animation
  30683. */
  30684. clone(): Animation;
  30685. /**
  30686. * Sets the key frames of the animation
  30687. * @param values The animation key frames to set
  30688. */
  30689. setKeys(values: Array<IAnimationKey>): void;
  30690. /**
  30691. * Serializes the animation to an object
  30692. * @returns Serialized object
  30693. */
  30694. serialize(): any;
  30695. /**
  30696. * Float animation type
  30697. */
  30698. static readonly ANIMATIONTYPE_FLOAT: number;
  30699. /**
  30700. * Vector3 animation type
  30701. */
  30702. static readonly ANIMATIONTYPE_VECTOR3: number;
  30703. /**
  30704. * Quaternion animation type
  30705. */
  30706. static readonly ANIMATIONTYPE_QUATERNION: number;
  30707. /**
  30708. * Matrix animation type
  30709. */
  30710. static readonly ANIMATIONTYPE_MATRIX: number;
  30711. /**
  30712. * Color3 animation type
  30713. */
  30714. static readonly ANIMATIONTYPE_COLOR3: number;
  30715. /**
  30716. * Color3 animation type
  30717. */
  30718. static readonly ANIMATIONTYPE_COLOR4: number;
  30719. /**
  30720. * Vector2 animation type
  30721. */
  30722. static readonly ANIMATIONTYPE_VECTOR2: number;
  30723. /**
  30724. * Size animation type
  30725. */
  30726. static readonly ANIMATIONTYPE_SIZE: number;
  30727. /**
  30728. * Relative Loop Mode
  30729. */
  30730. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30731. /**
  30732. * Cycle Loop Mode
  30733. */
  30734. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30735. /**
  30736. * Constant Loop Mode
  30737. */
  30738. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30739. /** @hidden */
  30740. static _UniversalLerp(left: any, right: any, amount: number): any;
  30741. /**
  30742. * Parses an animation object and creates an animation
  30743. * @param parsedAnimation Parsed animation object
  30744. * @returns Animation object
  30745. */
  30746. static Parse(parsedAnimation: any): Animation;
  30747. /**
  30748. * Appends the serialized animations from the source animations
  30749. * @param source Source containing the animations
  30750. * @param destination Target to store the animations
  30751. */
  30752. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30753. }
  30754. }
  30755. declare module "babylonjs/Animations/animatable.interface" {
  30756. import { Nullable } from "babylonjs/types";
  30757. import { Animation } from "babylonjs/Animations/animation";
  30758. /**
  30759. * Interface containing an array of animations
  30760. */
  30761. export interface IAnimatable {
  30762. /**
  30763. * Array of animations
  30764. */
  30765. animations: Nullable<Array<Animation>>;
  30766. }
  30767. }
  30768. declare module "babylonjs/Misc/decorators" {
  30769. import { Nullable } from "babylonjs/types";
  30770. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30771. import { Scene } from "babylonjs/scene";
  30772. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30773. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30774. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30775. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30776. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30777. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30778. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30779. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30780. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30781. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30782. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30783. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30784. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30785. /**
  30786. * Decorator used to define property that can be serialized as reference to a camera
  30787. * @param sourceName defines the name of the property to decorate
  30788. */
  30789. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30790. /**
  30791. * Class used to help serialization objects
  30792. */
  30793. export class SerializationHelper {
  30794. /** @hidden */
  30795. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30796. /** @hidden */
  30797. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30798. /** @hidden */
  30799. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30800. /** @hidden */
  30801. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30802. /**
  30803. * Appends the serialized animations from the source animations
  30804. * @param source Source containing the animations
  30805. * @param destination Target to store the animations
  30806. */
  30807. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30808. /**
  30809. * Static function used to serialized a specific entity
  30810. * @param entity defines the entity to serialize
  30811. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30812. * @returns a JSON compatible object representing the serialization of the entity
  30813. */
  30814. static Serialize<T>(entity: T, serializationObject?: any): any;
  30815. /**
  30816. * Creates a new entity from a serialization data object
  30817. * @param creationFunction defines a function used to instanciated the new entity
  30818. * @param source defines the source serialization data
  30819. * @param scene defines the hosting scene
  30820. * @param rootUrl defines the root url for resources
  30821. * @returns a new entity
  30822. */
  30823. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30824. /**
  30825. * Clones an object
  30826. * @param creationFunction defines the function used to instanciate the new object
  30827. * @param source defines the source object
  30828. * @returns the cloned object
  30829. */
  30830. static Clone<T>(creationFunction: () => T, source: T): T;
  30831. /**
  30832. * Instanciates a new object based on a source one (some data will be shared between both object)
  30833. * @param creationFunction defines the function used to instanciate the new object
  30834. * @param source defines the source object
  30835. * @returns the new object
  30836. */
  30837. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30838. }
  30839. }
  30840. declare module "babylonjs/Misc/guid" {
  30841. /**
  30842. * Class used to manipulate GUIDs
  30843. */
  30844. export class GUID {
  30845. /**
  30846. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30847. * Be aware Math.random() could cause collisions, but:
  30848. * "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"
  30849. * @returns a pseudo random id
  30850. */
  30851. static RandomId(): string;
  30852. }
  30853. }
  30854. declare module "babylonjs/Materials/Textures/baseTexture" {
  30855. import { Observable } from "babylonjs/Misc/observable";
  30856. import { Nullable } from "babylonjs/types";
  30857. import { Scene } from "babylonjs/scene";
  30858. import { Matrix } from "babylonjs/Maths/math.vector";
  30859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30861. import { ISize } from "babylonjs/Maths/math.size";
  30862. import "babylonjs/Misc/fileTools";
  30863. /**
  30864. * Base class of all the textures in babylon.
  30865. * It groups all the common properties the materials, post process, lights... might need
  30866. * in order to make a correct use of the texture.
  30867. */
  30868. export class BaseTexture implements IAnimatable {
  30869. /**
  30870. * Default anisotropic filtering level for the application.
  30871. * It is set to 4 as a good tradeoff between perf and quality.
  30872. */
  30873. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30874. /**
  30875. * Gets or sets the unique id of the texture
  30876. */
  30877. uniqueId: number;
  30878. /**
  30879. * Define the name of the texture.
  30880. */
  30881. name: string;
  30882. /**
  30883. * Gets or sets an object used to store user defined information.
  30884. */
  30885. metadata: any;
  30886. /**
  30887. * For internal use only. Please do not use.
  30888. */
  30889. reservedDataStore: any;
  30890. private _hasAlpha;
  30891. /**
  30892. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30893. */
  30894. set hasAlpha(value: boolean);
  30895. get hasAlpha(): boolean;
  30896. /**
  30897. * Defines if the alpha value should be determined via the rgb values.
  30898. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30899. */
  30900. getAlphaFromRGB: boolean;
  30901. /**
  30902. * Intensity or strength of the texture.
  30903. * It is commonly used by materials to fine tune the intensity of the texture
  30904. */
  30905. level: number;
  30906. /**
  30907. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30908. * This is part of the texture as textures usually maps to one uv set.
  30909. */
  30910. coordinatesIndex: number;
  30911. private _coordinatesMode;
  30912. /**
  30913. * How a texture is mapped.
  30914. *
  30915. * | Value | Type | Description |
  30916. * | ----- | ----------------------------------- | ----------- |
  30917. * | 0 | EXPLICIT_MODE | |
  30918. * | 1 | SPHERICAL_MODE | |
  30919. * | 2 | PLANAR_MODE | |
  30920. * | 3 | CUBIC_MODE | |
  30921. * | 4 | PROJECTION_MODE | |
  30922. * | 5 | SKYBOX_MODE | |
  30923. * | 6 | INVCUBIC_MODE | |
  30924. * | 7 | EQUIRECTANGULAR_MODE | |
  30925. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30926. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30927. */
  30928. set coordinatesMode(value: number);
  30929. get coordinatesMode(): number;
  30930. /**
  30931. * | Value | Type | Description |
  30932. * | ----- | ------------------ | ----------- |
  30933. * | 0 | CLAMP_ADDRESSMODE | |
  30934. * | 1 | WRAP_ADDRESSMODE | |
  30935. * | 2 | MIRROR_ADDRESSMODE | |
  30936. */
  30937. wrapU: number;
  30938. /**
  30939. * | Value | Type | Description |
  30940. * | ----- | ------------------ | ----------- |
  30941. * | 0 | CLAMP_ADDRESSMODE | |
  30942. * | 1 | WRAP_ADDRESSMODE | |
  30943. * | 2 | MIRROR_ADDRESSMODE | |
  30944. */
  30945. wrapV: number;
  30946. /**
  30947. * | Value | Type | Description |
  30948. * | ----- | ------------------ | ----------- |
  30949. * | 0 | CLAMP_ADDRESSMODE | |
  30950. * | 1 | WRAP_ADDRESSMODE | |
  30951. * | 2 | MIRROR_ADDRESSMODE | |
  30952. */
  30953. wrapR: number;
  30954. /**
  30955. * With compliant hardware and browser (supporting anisotropic filtering)
  30956. * this defines the level of anisotropic filtering in the texture.
  30957. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30958. */
  30959. anisotropicFilteringLevel: number;
  30960. /**
  30961. * Define if the texture is a cube texture or if false a 2d texture.
  30962. */
  30963. get isCube(): boolean;
  30964. set isCube(value: boolean);
  30965. /**
  30966. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30967. */
  30968. get is3D(): boolean;
  30969. set is3D(value: boolean);
  30970. /**
  30971. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30972. */
  30973. get is2DArray(): boolean;
  30974. set is2DArray(value: boolean);
  30975. /**
  30976. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30977. * HDR texture are usually stored in linear space.
  30978. * This only impacts the PBR and Background materials
  30979. */
  30980. gammaSpace: boolean;
  30981. /**
  30982. * Gets or sets whether or not the texture contains RGBD data.
  30983. */
  30984. get isRGBD(): boolean;
  30985. set isRGBD(value: boolean);
  30986. /**
  30987. * Is Z inverted in the texture (useful in a cube texture).
  30988. */
  30989. invertZ: boolean;
  30990. /**
  30991. * Are mip maps generated for this texture or not.
  30992. */
  30993. get noMipmap(): boolean;
  30994. /**
  30995. * @hidden
  30996. */
  30997. lodLevelInAlpha: boolean;
  30998. /**
  30999. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31000. */
  31001. get lodGenerationOffset(): number;
  31002. set lodGenerationOffset(value: number);
  31003. /**
  31004. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31005. */
  31006. get lodGenerationScale(): number;
  31007. set lodGenerationScale(value: number);
  31008. /**
  31009. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31010. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31011. * average roughness values.
  31012. */
  31013. get linearSpecularLOD(): boolean;
  31014. set linearSpecularLOD(value: boolean);
  31015. /**
  31016. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31017. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31018. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31019. */
  31020. get irradianceTexture(): Nullable<BaseTexture>;
  31021. set irradianceTexture(value: Nullable<BaseTexture>);
  31022. /**
  31023. * Define if the texture is a render target.
  31024. */
  31025. isRenderTarget: boolean;
  31026. /**
  31027. * Define the unique id of the texture in the scene.
  31028. */
  31029. get uid(): string;
  31030. /**
  31031. * Return a string representation of the texture.
  31032. * @returns the texture as a string
  31033. */
  31034. toString(): string;
  31035. /**
  31036. * Get the class name of the texture.
  31037. * @returns "BaseTexture"
  31038. */
  31039. getClassName(): string;
  31040. /**
  31041. * Define the list of animation attached to the texture.
  31042. */
  31043. animations: import("babylonjs/Animations/animation").Animation[];
  31044. /**
  31045. * An event triggered when the texture is disposed.
  31046. */
  31047. onDisposeObservable: Observable<BaseTexture>;
  31048. private _onDisposeObserver;
  31049. /**
  31050. * Callback triggered when the texture has been disposed.
  31051. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31052. */
  31053. set onDispose(callback: () => void);
  31054. /**
  31055. * Define the current state of the loading sequence when in delayed load mode.
  31056. */
  31057. delayLoadState: number;
  31058. private _scene;
  31059. /** @hidden */
  31060. _texture: Nullable<InternalTexture>;
  31061. private _uid;
  31062. /**
  31063. * Define if the texture is preventinga material to render or not.
  31064. * If not and the texture is not ready, the engine will use a default black texture instead.
  31065. */
  31066. get isBlocking(): boolean;
  31067. /**
  31068. * Instantiates a new BaseTexture.
  31069. * Base class of all the textures in babylon.
  31070. * It groups all the common properties the materials, post process, lights... might need
  31071. * in order to make a correct use of the texture.
  31072. * @param scene Define the scene the texture blongs to
  31073. */
  31074. constructor(scene: Nullable<Scene>);
  31075. /**
  31076. * Get the scene the texture belongs to.
  31077. * @returns the scene or null if undefined
  31078. */
  31079. getScene(): Nullable<Scene>;
  31080. /**
  31081. * Get the texture transform matrix used to offset tile the texture for istance.
  31082. * @returns the transformation matrix
  31083. */
  31084. getTextureMatrix(): Matrix;
  31085. /**
  31086. * Get the texture reflection matrix used to rotate/transform the reflection.
  31087. * @returns the reflection matrix
  31088. */
  31089. getReflectionTextureMatrix(): Matrix;
  31090. /**
  31091. * Get the underlying lower level texture from Babylon.
  31092. * @returns the insternal texture
  31093. */
  31094. getInternalTexture(): Nullable<InternalTexture>;
  31095. /**
  31096. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31097. * @returns true if ready or not blocking
  31098. */
  31099. isReadyOrNotBlocking(): boolean;
  31100. /**
  31101. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31102. * @returns true if fully ready
  31103. */
  31104. isReady(): boolean;
  31105. private _cachedSize;
  31106. /**
  31107. * Get the size of the texture.
  31108. * @returns the texture size.
  31109. */
  31110. getSize(): ISize;
  31111. /**
  31112. * Get the base size of the texture.
  31113. * It can be different from the size if the texture has been resized for POT for instance
  31114. * @returns the base size
  31115. */
  31116. getBaseSize(): ISize;
  31117. /**
  31118. * Update the sampling mode of the texture.
  31119. * Default is Trilinear mode.
  31120. *
  31121. * | Value | Type | Description |
  31122. * | ----- | ------------------ | ----------- |
  31123. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31124. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31125. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31126. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31127. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31128. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31129. * | 7 | NEAREST_LINEAR | |
  31130. * | 8 | NEAREST_NEAREST | |
  31131. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31132. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31133. * | 11 | LINEAR_LINEAR | |
  31134. * | 12 | LINEAR_NEAREST | |
  31135. *
  31136. * > _mag_: magnification filter (close to the viewer)
  31137. * > _min_: minification filter (far from the viewer)
  31138. * > _mip_: filter used between mip map levels
  31139. *@param samplingMode Define the new sampling mode of the texture
  31140. */
  31141. updateSamplingMode(samplingMode: number): void;
  31142. /**
  31143. * Scales the texture if is `canRescale()`
  31144. * @param ratio the resize factor we want to use to rescale
  31145. */
  31146. scale(ratio: number): void;
  31147. /**
  31148. * Get if the texture can rescale.
  31149. */
  31150. get canRescale(): boolean;
  31151. /** @hidden */
  31152. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31153. /** @hidden */
  31154. _rebuild(): void;
  31155. /**
  31156. * Triggers the load sequence in delayed load mode.
  31157. */
  31158. delayLoad(): void;
  31159. /**
  31160. * Clones the texture.
  31161. * @returns the cloned texture
  31162. */
  31163. clone(): Nullable<BaseTexture>;
  31164. /**
  31165. * Get the texture underlying type (INT, FLOAT...)
  31166. */
  31167. get textureType(): number;
  31168. /**
  31169. * Get the texture underlying format (RGB, RGBA...)
  31170. */
  31171. get textureFormat(): number;
  31172. /**
  31173. * Indicates that textures need to be re-calculated for all materials
  31174. */
  31175. protected _markAllSubMeshesAsTexturesDirty(): void;
  31176. /**
  31177. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31178. * This will returns an RGBA array buffer containing either in values (0-255) or
  31179. * float values (0-1) depending of the underlying buffer type.
  31180. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31181. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31182. * @param buffer defines a user defined buffer to fill with data (can be null)
  31183. * @returns The Array buffer containing the pixels data.
  31184. */
  31185. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31186. /**
  31187. * Release and destroy the underlying lower level texture aka internalTexture.
  31188. */
  31189. releaseInternalTexture(): void;
  31190. /** @hidden */
  31191. get _lodTextureHigh(): Nullable<BaseTexture>;
  31192. /** @hidden */
  31193. get _lodTextureMid(): Nullable<BaseTexture>;
  31194. /** @hidden */
  31195. get _lodTextureLow(): Nullable<BaseTexture>;
  31196. /**
  31197. * Dispose the texture and release its associated resources.
  31198. */
  31199. dispose(): void;
  31200. /**
  31201. * Serialize the texture into a JSON representation that can be parsed later on.
  31202. * @returns the JSON representation of the texture
  31203. */
  31204. serialize(): any;
  31205. /**
  31206. * Helper function to be called back once a list of texture contains only ready textures.
  31207. * @param textures Define the list of textures to wait for
  31208. * @param callback Define the callback triggered once the entire list will be ready
  31209. */
  31210. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31211. }
  31212. }
  31213. declare module "babylonjs/Materials/effect" {
  31214. import { Observable } from "babylonjs/Misc/observable";
  31215. import { Nullable } from "babylonjs/types";
  31216. import { IDisposable } from "babylonjs/scene";
  31217. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31218. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31219. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31220. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31221. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31222. import { Engine } from "babylonjs/Engines/engine";
  31223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31227. /**
  31228. * Options to be used when creating an effect.
  31229. */
  31230. export interface IEffectCreationOptions {
  31231. /**
  31232. * Atrributes that will be used in the shader.
  31233. */
  31234. attributes: string[];
  31235. /**
  31236. * Uniform varible names that will be set in the shader.
  31237. */
  31238. uniformsNames: string[];
  31239. /**
  31240. * Uniform buffer variable names that will be set in the shader.
  31241. */
  31242. uniformBuffersNames: string[];
  31243. /**
  31244. * Sampler texture variable names that will be set in the shader.
  31245. */
  31246. samplers: string[];
  31247. /**
  31248. * Define statements that will be set in the shader.
  31249. */
  31250. defines: any;
  31251. /**
  31252. * Possible fallbacks for this effect to improve performance when needed.
  31253. */
  31254. fallbacks: Nullable<IEffectFallbacks>;
  31255. /**
  31256. * Callback that will be called when the shader is compiled.
  31257. */
  31258. onCompiled: Nullable<(effect: Effect) => void>;
  31259. /**
  31260. * Callback that will be called if an error occurs during shader compilation.
  31261. */
  31262. onError: Nullable<(effect: Effect, errors: string) => void>;
  31263. /**
  31264. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31265. */
  31266. indexParameters?: any;
  31267. /**
  31268. * Max number of lights that can be used in the shader.
  31269. */
  31270. maxSimultaneousLights?: number;
  31271. /**
  31272. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31273. */
  31274. transformFeedbackVaryings?: Nullable<string[]>;
  31275. }
  31276. /**
  31277. * Effect containing vertex and fragment shader that can be executed on an object.
  31278. */
  31279. export class Effect implements IDisposable {
  31280. /**
  31281. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31282. */
  31283. static ShadersRepository: string;
  31284. /**
  31285. * Enable logging of the shader code when a compilation error occurs
  31286. */
  31287. static LogShaderCodeOnCompilationError: boolean;
  31288. /**
  31289. * Name of the effect.
  31290. */
  31291. name: any;
  31292. /**
  31293. * String container all the define statements that should be set on the shader.
  31294. */
  31295. defines: string;
  31296. /**
  31297. * Callback that will be called when the shader is compiled.
  31298. */
  31299. onCompiled: Nullable<(effect: Effect) => void>;
  31300. /**
  31301. * Callback that will be called if an error occurs during shader compilation.
  31302. */
  31303. onError: Nullable<(effect: Effect, errors: string) => void>;
  31304. /**
  31305. * Callback that will be called when effect is bound.
  31306. */
  31307. onBind: Nullable<(effect: Effect) => void>;
  31308. /**
  31309. * Unique ID of the effect.
  31310. */
  31311. uniqueId: number;
  31312. /**
  31313. * Observable that will be called when the shader is compiled.
  31314. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31315. */
  31316. onCompileObservable: Observable<Effect>;
  31317. /**
  31318. * Observable that will be called if an error occurs during shader compilation.
  31319. */
  31320. onErrorObservable: Observable<Effect>;
  31321. /** @hidden */
  31322. _onBindObservable: Nullable<Observable<Effect>>;
  31323. /**
  31324. * @hidden
  31325. * Specifies if the effect was previously ready
  31326. */
  31327. _wasPreviouslyReady: boolean;
  31328. /**
  31329. * Observable that will be called when effect is bound.
  31330. */
  31331. get onBindObservable(): Observable<Effect>;
  31332. /** @hidden */
  31333. _bonesComputationForcedToCPU: boolean;
  31334. private static _uniqueIdSeed;
  31335. private _engine;
  31336. private _uniformBuffersNames;
  31337. private _uniformsNames;
  31338. private _samplerList;
  31339. private _samplers;
  31340. private _isReady;
  31341. private _compilationError;
  31342. private _allFallbacksProcessed;
  31343. private _attributesNames;
  31344. private _attributes;
  31345. private _attributeLocationByName;
  31346. private _uniforms;
  31347. /**
  31348. * Key for the effect.
  31349. * @hidden
  31350. */
  31351. _key: string;
  31352. private _indexParameters;
  31353. private _fallbacks;
  31354. private _vertexSourceCode;
  31355. private _fragmentSourceCode;
  31356. private _vertexSourceCodeOverride;
  31357. private _fragmentSourceCodeOverride;
  31358. private _transformFeedbackVaryings;
  31359. /**
  31360. * Compiled shader to webGL program.
  31361. * @hidden
  31362. */
  31363. _pipelineContext: Nullable<IPipelineContext>;
  31364. private _valueCache;
  31365. private static _baseCache;
  31366. /**
  31367. * Instantiates an effect.
  31368. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31369. * @param baseName Name of the effect.
  31370. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31371. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31372. * @param samplers List of sampler variables that will be passed to the shader.
  31373. * @param engine Engine to be used to render the effect
  31374. * @param defines Define statements to be added to the shader.
  31375. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31376. * @param onCompiled Callback that will be called when the shader is compiled.
  31377. * @param onError Callback that will be called if an error occurs during shader compilation.
  31378. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31379. */
  31380. 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);
  31381. private _useFinalCode;
  31382. /**
  31383. * Unique key for this effect
  31384. */
  31385. get key(): string;
  31386. /**
  31387. * If the effect has been compiled and prepared.
  31388. * @returns if the effect is compiled and prepared.
  31389. */
  31390. isReady(): boolean;
  31391. private _isReadyInternal;
  31392. /**
  31393. * The engine the effect was initialized with.
  31394. * @returns the engine.
  31395. */
  31396. getEngine(): Engine;
  31397. /**
  31398. * The pipeline context for this effect
  31399. * @returns the associated pipeline context
  31400. */
  31401. getPipelineContext(): Nullable<IPipelineContext>;
  31402. /**
  31403. * The set of names of attribute variables for the shader.
  31404. * @returns An array of attribute names.
  31405. */
  31406. getAttributesNames(): string[];
  31407. /**
  31408. * Returns the attribute at the given index.
  31409. * @param index The index of the attribute.
  31410. * @returns The location of the attribute.
  31411. */
  31412. getAttributeLocation(index: number): number;
  31413. /**
  31414. * Returns the attribute based on the name of the variable.
  31415. * @param name of the attribute to look up.
  31416. * @returns the attribute location.
  31417. */
  31418. getAttributeLocationByName(name: string): number;
  31419. /**
  31420. * The number of attributes.
  31421. * @returns the numnber of attributes.
  31422. */
  31423. getAttributesCount(): number;
  31424. /**
  31425. * Gets the index of a uniform variable.
  31426. * @param uniformName of the uniform to look up.
  31427. * @returns the index.
  31428. */
  31429. getUniformIndex(uniformName: string): number;
  31430. /**
  31431. * Returns the attribute based on the name of the variable.
  31432. * @param uniformName of the uniform to look up.
  31433. * @returns the location of the uniform.
  31434. */
  31435. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31436. /**
  31437. * Returns an array of sampler variable names
  31438. * @returns The array of sampler variable neames.
  31439. */
  31440. getSamplers(): string[];
  31441. /**
  31442. * The error from the last compilation.
  31443. * @returns the error string.
  31444. */
  31445. getCompilationError(): string;
  31446. /**
  31447. * Gets a boolean indicating that all fallbacks were used during compilation
  31448. * @returns true if all fallbacks were used
  31449. */
  31450. allFallbacksProcessed(): boolean;
  31451. /**
  31452. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31453. * @param func The callback to be used.
  31454. */
  31455. executeWhenCompiled(func: (effect: Effect) => void): void;
  31456. private _checkIsReady;
  31457. private _loadShader;
  31458. /**
  31459. * Recompiles the webGL program
  31460. * @param vertexSourceCode The source code for the vertex shader.
  31461. * @param fragmentSourceCode The source code for the fragment shader.
  31462. * @param onCompiled Callback called when completed.
  31463. * @param onError Callback called on error.
  31464. * @hidden
  31465. */
  31466. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31467. /**
  31468. * Prepares the effect
  31469. * @hidden
  31470. */
  31471. _prepareEffect(): void;
  31472. private _getShaderCodeAndErrorLine;
  31473. private _processCompilationErrors;
  31474. /**
  31475. * Checks if the effect is supported. (Must be called after compilation)
  31476. */
  31477. get isSupported(): boolean;
  31478. /**
  31479. * Binds a texture to the engine to be used as output of the shader.
  31480. * @param channel Name of the output variable.
  31481. * @param texture Texture to bind.
  31482. * @hidden
  31483. */
  31484. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31485. /**
  31486. * Sets a texture on the engine to be used in the shader.
  31487. * @param channel Name of the sampler variable.
  31488. * @param texture Texture to set.
  31489. */
  31490. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31491. /**
  31492. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31493. * @param channel Name of the sampler variable.
  31494. * @param texture Texture to set.
  31495. */
  31496. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31497. /**
  31498. * Sets an array of textures on the engine to be used in the shader.
  31499. * @param channel Name of the variable.
  31500. * @param textures Textures to set.
  31501. */
  31502. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31503. /**
  31504. * 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)
  31505. * @param channel Name of the sampler variable.
  31506. * @param postProcess Post process to get the input texture from.
  31507. */
  31508. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31509. /**
  31510. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31511. * 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)
  31512. * @param channel Name of the sampler variable.
  31513. * @param postProcess Post process to get the output texture from.
  31514. */
  31515. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31516. /** @hidden */
  31517. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31518. /** @hidden */
  31519. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31520. /** @hidden */
  31521. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31522. /** @hidden */
  31523. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31524. /**
  31525. * Binds a buffer to a uniform.
  31526. * @param buffer Buffer to bind.
  31527. * @param name Name of the uniform variable to bind to.
  31528. */
  31529. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31530. /**
  31531. * Binds block to a uniform.
  31532. * @param blockName Name of the block to bind.
  31533. * @param index Index to bind.
  31534. */
  31535. bindUniformBlock(blockName: string, index: number): void;
  31536. /**
  31537. * Sets an interger value on a uniform variable.
  31538. * @param uniformName Name of the variable.
  31539. * @param value Value to be set.
  31540. * @returns this effect.
  31541. */
  31542. setInt(uniformName: string, value: number): Effect;
  31543. /**
  31544. * Sets an int array on a uniform variable.
  31545. * @param uniformName Name of the variable.
  31546. * @param array array to be set.
  31547. * @returns this effect.
  31548. */
  31549. setIntArray(uniformName: string, array: Int32Array): Effect;
  31550. /**
  31551. * 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)
  31552. * @param uniformName Name of the variable.
  31553. * @param array array to be set.
  31554. * @returns this effect.
  31555. */
  31556. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31557. /**
  31558. * 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)
  31559. * @param uniformName Name of the variable.
  31560. * @param array array to be set.
  31561. * @returns this effect.
  31562. */
  31563. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31564. /**
  31565. * 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)
  31566. * @param uniformName Name of the variable.
  31567. * @param array array to be set.
  31568. * @returns this effect.
  31569. */
  31570. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31571. /**
  31572. * Sets an float array on a uniform variable.
  31573. * @param uniformName Name of the variable.
  31574. * @param array array to be set.
  31575. * @returns this effect.
  31576. */
  31577. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31578. /**
  31579. * 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)
  31580. * @param uniformName Name of the variable.
  31581. * @param array array to be set.
  31582. * @returns this effect.
  31583. */
  31584. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31585. /**
  31586. * 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)
  31587. * @param uniformName Name of the variable.
  31588. * @param array array to be set.
  31589. * @returns this effect.
  31590. */
  31591. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31592. /**
  31593. * 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)
  31594. * @param uniformName Name of the variable.
  31595. * @param array array to be set.
  31596. * @returns this effect.
  31597. */
  31598. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31599. /**
  31600. * Sets an array on a uniform variable.
  31601. * @param uniformName Name of the variable.
  31602. * @param array array to be set.
  31603. * @returns this effect.
  31604. */
  31605. setArray(uniformName: string, array: number[]): Effect;
  31606. /**
  31607. * 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)
  31608. * @param uniformName Name of the variable.
  31609. * @param array array to be set.
  31610. * @returns this effect.
  31611. */
  31612. setArray2(uniformName: string, array: number[]): Effect;
  31613. /**
  31614. * 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)
  31615. * @param uniformName Name of the variable.
  31616. * @param array array to be set.
  31617. * @returns this effect.
  31618. */
  31619. setArray3(uniformName: string, array: number[]): Effect;
  31620. /**
  31621. * 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)
  31622. * @param uniformName Name of the variable.
  31623. * @param array array to be set.
  31624. * @returns this effect.
  31625. */
  31626. setArray4(uniformName: string, array: number[]): Effect;
  31627. /**
  31628. * Sets matrices on a uniform variable.
  31629. * @param uniformName Name of the variable.
  31630. * @param matrices matrices to be set.
  31631. * @returns this effect.
  31632. */
  31633. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31634. /**
  31635. * Sets matrix on a uniform variable.
  31636. * @param uniformName Name of the variable.
  31637. * @param matrix matrix to be set.
  31638. * @returns this effect.
  31639. */
  31640. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31641. /**
  31642. * 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)
  31643. * @param uniformName Name of the variable.
  31644. * @param matrix matrix to be set.
  31645. * @returns this effect.
  31646. */
  31647. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31648. /**
  31649. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31650. * @param uniformName Name of the variable.
  31651. * @param matrix matrix to be set.
  31652. * @returns this effect.
  31653. */
  31654. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31655. /**
  31656. * Sets a float on a uniform variable.
  31657. * @param uniformName Name of the variable.
  31658. * @param value value to be set.
  31659. * @returns this effect.
  31660. */
  31661. setFloat(uniformName: string, value: number): Effect;
  31662. /**
  31663. * Sets a boolean on a uniform variable.
  31664. * @param uniformName Name of the variable.
  31665. * @param bool value to be set.
  31666. * @returns this effect.
  31667. */
  31668. setBool(uniformName: string, bool: boolean): Effect;
  31669. /**
  31670. * Sets a Vector2 on a uniform variable.
  31671. * @param uniformName Name of the variable.
  31672. * @param vector2 vector2 to be set.
  31673. * @returns this effect.
  31674. */
  31675. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31676. /**
  31677. * Sets a float2 on a uniform variable.
  31678. * @param uniformName Name of the variable.
  31679. * @param x First float in float2.
  31680. * @param y Second float in float2.
  31681. * @returns this effect.
  31682. */
  31683. setFloat2(uniformName: string, x: number, y: number): Effect;
  31684. /**
  31685. * Sets a Vector3 on a uniform variable.
  31686. * @param uniformName Name of the variable.
  31687. * @param vector3 Value to be set.
  31688. * @returns this effect.
  31689. */
  31690. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31691. /**
  31692. * Sets a float3 on a uniform variable.
  31693. * @param uniformName Name of the variable.
  31694. * @param x First float in float3.
  31695. * @param y Second float in float3.
  31696. * @param z Third float in float3.
  31697. * @returns this effect.
  31698. */
  31699. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31700. /**
  31701. * Sets a Vector4 on a uniform variable.
  31702. * @param uniformName Name of the variable.
  31703. * @param vector4 Value to be set.
  31704. * @returns this effect.
  31705. */
  31706. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31707. /**
  31708. * Sets a float4 on a uniform variable.
  31709. * @param uniformName Name of the variable.
  31710. * @param x First float in float4.
  31711. * @param y Second float in float4.
  31712. * @param z Third float in float4.
  31713. * @param w Fourth float in float4.
  31714. * @returns this effect.
  31715. */
  31716. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31717. /**
  31718. * Sets a Color3 on a uniform variable.
  31719. * @param uniformName Name of the variable.
  31720. * @param color3 Value to be set.
  31721. * @returns this effect.
  31722. */
  31723. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31724. /**
  31725. * Sets a Color4 on a uniform variable.
  31726. * @param uniformName Name of the variable.
  31727. * @param color3 Value to be set.
  31728. * @param alpha Alpha value to be set.
  31729. * @returns this effect.
  31730. */
  31731. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31732. /**
  31733. * Sets a Color4 on a uniform variable
  31734. * @param uniformName defines the name of the variable
  31735. * @param color4 defines the value to be set
  31736. * @returns this effect.
  31737. */
  31738. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31739. /** Release all associated resources */
  31740. dispose(): void;
  31741. /**
  31742. * This function will add a new shader to the shader store
  31743. * @param name the name of the shader
  31744. * @param pixelShader optional pixel shader content
  31745. * @param vertexShader optional vertex shader content
  31746. */
  31747. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31748. /**
  31749. * Store of each shader (The can be looked up using effect.key)
  31750. */
  31751. static ShadersStore: {
  31752. [key: string]: string;
  31753. };
  31754. /**
  31755. * Store of each included file for a shader (The can be looked up using effect.key)
  31756. */
  31757. static IncludesShadersStore: {
  31758. [key: string]: string;
  31759. };
  31760. /**
  31761. * Resets the cache of effects.
  31762. */
  31763. static ResetCache(): void;
  31764. }
  31765. }
  31766. declare module "babylonjs/Engines/engineCapabilities" {
  31767. /**
  31768. * Interface used to describe the capabilities of the engine relatively to the current browser
  31769. */
  31770. export interface EngineCapabilities {
  31771. /** Maximum textures units per fragment shader */
  31772. maxTexturesImageUnits: number;
  31773. /** Maximum texture units per vertex shader */
  31774. maxVertexTextureImageUnits: number;
  31775. /** Maximum textures units in the entire pipeline */
  31776. maxCombinedTexturesImageUnits: number;
  31777. /** Maximum texture size */
  31778. maxTextureSize: number;
  31779. /** Maximum texture samples */
  31780. maxSamples?: number;
  31781. /** Maximum cube texture size */
  31782. maxCubemapTextureSize: number;
  31783. /** Maximum render texture size */
  31784. maxRenderTextureSize: number;
  31785. /** Maximum number of vertex attributes */
  31786. maxVertexAttribs: number;
  31787. /** Maximum number of varyings */
  31788. maxVaryingVectors: number;
  31789. /** Maximum number of uniforms per vertex shader */
  31790. maxVertexUniformVectors: number;
  31791. /** Maximum number of uniforms per fragment shader */
  31792. maxFragmentUniformVectors: number;
  31793. /** Defines if standard derivates (dx/dy) are supported */
  31794. standardDerivatives: boolean;
  31795. /** Defines if s3tc texture compression is supported */
  31796. s3tc?: WEBGL_compressed_texture_s3tc;
  31797. /** Defines if pvrtc texture compression is supported */
  31798. pvrtc: any;
  31799. /** Defines if etc1 texture compression is supported */
  31800. etc1: any;
  31801. /** Defines if etc2 texture compression is supported */
  31802. etc2: any;
  31803. /** Defines if astc texture compression is supported */
  31804. astc: any;
  31805. /** Defines if float textures are supported */
  31806. textureFloat: boolean;
  31807. /** Defines if vertex array objects are supported */
  31808. vertexArrayObject: boolean;
  31809. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31810. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31811. /** Gets the maximum level of anisotropy supported */
  31812. maxAnisotropy: number;
  31813. /** Defines if instancing is supported */
  31814. instancedArrays: boolean;
  31815. /** Defines if 32 bits indices are supported */
  31816. uintIndices: boolean;
  31817. /** Defines if high precision shaders are supported */
  31818. highPrecisionShaderSupported: boolean;
  31819. /** Defines if depth reading in the fragment shader is supported */
  31820. fragmentDepthSupported: boolean;
  31821. /** Defines if float texture linear filtering is supported*/
  31822. textureFloatLinearFiltering: boolean;
  31823. /** Defines if rendering to float textures is supported */
  31824. textureFloatRender: boolean;
  31825. /** Defines if half float textures are supported*/
  31826. textureHalfFloat: boolean;
  31827. /** Defines if half float texture linear filtering is supported*/
  31828. textureHalfFloatLinearFiltering: boolean;
  31829. /** Defines if rendering to half float textures is supported */
  31830. textureHalfFloatRender: boolean;
  31831. /** Defines if textureLOD shader command is supported */
  31832. textureLOD: boolean;
  31833. /** Defines if draw buffers extension is supported */
  31834. drawBuffersExtension: boolean;
  31835. /** Defines if depth textures are supported */
  31836. depthTextureExtension: boolean;
  31837. /** Defines if float color buffer are supported */
  31838. colorBufferFloat: boolean;
  31839. /** Gets disjoint timer query extension (null if not supported) */
  31840. timerQuery?: EXT_disjoint_timer_query;
  31841. /** Defines if timestamp can be used with timer query */
  31842. canUseTimestampForTimerQuery: boolean;
  31843. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31844. multiview?: any;
  31845. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31846. oculusMultiview?: any;
  31847. /** Function used to let the system compiles shaders in background */
  31848. parallelShaderCompile?: {
  31849. COMPLETION_STATUS_KHR: number;
  31850. };
  31851. /** Max number of texture samples for MSAA */
  31852. maxMSAASamples: number;
  31853. /** Defines if the blend min max extension is supported */
  31854. blendMinMax: boolean;
  31855. }
  31856. }
  31857. declare module "babylonjs/States/depthCullingState" {
  31858. import { Nullable } from "babylonjs/types";
  31859. /**
  31860. * @hidden
  31861. **/
  31862. export class DepthCullingState {
  31863. private _isDepthTestDirty;
  31864. private _isDepthMaskDirty;
  31865. private _isDepthFuncDirty;
  31866. private _isCullFaceDirty;
  31867. private _isCullDirty;
  31868. private _isZOffsetDirty;
  31869. private _isFrontFaceDirty;
  31870. private _depthTest;
  31871. private _depthMask;
  31872. private _depthFunc;
  31873. private _cull;
  31874. private _cullFace;
  31875. private _zOffset;
  31876. private _frontFace;
  31877. /**
  31878. * Initializes the state.
  31879. */
  31880. constructor();
  31881. get isDirty(): boolean;
  31882. get zOffset(): number;
  31883. set zOffset(value: number);
  31884. get cullFace(): Nullable<number>;
  31885. set cullFace(value: Nullable<number>);
  31886. get cull(): Nullable<boolean>;
  31887. set cull(value: Nullable<boolean>);
  31888. get depthFunc(): Nullable<number>;
  31889. set depthFunc(value: Nullable<number>);
  31890. get depthMask(): boolean;
  31891. set depthMask(value: boolean);
  31892. get depthTest(): boolean;
  31893. set depthTest(value: boolean);
  31894. get frontFace(): Nullable<number>;
  31895. set frontFace(value: Nullable<number>);
  31896. reset(): void;
  31897. apply(gl: WebGLRenderingContext): void;
  31898. }
  31899. }
  31900. declare module "babylonjs/States/stencilState" {
  31901. /**
  31902. * @hidden
  31903. **/
  31904. export class StencilState {
  31905. /** 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 */
  31906. static readonly ALWAYS: number;
  31907. /** Passed to stencilOperation to specify that stencil value must be kept */
  31908. static readonly KEEP: number;
  31909. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31910. static readonly REPLACE: number;
  31911. private _isStencilTestDirty;
  31912. private _isStencilMaskDirty;
  31913. private _isStencilFuncDirty;
  31914. private _isStencilOpDirty;
  31915. private _stencilTest;
  31916. private _stencilMask;
  31917. private _stencilFunc;
  31918. private _stencilFuncRef;
  31919. private _stencilFuncMask;
  31920. private _stencilOpStencilFail;
  31921. private _stencilOpDepthFail;
  31922. private _stencilOpStencilDepthPass;
  31923. get isDirty(): boolean;
  31924. get stencilFunc(): number;
  31925. set stencilFunc(value: number);
  31926. get stencilFuncRef(): number;
  31927. set stencilFuncRef(value: number);
  31928. get stencilFuncMask(): number;
  31929. set stencilFuncMask(value: number);
  31930. get stencilOpStencilFail(): number;
  31931. set stencilOpStencilFail(value: number);
  31932. get stencilOpDepthFail(): number;
  31933. set stencilOpDepthFail(value: number);
  31934. get stencilOpStencilDepthPass(): number;
  31935. set stencilOpStencilDepthPass(value: number);
  31936. get stencilMask(): number;
  31937. set stencilMask(value: number);
  31938. get stencilTest(): boolean;
  31939. set stencilTest(value: boolean);
  31940. constructor();
  31941. reset(): void;
  31942. apply(gl: WebGLRenderingContext): void;
  31943. }
  31944. }
  31945. declare module "babylonjs/States/alphaCullingState" {
  31946. /**
  31947. * @hidden
  31948. **/
  31949. export class AlphaState {
  31950. private _isAlphaBlendDirty;
  31951. private _isBlendFunctionParametersDirty;
  31952. private _isBlendEquationParametersDirty;
  31953. private _isBlendConstantsDirty;
  31954. private _alphaBlend;
  31955. private _blendFunctionParameters;
  31956. private _blendEquationParameters;
  31957. private _blendConstants;
  31958. /**
  31959. * Initializes the state.
  31960. */
  31961. constructor();
  31962. get isDirty(): boolean;
  31963. get alphaBlend(): boolean;
  31964. set alphaBlend(value: boolean);
  31965. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31966. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31967. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31968. reset(): void;
  31969. apply(gl: WebGLRenderingContext): void;
  31970. }
  31971. }
  31972. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31973. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31974. /** @hidden */
  31975. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31976. attributeProcessor(attribute: string): string;
  31977. varyingProcessor(varying: string, isFragment: boolean): string;
  31978. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31979. }
  31980. }
  31981. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31982. /**
  31983. * Interface for attribute information associated with buffer instanciation
  31984. */
  31985. export interface InstancingAttributeInfo {
  31986. /**
  31987. * Name of the GLSL attribute
  31988. * if attribute index is not specified, this is used to retrieve the index from the effect
  31989. */
  31990. attributeName: string;
  31991. /**
  31992. * Index/offset of the attribute in the vertex shader
  31993. * if not specified, this will be computes from the name.
  31994. */
  31995. index?: number;
  31996. /**
  31997. * size of the attribute, 1, 2, 3 or 4
  31998. */
  31999. attributeSize: number;
  32000. /**
  32001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32002. */
  32003. offset: number;
  32004. /**
  32005. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32006. * default to 1
  32007. */
  32008. divisor?: number;
  32009. /**
  32010. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32011. * default is FLOAT
  32012. */
  32013. attributeType?: number;
  32014. /**
  32015. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32016. */
  32017. normalized?: boolean;
  32018. }
  32019. }
  32020. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32022. import { Nullable } from "babylonjs/types";
  32023. module "babylonjs/Engines/thinEngine" {
  32024. interface ThinEngine {
  32025. /**
  32026. * Update a video texture
  32027. * @param texture defines the texture to update
  32028. * @param video defines the video element to use
  32029. * @param invertY defines if data must be stored with Y axis inverted
  32030. */
  32031. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32032. }
  32033. }
  32034. }
  32035. declare module "babylonjs/Materials/Textures/videoTexture" {
  32036. import { Observable } from "babylonjs/Misc/observable";
  32037. import { Nullable } from "babylonjs/types";
  32038. import { Scene } from "babylonjs/scene";
  32039. import { Texture } from "babylonjs/Materials/Textures/texture";
  32040. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32041. /**
  32042. * Settings for finer control over video usage
  32043. */
  32044. export interface VideoTextureSettings {
  32045. /**
  32046. * Applies `autoplay` to video, if specified
  32047. */
  32048. autoPlay?: boolean;
  32049. /**
  32050. * Applies `loop` to video, if specified
  32051. */
  32052. loop?: boolean;
  32053. /**
  32054. * Automatically updates internal texture from video at every frame in the render loop
  32055. */
  32056. autoUpdateTexture: boolean;
  32057. /**
  32058. * Image src displayed during the video loading or until the user interacts with the video.
  32059. */
  32060. poster?: string;
  32061. }
  32062. /**
  32063. * If you want to display a video in your scene, this is the special texture for that.
  32064. * This special texture works similar to other textures, with the exception of a few parameters.
  32065. * @see https://doc.babylonjs.com/how_to/video_texture
  32066. */
  32067. export class VideoTexture extends Texture {
  32068. /**
  32069. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32070. */
  32071. readonly autoUpdateTexture: boolean;
  32072. /**
  32073. * The video instance used by the texture internally
  32074. */
  32075. readonly video: HTMLVideoElement;
  32076. private _onUserActionRequestedObservable;
  32077. /**
  32078. * Event triggerd when a dom action is required by the user to play the video.
  32079. * This happens due to recent changes in browser policies preventing video to auto start.
  32080. */
  32081. get onUserActionRequestedObservable(): Observable<Texture>;
  32082. private _generateMipMaps;
  32083. private _engine;
  32084. private _stillImageCaptured;
  32085. private _displayingPosterTexture;
  32086. private _settings;
  32087. private _createInternalTextureOnEvent;
  32088. private _frameId;
  32089. private _currentSrc;
  32090. /**
  32091. * Creates a video texture.
  32092. * If you want to display a video in your scene, this is the special texture for that.
  32093. * This special texture works similar to other textures, with the exception of a few parameters.
  32094. * @see https://doc.babylonjs.com/how_to/video_texture
  32095. * @param name optional name, will detect from video source, if not defined
  32096. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32097. * @param scene is obviously the current scene.
  32098. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32099. * @param invertY is false by default but can be used to invert video on Y axis
  32100. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32101. * @param settings allows finer control over video usage
  32102. */
  32103. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32104. private _getName;
  32105. private _getVideo;
  32106. private _createInternalTexture;
  32107. private reset;
  32108. /**
  32109. * @hidden Internal method to initiate `update`.
  32110. */
  32111. _rebuild(): void;
  32112. /**
  32113. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32114. */
  32115. update(): void;
  32116. /**
  32117. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32118. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32119. */
  32120. updateTexture(isVisible: boolean): void;
  32121. protected _updateInternalTexture: () => void;
  32122. /**
  32123. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32124. * @param url New url.
  32125. */
  32126. updateURL(url: string): void;
  32127. /**
  32128. * Clones the texture.
  32129. * @returns the cloned texture
  32130. */
  32131. clone(): VideoTexture;
  32132. /**
  32133. * Dispose the texture and release its associated resources.
  32134. */
  32135. dispose(): void;
  32136. /**
  32137. * Creates a video texture straight from a stream.
  32138. * @param scene Define the scene the texture should be created in
  32139. * @param stream Define the stream the texture should be created from
  32140. * @returns The created video texture as a promise
  32141. */
  32142. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32143. /**
  32144. * Creates a video texture straight from your WebCam video feed.
  32145. * @param scene Define the scene the texture should be created in
  32146. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32147. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32148. * @returns The created video texture as a promise
  32149. */
  32150. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32151. minWidth: number;
  32152. maxWidth: number;
  32153. minHeight: number;
  32154. maxHeight: number;
  32155. deviceId: string;
  32156. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32157. /**
  32158. * Creates a video texture straight from your WebCam video feed.
  32159. * @param scene Define the scene the texture should be created in
  32160. * @param onReady Define a callback to triggered once the texture will be ready
  32161. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32162. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32163. */
  32164. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32165. minWidth: number;
  32166. maxWidth: number;
  32167. minHeight: number;
  32168. maxHeight: number;
  32169. deviceId: string;
  32170. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32171. }
  32172. }
  32173. declare module "babylonjs/Engines/thinEngine" {
  32174. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32175. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32176. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32177. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32178. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32179. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32180. import { Observable } from "babylonjs/Misc/observable";
  32181. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32182. import { StencilState } from "babylonjs/States/stencilState";
  32183. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32185. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32186. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32187. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32188. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32189. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32190. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32191. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32193. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32194. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32195. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32196. import { WebRequest } from "babylonjs/Misc/webRequest";
  32197. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32198. /**
  32199. * Defines the interface used by objects working like Scene
  32200. * @hidden
  32201. */
  32202. export interface ISceneLike {
  32203. _addPendingData(data: any): void;
  32204. _removePendingData(data: any): void;
  32205. offlineProvider: IOfflineProvider;
  32206. }
  32207. /** Interface defining initialization parameters for Engine class */
  32208. export interface EngineOptions extends WebGLContextAttributes {
  32209. /**
  32210. * Defines if the engine should no exceed a specified device ratio
  32211. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32212. */
  32213. limitDeviceRatio?: number;
  32214. /**
  32215. * Defines if webvr should be enabled automatically
  32216. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32217. */
  32218. autoEnableWebVR?: boolean;
  32219. /**
  32220. * Defines if webgl2 should be turned off even if supported
  32221. * @see http://doc.babylonjs.com/features/webgl2
  32222. */
  32223. disableWebGL2Support?: boolean;
  32224. /**
  32225. * Defines if webaudio should be initialized as well
  32226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32227. */
  32228. audioEngine?: boolean;
  32229. /**
  32230. * Defines if animations should run using a deterministic lock step
  32231. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32232. */
  32233. deterministicLockstep?: boolean;
  32234. /** Defines the maximum steps to use with deterministic lock step mode */
  32235. lockstepMaxSteps?: number;
  32236. /** Defines the seconds between each deterministic lock step */
  32237. timeStep?: number;
  32238. /**
  32239. * Defines that engine should ignore context lost events
  32240. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32241. */
  32242. doNotHandleContextLost?: boolean;
  32243. /**
  32244. * Defines that engine should ignore modifying touch action attribute and style
  32245. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32246. */
  32247. doNotHandleTouchAction?: boolean;
  32248. /**
  32249. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32250. */
  32251. useHighPrecisionFloats?: boolean;
  32252. }
  32253. /**
  32254. * The base engine class (root of all engines)
  32255. */
  32256. export class ThinEngine {
  32257. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32258. static ExceptionList: ({
  32259. key: string;
  32260. capture: string;
  32261. captureConstraint: number;
  32262. targets: string[];
  32263. } | {
  32264. key: string;
  32265. capture: null;
  32266. captureConstraint: null;
  32267. targets: string[];
  32268. })[];
  32269. /** @hidden */
  32270. static _TextureLoaders: IInternalTextureLoader[];
  32271. /**
  32272. * Returns the current npm package of the sdk
  32273. */
  32274. static get NpmPackage(): string;
  32275. /**
  32276. * Returns the current version of the framework
  32277. */
  32278. static get Version(): string;
  32279. /**
  32280. * Returns a string describing the current engine
  32281. */
  32282. get description(): string;
  32283. /**
  32284. * Gets or sets the epsilon value used by collision engine
  32285. */
  32286. static CollisionsEpsilon: number;
  32287. /**
  32288. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32289. */
  32290. static get ShadersRepository(): string;
  32291. static set ShadersRepository(value: string);
  32292. /** @hidden */
  32293. _shaderProcessor: IShaderProcessor;
  32294. /**
  32295. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32296. */
  32297. forcePOTTextures: boolean;
  32298. /**
  32299. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32300. */
  32301. isFullscreen: boolean;
  32302. /**
  32303. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32304. */
  32305. cullBackFaces: boolean;
  32306. /**
  32307. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32308. */
  32309. renderEvenInBackground: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating that cache can be kept between frames
  32312. */
  32313. preventCacheWipeBetweenFrames: boolean;
  32314. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32315. validateShaderPrograms: boolean;
  32316. /**
  32317. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32318. * This can provide greater z depth for distant objects.
  32319. */
  32320. useReverseDepthBuffer: boolean;
  32321. /**
  32322. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32323. */
  32324. disableUniformBuffers: boolean;
  32325. /** @hidden */
  32326. _uniformBuffers: UniformBuffer[];
  32327. /**
  32328. * Gets a boolean indicating that the engine supports uniform buffers
  32329. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32330. */
  32331. get supportsUniformBuffers(): boolean;
  32332. /** @hidden */
  32333. _gl: WebGLRenderingContext;
  32334. /** @hidden */
  32335. _webGLVersion: number;
  32336. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32337. protected _windowIsBackground: boolean;
  32338. protected _creationOptions: EngineOptions;
  32339. protected _highPrecisionShadersAllowed: boolean;
  32340. /** @hidden */
  32341. get _shouldUseHighPrecisionShader(): boolean;
  32342. /**
  32343. * Gets a boolean indicating that only power of 2 textures are supported
  32344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32345. */
  32346. get needPOTTextures(): boolean;
  32347. /** @hidden */
  32348. _badOS: boolean;
  32349. /** @hidden */
  32350. _badDesktopOS: boolean;
  32351. private _hardwareScalingLevel;
  32352. /** @hidden */
  32353. _caps: EngineCapabilities;
  32354. private _isStencilEnable;
  32355. private _glVersion;
  32356. private _glRenderer;
  32357. private _glVendor;
  32358. /** @hidden */
  32359. _videoTextureSupported: boolean;
  32360. protected _renderingQueueLaunched: boolean;
  32361. protected _activeRenderLoops: (() => void)[];
  32362. /**
  32363. * Observable signaled when a context lost event is raised
  32364. */
  32365. onContextLostObservable: Observable<ThinEngine>;
  32366. /**
  32367. * Observable signaled when a context restored event is raised
  32368. */
  32369. onContextRestoredObservable: Observable<ThinEngine>;
  32370. private _onContextLost;
  32371. private _onContextRestored;
  32372. protected _contextWasLost: boolean;
  32373. /** @hidden */
  32374. _doNotHandleContextLost: boolean;
  32375. /**
  32376. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32378. */
  32379. get doNotHandleContextLost(): boolean;
  32380. set doNotHandleContextLost(value: boolean);
  32381. /**
  32382. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32383. */
  32384. disableVertexArrayObjects: boolean;
  32385. /** @hidden */
  32386. protected _colorWrite: boolean;
  32387. /** @hidden */
  32388. protected _colorWriteChanged: boolean;
  32389. /** @hidden */
  32390. protected _depthCullingState: DepthCullingState;
  32391. /** @hidden */
  32392. protected _stencilState: StencilState;
  32393. /** @hidden */
  32394. _alphaState: AlphaState;
  32395. /** @hidden */
  32396. _alphaMode: number;
  32397. /** @hidden */
  32398. _alphaEquation: number;
  32399. /** @hidden */
  32400. _internalTexturesCache: InternalTexture[];
  32401. /** @hidden */
  32402. protected _activeChannel: number;
  32403. private _currentTextureChannel;
  32404. /** @hidden */
  32405. protected _boundTexturesCache: {
  32406. [key: string]: Nullable<InternalTexture>;
  32407. };
  32408. /** @hidden */
  32409. protected _currentEffect: Nullable<Effect>;
  32410. /** @hidden */
  32411. protected _currentProgram: Nullable<WebGLProgram>;
  32412. private _compiledEffects;
  32413. private _vertexAttribArraysEnabled;
  32414. /** @hidden */
  32415. protected _cachedViewport: Nullable<IViewportLike>;
  32416. private _cachedVertexArrayObject;
  32417. /** @hidden */
  32418. protected _cachedVertexBuffers: any;
  32419. /** @hidden */
  32420. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32421. /** @hidden */
  32422. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32423. /** @hidden */
  32424. _currentRenderTarget: Nullable<InternalTexture>;
  32425. private _uintIndicesCurrentlySet;
  32426. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32427. /** @hidden */
  32428. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32429. private _currentBufferPointers;
  32430. private _currentInstanceLocations;
  32431. private _currentInstanceBuffers;
  32432. private _textureUnits;
  32433. /** @hidden */
  32434. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32435. /** @hidden */
  32436. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32437. /** @hidden */
  32438. _boundRenderFunction: any;
  32439. private _vaoRecordInProgress;
  32440. private _mustWipeVertexAttributes;
  32441. private _emptyTexture;
  32442. private _emptyCubeTexture;
  32443. private _emptyTexture3D;
  32444. private _emptyTexture2DArray;
  32445. /** @hidden */
  32446. _frameHandler: number;
  32447. private _nextFreeTextureSlots;
  32448. private _maxSimultaneousTextures;
  32449. private _activeRequests;
  32450. /** @hidden */
  32451. _transformTextureUrl: Nullable<(url: string) => string>;
  32452. protected get _supportsHardwareTextureRescaling(): boolean;
  32453. private _framebufferDimensionsObject;
  32454. /**
  32455. * sets the object from which width and height will be taken from when getting render width and height
  32456. * Will fallback to the gl object
  32457. * @param dimensions the framebuffer width and height that will be used.
  32458. */
  32459. set framebufferDimensionsObject(dimensions: Nullable<{
  32460. framebufferWidth: number;
  32461. framebufferHeight: number;
  32462. }>);
  32463. /**
  32464. * Gets the current viewport
  32465. */
  32466. get currentViewport(): Nullable<IViewportLike>;
  32467. /**
  32468. * Gets the default empty texture
  32469. */
  32470. get emptyTexture(): InternalTexture;
  32471. /**
  32472. * Gets the default empty 3D texture
  32473. */
  32474. get emptyTexture3D(): InternalTexture;
  32475. /**
  32476. * Gets the default empty 2D array texture
  32477. */
  32478. get emptyTexture2DArray(): InternalTexture;
  32479. /**
  32480. * Gets the default empty cube texture
  32481. */
  32482. get emptyCubeTexture(): InternalTexture;
  32483. /**
  32484. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32485. */
  32486. readonly premultipliedAlpha: boolean;
  32487. /**
  32488. * Observable event triggered before each texture is initialized
  32489. */
  32490. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32491. /**
  32492. * Creates a new engine
  32493. * @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
  32494. * @param antialias defines enable antialiasing (default: false)
  32495. * @param options defines further options to be sent to the getContext() function
  32496. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32497. */
  32498. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32499. private _rebuildInternalTextures;
  32500. private _rebuildEffects;
  32501. /**
  32502. * Gets a boolean indicating if all created effects are ready
  32503. * @returns true if all effects are ready
  32504. */
  32505. areAllEffectsReady(): boolean;
  32506. protected _rebuildBuffers(): void;
  32507. protected _initGLContext(): void;
  32508. /**
  32509. * Gets version of the current webGL context
  32510. */
  32511. get webGLVersion(): number;
  32512. /**
  32513. * Gets a string idenfifying the name of the class
  32514. * @returns "Engine" string
  32515. */
  32516. getClassName(): string;
  32517. /**
  32518. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32519. */
  32520. get isStencilEnable(): boolean;
  32521. /** @hidden */
  32522. _prepareWorkingCanvas(): void;
  32523. /**
  32524. * Reset the texture cache to empty state
  32525. */
  32526. resetTextureCache(): void;
  32527. /**
  32528. * Gets an object containing information about the current webGL context
  32529. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32530. */
  32531. getGlInfo(): {
  32532. vendor: string;
  32533. renderer: string;
  32534. version: string;
  32535. };
  32536. /**
  32537. * Defines the hardware scaling level.
  32538. * By default the hardware scaling level is computed from the window device ratio.
  32539. * 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.
  32540. * @param level defines the level to use
  32541. */
  32542. setHardwareScalingLevel(level: number): void;
  32543. /**
  32544. * Gets the current hardware scaling level.
  32545. * By default the hardware scaling level is computed from the window device ratio.
  32546. * 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.
  32547. * @returns a number indicating the current hardware scaling level
  32548. */
  32549. getHardwareScalingLevel(): number;
  32550. /**
  32551. * Gets the list of loaded textures
  32552. * @returns an array containing all loaded textures
  32553. */
  32554. getLoadedTexturesCache(): InternalTexture[];
  32555. /**
  32556. * Gets the object containing all engine capabilities
  32557. * @returns the EngineCapabilities object
  32558. */
  32559. getCaps(): EngineCapabilities;
  32560. /**
  32561. * stop executing a render loop function and remove it from the execution array
  32562. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32563. */
  32564. stopRenderLoop(renderFunction?: () => void): void;
  32565. /** @hidden */
  32566. _renderLoop(): void;
  32567. /**
  32568. * Gets the HTML canvas attached with the current webGL context
  32569. * @returns a HTML canvas
  32570. */
  32571. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32572. /**
  32573. * Gets host window
  32574. * @returns the host window object
  32575. */
  32576. getHostWindow(): Nullable<Window>;
  32577. /**
  32578. * Gets the current render width
  32579. * @param useScreen defines if screen size must be used (or the current render target if any)
  32580. * @returns a number defining the current render width
  32581. */
  32582. getRenderWidth(useScreen?: boolean): number;
  32583. /**
  32584. * Gets the current render height
  32585. * @param useScreen defines if screen size must be used (or the current render target if any)
  32586. * @returns a number defining the current render height
  32587. */
  32588. getRenderHeight(useScreen?: boolean): number;
  32589. /**
  32590. * Can be used to override the current requestAnimationFrame requester.
  32591. * @hidden
  32592. */
  32593. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32594. /**
  32595. * Register and execute a render loop. The engine can have more than one render function
  32596. * @param renderFunction defines the function to continuously execute
  32597. */
  32598. runRenderLoop(renderFunction: () => void): void;
  32599. /**
  32600. * Clear the current render buffer or the current render target (if any is set up)
  32601. * @param color defines the color to use
  32602. * @param backBuffer defines if the back buffer must be cleared
  32603. * @param depth defines if the depth buffer must be cleared
  32604. * @param stencil defines if the stencil buffer must be cleared
  32605. */
  32606. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32607. private _viewportCached;
  32608. /** @hidden */
  32609. _viewport(x: number, y: number, width: number, height: number): void;
  32610. /**
  32611. * Set the WebGL's viewport
  32612. * @param viewport defines the viewport element to be used
  32613. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32614. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32615. */
  32616. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32617. /**
  32618. * Begin a new frame
  32619. */
  32620. beginFrame(): void;
  32621. /**
  32622. * Enf the current frame
  32623. */
  32624. endFrame(): void;
  32625. /**
  32626. * Resize the view according to the canvas' size
  32627. */
  32628. resize(): void;
  32629. /**
  32630. * Force a specific size of the canvas
  32631. * @param width defines the new canvas' width
  32632. * @param height defines the new canvas' height
  32633. */
  32634. setSize(width: number, height: number): void;
  32635. /**
  32636. * Binds the frame buffer to the specified texture.
  32637. * @param texture The texture to render to or null for the default canvas
  32638. * @param faceIndex The face of the texture to render to in case of cube texture
  32639. * @param requiredWidth The width of the target to render to
  32640. * @param requiredHeight The height of the target to render to
  32641. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32642. * @param lodLevel defines the lod level to bind to the frame buffer
  32643. * @param layer defines the 2d array index to bind to frame buffer to
  32644. */
  32645. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32646. /** @hidden */
  32647. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32648. /**
  32649. * Unbind the current render target texture from the webGL context
  32650. * @param texture defines the render target texture to unbind
  32651. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32652. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32653. */
  32654. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32655. /**
  32656. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32657. */
  32658. flushFramebuffer(): void;
  32659. /**
  32660. * Unbind the current render target and bind the default framebuffer
  32661. */
  32662. restoreDefaultFramebuffer(): void;
  32663. /** @hidden */
  32664. protected _resetVertexBufferBinding(): void;
  32665. /**
  32666. * Creates a vertex buffer
  32667. * @param data the data for the vertex buffer
  32668. * @returns the new WebGL static buffer
  32669. */
  32670. createVertexBuffer(data: DataArray): DataBuffer;
  32671. private _createVertexBuffer;
  32672. /**
  32673. * Creates a dynamic vertex buffer
  32674. * @param data the data for the dynamic vertex buffer
  32675. * @returns the new WebGL dynamic buffer
  32676. */
  32677. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32678. protected _resetIndexBufferBinding(): void;
  32679. /**
  32680. * Creates a new index buffer
  32681. * @param indices defines the content of the index buffer
  32682. * @param updatable defines if the index buffer must be updatable
  32683. * @returns a new webGL buffer
  32684. */
  32685. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32686. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32687. /**
  32688. * Bind a webGL buffer to the webGL context
  32689. * @param buffer defines the buffer to bind
  32690. */
  32691. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32692. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32693. private bindBuffer;
  32694. /**
  32695. * update the bound buffer with the given data
  32696. * @param data defines the data to update
  32697. */
  32698. updateArrayBuffer(data: Float32Array): void;
  32699. private _vertexAttribPointer;
  32700. /** @hidden */
  32701. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32702. private _bindVertexBuffersAttributes;
  32703. /**
  32704. * Records a vertex array object
  32705. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32706. * @param vertexBuffers defines the list of vertex buffers to store
  32707. * @param indexBuffer defines the index buffer to store
  32708. * @param effect defines the effect to store
  32709. * @returns the new vertex array object
  32710. */
  32711. recordVertexArrayObject(vertexBuffers: {
  32712. [key: string]: VertexBuffer;
  32713. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32714. /**
  32715. * Bind a specific vertex array object
  32716. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32717. * @param vertexArrayObject defines the vertex array object to bind
  32718. * @param indexBuffer defines the index buffer to bind
  32719. */
  32720. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32721. /**
  32722. * Bind webGl buffers directly to the webGL context
  32723. * @param vertexBuffer defines the vertex buffer to bind
  32724. * @param indexBuffer defines the index buffer to bind
  32725. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32726. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32727. * @param effect defines the effect associated with the vertex buffer
  32728. */
  32729. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32730. private _unbindVertexArrayObject;
  32731. /**
  32732. * Bind a list of vertex buffers to the webGL context
  32733. * @param vertexBuffers defines the list of vertex buffers to bind
  32734. * @param indexBuffer defines the index buffer to bind
  32735. * @param effect defines the effect associated with the vertex buffers
  32736. */
  32737. bindBuffers(vertexBuffers: {
  32738. [key: string]: Nullable<VertexBuffer>;
  32739. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32740. /**
  32741. * Unbind all instance attributes
  32742. */
  32743. unbindInstanceAttributes(): void;
  32744. /**
  32745. * Release and free the memory of a vertex array object
  32746. * @param vao defines the vertex array object to delete
  32747. */
  32748. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32749. /** @hidden */
  32750. _releaseBuffer(buffer: DataBuffer): boolean;
  32751. protected _deleteBuffer(buffer: DataBuffer): void;
  32752. /**
  32753. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32754. * @param instancesBuffer defines the webGL buffer to update and bind
  32755. * @param data defines the data to store in the buffer
  32756. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32757. */
  32758. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32759. /**
  32760. * Bind the content of a webGL buffer used with instantiation
  32761. * @param instancesBuffer defines the webGL buffer to bind
  32762. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32763. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32764. */
  32765. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32766. /**
  32767. * Disable the instance attribute corresponding to the name in parameter
  32768. * @param name defines the name of the attribute to disable
  32769. */
  32770. disableInstanceAttributeByName(name: string): void;
  32771. /**
  32772. * Disable the instance attribute corresponding to the location in parameter
  32773. * @param attributeLocation defines the attribute location of the attribute to disable
  32774. */
  32775. disableInstanceAttribute(attributeLocation: number): void;
  32776. /**
  32777. * Disable the attribute corresponding to the location in parameter
  32778. * @param attributeLocation defines the attribute location of the attribute to disable
  32779. */
  32780. disableAttributeByIndex(attributeLocation: number): void;
  32781. /**
  32782. * Send a draw order
  32783. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32784. * @param indexStart defines the starting index
  32785. * @param indexCount defines the number of index to draw
  32786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32787. */
  32788. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32789. /**
  32790. * Draw a list of points
  32791. * @param verticesStart defines the index of first vertex to draw
  32792. * @param verticesCount defines the count of vertices to draw
  32793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32794. */
  32795. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32796. /**
  32797. * Draw a list of unindexed primitives
  32798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32799. * @param verticesStart defines the index of first vertex to draw
  32800. * @param verticesCount defines the count of vertices to draw
  32801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32802. */
  32803. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32804. /**
  32805. * Draw a list of indexed primitives
  32806. * @param fillMode defines the primitive to use
  32807. * @param indexStart defines the starting index
  32808. * @param indexCount defines the number of index to draw
  32809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32810. */
  32811. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32812. /**
  32813. * Draw a list of unindexed primitives
  32814. * @param fillMode defines the primitive to use
  32815. * @param verticesStart defines the index of first vertex to draw
  32816. * @param verticesCount defines the count of vertices to draw
  32817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32818. */
  32819. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32820. private _drawMode;
  32821. /** @hidden */
  32822. protected _reportDrawCall(): void;
  32823. /** @hidden */
  32824. _releaseEffect(effect: Effect): void;
  32825. /** @hidden */
  32826. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32827. /**
  32828. * Create a new effect (used to store vertex/fragment shaders)
  32829. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32830. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32831. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32832. * @param samplers defines an array of string used to represent textures
  32833. * @param defines defines the string containing the defines to use to compile the shaders
  32834. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32835. * @param onCompiled defines a function to call when the effect creation is successful
  32836. * @param onError defines a function to call when the effect creation has failed
  32837. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32838. * @returns the new Effect
  32839. */
  32840. 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;
  32841. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32842. private _compileShader;
  32843. private _compileRawShader;
  32844. /** @hidden */
  32845. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32846. /**
  32847. * Directly creates a webGL program
  32848. * @param pipelineContext defines the pipeline context to attach to
  32849. * @param vertexCode defines the vertex shader code to use
  32850. * @param fragmentCode defines the fragment shader code to use
  32851. * @param context defines the webGL context to use (if not set, the current one will be used)
  32852. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32853. * @returns the new webGL program
  32854. */
  32855. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32856. /**
  32857. * Creates a webGL program
  32858. * @param pipelineContext defines the pipeline context to attach to
  32859. * @param vertexCode defines the vertex shader code to use
  32860. * @param fragmentCode defines the fragment shader code to use
  32861. * @param defines defines the string containing the defines to use to compile the shaders
  32862. * @param context defines the webGL context to use (if not set, the current one will be used)
  32863. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32864. * @returns the new webGL program
  32865. */
  32866. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32867. /**
  32868. * Creates a new pipeline context
  32869. * @returns the new pipeline
  32870. */
  32871. createPipelineContext(): IPipelineContext;
  32872. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32873. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32874. /** @hidden */
  32875. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32876. /** @hidden */
  32877. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32878. /** @hidden */
  32879. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32880. /**
  32881. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32882. * @param pipelineContext defines the pipeline context to use
  32883. * @param uniformsNames defines the list of uniform names
  32884. * @returns an array of webGL uniform locations
  32885. */
  32886. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32887. /**
  32888. * Gets the lsit of active attributes for a given webGL program
  32889. * @param pipelineContext defines the pipeline context to use
  32890. * @param attributesNames defines the list of attribute names to get
  32891. * @returns an array of indices indicating the offset of each attribute
  32892. */
  32893. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32894. /**
  32895. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32896. * @param effect defines the effect to activate
  32897. */
  32898. enableEffect(effect: Nullable<Effect>): void;
  32899. /**
  32900. * Set the value of an uniform to a number (int)
  32901. * @param uniform defines the webGL uniform location where to store the value
  32902. * @param value defines the int number to store
  32903. */
  32904. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32905. /**
  32906. * Set the value of an uniform to an array of int32
  32907. * @param uniform defines the webGL uniform location where to store the value
  32908. * @param array defines the array of int32 to store
  32909. */
  32910. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32911. /**
  32912. * Set the value of an uniform to an array of int32 (stored as vec2)
  32913. * @param uniform defines the webGL uniform location where to store the value
  32914. * @param array defines the array of int32 to store
  32915. */
  32916. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32917. /**
  32918. * Set the value of an uniform to an array of int32 (stored as vec3)
  32919. * @param uniform defines the webGL uniform location where to store the value
  32920. * @param array defines the array of int32 to store
  32921. */
  32922. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32923. /**
  32924. * Set the value of an uniform to an array of int32 (stored as vec4)
  32925. * @param uniform defines the webGL uniform location where to store the value
  32926. * @param array defines the array of int32 to store
  32927. */
  32928. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32929. /**
  32930. * Set the value of an uniform to an array of number
  32931. * @param uniform defines the webGL uniform location where to store the value
  32932. * @param array defines the array of number to store
  32933. */
  32934. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32935. /**
  32936. * Set the value of an uniform to an array of number (stored as vec2)
  32937. * @param uniform defines the webGL uniform location where to store the value
  32938. * @param array defines the array of number to store
  32939. */
  32940. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32941. /**
  32942. * Set the value of an uniform to an array of number (stored as vec3)
  32943. * @param uniform defines the webGL uniform location where to store the value
  32944. * @param array defines the array of number to store
  32945. */
  32946. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32947. /**
  32948. * Set the value of an uniform to an array of number (stored as vec4)
  32949. * @param uniform defines the webGL uniform location where to store the value
  32950. * @param array defines the array of number to store
  32951. */
  32952. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32953. /**
  32954. * Set the value of an uniform to an array of float32 (stored as matrices)
  32955. * @param uniform defines the webGL uniform location where to store the value
  32956. * @param matrices defines the array of float32 to store
  32957. */
  32958. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32959. /**
  32960. * Set the value of an uniform to a matrix (3x3)
  32961. * @param uniform defines the webGL uniform location where to store the value
  32962. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32963. */
  32964. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32965. /**
  32966. * Set the value of an uniform to a matrix (2x2)
  32967. * @param uniform defines the webGL uniform location where to store the value
  32968. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32969. */
  32970. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32971. /**
  32972. * Set the value of an uniform to a number (float)
  32973. * @param uniform defines the webGL uniform location where to store the value
  32974. * @param value defines the float number to store
  32975. */
  32976. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32977. /**
  32978. * Set the value of an uniform to a vec2
  32979. * @param uniform defines the webGL uniform location where to store the value
  32980. * @param x defines the 1st component of the value
  32981. * @param y defines the 2nd component of the value
  32982. */
  32983. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32984. /**
  32985. * Set the value of an uniform to a vec3
  32986. * @param uniform defines the webGL uniform location where to store the value
  32987. * @param x defines the 1st component of the value
  32988. * @param y defines the 2nd component of the value
  32989. * @param z defines the 3rd component of the value
  32990. */
  32991. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32992. /**
  32993. * Set the value of an uniform to a vec4
  32994. * @param uniform defines the webGL uniform location where to store the value
  32995. * @param x defines the 1st component of the value
  32996. * @param y defines the 2nd component of the value
  32997. * @param z defines the 3rd component of the value
  32998. * @param w defines the 4th component of the value
  32999. */
  33000. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33001. /**
  33002. * Apply all cached states (depth, culling, stencil and alpha)
  33003. */
  33004. applyStates(): void;
  33005. /**
  33006. * Enable or disable color writing
  33007. * @param enable defines the state to set
  33008. */
  33009. setColorWrite(enable: boolean): void;
  33010. /**
  33011. * Gets a boolean indicating if color writing is enabled
  33012. * @returns the current color writing state
  33013. */
  33014. getColorWrite(): boolean;
  33015. /**
  33016. * Gets the depth culling state manager
  33017. */
  33018. get depthCullingState(): DepthCullingState;
  33019. /**
  33020. * Gets the alpha state manager
  33021. */
  33022. get alphaState(): AlphaState;
  33023. /**
  33024. * Gets the stencil state manager
  33025. */
  33026. get stencilState(): StencilState;
  33027. /**
  33028. * Clears the list of texture accessible through engine.
  33029. * This can help preventing texture load conflict due to name collision.
  33030. */
  33031. clearInternalTexturesCache(): void;
  33032. /**
  33033. * Force the entire cache to be cleared
  33034. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33035. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33036. */
  33037. wipeCaches(bruteForce?: boolean): void;
  33038. /** @hidden */
  33039. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33040. min: number;
  33041. mag: number;
  33042. };
  33043. /** @hidden */
  33044. _createTexture(): WebGLTexture;
  33045. /**
  33046. * Usually called from Texture.ts.
  33047. * Passed information to create a WebGLTexture
  33048. * @param url defines a value which contains one of the following:
  33049. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33050. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33051. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33052. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33053. * @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)
  33054. * @param scene needed for loading to the correct scene
  33055. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33056. * @param onLoad optional callback to be called upon successful completion
  33057. * @param onError optional callback to be called upon failure
  33058. * @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
  33059. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33060. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33061. * @param forcedExtension defines the extension to use to pick the right loader
  33062. * @param mimeType defines an optional mime type
  33063. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33064. */
  33065. 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;
  33066. /**
  33067. * Loads an image as an HTMLImageElement.
  33068. * @param input url string, ArrayBuffer, or Blob to load
  33069. * @param onLoad callback called when the image successfully loads
  33070. * @param onError callback called when the image fails to load
  33071. * @param offlineProvider offline provider for caching
  33072. * @param mimeType optional mime type
  33073. * @returns the HTMLImageElement of the loaded image
  33074. * @hidden
  33075. */
  33076. 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>;
  33077. /**
  33078. * @hidden
  33079. */
  33080. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33081. /**
  33082. * Creates a raw texture
  33083. * @param data defines the data to store in the texture
  33084. * @param width defines the width of the texture
  33085. * @param height defines the height of the texture
  33086. * @param format defines the format of the data
  33087. * @param generateMipMaps defines if the engine should generate the mip levels
  33088. * @param invertY defines if data must be stored with Y axis inverted
  33089. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33090. * @param compression defines the compression used (null by default)
  33091. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33092. * @returns the raw texture inside an InternalTexture
  33093. */
  33094. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33095. /**
  33096. * Creates a new raw cube texture
  33097. * @param data defines the array of data to use to create each face
  33098. * @param size defines the size of the textures
  33099. * @param format defines the format of the data
  33100. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33101. * @param generateMipMaps defines if the engine should generate the mip levels
  33102. * @param invertY defines if data must be stored with Y axis inverted
  33103. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33104. * @param compression defines the compression used (null by default)
  33105. * @returns the cube texture as an InternalTexture
  33106. */
  33107. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33108. /**
  33109. * Creates a new raw 3D texture
  33110. * @param data defines the data used to create the texture
  33111. * @param width defines the width of the texture
  33112. * @param height defines the height of the texture
  33113. * @param depth defines the depth of the texture
  33114. * @param format defines the format of the texture
  33115. * @param generateMipMaps defines if the engine must generate mip levels
  33116. * @param invertY defines if data must be stored with Y axis inverted
  33117. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33118. * @param compression defines the compressed used (can be null)
  33119. * @param textureType defines the compressed used (can be null)
  33120. * @returns a new raw 3D texture (stored in an InternalTexture)
  33121. */
  33122. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33123. /**
  33124. * Creates a new raw 2D array texture
  33125. * @param data defines the data used to create the texture
  33126. * @param width defines the width of the texture
  33127. * @param height defines the height of the texture
  33128. * @param depth defines the number of layers of the texture
  33129. * @param format defines the format of the texture
  33130. * @param generateMipMaps defines if the engine must generate mip levels
  33131. * @param invertY defines if data must be stored with Y axis inverted
  33132. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33133. * @param compression defines the compressed used (can be null)
  33134. * @param textureType defines the compressed used (can be null)
  33135. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33136. */
  33137. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33138. private _unpackFlipYCached;
  33139. /**
  33140. * In case you are sharing the context with other applications, it might
  33141. * be interested to not cache the unpack flip y state to ensure a consistent
  33142. * value would be set.
  33143. */
  33144. enableUnpackFlipYCached: boolean;
  33145. /** @hidden */
  33146. _unpackFlipY(value: boolean): void;
  33147. /** @hidden */
  33148. _getUnpackAlignement(): number;
  33149. private _getTextureTarget;
  33150. /**
  33151. * Update the sampling mode of a given texture
  33152. * @param samplingMode defines the required sampling mode
  33153. * @param texture defines the texture to update
  33154. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33155. */
  33156. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33157. /**
  33158. * Update the sampling mode of a given texture
  33159. * @param texture defines the texture to update
  33160. * @param wrapU defines the texture wrap mode of the u coordinates
  33161. * @param wrapV defines the texture wrap mode of the v coordinates
  33162. * @param wrapR defines the texture wrap mode of the r coordinates
  33163. */
  33164. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33165. /** @hidden */
  33166. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33167. width: number;
  33168. height: number;
  33169. layers?: number;
  33170. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33171. /** @hidden */
  33172. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33173. /** @hidden */
  33174. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33175. /**
  33176. * Update a portion of an internal texture
  33177. * @param texture defines the texture to update
  33178. * @param imageData defines the data to store into the texture
  33179. * @param xOffset defines the x coordinates of the update rectangle
  33180. * @param yOffset defines the y coordinates of the update rectangle
  33181. * @param width defines the width of the update rectangle
  33182. * @param height defines the height of the update rectangle
  33183. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33184. * @param lod defines the lod level to update (0 by default)
  33185. */
  33186. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33187. /** @hidden */
  33188. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33189. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33190. private _prepareWebGLTexture;
  33191. /** @hidden */
  33192. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33193. private _getDepthStencilBuffer;
  33194. /** @hidden */
  33195. _releaseFramebufferObjects(texture: InternalTexture): void;
  33196. /** @hidden */
  33197. _releaseTexture(texture: InternalTexture): void;
  33198. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33199. protected _setProgram(program: WebGLProgram): void;
  33200. protected _boundUniforms: {
  33201. [key: number]: WebGLUniformLocation;
  33202. };
  33203. /**
  33204. * Binds an effect to the webGL context
  33205. * @param effect defines the effect to bind
  33206. */
  33207. bindSamplers(effect: Effect): void;
  33208. private _activateCurrentTexture;
  33209. /** @hidden */
  33210. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33211. /** @hidden */
  33212. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33213. /**
  33214. * Unbind all textures from the webGL context
  33215. */
  33216. unbindAllTextures(): void;
  33217. /**
  33218. * Sets a texture to the according uniform.
  33219. * @param channel The texture channel
  33220. * @param uniform The uniform to set
  33221. * @param texture The texture to apply
  33222. */
  33223. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33224. private _bindSamplerUniformToChannel;
  33225. private _getTextureWrapMode;
  33226. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33227. /**
  33228. * Sets an array of texture to the webGL context
  33229. * @param channel defines the channel where the texture array must be set
  33230. * @param uniform defines the associated uniform location
  33231. * @param textures defines the array of textures to bind
  33232. */
  33233. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33234. /** @hidden */
  33235. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33236. private _setTextureParameterFloat;
  33237. private _setTextureParameterInteger;
  33238. /**
  33239. * Unbind all vertex attributes from the webGL context
  33240. */
  33241. unbindAllAttributes(): void;
  33242. /**
  33243. * 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
  33244. */
  33245. releaseEffects(): void;
  33246. /**
  33247. * Dispose and release all associated resources
  33248. */
  33249. dispose(): void;
  33250. /**
  33251. * Attach a new callback raised when context lost event is fired
  33252. * @param callback defines the callback to call
  33253. */
  33254. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33255. /**
  33256. * Attach a new callback raised when context restored event is fired
  33257. * @param callback defines the callback to call
  33258. */
  33259. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33260. /**
  33261. * Get the current error code of the webGL context
  33262. * @returns the error code
  33263. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33264. */
  33265. getError(): number;
  33266. private _canRenderToFloatFramebuffer;
  33267. private _canRenderToHalfFloatFramebuffer;
  33268. private _canRenderToFramebuffer;
  33269. /** @hidden */
  33270. _getWebGLTextureType(type: number): number;
  33271. /** @hidden */
  33272. _getInternalFormat(format: number): number;
  33273. /** @hidden */
  33274. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33275. /** @hidden */
  33276. _getRGBAMultiSampleBufferFormat(type: number): number;
  33277. /** @hidden */
  33278. _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;
  33279. /**
  33280. * Loads a file from a url
  33281. * @param url url to load
  33282. * @param onSuccess callback called when the file successfully loads
  33283. * @param onProgress callback called while file is loading (if the server supports this mode)
  33284. * @param offlineProvider defines the offline provider for caching
  33285. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33286. * @param onError callback called when the file fails to load
  33287. * @returns a file request object
  33288. * @hidden
  33289. */
  33290. 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;
  33291. /**
  33292. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33293. * @param x defines the x coordinate of the rectangle where pixels must be read
  33294. * @param y defines the y coordinate of the rectangle where pixels must be read
  33295. * @param width defines the width of the rectangle where pixels must be read
  33296. * @param height defines the height of the rectangle where pixels must be read
  33297. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33298. * @returns a Uint8Array containing RGBA colors
  33299. */
  33300. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33301. private static _isSupported;
  33302. /**
  33303. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33304. * @returns true if the engine can be created
  33305. * @ignorenaming
  33306. */
  33307. static isSupported(): boolean;
  33308. /**
  33309. * Find the next highest power of two.
  33310. * @param x Number to start search from.
  33311. * @return Next highest power of two.
  33312. */
  33313. static CeilingPOT(x: number): number;
  33314. /**
  33315. * Find the next lowest power of two.
  33316. * @param x Number to start search from.
  33317. * @return Next lowest power of two.
  33318. */
  33319. static FloorPOT(x: number): number;
  33320. /**
  33321. * Find the nearest power of two.
  33322. * @param x Number to start search from.
  33323. * @return Next nearest power of two.
  33324. */
  33325. static NearestPOT(x: number): number;
  33326. /**
  33327. * Get the closest exponent of two
  33328. * @param value defines the value to approximate
  33329. * @param max defines the maximum value to return
  33330. * @param mode defines how to define the closest value
  33331. * @returns closest exponent of two of the given value
  33332. */
  33333. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33334. /**
  33335. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33336. * @param func - the function to be called
  33337. * @param requester - the object that will request the next frame. Falls back to window.
  33338. * @returns frame number
  33339. */
  33340. static QueueNewFrame(func: () => void, requester?: any): number;
  33341. /**
  33342. * Gets host document
  33343. * @returns the host document object
  33344. */
  33345. getHostDocument(): Nullable<Document>;
  33346. }
  33347. }
  33348. declare module "babylonjs/Maths/sphericalPolynomial" {
  33349. import { Vector3 } from "babylonjs/Maths/math.vector";
  33350. import { Color3 } from "babylonjs/Maths/math.color";
  33351. /**
  33352. * Class representing spherical harmonics coefficients to the 3rd degree
  33353. */
  33354. export class SphericalHarmonics {
  33355. /**
  33356. * Defines whether or not the harmonics have been prescaled for rendering.
  33357. */
  33358. preScaled: boolean;
  33359. /**
  33360. * The l0,0 coefficients of the spherical harmonics
  33361. */
  33362. l00: Vector3;
  33363. /**
  33364. * The l1,-1 coefficients of the spherical harmonics
  33365. */
  33366. l1_1: Vector3;
  33367. /**
  33368. * The l1,0 coefficients of the spherical harmonics
  33369. */
  33370. l10: Vector3;
  33371. /**
  33372. * The l1,1 coefficients of the spherical harmonics
  33373. */
  33374. l11: Vector3;
  33375. /**
  33376. * The l2,-2 coefficients of the spherical harmonics
  33377. */
  33378. l2_2: Vector3;
  33379. /**
  33380. * The l2,-1 coefficients of the spherical harmonics
  33381. */
  33382. l2_1: Vector3;
  33383. /**
  33384. * The l2,0 coefficients of the spherical harmonics
  33385. */
  33386. l20: Vector3;
  33387. /**
  33388. * The l2,1 coefficients of the spherical harmonics
  33389. */
  33390. l21: Vector3;
  33391. /**
  33392. * The l2,2 coefficients of the spherical harmonics
  33393. */
  33394. l22: Vector3;
  33395. /**
  33396. * Adds a light to the spherical harmonics
  33397. * @param direction the direction of the light
  33398. * @param color the color of the light
  33399. * @param deltaSolidAngle the delta solid angle of the light
  33400. */
  33401. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33402. /**
  33403. * Scales the spherical harmonics by the given amount
  33404. * @param scale the amount to scale
  33405. */
  33406. scaleInPlace(scale: number): void;
  33407. /**
  33408. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33409. *
  33410. * ```
  33411. * E_lm = A_l * L_lm
  33412. * ```
  33413. *
  33414. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33415. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33416. * the scaling factors are given in equation 9.
  33417. */
  33418. convertIncidentRadianceToIrradiance(): void;
  33419. /**
  33420. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33421. *
  33422. * ```
  33423. * L = (1/pi) * E * rho
  33424. * ```
  33425. *
  33426. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33427. */
  33428. convertIrradianceToLambertianRadiance(): void;
  33429. /**
  33430. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33431. * required operations at run time.
  33432. *
  33433. * This is simply done by scaling back the SH with Ylm constants parameter.
  33434. * The trigonometric part being applied by the shader at run time.
  33435. */
  33436. preScaleForRendering(): void;
  33437. /**
  33438. * Constructs a spherical harmonics from an array.
  33439. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33440. * @returns the spherical harmonics
  33441. */
  33442. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33443. /**
  33444. * Gets the spherical harmonics from polynomial
  33445. * @param polynomial the spherical polynomial
  33446. * @returns the spherical harmonics
  33447. */
  33448. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33449. }
  33450. /**
  33451. * Class representing spherical polynomial coefficients to the 3rd degree
  33452. */
  33453. export class SphericalPolynomial {
  33454. private _harmonics;
  33455. /**
  33456. * The spherical harmonics used to create the polynomials.
  33457. */
  33458. get preScaledHarmonics(): SphericalHarmonics;
  33459. /**
  33460. * The x coefficients of the spherical polynomial
  33461. */
  33462. x: Vector3;
  33463. /**
  33464. * The y coefficients of the spherical polynomial
  33465. */
  33466. y: Vector3;
  33467. /**
  33468. * The z coefficients of the spherical polynomial
  33469. */
  33470. z: Vector3;
  33471. /**
  33472. * The xx coefficients of the spherical polynomial
  33473. */
  33474. xx: Vector3;
  33475. /**
  33476. * The yy coefficients of the spherical polynomial
  33477. */
  33478. yy: Vector3;
  33479. /**
  33480. * The zz coefficients of the spherical polynomial
  33481. */
  33482. zz: Vector3;
  33483. /**
  33484. * The xy coefficients of the spherical polynomial
  33485. */
  33486. xy: Vector3;
  33487. /**
  33488. * The yz coefficients of the spherical polynomial
  33489. */
  33490. yz: Vector3;
  33491. /**
  33492. * The zx coefficients of the spherical polynomial
  33493. */
  33494. zx: Vector3;
  33495. /**
  33496. * Adds an ambient color to the spherical polynomial
  33497. * @param color the color to add
  33498. */
  33499. addAmbient(color: Color3): void;
  33500. /**
  33501. * Scales the spherical polynomial by the given amount
  33502. * @param scale the amount to scale
  33503. */
  33504. scaleInPlace(scale: number): void;
  33505. /**
  33506. * Gets the spherical polynomial from harmonics
  33507. * @param harmonics the spherical harmonics
  33508. * @returns the spherical polynomial
  33509. */
  33510. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33511. /**
  33512. * Constructs a spherical polynomial from an array.
  33513. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33514. * @returns the spherical polynomial
  33515. */
  33516. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33517. }
  33518. }
  33519. declare module "babylonjs/Materials/Textures/internalTexture" {
  33520. import { Observable } from "babylonjs/Misc/observable";
  33521. import { Nullable, int } from "babylonjs/types";
  33522. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33523. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33524. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33525. /**
  33526. * Defines the source of the internal texture
  33527. */
  33528. export enum InternalTextureSource {
  33529. /**
  33530. * The source of the texture data is unknown
  33531. */
  33532. Unknown = 0,
  33533. /**
  33534. * Texture data comes from an URL
  33535. */
  33536. Url = 1,
  33537. /**
  33538. * Texture data is only used for temporary storage
  33539. */
  33540. Temp = 2,
  33541. /**
  33542. * Texture data comes from raw data (ArrayBuffer)
  33543. */
  33544. Raw = 3,
  33545. /**
  33546. * Texture content is dynamic (video or dynamic texture)
  33547. */
  33548. Dynamic = 4,
  33549. /**
  33550. * Texture content is generated by rendering to it
  33551. */
  33552. RenderTarget = 5,
  33553. /**
  33554. * Texture content is part of a multi render target process
  33555. */
  33556. MultiRenderTarget = 6,
  33557. /**
  33558. * Texture data comes from a cube data file
  33559. */
  33560. Cube = 7,
  33561. /**
  33562. * Texture data comes from a raw cube data
  33563. */
  33564. CubeRaw = 8,
  33565. /**
  33566. * Texture data come from a prefiltered cube data file
  33567. */
  33568. CubePrefiltered = 9,
  33569. /**
  33570. * Texture content is raw 3D data
  33571. */
  33572. Raw3D = 10,
  33573. /**
  33574. * Texture content is raw 2D array data
  33575. */
  33576. Raw2DArray = 11,
  33577. /**
  33578. * Texture content is a depth texture
  33579. */
  33580. Depth = 12,
  33581. /**
  33582. * Texture data comes from a raw cube data encoded with RGBD
  33583. */
  33584. CubeRawRGBD = 13
  33585. }
  33586. /**
  33587. * Class used to store data associated with WebGL texture data for the engine
  33588. * This class should not be used directly
  33589. */
  33590. export class InternalTexture {
  33591. /** @hidden */
  33592. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33593. /**
  33594. * Defines if the texture is ready
  33595. */
  33596. isReady: boolean;
  33597. /**
  33598. * Defines if the texture is a cube texture
  33599. */
  33600. isCube: boolean;
  33601. /**
  33602. * Defines if the texture contains 3D data
  33603. */
  33604. is3D: boolean;
  33605. /**
  33606. * Defines if the texture contains 2D array data
  33607. */
  33608. is2DArray: boolean;
  33609. /**
  33610. * Defines if the texture contains multiview data
  33611. */
  33612. isMultiview: boolean;
  33613. /**
  33614. * Gets the URL used to load this texture
  33615. */
  33616. url: string;
  33617. /**
  33618. * Gets the sampling mode of the texture
  33619. */
  33620. samplingMode: number;
  33621. /**
  33622. * Gets a boolean indicating if the texture needs mipmaps generation
  33623. */
  33624. generateMipMaps: boolean;
  33625. /**
  33626. * Gets the number of samples used by the texture (WebGL2+ only)
  33627. */
  33628. samples: number;
  33629. /**
  33630. * Gets the type of the texture (int, float...)
  33631. */
  33632. type: number;
  33633. /**
  33634. * Gets the format of the texture (RGB, RGBA...)
  33635. */
  33636. format: number;
  33637. /**
  33638. * Observable called when the texture is loaded
  33639. */
  33640. onLoadedObservable: Observable<InternalTexture>;
  33641. /**
  33642. * Gets the width of the texture
  33643. */
  33644. width: number;
  33645. /**
  33646. * Gets the height of the texture
  33647. */
  33648. height: number;
  33649. /**
  33650. * Gets the depth of the texture
  33651. */
  33652. depth: number;
  33653. /**
  33654. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33655. */
  33656. baseWidth: number;
  33657. /**
  33658. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33659. */
  33660. baseHeight: number;
  33661. /**
  33662. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33663. */
  33664. baseDepth: number;
  33665. /**
  33666. * Gets a boolean indicating if the texture is inverted on Y axis
  33667. */
  33668. invertY: boolean;
  33669. /** @hidden */
  33670. _invertVScale: boolean;
  33671. /** @hidden */
  33672. _associatedChannel: number;
  33673. /** @hidden */
  33674. _source: InternalTextureSource;
  33675. /** @hidden */
  33676. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33677. /** @hidden */
  33678. _bufferView: Nullable<ArrayBufferView>;
  33679. /** @hidden */
  33680. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33681. /** @hidden */
  33682. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33683. /** @hidden */
  33684. _size: number;
  33685. /** @hidden */
  33686. _extension: string;
  33687. /** @hidden */
  33688. _files: Nullable<string[]>;
  33689. /** @hidden */
  33690. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33691. /** @hidden */
  33692. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33693. /** @hidden */
  33694. _framebuffer: Nullable<WebGLFramebuffer>;
  33695. /** @hidden */
  33696. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33697. /** @hidden */
  33698. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33699. /** @hidden */
  33700. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33701. /** @hidden */
  33702. _attachments: Nullable<number[]>;
  33703. /** @hidden */
  33704. _cachedCoordinatesMode: Nullable<number>;
  33705. /** @hidden */
  33706. _cachedWrapU: Nullable<number>;
  33707. /** @hidden */
  33708. _cachedWrapV: Nullable<number>;
  33709. /** @hidden */
  33710. _cachedWrapR: Nullable<number>;
  33711. /** @hidden */
  33712. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33713. /** @hidden */
  33714. _isDisabled: boolean;
  33715. /** @hidden */
  33716. _compression: Nullable<string>;
  33717. /** @hidden */
  33718. _generateStencilBuffer: boolean;
  33719. /** @hidden */
  33720. _generateDepthBuffer: boolean;
  33721. /** @hidden */
  33722. _comparisonFunction: number;
  33723. /** @hidden */
  33724. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33725. /** @hidden */
  33726. _lodGenerationScale: number;
  33727. /** @hidden */
  33728. _lodGenerationOffset: number;
  33729. /** @hidden */
  33730. _depthStencilTexture: Nullable<InternalTexture>;
  33731. /** @hidden */
  33732. _colorTextureArray: Nullable<WebGLTexture>;
  33733. /** @hidden */
  33734. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33735. /** @hidden */
  33736. _lodTextureHigh: Nullable<BaseTexture>;
  33737. /** @hidden */
  33738. _lodTextureMid: Nullable<BaseTexture>;
  33739. /** @hidden */
  33740. _lodTextureLow: Nullable<BaseTexture>;
  33741. /** @hidden */
  33742. _isRGBD: boolean;
  33743. /** @hidden */
  33744. _linearSpecularLOD: boolean;
  33745. /** @hidden */
  33746. _irradianceTexture: Nullable<BaseTexture>;
  33747. /** @hidden */
  33748. _webGLTexture: Nullable<WebGLTexture>;
  33749. /** @hidden */
  33750. _references: number;
  33751. private _engine;
  33752. /**
  33753. * Gets the Engine the texture belongs to.
  33754. * @returns The babylon engine
  33755. */
  33756. getEngine(): ThinEngine;
  33757. /**
  33758. * Gets the data source type of the texture
  33759. */
  33760. get source(): InternalTextureSource;
  33761. /**
  33762. * Creates a new InternalTexture
  33763. * @param engine defines the engine to use
  33764. * @param source defines the type of data that will be used
  33765. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33766. */
  33767. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33768. /**
  33769. * Increments the number of references (ie. the number of Texture that point to it)
  33770. */
  33771. incrementReferences(): void;
  33772. /**
  33773. * Change the size of the texture (not the size of the content)
  33774. * @param width defines the new width
  33775. * @param height defines the new height
  33776. * @param depth defines the new depth (1 by default)
  33777. */
  33778. updateSize(width: int, height: int, depth?: int): void;
  33779. /** @hidden */
  33780. _rebuild(): void;
  33781. /** @hidden */
  33782. _swapAndDie(target: InternalTexture): void;
  33783. /**
  33784. * Dispose the current allocated resources
  33785. */
  33786. dispose(): void;
  33787. }
  33788. }
  33789. declare module "babylonjs/Audio/analyser" {
  33790. import { Scene } from "babylonjs/scene";
  33791. /**
  33792. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33794. */
  33795. export class Analyser {
  33796. /**
  33797. * Gets or sets the smoothing
  33798. * @ignorenaming
  33799. */
  33800. SMOOTHING: number;
  33801. /**
  33802. * Gets or sets the FFT table size
  33803. * @ignorenaming
  33804. */
  33805. FFT_SIZE: number;
  33806. /**
  33807. * Gets or sets the bar graph amplitude
  33808. * @ignorenaming
  33809. */
  33810. BARGRAPHAMPLITUDE: number;
  33811. /**
  33812. * Gets or sets the position of the debug canvas
  33813. * @ignorenaming
  33814. */
  33815. DEBUGCANVASPOS: {
  33816. x: number;
  33817. y: number;
  33818. };
  33819. /**
  33820. * Gets or sets the debug canvas size
  33821. * @ignorenaming
  33822. */
  33823. DEBUGCANVASSIZE: {
  33824. width: number;
  33825. height: number;
  33826. };
  33827. private _byteFreqs;
  33828. private _byteTime;
  33829. private _floatFreqs;
  33830. private _webAudioAnalyser;
  33831. private _debugCanvas;
  33832. private _debugCanvasContext;
  33833. private _scene;
  33834. private _registerFunc;
  33835. private _audioEngine;
  33836. /**
  33837. * Creates a new analyser
  33838. * @param scene defines hosting scene
  33839. */
  33840. constructor(scene: Scene);
  33841. /**
  33842. * Get the number of data values you will have to play with for the visualization
  33843. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33844. * @returns a number
  33845. */
  33846. getFrequencyBinCount(): number;
  33847. /**
  33848. * Gets the current frequency data as a byte array
  33849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33850. * @returns a Uint8Array
  33851. */
  33852. getByteFrequencyData(): Uint8Array;
  33853. /**
  33854. * Gets the current waveform as a byte array
  33855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33856. * @returns a Uint8Array
  33857. */
  33858. getByteTimeDomainData(): Uint8Array;
  33859. /**
  33860. * Gets the current frequency data as a float array
  33861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33862. * @returns a Float32Array
  33863. */
  33864. getFloatFrequencyData(): Float32Array;
  33865. /**
  33866. * Renders the debug canvas
  33867. */
  33868. drawDebugCanvas(): void;
  33869. /**
  33870. * Stops rendering the debug canvas and removes it
  33871. */
  33872. stopDebugCanvas(): void;
  33873. /**
  33874. * Connects two audio nodes
  33875. * @param inputAudioNode defines first node to connect
  33876. * @param outputAudioNode defines second node to connect
  33877. */
  33878. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33879. /**
  33880. * Releases all associated resources
  33881. */
  33882. dispose(): void;
  33883. }
  33884. }
  33885. declare module "babylonjs/Audio/audioEngine" {
  33886. import { IDisposable } from "babylonjs/scene";
  33887. import { Analyser } from "babylonjs/Audio/analyser";
  33888. import { Nullable } from "babylonjs/types";
  33889. import { Observable } from "babylonjs/Misc/observable";
  33890. /**
  33891. * This represents an audio engine and it is responsible
  33892. * to play, synchronize and analyse sounds throughout the application.
  33893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33894. */
  33895. export interface IAudioEngine extends IDisposable {
  33896. /**
  33897. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33898. */
  33899. readonly canUseWebAudio: boolean;
  33900. /**
  33901. * Gets the current AudioContext if available.
  33902. */
  33903. readonly audioContext: Nullable<AudioContext>;
  33904. /**
  33905. * The master gain node defines the global audio volume of your audio engine.
  33906. */
  33907. readonly masterGain: GainNode;
  33908. /**
  33909. * Gets whether or not mp3 are supported by your browser.
  33910. */
  33911. readonly isMP3supported: boolean;
  33912. /**
  33913. * Gets whether or not ogg are supported by your browser.
  33914. */
  33915. readonly isOGGsupported: boolean;
  33916. /**
  33917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33918. * @ignoreNaming
  33919. */
  33920. WarnedWebAudioUnsupported: boolean;
  33921. /**
  33922. * Defines if the audio engine relies on a custom unlocked button.
  33923. * In this case, the embedded button will not be displayed.
  33924. */
  33925. useCustomUnlockedButton: boolean;
  33926. /**
  33927. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33928. */
  33929. readonly unlocked: boolean;
  33930. /**
  33931. * Event raised when audio has been unlocked on the browser.
  33932. */
  33933. onAudioUnlockedObservable: Observable<AudioEngine>;
  33934. /**
  33935. * Event raised when audio has been locked on the browser.
  33936. */
  33937. onAudioLockedObservable: Observable<AudioEngine>;
  33938. /**
  33939. * Flags the audio engine in Locked state.
  33940. * This happens due to new browser policies preventing audio to autoplay.
  33941. */
  33942. lock(): void;
  33943. /**
  33944. * Unlocks the audio engine once a user action has been done on the dom.
  33945. * This is helpful to resume play once browser policies have been satisfied.
  33946. */
  33947. unlock(): void;
  33948. /**
  33949. * Gets the global volume sets on the master gain.
  33950. * @returns the global volume if set or -1 otherwise
  33951. */
  33952. getGlobalVolume(): number;
  33953. /**
  33954. * Sets the global volume of your experience (sets on the master gain).
  33955. * @param newVolume Defines the new global volume of the application
  33956. */
  33957. setGlobalVolume(newVolume: number): void;
  33958. /**
  33959. * Connect the audio engine to an audio analyser allowing some amazing
  33960. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33962. * @param analyser The analyser to connect to the engine
  33963. */
  33964. connectToAnalyser(analyser: Analyser): void;
  33965. }
  33966. /**
  33967. * This represents the default audio engine used in babylon.
  33968. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33970. */
  33971. export class AudioEngine implements IAudioEngine {
  33972. private _audioContext;
  33973. private _audioContextInitialized;
  33974. private _muteButton;
  33975. private _hostElement;
  33976. /**
  33977. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33978. */
  33979. canUseWebAudio: boolean;
  33980. /**
  33981. * The master gain node defines the global audio volume of your audio engine.
  33982. */
  33983. masterGain: GainNode;
  33984. /**
  33985. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33986. * @ignoreNaming
  33987. */
  33988. WarnedWebAudioUnsupported: boolean;
  33989. /**
  33990. * Gets whether or not mp3 are supported by your browser.
  33991. */
  33992. isMP3supported: boolean;
  33993. /**
  33994. * Gets whether or not ogg are supported by your browser.
  33995. */
  33996. isOGGsupported: boolean;
  33997. /**
  33998. * Gets whether audio has been unlocked on the device.
  33999. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34000. * a user interaction has happened.
  34001. */
  34002. unlocked: boolean;
  34003. /**
  34004. * Defines if the audio engine relies on a custom unlocked button.
  34005. * In this case, the embedded button will not be displayed.
  34006. */
  34007. useCustomUnlockedButton: boolean;
  34008. /**
  34009. * Event raised when audio has been unlocked on the browser.
  34010. */
  34011. onAudioUnlockedObservable: Observable<AudioEngine>;
  34012. /**
  34013. * Event raised when audio has been locked on the browser.
  34014. */
  34015. onAudioLockedObservable: Observable<AudioEngine>;
  34016. /**
  34017. * Gets the current AudioContext if available.
  34018. */
  34019. get audioContext(): Nullable<AudioContext>;
  34020. private _connectedAnalyser;
  34021. /**
  34022. * Instantiates a new audio engine.
  34023. *
  34024. * There should be only one per page as some browsers restrict the number
  34025. * of audio contexts you can create.
  34026. * @param hostElement defines the host element where to display the mute icon if necessary
  34027. */
  34028. constructor(hostElement?: Nullable<HTMLElement>);
  34029. /**
  34030. * Flags the audio engine in Locked state.
  34031. * This happens due to new browser policies preventing audio to autoplay.
  34032. */
  34033. lock(): void;
  34034. /**
  34035. * Unlocks the audio engine once a user action has been done on the dom.
  34036. * This is helpful to resume play once browser policies have been satisfied.
  34037. */
  34038. unlock(): void;
  34039. private _resumeAudioContext;
  34040. private _initializeAudioContext;
  34041. private _tryToRun;
  34042. private _triggerRunningState;
  34043. private _triggerSuspendedState;
  34044. private _displayMuteButton;
  34045. private _moveButtonToTopLeft;
  34046. private _onResize;
  34047. private _hideMuteButton;
  34048. /**
  34049. * Destroy and release the resources associated with the audio ccontext.
  34050. */
  34051. dispose(): void;
  34052. /**
  34053. * Gets the global volume sets on the master gain.
  34054. * @returns the global volume if set or -1 otherwise
  34055. */
  34056. getGlobalVolume(): number;
  34057. /**
  34058. * Sets the global volume of your experience (sets on the master gain).
  34059. * @param newVolume Defines the new global volume of the application
  34060. */
  34061. setGlobalVolume(newVolume: number): void;
  34062. /**
  34063. * Connect the audio engine to an audio analyser allowing some amazing
  34064. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34066. * @param analyser The analyser to connect to the engine
  34067. */
  34068. connectToAnalyser(analyser: Analyser): void;
  34069. }
  34070. }
  34071. declare module "babylonjs/Loading/loadingScreen" {
  34072. /**
  34073. * Interface used to present a loading screen while loading a scene
  34074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34075. */
  34076. export interface ILoadingScreen {
  34077. /**
  34078. * Function called to display the loading screen
  34079. */
  34080. displayLoadingUI: () => void;
  34081. /**
  34082. * Function called to hide the loading screen
  34083. */
  34084. hideLoadingUI: () => void;
  34085. /**
  34086. * Gets or sets the color to use for the background
  34087. */
  34088. loadingUIBackgroundColor: string;
  34089. /**
  34090. * Gets or sets the text to display while loading
  34091. */
  34092. loadingUIText: string;
  34093. }
  34094. /**
  34095. * Class used for the default loading screen
  34096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34097. */
  34098. export class DefaultLoadingScreen implements ILoadingScreen {
  34099. private _renderingCanvas;
  34100. private _loadingText;
  34101. private _loadingDivBackgroundColor;
  34102. private _loadingDiv;
  34103. private _loadingTextDiv;
  34104. /** Gets or sets the logo url to use for the default loading screen */
  34105. static DefaultLogoUrl: string;
  34106. /** Gets or sets the spinner url to use for the default loading screen */
  34107. static DefaultSpinnerUrl: string;
  34108. /**
  34109. * Creates a new default loading screen
  34110. * @param _renderingCanvas defines the canvas used to render the scene
  34111. * @param _loadingText defines the default text to display
  34112. * @param _loadingDivBackgroundColor defines the default background color
  34113. */
  34114. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34115. /**
  34116. * Function called to display the loading screen
  34117. */
  34118. displayLoadingUI(): void;
  34119. /**
  34120. * Function called to hide the loading screen
  34121. */
  34122. hideLoadingUI(): void;
  34123. /**
  34124. * Gets or sets the text to display while loading
  34125. */
  34126. set loadingUIText(text: string);
  34127. get loadingUIText(): string;
  34128. /**
  34129. * Gets or sets the color to use for the background
  34130. */
  34131. get loadingUIBackgroundColor(): string;
  34132. set loadingUIBackgroundColor(color: string);
  34133. private _resizeLoadingUI;
  34134. }
  34135. }
  34136. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34137. /**
  34138. * Interface for any object that can request an animation frame
  34139. */
  34140. export interface ICustomAnimationFrameRequester {
  34141. /**
  34142. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34143. */
  34144. renderFunction?: Function;
  34145. /**
  34146. * Called to request the next frame to render to
  34147. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34148. */
  34149. requestAnimationFrame: Function;
  34150. /**
  34151. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34152. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34153. */
  34154. requestID?: number;
  34155. }
  34156. }
  34157. declare module "babylonjs/Misc/performanceMonitor" {
  34158. /**
  34159. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34160. */
  34161. export class PerformanceMonitor {
  34162. private _enabled;
  34163. private _rollingFrameTime;
  34164. private _lastFrameTimeMs;
  34165. /**
  34166. * constructor
  34167. * @param frameSampleSize The number of samples required to saturate the sliding window
  34168. */
  34169. constructor(frameSampleSize?: number);
  34170. /**
  34171. * Samples current frame
  34172. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34173. */
  34174. sampleFrame(timeMs?: number): void;
  34175. /**
  34176. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34177. */
  34178. get averageFrameTime(): number;
  34179. /**
  34180. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34181. */
  34182. get averageFrameTimeVariance(): number;
  34183. /**
  34184. * Returns the frame time of the most recent frame
  34185. */
  34186. get instantaneousFrameTime(): number;
  34187. /**
  34188. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34189. */
  34190. get averageFPS(): number;
  34191. /**
  34192. * Returns the average framerate in frames per second using the most recent frame time
  34193. */
  34194. get instantaneousFPS(): number;
  34195. /**
  34196. * Returns true if enough samples have been taken to completely fill the sliding window
  34197. */
  34198. get isSaturated(): boolean;
  34199. /**
  34200. * Enables contributions to the sliding window sample set
  34201. */
  34202. enable(): void;
  34203. /**
  34204. * Disables contributions to the sliding window sample set
  34205. * Samples will not be interpolated over the disabled period
  34206. */
  34207. disable(): void;
  34208. /**
  34209. * Returns true if sampling is enabled
  34210. */
  34211. get isEnabled(): boolean;
  34212. /**
  34213. * Resets performance monitor
  34214. */
  34215. reset(): void;
  34216. }
  34217. /**
  34218. * RollingAverage
  34219. *
  34220. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34221. */
  34222. export class RollingAverage {
  34223. /**
  34224. * Current average
  34225. */
  34226. average: number;
  34227. /**
  34228. * Current variance
  34229. */
  34230. variance: number;
  34231. protected _samples: Array<number>;
  34232. protected _sampleCount: number;
  34233. protected _pos: number;
  34234. protected _m2: number;
  34235. /**
  34236. * constructor
  34237. * @param length The number of samples required to saturate the sliding window
  34238. */
  34239. constructor(length: number);
  34240. /**
  34241. * Adds a sample to the sample set
  34242. * @param v The sample value
  34243. */
  34244. add(v: number): void;
  34245. /**
  34246. * Returns previously added values or null if outside of history or outside the sliding window domain
  34247. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34248. * @return Value previously recorded with add() or null if outside of range
  34249. */
  34250. history(i: number): number;
  34251. /**
  34252. * Returns true if enough samples have been taken to completely fill the sliding window
  34253. * @return true if sample-set saturated
  34254. */
  34255. isSaturated(): boolean;
  34256. /**
  34257. * Resets the rolling average (equivalent to 0 samples taken so far)
  34258. */
  34259. reset(): void;
  34260. /**
  34261. * Wraps a value around the sample range boundaries
  34262. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34263. * @return Wrapped position in sample range
  34264. */
  34265. protected _wrapPosition(i: number): number;
  34266. }
  34267. }
  34268. declare module "babylonjs/Misc/perfCounter" {
  34269. /**
  34270. * This class is used to track a performance counter which is number based.
  34271. * The user has access to many properties which give statistics of different nature.
  34272. *
  34273. * The implementer can track two kinds of Performance Counter: time and count.
  34274. * 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.
  34275. * 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.
  34276. */
  34277. export class PerfCounter {
  34278. /**
  34279. * Gets or sets a global boolean to turn on and off all the counters
  34280. */
  34281. static Enabled: boolean;
  34282. /**
  34283. * Returns the smallest value ever
  34284. */
  34285. get min(): number;
  34286. /**
  34287. * Returns the biggest value ever
  34288. */
  34289. get max(): number;
  34290. /**
  34291. * Returns the average value since the performance counter is running
  34292. */
  34293. get average(): number;
  34294. /**
  34295. * Returns the average value of the last second the counter was monitored
  34296. */
  34297. get lastSecAverage(): number;
  34298. /**
  34299. * Returns the current value
  34300. */
  34301. get current(): number;
  34302. /**
  34303. * Gets the accumulated total
  34304. */
  34305. get total(): number;
  34306. /**
  34307. * Gets the total value count
  34308. */
  34309. get count(): number;
  34310. /**
  34311. * Creates a new counter
  34312. */
  34313. constructor();
  34314. /**
  34315. * Call this method to start monitoring a new frame.
  34316. * 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.
  34317. */
  34318. fetchNewFrame(): void;
  34319. /**
  34320. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34321. * @param newCount the count value to add to the monitored count
  34322. * @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.
  34323. */
  34324. addCount(newCount: number, fetchResult: boolean): void;
  34325. /**
  34326. * Start monitoring this performance counter
  34327. */
  34328. beginMonitoring(): void;
  34329. /**
  34330. * Compute the time lapsed since the previous beginMonitoring() call.
  34331. * @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
  34332. */
  34333. endMonitoring(newFrame?: boolean): void;
  34334. private _fetchResult;
  34335. private _startMonitoringTime;
  34336. private _min;
  34337. private _max;
  34338. private _average;
  34339. private _current;
  34340. private _totalValueCount;
  34341. private _totalAccumulated;
  34342. private _lastSecAverage;
  34343. private _lastSecAccumulated;
  34344. private _lastSecTime;
  34345. private _lastSecValueCount;
  34346. }
  34347. }
  34348. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34349. module "babylonjs/Engines/thinEngine" {
  34350. interface ThinEngine {
  34351. /**
  34352. * Sets alpha constants used by some alpha blending modes
  34353. * @param r defines the red component
  34354. * @param g defines the green component
  34355. * @param b defines the blue component
  34356. * @param a defines the alpha component
  34357. */
  34358. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34359. /**
  34360. * Sets the current alpha mode
  34361. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34362. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34364. */
  34365. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34366. /**
  34367. * Gets the current alpha mode
  34368. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34369. * @returns the current alpha mode
  34370. */
  34371. getAlphaMode(): number;
  34372. /**
  34373. * Sets the current alpha equation
  34374. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34375. */
  34376. setAlphaEquation(equation: number): void;
  34377. /**
  34378. * Gets the current alpha equation.
  34379. * @returns the current alpha equation
  34380. */
  34381. getAlphaEquation(): number;
  34382. }
  34383. }
  34384. }
  34385. declare module "babylonjs/Engines/engine" {
  34386. import { Observable } from "babylonjs/Misc/observable";
  34387. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34388. import { Scene } from "babylonjs/scene";
  34389. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34390. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34392. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34393. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34394. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34395. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34396. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34397. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34398. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34399. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34400. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34401. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34402. import "babylonjs/Engines/Extensions/engine.alpha";
  34403. import { Material } from "babylonjs/Materials/material";
  34404. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34405. /**
  34406. * Defines the interface used by display changed events
  34407. */
  34408. export interface IDisplayChangedEventArgs {
  34409. /** Gets the vrDisplay object (if any) */
  34410. vrDisplay: Nullable<any>;
  34411. /** Gets a boolean indicating if webVR is supported */
  34412. vrSupported: boolean;
  34413. }
  34414. /**
  34415. * Defines the interface used by objects containing a viewport (like a camera)
  34416. */
  34417. interface IViewportOwnerLike {
  34418. /**
  34419. * Gets or sets the viewport
  34420. */
  34421. viewport: IViewportLike;
  34422. }
  34423. /**
  34424. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34425. */
  34426. export class Engine extends ThinEngine {
  34427. /** Defines that alpha blending is disabled */
  34428. static readonly ALPHA_DISABLE: number;
  34429. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34430. static readonly ALPHA_ADD: number;
  34431. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34432. static readonly ALPHA_COMBINE: number;
  34433. /** Defines that alpha blending to DEST - SRC * DEST */
  34434. static readonly ALPHA_SUBTRACT: number;
  34435. /** Defines that alpha blending to SRC * DEST */
  34436. static readonly ALPHA_MULTIPLY: number;
  34437. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34438. static readonly ALPHA_MAXIMIZED: number;
  34439. /** Defines that alpha blending to SRC + DEST */
  34440. static readonly ALPHA_ONEONE: number;
  34441. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34442. static readonly ALPHA_PREMULTIPLIED: number;
  34443. /**
  34444. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34445. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34446. */
  34447. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34448. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34449. static readonly ALPHA_INTERPOLATE: number;
  34450. /**
  34451. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34452. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34453. */
  34454. static readonly ALPHA_SCREENMODE: number;
  34455. /** Defines that the ressource is not delayed*/
  34456. static readonly DELAYLOADSTATE_NONE: number;
  34457. /** Defines that the ressource was successfully delay loaded */
  34458. static readonly DELAYLOADSTATE_LOADED: number;
  34459. /** Defines that the ressource is currently delay loading */
  34460. static readonly DELAYLOADSTATE_LOADING: number;
  34461. /** Defines that the ressource is delayed and has not started loading */
  34462. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34464. static readonly NEVER: number;
  34465. /** 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 */
  34466. static readonly ALWAYS: number;
  34467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34468. static readonly LESS: number;
  34469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34470. static readonly EQUAL: number;
  34471. /** 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 */
  34472. static readonly LEQUAL: number;
  34473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34474. static readonly GREATER: number;
  34475. /** 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 */
  34476. static readonly GEQUAL: number;
  34477. /** 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 */
  34478. static readonly NOTEQUAL: number;
  34479. /** Passed to stencilOperation to specify that stencil value must be kept */
  34480. static readonly KEEP: number;
  34481. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34482. static readonly REPLACE: number;
  34483. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34484. static readonly INCR: number;
  34485. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34486. static readonly DECR: number;
  34487. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34488. static readonly INVERT: number;
  34489. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34490. static readonly INCR_WRAP: number;
  34491. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34492. static readonly DECR_WRAP: number;
  34493. /** Texture is not repeating outside of 0..1 UVs */
  34494. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34495. /** Texture is repeating outside of 0..1 UVs */
  34496. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34497. /** Texture is repeating and mirrored */
  34498. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34499. /** ALPHA */
  34500. static readonly TEXTUREFORMAT_ALPHA: number;
  34501. /** LUMINANCE */
  34502. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34503. /** LUMINANCE_ALPHA */
  34504. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34505. /** RGB */
  34506. static readonly TEXTUREFORMAT_RGB: number;
  34507. /** RGBA */
  34508. static readonly TEXTUREFORMAT_RGBA: number;
  34509. /** RED */
  34510. static readonly TEXTUREFORMAT_RED: number;
  34511. /** RED (2nd reference) */
  34512. static readonly TEXTUREFORMAT_R: number;
  34513. /** RG */
  34514. static readonly TEXTUREFORMAT_RG: number;
  34515. /** RED_INTEGER */
  34516. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34517. /** RED_INTEGER (2nd reference) */
  34518. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34519. /** RG_INTEGER */
  34520. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34521. /** RGB_INTEGER */
  34522. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34523. /** RGBA_INTEGER */
  34524. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34525. /** UNSIGNED_BYTE */
  34526. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34527. /** UNSIGNED_BYTE (2nd reference) */
  34528. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34529. /** FLOAT */
  34530. static readonly TEXTURETYPE_FLOAT: number;
  34531. /** HALF_FLOAT */
  34532. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34533. /** BYTE */
  34534. static readonly TEXTURETYPE_BYTE: number;
  34535. /** SHORT */
  34536. static readonly TEXTURETYPE_SHORT: number;
  34537. /** UNSIGNED_SHORT */
  34538. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34539. /** INT */
  34540. static readonly TEXTURETYPE_INT: number;
  34541. /** UNSIGNED_INT */
  34542. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34543. /** UNSIGNED_SHORT_4_4_4_4 */
  34544. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34545. /** UNSIGNED_SHORT_5_5_5_1 */
  34546. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34547. /** UNSIGNED_SHORT_5_6_5 */
  34548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34549. /** UNSIGNED_INT_2_10_10_10_REV */
  34550. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34551. /** UNSIGNED_INT_24_8 */
  34552. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34553. /** UNSIGNED_INT_10F_11F_11F_REV */
  34554. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34555. /** UNSIGNED_INT_5_9_9_9_REV */
  34556. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34557. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34558. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34559. /** nearest is mag = nearest and min = nearest and mip = linear */
  34560. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34562. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34563. /** Trilinear is mag = linear and min = linear and mip = linear */
  34564. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34565. /** nearest is mag = nearest and min = nearest and mip = linear */
  34566. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34567. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34568. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34569. /** Trilinear is mag = linear and min = linear and mip = linear */
  34570. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34571. /** mag = nearest and min = nearest and mip = nearest */
  34572. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34573. /** mag = nearest and min = linear and mip = nearest */
  34574. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34575. /** mag = nearest and min = linear and mip = linear */
  34576. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34577. /** mag = nearest and min = linear and mip = none */
  34578. static readonly TEXTURE_NEAREST_LINEAR: number;
  34579. /** mag = nearest and min = nearest and mip = none */
  34580. static readonly TEXTURE_NEAREST_NEAREST: number;
  34581. /** mag = linear and min = nearest and mip = nearest */
  34582. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34583. /** mag = linear and min = nearest and mip = linear */
  34584. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34585. /** mag = linear and min = linear and mip = none */
  34586. static readonly TEXTURE_LINEAR_LINEAR: number;
  34587. /** mag = linear and min = nearest and mip = none */
  34588. static readonly TEXTURE_LINEAR_NEAREST: number;
  34589. /** Explicit coordinates mode */
  34590. static readonly TEXTURE_EXPLICIT_MODE: number;
  34591. /** Spherical coordinates mode */
  34592. static readonly TEXTURE_SPHERICAL_MODE: number;
  34593. /** Planar coordinates mode */
  34594. static readonly TEXTURE_PLANAR_MODE: number;
  34595. /** Cubic coordinates mode */
  34596. static readonly TEXTURE_CUBIC_MODE: number;
  34597. /** Projection coordinates mode */
  34598. static readonly TEXTURE_PROJECTION_MODE: number;
  34599. /** Skybox coordinates mode */
  34600. static readonly TEXTURE_SKYBOX_MODE: number;
  34601. /** Inverse Cubic coordinates mode */
  34602. static readonly TEXTURE_INVCUBIC_MODE: number;
  34603. /** Equirectangular coordinates mode */
  34604. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34605. /** Equirectangular Fixed coordinates mode */
  34606. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34607. /** Equirectangular Fixed Mirrored coordinates mode */
  34608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34609. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34610. static readonly SCALEMODE_FLOOR: number;
  34611. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34612. static readonly SCALEMODE_NEAREST: number;
  34613. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34614. static readonly SCALEMODE_CEILING: number;
  34615. /**
  34616. * Returns the current npm package of the sdk
  34617. */
  34618. static get NpmPackage(): string;
  34619. /**
  34620. * Returns the current version of the framework
  34621. */
  34622. static get Version(): string;
  34623. /** Gets the list of created engines */
  34624. static get Instances(): Engine[];
  34625. /**
  34626. * Gets the latest created engine
  34627. */
  34628. static get LastCreatedEngine(): Nullable<Engine>;
  34629. /**
  34630. * Gets the latest created scene
  34631. */
  34632. static get LastCreatedScene(): Nullable<Scene>;
  34633. /**
  34634. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34635. * @param flag defines which part of the materials must be marked as dirty
  34636. * @param predicate defines a predicate used to filter which materials should be affected
  34637. */
  34638. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34639. /**
  34640. * Method called to create the default loading screen.
  34641. * This can be overriden in your own app.
  34642. * @param canvas The rendering canvas element
  34643. * @returns The loading screen
  34644. */
  34645. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34646. /**
  34647. * Method called to create the default rescale post process on each engine.
  34648. */
  34649. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34650. /**
  34651. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34652. **/
  34653. enableOfflineSupport: boolean;
  34654. /**
  34655. * 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)
  34656. **/
  34657. disableManifestCheck: boolean;
  34658. /**
  34659. * Gets the list of created scenes
  34660. */
  34661. scenes: Scene[];
  34662. /**
  34663. * Event raised when a new scene is created
  34664. */
  34665. onNewSceneAddedObservable: Observable<Scene>;
  34666. /**
  34667. * Gets the list of created postprocesses
  34668. */
  34669. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34670. /**
  34671. * Gets a boolean indicating if the pointer is currently locked
  34672. */
  34673. isPointerLock: boolean;
  34674. /**
  34675. * Observable event triggered each time the rendering canvas is resized
  34676. */
  34677. onResizeObservable: Observable<Engine>;
  34678. /**
  34679. * Observable event triggered each time the canvas loses focus
  34680. */
  34681. onCanvasBlurObservable: Observable<Engine>;
  34682. /**
  34683. * Observable event triggered each time the canvas gains focus
  34684. */
  34685. onCanvasFocusObservable: Observable<Engine>;
  34686. /**
  34687. * Observable event triggered each time the canvas receives pointerout event
  34688. */
  34689. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34690. /**
  34691. * Observable raised when the engine begins a new frame
  34692. */
  34693. onBeginFrameObservable: Observable<Engine>;
  34694. /**
  34695. * If set, will be used to request the next animation frame for the render loop
  34696. */
  34697. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34698. /**
  34699. * Observable raised when the engine ends the current frame
  34700. */
  34701. onEndFrameObservable: Observable<Engine>;
  34702. /**
  34703. * Observable raised when the engine is about to compile a shader
  34704. */
  34705. onBeforeShaderCompilationObservable: Observable<Engine>;
  34706. /**
  34707. * Observable raised when the engine has jsut compiled a shader
  34708. */
  34709. onAfterShaderCompilationObservable: Observable<Engine>;
  34710. /**
  34711. * Gets the audio engine
  34712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34713. * @ignorenaming
  34714. */
  34715. static audioEngine: IAudioEngine;
  34716. /**
  34717. * Default AudioEngine factory responsible of creating the Audio Engine.
  34718. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34719. */
  34720. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34721. /**
  34722. * Default offline support factory responsible of creating a tool used to store data locally.
  34723. * By default, this will create a Database object if the workload has been embedded.
  34724. */
  34725. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34726. private _loadingScreen;
  34727. private _pointerLockRequested;
  34728. private _dummyFramebuffer;
  34729. private _rescalePostProcess;
  34730. private _deterministicLockstep;
  34731. private _lockstepMaxSteps;
  34732. private _timeStep;
  34733. protected get _supportsHardwareTextureRescaling(): boolean;
  34734. private _fps;
  34735. private _deltaTime;
  34736. /** @hidden */
  34737. _drawCalls: PerfCounter;
  34738. /** 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 */
  34739. canvasTabIndex: number;
  34740. /**
  34741. * Turn this value on if you want to pause FPS computation when in background
  34742. */
  34743. disablePerformanceMonitorInBackground: boolean;
  34744. private _performanceMonitor;
  34745. /**
  34746. * Gets the performance monitor attached to this engine
  34747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34748. */
  34749. get performanceMonitor(): PerformanceMonitor;
  34750. private _onFocus;
  34751. private _onBlur;
  34752. private _onCanvasPointerOut;
  34753. private _onCanvasBlur;
  34754. private _onCanvasFocus;
  34755. private _onFullscreenChange;
  34756. private _onPointerLockChange;
  34757. /**
  34758. * Gets the HTML element used to attach event listeners
  34759. * @returns a HTML element
  34760. */
  34761. getInputElement(): Nullable<HTMLElement>;
  34762. /**
  34763. * Creates a new engine
  34764. * @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
  34765. * @param antialias defines enable antialiasing (default: false)
  34766. * @param options defines further options to be sent to the getContext() function
  34767. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34768. */
  34769. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34770. /**
  34771. * Gets current aspect ratio
  34772. * @param viewportOwner defines the camera to use to get the aspect ratio
  34773. * @param useScreen defines if screen size must be used (or the current render target if any)
  34774. * @returns a number defining the aspect ratio
  34775. */
  34776. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34777. /**
  34778. * Gets current screen aspect ratio
  34779. * @returns a number defining the aspect ratio
  34780. */
  34781. getScreenAspectRatio(): number;
  34782. /**
  34783. * Gets the client rect of the HTML canvas attached with the current webGL context
  34784. * @returns a client rectanglee
  34785. */
  34786. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34787. /**
  34788. * Gets the client rect of the HTML element used for events
  34789. * @returns a client rectanglee
  34790. */
  34791. getInputElementClientRect(): Nullable<ClientRect>;
  34792. /**
  34793. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34795. * @returns true if engine is in deterministic lock step mode
  34796. */
  34797. isDeterministicLockStep(): boolean;
  34798. /**
  34799. * Gets the max steps when engine is running in deterministic lock step
  34800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34801. * @returns the max steps
  34802. */
  34803. getLockstepMaxSteps(): number;
  34804. /**
  34805. * Returns the time in ms between steps when using deterministic lock step.
  34806. * @returns time step in (ms)
  34807. */
  34808. getTimeStep(): number;
  34809. /**
  34810. * Force the mipmap generation for the given render target texture
  34811. * @param texture defines the render target texture to use
  34812. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34813. */
  34814. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34815. /** States */
  34816. /**
  34817. * Set various states to the webGL context
  34818. * @param culling defines backface culling state
  34819. * @param zOffset defines the value to apply to zOffset (0 by default)
  34820. * @param force defines if states must be applied even if cache is up to date
  34821. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34822. */
  34823. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34824. /**
  34825. * Set the z offset to apply to current rendering
  34826. * @param value defines the offset to apply
  34827. */
  34828. setZOffset(value: number): void;
  34829. /**
  34830. * Gets the current value of the zOffset
  34831. * @returns the current zOffset state
  34832. */
  34833. getZOffset(): number;
  34834. /**
  34835. * Enable or disable depth buffering
  34836. * @param enable defines the state to set
  34837. */
  34838. setDepthBuffer(enable: boolean): void;
  34839. /**
  34840. * Gets a boolean indicating if depth writing is enabled
  34841. * @returns the current depth writing state
  34842. */
  34843. getDepthWrite(): boolean;
  34844. /**
  34845. * Enable or disable depth writing
  34846. * @param enable defines the state to set
  34847. */
  34848. setDepthWrite(enable: boolean): void;
  34849. /**
  34850. * Gets a boolean indicating if stencil buffer is enabled
  34851. * @returns the current stencil buffer state
  34852. */
  34853. getStencilBuffer(): boolean;
  34854. /**
  34855. * Enable or disable the stencil buffer
  34856. * @param enable defines if the stencil buffer must be enabled or disabled
  34857. */
  34858. setStencilBuffer(enable: boolean): void;
  34859. /**
  34860. * Gets the current stencil mask
  34861. * @returns a number defining the new stencil mask to use
  34862. */
  34863. getStencilMask(): number;
  34864. /**
  34865. * Sets the current stencil mask
  34866. * @param mask defines the new stencil mask to use
  34867. */
  34868. setStencilMask(mask: number): void;
  34869. /**
  34870. * Gets the current stencil function
  34871. * @returns a number defining the stencil function to use
  34872. */
  34873. getStencilFunction(): number;
  34874. /**
  34875. * Gets the current stencil reference value
  34876. * @returns a number defining the stencil reference value to use
  34877. */
  34878. getStencilFunctionReference(): number;
  34879. /**
  34880. * Gets the current stencil mask
  34881. * @returns a number defining the stencil mask to use
  34882. */
  34883. getStencilFunctionMask(): number;
  34884. /**
  34885. * Sets the current stencil function
  34886. * @param stencilFunc defines the new stencil function to use
  34887. */
  34888. setStencilFunction(stencilFunc: number): void;
  34889. /**
  34890. * Sets the current stencil reference
  34891. * @param reference defines the new stencil reference to use
  34892. */
  34893. setStencilFunctionReference(reference: number): void;
  34894. /**
  34895. * Sets the current stencil mask
  34896. * @param mask defines the new stencil mask to use
  34897. */
  34898. setStencilFunctionMask(mask: number): void;
  34899. /**
  34900. * Gets the current stencil operation when stencil fails
  34901. * @returns a number defining stencil operation to use when stencil fails
  34902. */
  34903. getStencilOperationFail(): number;
  34904. /**
  34905. * Gets the current stencil operation when depth fails
  34906. * @returns a number defining stencil operation to use when depth fails
  34907. */
  34908. getStencilOperationDepthFail(): number;
  34909. /**
  34910. * Gets the current stencil operation when stencil passes
  34911. * @returns a number defining stencil operation to use when stencil passes
  34912. */
  34913. getStencilOperationPass(): number;
  34914. /**
  34915. * Sets the stencil operation to use when stencil fails
  34916. * @param operation defines the stencil operation to use when stencil fails
  34917. */
  34918. setStencilOperationFail(operation: number): void;
  34919. /**
  34920. * Sets the stencil operation to use when depth fails
  34921. * @param operation defines the stencil operation to use when depth fails
  34922. */
  34923. setStencilOperationDepthFail(operation: number): void;
  34924. /**
  34925. * Sets the stencil operation to use when stencil passes
  34926. * @param operation defines the stencil operation to use when stencil passes
  34927. */
  34928. setStencilOperationPass(operation: number): void;
  34929. /**
  34930. * Sets a boolean indicating if the dithering state is enabled or disabled
  34931. * @param value defines the dithering state
  34932. */
  34933. setDitheringState(value: boolean): void;
  34934. /**
  34935. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34936. * @param value defines the rasterizer state
  34937. */
  34938. setRasterizerState(value: boolean): void;
  34939. /**
  34940. * Gets the current depth function
  34941. * @returns a number defining the depth function
  34942. */
  34943. getDepthFunction(): Nullable<number>;
  34944. /**
  34945. * Sets the current depth function
  34946. * @param depthFunc defines the function to use
  34947. */
  34948. setDepthFunction(depthFunc: number): void;
  34949. /**
  34950. * Sets the current depth function to GREATER
  34951. */
  34952. setDepthFunctionToGreater(): void;
  34953. /**
  34954. * Sets the current depth function to GEQUAL
  34955. */
  34956. setDepthFunctionToGreaterOrEqual(): void;
  34957. /**
  34958. * Sets the current depth function to LESS
  34959. */
  34960. setDepthFunctionToLess(): void;
  34961. /**
  34962. * Sets the current depth function to LEQUAL
  34963. */
  34964. setDepthFunctionToLessOrEqual(): void;
  34965. private _cachedStencilBuffer;
  34966. private _cachedStencilFunction;
  34967. private _cachedStencilMask;
  34968. private _cachedStencilOperationPass;
  34969. private _cachedStencilOperationFail;
  34970. private _cachedStencilOperationDepthFail;
  34971. private _cachedStencilReference;
  34972. /**
  34973. * Caches the the state of the stencil buffer
  34974. */
  34975. cacheStencilState(): void;
  34976. /**
  34977. * Restores the state of the stencil buffer
  34978. */
  34979. restoreStencilState(): void;
  34980. /**
  34981. * Directly set the WebGL Viewport
  34982. * @param x defines the x coordinate of the viewport (in screen space)
  34983. * @param y defines the y coordinate of the viewport (in screen space)
  34984. * @param width defines the width of the viewport (in screen space)
  34985. * @param height defines the height of the viewport (in screen space)
  34986. * @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
  34987. */
  34988. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34989. /**
  34990. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34991. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34992. * @param y defines the y-coordinate of the corner of the clear rectangle
  34993. * @param width defines the width of the clear rectangle
  34994. * @param height defines the height of the clear rectangle
  34995. * @param clearColor defines the clear color
  34996. */
  34997. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34998. /**
  34999. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35001. * @param y defines the y-coordinate of the corner of the clear rectangle
  35002. * @param width defines the width of the clear rectangle
  35003. * @param height defines the height of the clear rectangle
  35004. */
  35005. enableScissor(x: number, y: number, width: number, height: number): void;
  35006. /**
  35007. * Disable previously set scissor test rectangle
  35008. */
  35009. disableScissor(): void;
  35010. protected _reportDrawCall(): void;
  35011. /**
  35012. * Initializes a webVR display and starts listening to display change events
  35013. * The onVRDisplayChangedObservable will be notified upon these changes
  35014. * @returns The onVRDisplayChangedObservable
  35015. */
  35016. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35017. /** @hidden */
  35018. _prepareVRComponent(): void;
  35019. /** @hidden */
  35020. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35021. /** @hidden */
  35022. _submitVRFrame(): void;
  35023. /**
  35024. * Call this function to leave webVR mode
  35025. * Will do nothing if webVR is not supported or if there is no webVR device
  35026. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35027. */
  35028. disableVR(): void;
  35029. /**
  35030. * Gets a boolean indicating that the system is in VR mode and is presenting
  35031. * @returns true if VR mode is engaged
  35032. */
  35033. isVRPresenting(): boolean;
  35034. /** @hidden */
  35035. _requestVRFrame(): void;
  35036. /** @hidden */
  35037. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35038. /**
  35039. * Gets the source code of the vertex shader associated with a specific webGL program
  35040. * @param program defines the program to use
  35041. * @returns a string containing the source code of the vertex shader associated with the program
  35042. */
  35043. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35044. /**
  35045. * Gets the source code of the fragment shader associated with a specific webGL program
  35046. * @param program defines the program to use
  35047. * @returns a string containing the source code of the fragment shader associated with the program
  35048. */
  35049. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35050. /**
  35051. * Sets a depth stencil texture from a render target to the according uniform.
  35052. * @param channel The texture channel
  35053. * @param uniform The uniform to set
  35054. * @param texture The render target texture containing the depth stencil texture to apply
  35055. */
  35056. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35057. /**
  35058. * Sets a texture to the webGL context from a postprocess
  35059. * @param channel defines the channel to use
  35060. * @param postProcess defines the source postprocess
  35061. */
  35062. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35063. /**
  35064. * Binds the output of the passed in post process to the texture channel specified
  35065. * @param channel The channel the texture should be bound to
  35066. * @param postProcess The post process which's output should be bound
  35067. */
  35068. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35069. /** @hidden */
  35070. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35071. protected _rebuildBuffers(): void;
  35072. /** @hidden */
  35073. _renderFrame(): void;
  35074. _renderLoop(): void;
  35075. /** @hidden */
  35076. _renderViews(): boolean;
  35077. /**
  35078. * Toggle full screen mode
  35079. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35080. */
  35081. switchFullscreen(requestPointerLock: boolean): void;
  35082. /**
  35083. * Enters full screen mode
  35084. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35085. */
  35086. enterFullscreen(requestPointerLock: boolean): void;
  35087. /**
  35088. * Exits full screen mode
  35089. */
  35090. exitFullscreen(): void;
  35091. /**
  35092. * Enters Pointerlock mode
  35093. */
  35094. enterPointerlock(): void;
  35095. /**
  35096. * Exits Pointerlock mode
  35097. */
  35098. exitPointerlock(): void;
  35099. /**
  35100. * Begin a new frame
  35101. */
  35102. beginFrame(): void;
  35103. /**
  35104. * Enf the current frame
  35105. */
  35106. endFrame(): void;
  35107. resize(): void;
  35108. /**
  35109. * Force a specific size of the canvas
  35110. * @param width defines the new canvas' width
  35111. * @param height defines the new canvas' height
  35112. */
  35113. setSize(width: number, height: number): void;
  35114. /**
  35115. * Updates a dynamic vertex buffer.
  35116. * @param vertexBuffer the vertex buffer to update
  35117. * @param data the data used to update the vertex buffer
  35118. * @param byteOffset the byte offset of the data
  35119. * @param byteLength the byte length of the data
  35120. */
  35121. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35122. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35124. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35125. _releaseTexture(texture: InternalTexture): void;
  35126. /**
  35127. * @hidden
  35128. * Rescales a texture
  35129. * @param source input texutre
  35130. * @param destination destination texture
  35131. * @param scene scene to use to render the resize
  35132. * @param internalFormat format to use when resizing
  35133. * @param onComplete callback to be called when resize has completed
  35134. */
  35135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35136. /**
  35137. * Gets the current framerate
  35138. * @returns a number representing the framerate
  35139. */
  35140. getFps(): number;
  35141. /**
  35142. * Gets the time spent between current and previous frame
  35143. * @returns a number representing the delta time in ms
  35144. */
  35145. getDeltaTime(): number;
  35146. private _measureFps;
  35147. /** @hidden */
  35148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35149. /**
  35150. * Update a dynamic index buffer
  35151. * @param indexBuffer defines the target index buffer
  35152. * @param indices defines the data to update
  35153. * @param offset defines the offset in the target index buffer where update should start
  35154. */
  35155. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35156. /**
  35157. * Updates the sample count of a render target texture
  35158. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35159. * @param texture defines the texture to update
  35160. * @param samples defines the sample count to set
  35161. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35162. */
  35163. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35164. /**
  35165. * Updates a depth texture Comparison Mode and Function.
  35166. * If the comparison Function is equal to 0, the mode will be set to none.
  35167. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35168. * @param texture The texture to set the comparison function for
  35169. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35170. */
  35171. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35172. /**
  35173. * Creates a webGL buffer to use with instanciation
  35174. * @param capacity defines the size of the buffer
  35175. * @returns the webGL buffer
  35176. */
  35177. createInstancesBuffer(capacity: number): DataBuffer;
  35178. /**
  35179. * Delete a webGL buffer used with instanciation
  35180. * @param buffer defines the webGL buffer to delete
  35181. */
  35182. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35183. private _clientWaitAsync;
  35184. /** @hidden */
  35185. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35186. /** @hidden */
  35187. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35188. dispose(): void;
  35189. private _disableTouchAction;
  35190. /**
  35191. * Display the loading screen
  35192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35193. */
  35194. displayLoadingUI(): void;
  35195. /**
  35196. * Hide the loading screen
  35197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35198. */
  35199. hideLoadingUI(): void;
  35200. /**
  35201. * Gets the current loading screen object
  35202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35203. */
  35204. get loadingScreen(): ILoadingScreen;
  35205. /**
  35206. * Sets the current loading screen object
  35207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35208. */
  35209. set loadingScreen(loadingScreen: ILoadingScreen);
  35210. /**
  35211. * Sets the current loading screen text
  35212. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35213. */
  35214. set loadingUIText(text: string);
  35215. /**
  35216. * Sets the current loading screen background color
  35217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35218. */
  35219. set loadingUIBackgroundColor(color: string);
  35220. /** Pointerlock and fullscreen */
  35221. /**
  35222. * Ask the browser to promote the current element to pointerlock mode
  35223. * @param element defines the DOM element to promote
  35224. */
  35225. static _RequestPointerlock(element: HTMLElement): void;
  35226. /**
  35227. * Asks the browser to exit pointerlock mode
  35228. */
  35229. static _ExitPointerlock(): void;
  35230. /**
  35231. * Ask the browser to promote the current element to fullscreen rendering mode
  35232. * @param element defines the DOM element to promote
  35233. */
  35234. static _RequestFullscreen(element: HTMLElement): void;
  35235. /**
  35236. * Asks the browser to exit fullscreen mode
  35237. */
  35238. static _ExitFullscreen(): void;
  35239. }
  35240. }
  35241. declare module "babylonjs/Engines/engineStore" {
  35242. import { Nullable } from "babylonjs/types";
  35243. import { Engine } from "babylonjs/Engines/engine";
  35244. import { Scene } from "babylonjs/scene";
  35245. /**
  35246. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35247. * during the life time of the application.
  35248. */
  35249. export class EngineStore {
  35250. /** Gets the list of created engines */
  35251. static Instances: import("babylonjs/Engines/engine").Engine[];
  35252. /** @hidden */
  35253. static _LastCreatedScene: Nullable<Scene>;
  35254. /**
  35255. * Gets the latest created engine
  35256. */
  35257. static get LastCreatedEngine(): Nullable<Engine>;
  35258. /**
  35259. * Gets the latest created scene
  35260. */
  35261. static get LastCreatedScene(): Nullable<Scene>;
  35262. /**
  35263. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35264. * @ignorenaming
  35265. */
  35266. static UseFallbackTexture: boolean;
  35267. /**
  35268. * Texture content used if a texture cannot loaded
  35269. * @ignorenaming
  35270. */
  35271. static FallbackTexture: string;
  35272. }
  35273. }
  35274. declare module "babylonjs/Misc/promise" {
  35275. /**
  35276. * Helper class that provides a small promise polyfill
  35277. */
  35278. export class PromisePolyfill {
  35279. /**
  35280. * Static function used to check if the polyfill is required
  35281. * If this is the case then the function will inject the polyfill to window.Promise
  35282. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35283. */
  35284. static Apply(force?: boolean): void;
  35285. }
  35286. }
  35287. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35288. /**
  35289. * Interface for screenshot methods with describe argument called `size` as object with options
  35290. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35291. */
  35292. export interface IScreenshotSize {
  35293. /**
  35294. * number in pixels for canvas height
  35295. */
  35296. height?: number;
  35297. /**
  35298. * multiplier allowing render at a higher or lower resolution
  35299. * If value is defined then height and width will be ignored and taken from camera
  35300. */
  35301. precision?: number;
  35302. /**
  35303. * number in pixels for canvas width
  35304. */
  35305. width?: number;
  35306. }
  35307. }
  35308. declare module "babylonjs/Misc/tools" {
  35309. import { Nullable, float } from "babylonjs/types";
  35310. import { DomManagement } from "babylonjs/Misc/domManagement";
  35311. import { WebRequest } from "babylonjs/Misc/webRequest";
  35312. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35313. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35314. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35315. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35316. import { Camera } from "babylonjs/Cameras/camera";
  35317. import { Engine } from "babylonjs/Engines/engine";
  35318. interface IColor4Like {
  35319. r: float;
  35320. g: float;
  35321. b: float;
  35322. a: float;
  35323. }
  35324. /**
  35325. * Class containing a set of static utilities functions
  35326. */
  35327. export class Tools {
  35328. /**
  35329. * Gets or sets the base URL to use to load assets
  35330. */
  35331. static get BaseUrl(): string;
  35332. static set BaseUrl(value: string);
  35333. /**
  35334. * Enable/Disable Custom HTTP Request Headers globally.
  35335. * default = false
  35336. * @see CustomRequestHeaders
  35337. */
  35338. static UseCustomRequestHeaders: boolean;
  35339. /**
  35340. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35341. * i.e. when loading files, where the server/service expects an Authorization header
  35342. */
  35343. static CustomRequestHeaders: {
  35344. [key: string]: string;
  35345. };
  35346. /**
  35347. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35348. */
  35349. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35350. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35351. /**
  35352. * Default behaviour for cors in the application.
  35353. * It can be a string if the expected behavior is identical in the entire app.
  35354. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35355. */
  35356. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35357. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35358. /**
  35359. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35360. * @ignorenaming
  35361. */
  35362. static get UseFallbackTexture(): boolean;
  35363. static set UseFallbackTexture(value: boolean);
  35364. /**
  35365. * Use this object to register external classes like custom textures or material
  35366. * to allow the laoders to instantiate them
  35367. */
  35368. static get RegisteredExternalClasses(): {
  35369. [key: string]: Object;
  35370. };
  35371. static set RegisteredExternalClasses(classes: {
  35372. [key: string]: Object;
  35373. });
  35374. /**
  35375. * Texture content used if a texture cannot loaded
  35376. * @ignorenaming
  35377. */
  35378. static get fallbackTexture(): string;
  35379. static set fallbackTexture(value: string);
  35380. /**
  35381. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35382. * @param u defines the coordinate on X axis
  35383. * @param v defines the coordinate on Y axis
  35384. * @param width defines the width of the source data
  35385. * @param height defines the height of the source data
  35386. * @param pixels defines the source byte array
  35387. * @param color defines the output color
  35388. */
  35389. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35390. /**
  35391. * Interpolates between a and b via alpha
  35392. * @param a The lower value (returned when alpha = 0)
  35393. * @param b The upper value (returned when alpha = 1)
  35394. * @param alpha The interpolation-factor
  35395. * @return The mixed value
  35396. */
  35397. static Mix(a: number, b: number, alpha: number): number;
  35398. /**
  35399. * Tries to instantiate a new object from a given class name
  35400. * @param className defines the class name to instantiate
  35401. * @returns the new object or null if the system was not able to do the instantiation
  35402. */
  35403. static Instantiate(className: string): any;
  35404. /**
  35405. * Provides a slice function that will work even on IE
  35406. * @param data defines the array to slice
  35407. * @param start defines the start of the data (optional)
  35408. * @param end defines the end of the data (optional)
  35409. * @returns the new sliced array
  35410. */
  35411. static Slice<T>(data: T, start?: number, end?: number): T;
  35412. /**
  35413. * Polyfill for setImmediate
  35414. * @param action defines the action to execute after the current execution block
  35415. */
  35416. static SetImmediate(action: () => void): void;
  35417. /**
  35418. * Function indicating if a number is an exponent of 2
  35419. * @param value defines the value to test
  35420. * @returns true if the value is an exponent of 2
  35421. */
  35422. static IsExponentOfTwo(value: number): boolean;
  35423. private static _tmpFloatArray;
  35424. /**
  35425. * Returns the nearest 32-bit single precision float representation of a Number
  35426. * @param value A Number. If the parameter is of a different type, it will get converted
  35427. * to a number or to NaN if it cannot be converted
  35428. * @returns number
  35429. */
  35430. static FloatRound(value: number): number;
  35431. /**
  35432. * Extracts the filename from a path
  35433. * @param path defines the path to use
  35434. * @returns the filename
  35435. */
  35436. static GetFilename(path: string): string;
  35437. /**
  35438. * Extracts the "folder" part of a path (everything before the filename).
  35439. * @param uri The URI to extract the info from
  35440. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35441. * @returns The "folder" part of the path
  35442. */
  35443. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35444. /**
  35445. * Extracts text content from a DOM element hierarchy
  35446. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35447. */
  35448. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35449. /**
  35450. * Convert an angle in radians to degrees
  35451. * @param angle defines the angle to convert
  35452. * @returns the angle in degrees
  35453. */
  35454. static ToDegrees(angle: number): number;
  35455. /**
  35456. * Convert an angle in degrees to radians
  35457. * @param angle defines the angle to convert
  35458. * @returns the angle in radians
  35459. */
  35460. static ToRadians(angle: number): number;
  35461. /**
  35462. * Returns an array if obj is not an array
  35463. * @param obj defines the object to evaluate as an array
  35464. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35465. * @returns either obj directly if obj is an array or a new array containing obj
  35466. */
  35467. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35468. /**
  35469. * Gets the pointer prefix to use
  35470. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35471. */
  35472. static GetPointerPrefix(): string;
  35473. /**
  35474. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35475. * @param url define the url we are trying
  35476. * @param element define the dom element where to configure the cors policy
  35477. */
  35478. static SetCorsBehavior(url: string | string[], element: {
  35479. crossOrigin: string | null;
  35480. }): void;
  35481. /**
  35482. * Removes unwanted characters from an url
  35483. * @param url defines the url to clean
  35484. * @returns the cleaned url
  35485. */
  35486. static CleanUrl(url: string): string;
  35487. /**
  35488. * Gets or sets a function used to pre-process url before using them to load assets
  35489. */
  35490. static get PreprocessUrl(): (url: string) => string;
  35491. static set PreprocessUrl(processor: (url: string) => string);
  35492. /**
  35493. * Loads an image as an HTMLImageElement.
  35494. * @param input url string, ArrayBuffer, or Blob to load
  35495. * @param onLoad callback called when the image successfully loads
  35496. * @param onError callback called when the image fails to load
  35497. * @param offlineProvider offline provider for caching
  35498. * @param mimeType optional mime type
  35499. * @returns the HTMLImageElement of the loaded image
  35500. */
  35501. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35502. /**
  35503. * Loads a file from a url
  35504. * @param url url string, ArrayBuffer, or Blob to load
  35505. * @param onSuccess callback called when the file successfully loads
  35506. * @param onProgress callback called while file is loading (if the server supports this mode)
  35507. * @param offlineProvider defines the offline provider for caching
  35508. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35509. * @param onError callback called when the file fails to load
  35510. * @returns a file request object
  35511. */
  35512. 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;
  35513. /**
  35514. * Loads a file from a url
  35515. * @param url the file url to load
  35516. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35517. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35518. */
  35519. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35520. /**
  35521. * Load a script (identified by an url). When the url returns, the
  35522. * content of this file is added into a new script element, attached to the DOM (body element)
  35523. * @param scriptUrl defines the url of the script to laod
  35524. * @param onSuccess defines the callback called when the script is loaded
  35525. * @param onError defines the callback to call if an error occurs
  35526. * @param scriptId defines the id of the script element
  35527. */
  35528. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35529. /**
  35530. * Load an asynchronous script (identified by an url). When the url returns, the
  35531. * content of this file is added into a new script element, attached to the DOM (body element)
  35532. * @param scriptUrl defines the url of the script to laod
  35533. * @param scriptId defines the id of the script element
  35534. * @returns a promise request object
  35535. */
  35536. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35537. /**
  35538. * Loads a file from a blob
  35539. * @param fileToLoad defines the blob to use
  35540. * @param callback defines the callback to call when data is loaded
  35541. * @param progressCallback defines the callback to call during loading process
  35542. * @returns a file request object
  35543. */
  35544. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35545. /**
  35546. * Reads a file from a File object
  35547. * @param file defines the file to load
  35548. * @param onSuccess defines the callback to call when data is loaded
  35549. * @param onProgress defines the callback to call during loading process
  35550. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35551. * @param onError defines the callback to call when an error occurs
  35552. * @returns a file request object
  35553. */
  35554. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35555. /**
  35556. * Creates a data url from a given string content
  35557. * @param content defines the content to convert
  35558. * @returns the new data url link
  35559. */
  35560. static FileAsURL(content: string): string;
  35561. /**
  35562. * Format the given number to a specific decimal format
  35563. * @param value defines the number to format
  35564. * @param decimals defines the number of decimals to use
  35565. * @returns the formatted string
  35566. */
  35567. static Format(value: number, decimals?: number): string;
  35568. /**
  35569. * Tries to copy an object by duplicating every property
  35570. * @param source defines the source object
  35571. * @param destination defines the target object
  35572. * @param doNotCopyList defines a list of properties to avoid
  35573. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35574. */
  35575. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35576. /**
  35577. * Gets a boolean indicating if the given object has no own property
  35578. * @param obj defines the object to test
  35579. * @returns true if object has no own property
  35580. */
  35581. static IsEmpty(obj: any): boolean;
  35582. /**
  35583. * Function used to register events at window level
  35584. * @param windowElement defines the Window object to use
  35585. * @param events defines the events to register
  35586. */
  35587. static RegisterTopRootEvents(windowElement: Window, events: {
  35588. name: string;
  35589. handler: Nullable<(e: FocusEvent) => any>;
  35590. }[]): void;
  35591. /**
  35592. * Function used to unregister events from window level
  35593. * @param windowElement defines the Window object to use
  35594. * @param events defines the events to unregister
  35595. */
  35596. static UnregisterTopRootEvents(windowElement: Window, events: {
  35597. name: string;
  35598. handler: Nullable<(e: FocusEvent) => any>;
  35599. }[]): void;
  35600. /**
  35601. * @ignore
  35602. */
  35603. static _ScreenshotCanvas: HTMLCanvasElement;
  35604. /**
  35605. * Dumps the current bound framebuffer
  35606. * @param width defines the rendering width
  35607. * @param height defines the rendering height
  35608. * @param engine defines the hosting engine
  35609. * @param successCallback defines the callback triggered once the data are available
  35610. * @param mimeType defines the mime type of the result
  35611. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35612. */
  35613. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35614. /**
  35615. * Converts the canvas data to blob.
  35616. * This acts as a polyfill for browsers not supporting the to blob function.
  35617. * @param canvas Defines the canvas to extract the data from
  35618. * @param successCallback Defines the callback triggered once the data are available
  35619. * @param mimeType Defines the mime type of the result
  35620. */
  35621. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35622. /**
  35623. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35624. * @param successCallback defines the callback triggered once the data are available
  35625. * @param mimeType defines the mime type of the result
  35626. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35627. */
  35628. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35629. /**
  35630. * Downloads a blob in the browser
  35631. * @param blob defines the blob to download
  35632. * @param fileName defines the name of the downloaded file
  35633. */
  35634. static Download(blob: Blob, fileName: string): void;
  35635. /**
  35636. * Captures a screenshot of the current rendering
  35637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35638. * @param engine defines the rendering engine
  35639. * @param camera defines the source camera
  35640. * @param size This parameter can be set to a single number or to an object with the
  35641. * following (optional) properties: precision, width, height. If a single number is passed,
  35642. * it will be used for both width and height. If an object is passed, the screenshot size
  35643. * will be derived from the parameters. The precision property is a multiplier allowing
  35644. * rendering at a higher or lower resolution
  35645. * @param successCallback defines the callback receives a single parameter which contains the
  35646. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35647. * src parameter of an <img> to display it
  35648. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35649. * Check your browser for supported MIME types
  35650. */
  35651. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: 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 mimeType defines the MIME type of the screenshot image (default: image/png).
  35663. * Check your browser for supported MIME types
  35664. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35665. * to the src parameter of an <img> to display it
  35666. */
  35667. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35668. /**
  35669. * Generates an image screenshot from the specified camera.
  35670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35671. * @param engine The engine to use for rendering
  35672. * @param camera The camera to use for rendering
  35673. * @param size This parameter can be set to a single number or to an object with the
  35674. * following (optional) properties: precision, width, height. If a single number is passed,
  35675. * it will be used for both width and height. If an object is passed, the screenshot size
  35676. * will be derived from the parameters. The precision property is a multiplier allowing
  35677. * rendering at a higher or lower resolution
  35678. * @param successCallback The callback receives a single parameter which contains the
  35679. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35680. * src parameter of an <img> to display it
  35681. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35682. * Check your browser for supported MIME types
  35683. * @param samples Texture samples (default: 1)
  35684. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35685. * @param fileName A name for for the downloaded file.
  35686. */
  35687. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35688. /**
  35689. * Generates an image screenshot from the specified camera.
  35690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35691. * @param engine The engine to use for rendering
  35692. * @param camera The camera to use for rendering
  35693. * @param size This parameter can be set to a single number or to an object with the
  35694. * following (optional) properties: precision, width, height. If a single number is passed,
  35695. * it will be used for both width and height. If an object is passed, the screenshot size
  35696. * will be derived from the parameters. The precision property is a multiplier allowing
  35697. * rendering at a higher or lower resolution
  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. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35704. * to the src parameter of an <img> to display it
  35705. */
  35706. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35707. /**
  35708. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35709. * Be aware Math.random() could cause collisions, but:
  35710. * "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"
  35711. * @returns a pseudo random id
  35712. */
  35713. static RandomId(): string;
  35714. /**
  35715. * Test if the given uri is a base64 string
  35716. * @param uri The uri to test
  35717. * @return True if the uri is a base64 string or false otherwise
  35718. */
  35719. static IsBase64(uri: string): boolean;
  35720. /**
  35721. * Decode the given base64 uri.
  35722. * @param uri The uri to decode
  35723. * @return The decoded base64 data.
  35724. */
  35725. static DecodeBase64(uri: string): ArrayBuffer;
  35726. /**
  35727. * Gets the absolute url.
  35728. * @param url the input url
  35729. * @return the absolute url
  35730. */
  35731. static GetAbsoluteUrl(url: string): string;
  35732. /**
  35733. * No log
  35734. */
  35735. static readonly NoneLogLevel: number;
  35736. /**
  35737. * Only message logs
  35738. */
  35739. static readonly MessageLogLevel: number;
  35740. /**
  35741. * Only warning logs
  35742. */
  35743. static readonly WarningLogLevel: number;
  35744. /**
  35745. * Only error logs
  35746. */
  35747. static readonly ErrorLogLevel: number;
  35748. /**
  35749. * All logs
  35750. */
  35751. static readonly AllLogLevel: number;
  35752. /**
  35753. * Gets a value indicating the number of loading errors
  35754. * @ignorenaming
  35755. */
  35756. static get errorsCount(): number;
  35757. /**
  35758. * Callback called when a new log is added
  35759. */
  35760. static OnNewCacheEntry: (entry: string) => void;
  35761. /**
  35762. * Log a message to the console
  35763. * @param message defines the message to log
  35764. */
  35765. static Log(message: string): void;
  35766. /**
  35767. * Write a warning message to the console
  35768. * @param message defines the message to log
  35769. */
  35770. static Warn(message: string): void;
  35771. /**
  35772. * Write an error message to the console
  35773. * @param message defines the message to log
  35774. */
  35775. static Error(message: string): void;
  35776. /**
  35777. * Gets current log cache (list of logs)
  35778. */
  35779. static get LogCache(): string;
  35780. /**
  35781. * Clears the log cache
  35782. */
  35783. static ClearLogCache(): void;
  35784. /**
  35785. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35786. */
  35787. static set LogLevels(level: number);
  35788. /**
  35789. * Checks if the window object exists
  35790. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35791. */
  35792. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35793. /**
  35794. * No performance log
  35795. */
  35796. static readonly PerformanceNoneLogLevel: number;
  35797. /**
  35798. * Use user marks to log performance
  35799. */
  35800. static readonly PerformanceUserMarkLogLevel: number;
  35801. /**
  35802. * Log performance to the console
  35803. */
  35804. static readonly PerformanceConsoleLogLevel: number;
  35805. private static _performance;
  35806. /**
  35807. * Sets the current performance log level
  35808. */
  35809. static set PerformanceLogLevel(level: number);
  35810. private static _StartPerformanceCounterDisabled;
  35811. private static _EndPerformanceCounterDisabled;
  35812. private static _StartUserMark;
  35813. private static _EndUserMark;
  35814. private static _StartPerformanceConsole;
  35815. private static _EndPerformanceConsole;
  35816. /**
  35817. * Starts a performance counter
  35818. */
  35819. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35820. /**
  35821. * Ends a specific performance coutner
  35822. */
  35823. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35824. /**
  35825. * Gets either window.performance.now() if supported or Date.now() else
  35826. */
  35827. static get Now(): number;
  35828. /**
  35829. * This method will return the name of the class used to create the instance of the given object.
  35830. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35831. * @param object the object to get the class name from
  35832. * @param isType defines if the object is actually a type
  35833. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35834. */
  35835. static GetClassName(object: any, isType?: boolean): string;
  35836. /**
  35837. * Gets the first element of an array satisfying a given predicate
  35838. * @param array defines the array to browse
  35839. * @param predicate defines the predicate to use
  35840. * @returns null if not found or the element
  35841. */
  35842. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35843. /**
  35844. * This method will return the name of the full name of the class, including its owning module (if any).
  35845. * 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).
  35846. * @param object the object to get the class name from
  35847. * @param isType defines if the object is actually a type
  35848. * @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.
  35849. * @ignorenaming
  35850. */
  35851. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35852. /**
  35853. * Returns a promise that resolves after the given amount of time.
  35854. * @param delay Number of milliseconds to delay
  35855. * @returns Promise that resolves after the given amount of time
  35856. */
  35857. static DelayAsync(delay: number): Promise<void>;
  35858. /**
  35859. * Utility function to detect if the current user agent is Safari
  35860. * @returns whether or not the current user agent is safari
  35861. */
  35862. static IsSafari(): boolean;
  35863. }
  35864. /**
  35865. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35866. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35867. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35868. * @param name The name of the class, case should be preserved
  35869. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35870. */
  35871. export function className(name: string, module?: string): (target: Object) => void;
  35872. /**
  35873. * An implementation of a loop for asynchronous functions.
  35874. */
  35875. export class AsyncLoop {
  35876. /**
  35877. * Defines the number of iterations for the loop
  35878. */
  35879. iterations: number;
  35880. /**
  35881. * Defines the current index of the loop.
  35882. */
  35883. index: number;
  35884. private _done;
  35885. private _fn;
  35886. private _successCallback;
  35887. /**
  35888. * Constructor.
  35889. * @param iterations the number of iterations.
  35890. * @param func the function to run each iteration
  35891. * @param successCallback the callback that will be called upon succesful execution
  35892. * @param offset starting offset.
  35893. */
  35894. constructor(
  35895. /**
  35896. * Defines the number of iterations for the loop
  35897. */
  35898. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35899. /**
  35900. * Execute the next iteration. Must be called after the last iteration was finished.
  35901. */
  35902. executeNext(): void;
  35903. /**
  35904. * Break the loop and run the success callback.
  35905. */
  35906. breakLoop(): void;
  35907. /**
  35908. * Create and run an async loop.
  35909. * @param iterations the number of iterations.
  35910. * @param fn the function to run each iteration
  35911. * @param successCallback the callback that will be called upon succesful execution
  35912. * @param offset starting offset.
  35913. * @returns the created async loop object
  35914. */
  35915. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35916. /**
  35917. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35918. * @param iterations total number of iterations
  35919. * @param syncedIterations number of synchronous iterations in each async iteration.
  35920. * @param fn the function to call each iteration.
  35921. * @param callback a success call back that will be called when iterating stops.
  35922. * @param breakFunction a break condition (optional)
  35923. * @param timeout timeout settings for the setTimeout function. default - 0.
  35924. * @returns the created async loop object
  35925. */
  35926. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35927. }
  35928. }
  35929. declare module "babylonjs/Misc/stringDictionary" {
  35930. import { Nullable } from "babylonjs/types";
  35931. /**
  35932. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35933. * The underlying implementation relies on an associative array to ensure the best performances.
  35934. * The value can be anything including 'null' but except 'undefined'
  35935. */
  35936. export class StringDictionary<T> {
  35937. /**
  35938. * This will clear this dictionary and copy the content from the 'source' one.
  35939. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35940. * @param source the dictionary to take the content from and copy to this dictionary
  35941. */
  35942. copyFrom(source: StringDictionary<T>): void;
  35943. /**
  35944. * Get a value based from its key
  35945. * @param key the given key to get the matching value from
  35946. * @return the value if found, otherwise undefined is returned
  35947. */
  35948. get(key: string): T | undefined;
  35949. /**
  35950. * Get a value from its key or add it if it doesn't exist.
  35951. * This method will ensure you that a given key/data will be present in the dictionary.
  35952. * @param key the given key to get the matching value from
  35953. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35954. * The factory will only be invoked if there's no data for the given key.
  35955. * @return the value corresponding to the key.
  35956. */
  35957. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35958. /**
  35959. * Get a value from its key if present in the dictionary otherwise add it
  35960. * @param key the key to get the value from
  35961. * @param val if there's no such key/value pair in the dictionary add it with this value
  35962. * @return the value corresponding to the key
  35963. */
  35964. getOrAdd(key: string, val: T): T;
  35965. /**
  35966. * Check if there's a given key in the dictionary
  35967. * @param key the key to check for
  35968. * @return true if the key is present, false otherwise
  35969. */
  35970. contains(key: string): boolean;
  35971. /**
  35972. * Add a new key and its corresponding value
  35973. * @param key the key to add
  35974. * @param value the value corresponding to the key
  35975. * @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
  35976. */
  35977. add(key: string, value: T): boolean;
  35978. /**
  35979. * Update a specific value associated to a key
  35980. * @param key defines the key to use
  35981. * @param value defines the value to store
  35982. * @returns true if the value was updated (or false if the key was not found)
  35983. */
  35984. set(key: string, value: T): boolean;
  35985. /**
  35986. * Get the element of the given key and remove it from the dictionary
  35987. * @param key defines the key to search
  35988. * @returns the value associated with the key or null if not found
  35989. */
  35990. getAndRemove(key: string): Nullable<T>;
  35991. /**
  35992. * Remove a key/value from the dictionary.
  35993. * @param key the key to remove
  35994. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35995. */
  35996. remove(key: string): boolean;
  35997. /**
  35998. * Clear the whole content of the dictionary
  35999. */
  36000. clear(): void;
  36001. /**
  36002. * Gets the current count
  36003. */
  36004. get count(): number;
  36005. /**
  36006. * Execute a callback on each key/val of the dictionary.
  36007. * Note that you can remove any element in this dictionary in the callback implementation
  36008. * @param callback the callback to execute on a given key/value pair
  36009. */
  36010. forEach(callback: (key: string, val: T) => void): void;
  36011. /**
  36012. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36013. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36014. * Note that you can remove any element in this dictionary in the callback implementation
  36015. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36016. * @returns the first item
  36017. */
  36018. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36019. private _count;
  36020. private _data;
  36021. }
  36022. }
  36023. declare module "babylonjs/Collisions/collisionCoordinator" {
  36024. import { Nullable } from "babylonjs/types";
  36025. import { Scene } from "babylonjs/scene";
  36026. import { Vector3 } from "babylonjs/Maths/math.vector";
  36027. import { Collider } from "babylonjs/Collisions/collider";
  36028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36029. /** @hidden */
  36030. export interface ICollisionCoordinator {
  36031. createCollider(): Collider;
  36032. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36033. init(scene: Scene): void;
  36034. }
  36035. /** @hidden */
  36036. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36037. private _scene;
  36038. private _scaledPosition;
  36039. private _scaledVelocity;
  36040. private _finalPosition;
  36041. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36042. createCollider(): Collider;
  36043. init(scene: Scene): void;
  36044. private _collideWithWorld;
  36045. }
  36046. }
  36047. declare module "babylonjs/Inputs/scene.inputManager" {
  36048. import { Nullable } from "babylonjs/types";
  36049. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36050. import { Vector2 } from "babylonjs/Maths/math.vector";
  36051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36052. import { Scene } from "babylonjs/scene";
  36053. /**
  36054. * Class used to manage all inputs for the scene.
  36055. */
  36056. export class InputManager {
  36057. /** The distance in pixel that you have to move to prevent some events */
  36058. static DragMovementThreshold: number;
  36059. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36060. static LongPressDelay: number;
  36061. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36062. static DoubleClickDelay: number;
  36063. /** If you need to check double click without raising a single click at first click, enable this flag */
  36064. static ExclusiveDoubleClickMode: boolean;
  36065. private _wheelEventName;
  36066. private _onPointerMove;
  36067. private _onPointerDown;
  36068. private _onPointerUp;
  36069. private _initClickEvent;
  36070. private _initActionManager;
  36071. private _delayedSimpleClick;
  36072. private _delayedSimpleClickTimeout;
  36073. private _previousDelayedSimpleClickTimeout;
  36074. private _meshPickProceed;
  36075. private _previousButtonPressed;
  36076. private _currentPickResult;
  36077. private _previousPickResult;
  36078. private _totalPointersPressed;
  36079. private _doubleClickOccured;
  36080. private _pointerOverMesh;
  36081. private _pickedDownMesh;
  36082. private _pickedUpMesh;
  36083. private _pointerX;
  36084. private _pointerY;
  36085. private _unTranslatedPointerX;
  36086. private _unTranslatedPointerY;
  36087. private _startingPointerPosition;
  36088. private _previousStartingPointerPosition;
  36089. private _startingPointerTime;
  36090. private _previousStartingPointerTime;
  36091. private _pointerCaptures;
  36092. private _onKeyDown;
  36093. private _onKeyUp;
  36094. private _onCanvasFocusObserver;
  36095. private _onCanvasBlurObserver;
  36096. private _scene;
  36097. /**
  36098. * Creates a new InputManager
  36099. * @param scene defines the hosting scene
  36100. */
  36101. constructor(scene: Scene);
  36102. /**
  36103. * Gets the mesh that is currently under the pointer
  36104. */
  36105. get meshUnderPointer(): Nullable<AbstractMesh>;
  36106. /**
  36107. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36108. */
  36109. get unTranslatedPointer(): Vector2;
  36110. /**
  36111. * Gets or sets the current on-screen X position of the pointer
  36112. */
  36113. get pointerX(): number;
  36114. set pointerX(value: number);
  36115. /**
  36116. * Gets or sets the current on-screen Y position of the pointer
  36117. */
  36118. get pointerY(): number;
  36119. set pointerY(value: number);
  36120. private _updatePointerPosition;
  36121. private _processPointerMove;
  36122. private _setRayOnPointerInfo;
  36123. private _checkPrePointerObservable;
  36124. /**
  36125. * Use this method to simulate a pointer move on a mesh
  36126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36129. */
  36130. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36131. /**
  36132. * Use this method to simulate a pointer down on a mesh
  36133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36136. */
  36137. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36138. private _processPointerDown;
  36139. /** @hidden */
  36140. _isPointerSwiping(): boolean;
  36141. /**
  36142. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36147. */
  36148. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36149. private _processPointerUp;
  36150. /**
  36151. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36152. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36153. * @returns true if the pointer was captured
  36154. */
  36155. isPointerCaptured(pointerId?: number): boolean;
  36156. /**
  36157. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36158. * @param attachUp defines if you want to attach events to pointerup
  36159. * @param attachDown defines if you want to attach events to pointerdown
  36160. * @param attachMove defines if you want to attach events to pointermove
  36161. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36162. */
  36163. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36164. /**
  36165. * Detaches all event handlers
  36166. */
  36167. detachControl(): void;
  36168. /**
  36169. * Force the value of meshUnderPointer
  36170. * @param mesh defines the mesh to use
  36171. */
  36172. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36173. /**
  36174. * Gets the mesh under the pointer
  36175. * @returns a Mesh or null if no mesh is under the pointer
  36176. */
  36177. getPointerOverMesh(): Nullable<AbstractMesh>;
  36178. }
  36179. }
  36180. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36181. /**
  36182. * Helper class used to generate session unique ID
  36183. */
  36184. export class UniqueIdGenerator {
  36185. private static _UniqueIdCounter;
  36186. /**
  36187. * Gets an unique (relatively to the current scene) Id
  36188. */
  36189. static get UniqueId(): number;
  36190. }
  36191. }
  36192. declare module "babylonjs/Animations/animationGroup" {
  36193. import { Animatable } from "babylonjs/Animations/animatable";
  36194. import { Animation } from "babylonjs/Animations/animation";
  36195. import { Scene, IDisposable } from "babylonjs/scene";
  36196. import { Observable } from "babylonjs/Misc/observable";
  36197. import { Nullable } from "babylonjs/types";
  36198. import "babylonjs/Animations/animatable";
  36199. /**
  36200. * This class defines the direct association between an animation and a target
  36201. */
  36202. export class TargetedAnimation {
  36203. /**
  36204. * Animation to perform
  36205. */
  36206. animation: Animation;
  36207. /**
  36208. * Target to animate
  36209. */
  36210. target: any;
  36211. /**
  36212. * Serialize the object
  36213. * @returns the JSON object representing the current entity
  36214. */
  36215. serialize(): any;
  36216. }
  36217. /**
  36218. * Use this class to create coordinated animations on multiple targets
  36219. */
  36220. export class AnimationGroup implements IDisposable {
  36221. /** The name of the animation group */
  36222. name: string;
  36223. private _scene;
  36224. private _targetedAnimations;
  36225. private _animatables;
  36226. private _from;
  36227. private _to;
  36228. private _isStarted;
  36229. private _isPaused;
  36230. private _speedRatio;
  36231. private _loopAnimation;
  36232. private _isAdditive;
  36233. /**
  36234. * Gets or sets the unique id of the node
  36235. */
  36236. uniqueId: number;
  36237. /**
  36238. * This observable will notify when one animation have ended
  36239. */
  36240. onAnimationEndObservable: Observable<TargetedAnimation>;
  36241. /**
  36242. * Observer raised when one animation loops
  36243. */
  36244. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36245. /**
  36246. * Observer raised when all animations have looped
  36247. */
  36248. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36249. /**
  36250. * This observable will notify when all animations have ended.
  36251. */
  36252. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36253. /**
  36254. * This observable will notify when all animations have paused.
  36255. */
  36256. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36257. /**
  36258. * This observable will notify when all animations are playing.
  36259. */
  36260. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36261. /**
  36262. * Gets the first frame
  36263. */
  36264. get from(): number;
  36265. /**
  36266. * Gets the last frame
  36267. */
  36268. get to(): number;
  36269. /**
  36270. * Define if the animations are started
  36271. */
  36272. get isStarted(): boolean;
  36273. /**
  36274. * Gets a value indicating that the current group is playing
  36275. */
  36276. get isPlaying(): boolean;
  36277. /**
  36278. * Gets or sets the speed ratio to use for all animations
  36279. */
  36280. get speedRatio(): number;
  36281. /**
  36282. * Gets or sets the speed ratio to use for all animations
  36283. */
  36284. set speedRatio(value: number);
  36285. /**
  36286. * Gets or sets if all animations should loop or not
  36287. */
  36288. get loopAnimation(): boolean;
  36289. set loopAnimation(value: boolean);
  36290. /**
  36291. * Gets or sets if all animations should be evaluated additively
  36292. */
  36293. get isAdditive(): boolean;
  36294. set isAdditive(value: boolean);
  36295. /**
  36296. * Gets the targeted animations for this animation group
  36297. */
  36298. get targetedAnimations(): Array<TargetedAnimation>;
  36299. /**
  36300. * returning the list of animatables controlled by this animation group.
  36301. */
  36302. get animatables(): Array<Animatable>;
  36303. /**
  36304. * Instantiates a new Animation Group.
  36305. * This helps managing several animations at once.
  36306. * @see http://doc.babylonjs.com/how_to/group
  36307. * @param name Defines the name of the group
  36308. * @param scene Defines the scene the group belongs to
  36309. */
  36310. constructor(
  36311. /** The name of the animation group */
  36312. name: string, scene?: Nullable<Scene>);
  36313. /**
  36314. * Add an animation (with its target) in the group
  36315. * @param animation defines the animation we want to add
  36316. * @param target defines the target of the animation
  36317. * @returns the TargetedAnimation object
  36318. */
  36319. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36320. /**
  36321. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36322. * It can add constant keys at begin or end
  36323. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36324. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36325. * @returns the animation group
  36326. */
  36327. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36328. private _animationLoopCount;
  36329. private _animationLoopFlags;
  36330. private _processLoop;
  36331. /**
  36332. * Start all animations on given targets
  36333. * @param loop defines if animations must loop
  36334. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36335. * @param from defines the from key (optional)
  36336. * @param to defines the to key (optional)
  36337. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36338. * @returns the current animation group
  36339. */
  36340. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36341. /**
  36342. * Pause all animations
  36343. * @returns the animation group
  36344. */
  36345. pause(): AnimationGroup;
  36346. /**
  36347. * Play all animations to initial state
  36348. * This function will start() the animations if they were not started or will restart() them if they were paused
  36349. * @param loop defines if animations must loop
  36350. * @returns the animation group
  36351. */
  36352. play(loop?: boolean): AnimationGroup;
  36353. /**
  36354. * Reset all animations to initial state
  36355. * @returns the animation group
  36356. */
  36357. reset(): AnimationGroup;
  36358. /**
  36359. * Restart animations from key 0
  36360. * @returns the animation group
  36361. */
  36362. restart(): AnimationGroup;
  36363. /**
  36364. * Stop all animations
  36365. * @returns the animation group
  36366. */
  36367. stop(): AnimationGroup;
  36368. /**
  36369. * Set animation weight for all animatables
  36370. * @param weight defines the weight to use
  36371. * @return the animationGroup
  36372. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36373. */
  36374. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36375. /**
  36376. * Synchronize and normalize all animatables with a source animatable
  36377. * @param root defines the root animatable to synchronize with
  36378. * @return the animationGroup
  36379. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36380. */
  36381. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36382. /**
  36383. * Goes to a specific frame in this animation group
  36384. * @param frame the frame number to go to
  36385. * @return the animationGroup
  36386. */
  36387. goToFrame(frame: number): AnimationGroup;
  36388. /**
  36389. * Dispose all associated resources
  36390. */
  36391. dispose(): void;
  36392. private _checkAnimationGroupEnded;
  36393. /**
  36394. * Clone the current animation group and returns a copy
  36395. * @param newName defines the name of the new group
  36396. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36397. * @returns the new aniamtion group
  36398. */
  36399. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36400. /**
  36401. * Serializes the animationGroup to an object
  36402. * @returns Serialized object
  36403. */
  36404. serialize(): any;
  36405. /**
  36406. * Returns a new AnimationGroup object parsed from the source provided.
  36407. * @param parsedAnimationGroup defines the source
  36408. * @param scene defines the scene that will receive the animationGroup
  36409. * @returns a new AnimationGroup
  36410. */
  36411. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36412. /**
  36413. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36414. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36415. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36416. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36417. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36418. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36419. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36420. */
  36421. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36422. /**
  36423. * Returns the string "AnimationGroup"
  36424. * @returns "AnimationGroup"
  36425. */
  36426. getClassName(): string;
  36427. /**
  36428. * Creates a detailled string about the object
  36429. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36430. * @returns a string representing the object
  36431. */
  36432. toString(fullDetails?: boolean): string;
  36433. }
  36434. }
  36435. declare module "babylonjs/scene" {
  36436. import { Nullable } from "babylonjs/types";
  36437. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36438. import { Observable } from "babylonjs/Misc/observable";
  36439. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36440. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36441. import { Geometry } from "babylonjs/Meshes/geometry";
  36442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36443. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36445. import { Mesh } from "babylonjs/Meshes/mesh";
  36446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36447. import { Bone } from "babylonjs/Bones/bone";
  36448. import { Skeleton } from "babylonjs/Bones/skeleton";
  36449. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36450. import { Camera } from "babylonjs/Cameras/camera";
  36451. import { AbstractScene } from "babylonjs/abstractScene";
  36452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36454. import { Material } from "babylonjs/Materials/material";
  36455. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36456. import { Effect } from "babylonjs/Materials/effect";
  36457. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36458. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36459. import { Light } from "babylonjs/Lights/light";
  36460. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36461. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36462. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36463. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36465. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36466. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36467. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36468. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36469. import { Engine } from "babylonjs/Engines/engine";
  36470. import { Node } from "babylonjs/node";
  36471. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36472. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36473. import { WebRequest } from "babylonjs/Misc/webRequest";
  36474. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36475. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36477. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36478. import { Plane } from "babylonjs/Maths/math.plane";
  36479. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36480. import { Ray } from "babylonjs/Culling/ray";
  36481. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36482. import { Animation } from "babylonjs/Animations/animation";
  36483. import { Animatable } from "babylonjs/Animations/animatable";
  36484. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36485. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36486. import { Collider } from "babylonjs/Collisions/collider";
  36487. /**
  36488. * Define an interface for all classes that will hold resources
  36489. */
  36490. export interface IDisposable {
  36491. /**
  36492. * Releases all held resources
  36493. */
  36494. dispose(): void;
  36495. }
  36496. /** Interface defining initialization parameters for Scene class */
  36497. export interface SceneOptions {
  36498. /**
  36499. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36500. * It will improve performance when the number of geometries becomes important.
  36501. */
  36502. useGeometryUniqueIdsMap?: boolean;
  36503. /**
  36504. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36505. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36506. */
  36507. useMaterialMeshMap?: boolean;
  36508. /**
  36509. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36510. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36511. */
  36512. useClonedMeshMap?: boolean;
  36513. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36514. virtual?: boolean;
  36515. }
  36516. /**
  36517. * Represents a scene to be rendered by the engine.
  36518. * @see http://doc.babylonjs.com/features/scene
  36519. */
  36520. export class Scene extends AbstractScene implements IAnimatable {
  36521. /** The fog is deactivated */
  36522. static readonly FOGMODE_NONE: number;
  36523. /** The fog density is following an exponential function */
  36524. static readonly FOGMODE_EXP: number;
  36525. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36526. static readonly FOGMODE_EXP2: number;
  36527. /** The fog density is following a linear function. */
  36528. static readonly FOGMODE_LINEAR: number;
  36529. /**
  36530. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36532. */
  36533. static MinDeltaTime: number;
  36534. /**
  36535. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36536. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36537. */
  36538. static MaxDeltaTime: number;
  36539. /**
  36540. * Factory used to create the default material.
  36541. * @param name The name of the material to create
  36542. * @param scene The scene to create the material for
  36543. * @returns The default material
  36544. */
  36545. static DefaultMaterialFactory(scene: Scene): Material;
  36546. /**
  36547. * Factory used to create the a collision coordinator.
  36548. * @returns The collision coordinator
  36549. */
  36550. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36551. /** @hidden */
  36552. _inputManager: InputManager;
  36553. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36554. cameraToUseForPointers: Nullable<Camera>;
  36555. /** @hidden */
  36556. readonly _isScene: boolean;
  36557. /** @hidden */
  36558. _blockEntityCollection: boolean;
  36559. /**
  36560. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36561. */
  36562. autoClear: boolean;
  36563. /**
  36564. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36565. */
  36566. autoClearDepthAndStencil: boolean;
  36567. /**
  36568. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36569. */
  36570. clearColor: Color4;
  36571. /**
  36572. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36573. */
  36574. ambientColor: Color3;
  36575. /**
  36576. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36577. * It should only be one of the following (if not the default embedded one):
  36578. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36579. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36580. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36581. * The material properties need to be setup according to the type of texture in use.
  36582. */
  36583. environmentBRDFTexture: BaseTexture;
  36584. /** @hidden */
  36585. protected _environmentTexture: Nullable<BaseTexture>;
  36586. /**
  36587. * Texture used in all pbr material as the reflection texture.
  36588. * As in the majority of the scene they are the same (exception for multi room and so on),
  36589. * this is easier to reference from here than from all the materials.
  36590. */
  36591. get environmentTexture(): Nullable<BaseTexture>;
  36592. /**
  36593. * Texture used in all pbr material as the reflection texture.
  36594. * As in the majority of the scene they are the same (exception for multi room and so on),
  36595. * this is easier to set here than in all the materials.
  36596. */
  36597. set environmentTexture(value: Nullable<BaseTexture>);
  36598. /** @hidden */
  36599. protected _environmentIntensity: number;
  36600. /**
  36601. * Intensity of the environment in all pbr material.
  36602. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36603. * As in the majority of the scene they are the same (exception for multi room and so on),
  36604. * this is easier to reference from here than from all the materials.
  36605. */
  36606. get environmentIntensity(): number;
  36607. /**
  36608. * Intensity of the environment in all pbr material.
  36609. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36610. * As in the majority of the scene they are the same (exception for multi room and so on),
  36611. * this is easier to set here than in all the materials.
  36612. */
  36613. set environmentIntensity(value: number);
  36614. /** @hidden */
  36615. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36616. /**
  36617. * Default image processing configuration used either in the rendering
  36618. * Forward main pass or through the imageProcessingPostProcess if present.
  36619. * As in the majority of the scene they are the same (exception for multi camera),
  36620. * this is easier to reference from here than from all the materials and post process.
  36621. *
  36622. * No setter as we it is a shared configuration, you can set the values instead.
  36623. */
  36624. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36625. private _forceWireframe;
  36626. /**
  36627. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36628. */
  36629. set forceWireframe(value: boolean);
  36630. get forceWireframe(): boolean;
  36631. private _skipFrustumClipping;
  36632. /**
  36633. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36634. */
  36635. set skipFrustumClipping(value: boolean);
  36636. get skipFrustumClipping(): boolean;
  36637. private _forcePointsCloud;
  36638. /**
  36639. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36640. */
  36641. set forcePointsCloud(value: boolean);
  36642. get forcePointsCloud(): boolean;
  36643. /**
  36644. * Gets or sets the active clipplane 1
  36645. */
  36646. clipPlane: Nullable<Plane>;
  36647. /**
  36648. * Gets or sets the active clipplane 2
  36649. */
  36650. clipPlane2: Nullable<Plane>;
  36651. /**
  36652. * Gets or sets the active clipplane 3
  36653. */
  36654. clipPlane3: Nullable<Plane>;
  36655. /**
  36656. * Gets or sets the active clipplane 4
  36657. */
  36658. clipPlane4: Nullable<Plane>;
  36659. /**
  36660. * Gets or sets the active clipplane 5
  36661. */
  36662. clipPlane5: Nullable<Plane>;
  36663. /**
  36664. * Gets or sets the active clipplane 6
  36665. */
  36666. clipPlane6: Nullable<Plane>;
  36667. /**
  36668. * Gets or sets a boolean indicating if animations are enabled
  36669. */
  36670. animationsEnabled: boolean;
  36671. private _animationPropertiesOverride;
  36672. /**
  36673. * Gets or sets the animation properties override
  36674. */
  36675. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36676. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36677. /**
  36678. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36679. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36680. */
  36681. useConstantAnimationDeltaTime: boolean;
  36682. /**
  36683. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36684. * Please note that it requires to run a ray cast through the scene on every frame
  36685. */
  36686. constantlyUpdateMeshUnderPointer: boolean;
  36687. /**
  36688. * Defines the HTML cursor to use when hovering over interactive elements
  36689. */
  36690. hoverCursor: string;
  36691. /**
  36692. * Defines the HTML default cursor to use (empty by default)
  36693. */
  36694. defaultCursor: string;
  36695. /**
  36696. * Defines whether cursors are handled by the scene.
  36697. */
  36698. doNotHandleCursors: boolean;
  36699. /**
  36700. * This is used to call preventDefault() on pointer down
  36701. * in order to block unwanted artifacts like system double clicks
  36702. */
  36703. preventDefaultOnPointerDown: boolean;
  36704. /**
  36705. * This is used to call preventDefault() on pointer up
  36706. * in order to block unwanted artifacts like system double clicks
  36707. */
  36708. preventDefaultOnPointerUp: boolean;
  36709. /**
  36710. * Gets or sets user defined metadata
  36711. */
  36712. metadata: any;
  36713. /**
  36714. * For internal use only. Please do not use.
  36715. */
  36716. reservedDataStore: any;
  36717. /**
  36718. * Gets the name of the plugin used to load this scene (null by default)
  36719. */
  36720. loadingPluginName: string;
  36721. /**
  36722. * Use this array to add regular expressions used to disable offline support for specific urls
  36723. */
  36724. disableOfflineSupportExceptionRules: RegExp[];
  36725. /**
  36726. * An event triggered when the scene is disposed.
  36727. */
  36728. onDisposeObservable: Observable<Scene>;
  36729. private _onDisposeObserver;
  36730. /** Sets a function to be executed when this scene is disposed. */
  36731. set onDispose(callback: () => void);
  36732. /**
  36733. * An event triggered before rendering the scene (right after animations and physics)
  36734. */
  36735. onBeforeRenderObservable: Observable<Scene>;
  36736. private _onBeforeRenderObserver;
  36737. /** Sets a function to be executed before rendering this scene */
  36738. set beforeRender(callback: Nullable<() => void>);
  36739. /**
  36740. * An event triggered after rendering the scene
  36741. */
  36742. onAfterRenderObservable: Observable<Scene>;
  36743. /**
  36744. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36745. */
  36746. onAfterRenderCameraObservable: Observable<Camera>;
  36747. private _onAfterRenderObserver;
  36748. /** Sets a function to be executed after rendering this scene */
  36749. set afterRender(callback: Nullable<() => void>);
  36750. /**
  36751. * An event triggered before animating the scene
  36752. */
  36753. onBeforeAnimationsObservable: Observable<Scene>;
  36754. /**
  36755. * An event triggered after animations processing
  36756. */
  36757. onAfterAnimationsObservable: Observable<Scene>;
  36758. /**
  36759. * An event triggered before draw calls are ready to be sent
  36760. */
  36761. onBeforeDrawPhaseObservable: Observable<Scene>;
  36762. /**
  36763. * An event triggered after draw calls have been sent
  36764. */
  36765. onAfterDrawPhaseObservable: Observable<Scene>;
  36766. /**
  36767. * An event triggered when the scene is ready
  36768. */
  36769. onReadyObservable: Observable<Scene>;
  36770. /**
  36771. * An event triggered before rendering a camera
  36772. */
  36773. onBeforeCameraRenderObservable: Observable<Camera>;
  36774. private _onBeforeCameraRenderObserver;
  36775. /** Sets a function to be executed before rendering a camera*/
  36776. set beforeCameraRender(callback: () => void);
  36777. /**
  36778. * An event triggered after rendering a camera
  36779. */
  36780. onAfterCameraRenderObservable: Observable<Camera>;
  36781. private _onAfterCameraRenderObserver;
  36782. /** Sets a function to be executed after rendering a camera*/
  36783. set afterCameraRender(callback: () => void);
  36784. /**
  36785. * An event triggered when active meshes evaluation is about to start
  36786. */
  36787. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36788. /**
  36789. * An event triggered when active meshes evaluation is done
  36790. */
  36791. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36792. /**
  36793. * An event triggered when particles rendering is about to start
  36794. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36795. */
  36796. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36797. /**
  36798. * An event triggered when particles rendering is done
  36799. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36800. */
  36801. onAfterParticlesRenderingObservable: Observable<Scene>;
  36802. /**
  36803. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36804. */
  36805. onDataLoadedObservable: Observable<Scene>;
  36806. /**
  36807. * An event triggered when a camera is created
  36808. */
  36809. onNewCameraAddedObservable: Observable<Camera>;
  36810. /**
  36811. * An event triggered when a camera is removed
  36812. */
  36813. onCameraRemovedObservable: Observable<Camera>;
  36814. /**
  36815. * An event triggered when a light is created
  36816. */
  36817. onNewLightAddedObservable: Observable<Light>;
  36818. /**
  36819. * An event triggered when a light is removed
  36820. */
  36821. onLightRemovedObservable: Observable<Light>;
  36822. /**
  36823. * An event triggered when a geometry is created
  36824. */
  36825. onNewGeometryAddedObservable: Observable<Geometry>;
  36826. /**
  36827. * An event triggered when a geometry is removed
  36828. */
  36829. onGeometryRemovedObservable: Observable<Geometry>;
  36830. /**
  36831. * An event triggered when a transform node is created
  36832. */
  36833. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36834. /**
  36835. * An event triggered when a transform node is removed
  36836. */
  36837. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36838. /**
  36839. * An event triggered when a mesh is created
  36840. */
  36841. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36842. /**
  36843. * An event triggered when a mesh is removed
  36844. */
  36845. onMeshRemovedObservable: Observable<AbstractMesh>;
  36846. /**
  36847. * An event triggered when a skeleton is created
  36848. */
  36849. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36850. /**
  36851. * An event triggered when a skeleton is removed
  36852. */
  36853. onSkeletonRemovedObservable: Observable<Skeleton>;
  36854. /**
  36855. * An event triggered when a material is created
  36856. */
  36857. onNewMaterialAddedObservable: Observable<Material>;
  36858. /**
  36859. * An event triggered when a material is removed
  36860. */
  36861. onMaterialRemovedObservable: Observable<Material>;
  36862. /**
  36863. * An event triggered when a texture is created
  36864. */
  36865. onNewTextureAddedObservable: Observable<BaseTexture>;
  36866. /**
  36867. * An event triggered when a texture is removed
  36868. */
  36869. onTextureRemovedObservable: Observable<BaseTexture>;
  36870. /**
  36871. * An event triggered when render targets are about to be rendered
  36872. * Can happen multiple times per frame.
  36873. */
  36874. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36875. /**
  36876. * An event triggered when render targets were rendered.
  36877. * Can happen multiple times per frame.
  36878. */
  36879. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36880. /**
  36881. * An event triggered before calculating deterministic simulation step
  36882. */
  36883. onBeforeStepObservable: Observable<Scene>;
  36884. /**
  36885. * An event triggered after calculating deterministic simulation step
  36886. */
  36887. onAfterStepObservable: Observable<Scene>;
  36888. /**
  36889. * An event triggered when the activeCamera property is updated
  36890. */
  36891. onActiveCameraChanged: Observable<Scene>;
  36892. /**
  36893. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36894. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36895. * 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)
  36896. */
  36897. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36898. /**
  36899. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36900. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36901. * 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)
  36902. */
  36903. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36904. /**
  36905. * This Observable will when a mesh has been imported into the scene.
  36906. */
  36907. onMeshImportedObservable: Observable<AbstractMesh>;
  36908. /**
  36909. * This Observable will when an animation file has been imported into the scene.
  36910. */
  36911. onAnimationFileImportedObservable: Observable<Scene>;
  36912. /**
  36913. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36914. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36915. */
  36916. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36917. /** @hidden */
  36918. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36919. /**
  36920. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36921. */
  36922. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36923. /**
  36924. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36925. */
  36926. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36927. /**
  36928. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36929. */
  36930. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36931. /** Callback called when a pointer move is detected */
  36932. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36933. /** Callback called when a pointer down is detected */
  36934. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36935. /** Callback called when a pointer up is detected */
  36936. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36937. /** Callback called when a pointer pick is detected */
  36938. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36939. /**
  36940. * 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).
  36941. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36942. */
  36943. onPrePointerObservable: Observable<PointerInfoPre>;
  36944. /**
  36945. * Observable event triggered each time an input event is received from the rendering canvas
  36946. */
  36947. onPointerObservable: Observable<PointerInfo>;
  36948. /**
  36949. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36950. */
  36951. get unTranslatedPointer(): Vector2;
  36952. /**
  36953. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36954. */
  36955. static get DragMovementThreshold(): number;
  36956. static set DragMovementThreshold(value: number);
  36957. /**
  36958. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36959. */
  36960. static get LongPressDelay(): number;
  36961. static set LongPressDelay(value: number);
  36962. /**
  36963. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36964. */
  36965. static get DoubleClickDelay(): number;
  36966. static set DoubleClickDelay(value: number);
  36967. /** If you need to check double click without raising a single click at first click, enable this flag */
  36968. static get ExclusiveDoubleClickMode(): boolean;
  36969. static set ExclusiveDoubleClickMode(value: boolean);
  36970. /** @hidden */
  36971. _mirroredCameraPosition: Nullable<Vector3>;
  36972. /**
  36973. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36974. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36975. */
  36976. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36977. /**
  36978. * Observable event triggered each time an keyboard event is received from the hosting window
  36979. */
  36980. onKeyboardObservable: Observable<KeyboardInfo>;
  36981. private _useRightHandedSystem;
  36982. /**
  36983. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36984. */
  36985. set useRightHandedSystem(value: boolean);
  36986. get useRightHandedSystem(): boolean;
  36987. private _timeAccumulator;
  36988. private _currentStepId;
  36989. private _currentInternalStep;
  36990. /**
  36991. * Sets the step Id used by deterministic lock step
  36992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36993. * @param newStepId defines the step Id
  36994. */
  36995. setStepId(newStepId: number): void;
  36996. /**
  36997. * Gets the step Id used by deterministic lock step
  36998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36999. * @returns the step Id
  37000. */
  37001. getStepId(): number;
  37002. /**
  37003. * Gets the internal step used by deterministic lock step
  37004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37005. * @returns the internal step
  37006. */
  37007. getInternalStep(): number;
  37008. private _fogEnabled;
  37009. /**
  37010. * Gets or sets a boolean indicating if fog is enabled on this scene
  37011. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37012. * (Default is true)
  37013. */
  37014. set fogEnabled(value: boolean);
  37015. get fogEnabled(): boolean;
  37016. private _fogMode;
  37017. /**
  37018. * Gets or sets the fog mode to use
  37019. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37020. * | mode | value |
  37021. * | --- | --- |
  37022. * | FOGMODE_NONE | 0 |
  37023. * | FOGMODE_EXP | 1 |
  37024. * | FOGMODE_EXP2 | 2 |
  37025. * | FOGMODE_LINEAR | 3 |
  37026. */
  37027. set fogMode(value: number);
  37028. get fogMode(): number;
  37029. /**
  37030. * Gets or sets the fog color to use
  37031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37032. * (Default is Color3(0.2, 0.2, 0.3))
  37033. */
  37034. fogColor: Color3;
  37035. /**
  37036. * Gets or sets the fog density to use
  37037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37038. * (Default is 0.1)
  37039. */
  37040. fogDensity: number;
  37041. /**
  37042. * Gets or sets the fog start distance to use
  37043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37044. * (Default is 0)
  37045. */
  37046. fogStart: number;
  37047. /**
  37048. * Gets or sets the fog end distance to use
  37049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37050. * (Default is 1000)
  37051. */
  37052. fogEnd: number;
  37053. private _shadowsEnabled;
  37054. /**
  37055. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37056. */
  37057. set shadowsEnabled(value: boolean);
  37058. get shadowsEnabled(): boolean;
  37059. private _lightsEnabled;
  37060. /**
  37061. * Gets or sets a boolean indicating if lights are enabled on this scene
  37062. */
  37063. set lightsEnabled(value: boolean);
  37064. get lightsEnabled(): boolean;
  37065. /** All of the active cameras added to this scene. */
  37066. activeCameras: Camera[];
  37067. /** @hidden */
  37068. _activeCamera: Nullable<Camera>;
  37069. /** Gets or sets the current active camera */
  37070. get activeCamera(): Nullable<Camera>;
  37071. set activeCamera(value: Nullable<Camera>);
  37072. private _defaultMaterial;
  37073. /** The default material used on meshes when no material is affected */
  37074. get defaultMaterial(): Material;
  37075. /** The default material used on meshes when no material is affected */
  37076. set defaultMaterial(value: Material);
  37077. private _texturesEnabled;
  37078. /**
  37079. * Gets or sets a boolean indicating if textures are enabled on this scene
  37080. */
  37081. set texturesEnabled(value: boolean);
  37082. get texturesEnabled(): boolean;
  37083. /**
  37084. * Gets or sets a boolean indicating if particles are enabled on this scene
  37085. */
  37086. particlesEnabled: boolean;
  37087. /**
  37088. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37089. */
  37090. spritesEnabled: boolean;
  37091. private _skeletonsEnabled;
  37092. /**
  37093. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37094. */
  37095. set skeletonsEnabled(value: boolean);
  37096. get skeletonsEnabled(): boolean;
  37097. /**
  37098. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37099. */
  37100. lensFlaresEnabled: boolean;
  37101. /**
  37102. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37104. */
  37105. collisionsEnabled: boolean;
  37106. private _collisionCoordinator;
  37107. /** @hidden */
  37108. get collisionCoordinator(): ICollisionCoordinator;
  37109. /**
  37110. * Defines the gravity applied to this scene (used only for collisions)
  37111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37112. */
  37113. gravity: Vector3;
  37114. /**
  37115. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37116. */
  37117. postProcessesEnabled: boolean;
  37118. /**
  37119. * The list of postprocesses added to the scene
  37120. */
  37121. postProcesses: PostProcess[];
  37122. /**
  37123. * Gets the current postprocess manager
  37124. */
  37125. postProcessManager: PostProcessManager;
  37126. /**
  37127. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37128. */
  37129. renderTargetsEnabled: boolean;
  37130. /**
  37131. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37132. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37133. */
  37134. dumpNextRenderTargets: boolean;
  37135. /**
  37136. * The list of user defined render targets added to the scene
  37137. */
  37138. customRenderTargets: RenderTargetTexture[];
  37139. /**
  37140. * Defines if texture loading must be delayed
  37141. * If true, textures will only be loaded when they need to be rendered
  37142. */
  37143. useDelayedTextureLoading: boolean;
  37144. /**
  37145. * Gets the list of meshes imported to the scene through SceneLoader
  37146. */
  37147. importedMeshesFiles: String[];
  37148. /**
  37149. * Gets or sets a boolean indicating if probes are enabled on this scene
  37150. */
  37151. probesEnabled: boolean;
  37152. /**
  37153. * Gets or sets the current offline provider to use to store scene data
  37154. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37155. */
  37156. offlineProvider: IOfflineProvider;
  37157. /**
  37158. * Gets or sets the action manager associated with the scene
  37159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37160. */
  37161. actionManager: AbstractActionManager;
  37162. private _meshesForIntersections;
  37163. /**
  37164. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37165. */
  37166. proceduralTexturesEnabled: boolean;
  37167. private _engine;
  37168. private _totalVertices;
  37169. /** @hidden */
  37170. _activeIndices: PerfCounter;
  37171. /** @hidden */
  37172. _activeParticles: PerfCounter;
  37173. /** @hidden */
  37174. _activeBones: PerfCounter;
  37175. private _animationRatio;
  37176. /** @hidden */
  37177. _animationTimeLast: number;
  37178. /** @hidden */
  37179. _animationTime: number;
  37180. /**
  37181. * Gets or sets a general scale for animation speed
  37182. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37183. */
  37184. animationTimeScale: number;
  37185. /** @hidden */
  37186. _cachedMaterial: Nullable<Material>;
  37187. /** @hidden */
  37188. _cachedEffect: Nullable<Effect>;
  37189. /** @hidden */
  37190. _cachedVisibility: Nullable<number>;
  37191. private _renderId;
  37192. private _frameId;
  37193. private _executeWhenReadyTimeoutId;
  37194. private _intermediateRendering;
  37195. private _viewUpdateFlag;
  37196. private _projectionUpdateFlag;
  37197. /** @hidden */
  37198. _toBeDisposed: Nullable<IDisposable>[];
  37199. private _activeRequests;
  37200. /** @hidden */
  37201. _pendingData: any[];
  37202. private _isDisposed;
  37203. /**
  37204. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37205. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37206. */
  37207. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37208. private _activeMeshes;
  37209. private _processedMaterials;
  37210. private _renderTargets;
  37211. /** @hidden */
  37212. _activeParticleSystems: SmartArray<IParticleSystem>;
  37213. private _activeSkeletons;
  37214. private _softwareSkinnedMeshes;
  37215. private _renderingManager;
  37216. /** @hidden */
  37217. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37218. private _transformMatrix;
  37219. private _sceneUbo;
  37220. /** @hidden */
  37221. _viewMatrix: Matrix;
  37222. private _projectionMatrix;
  37223. /** @hidden */
  37224. _forcedViewPosition: Nullable<Vector3>;
  37225. /** @hidden */
  37226. _frustumPlanes: Plane[];
  37227. /**
  37228. * Gets the list of frustum planes (built from the active camera)
  37229. */
  37230. get frustumPlanes(): Plane[];
  37231. /**
  37232. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37233. * This is useful if there are more lights that the maximum simulteanous authorized
  37234. */
  37235. requireLightSorting: boolean;
  37236. /** @hidden */
  37237. readonly useMaterialMeshMap: boolean;
  37238. /** @hidden */
  37239. readonly useClonedMeshMap: boolean;
  37240. private _externalData;
  37241. private _uid;
  37242. /**
  37243. * @hidden
  37244. * Backing store of defined scene components.
  37245. */
  37246. _components: ISceneComponent[];
  37247. /**
  37248. * @hidden
  37249. * Backing store of defined scene components.
  37250. */
  37251. _serializableComponents: ISceneSerializableComponent[];
  37252. /**
  37253. * List of components to register on the next registration step.
  37254. */
  37255. private _transientComponents;
  37256. /**
  37257. * Registers the transient components if needed.
  37258. */
  37259. private _registerTransientComponents;
  37260. /**
  37261. * @hidden
  37262. * Add a component to the scene.
  37263. * Note that the ccomponent could be registered on th next frame if this is called after
  37264. * the register component stage.
  37265. * @param component Defines the component to add to the scene
  37266. */
  37267. _addComponent(component: ISceneComponent): void;
  37268. /**
  37269. * @hidden
  37270. * Gets a component from the scene.
  37271. * @param name defines the name of the component to retrieve
  37272. * @returns the component or null if not present
  37273. */
  37274. _getComponent(name: string): Nullable<ISceneComponent>;
  37275. /**
  37276. * @hidden
  37277. * Defines the actions happening before camera updates.
  37278. */
  37279. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37280. /**
  37281. * @hidden
  37282. * Defines the actions happening before clear the canvas.
  37283. */
  37284. _beforeClearStage: Stage<SimpleStageAction>;
  37285. /**
  37286. * @hidden
  37287. * Defines the actions when collecting render targets for the frame.
  37288. */
  37289. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37290. /**
  37291. * @hidden
  37292. * Defines the actions happening for one camera in the frame.
  37293. */
  37294. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37295. /**
  37296. * @hidden
  37297. * Defines the actions happening during the per mesh ready checks.
  37298. */
  37299. _isReadyForMeshStage: Stage<MeshStageAction>;
  37300. /**
  37301. * @hidden
  37302. * Defines the actions happening before evaluate active mesh checks.
  37303. */
  37304. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37305. /**
  37306. * @hidden
  37307. * Defines the actions happening during the evaluate sub mesh checks.
  37308. */
  37309. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37310. /**
  37311. * @hidden
  37312. * Defines the actions happening during the active mesh stage.
  37313. */
  37314. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37315. /**
  37316. * @hidden
  37317. * Defines the actions happening during the per camera render target step.
  37318. */
  37319. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37320. /**
  37321. * @hidden
  37322. * Defines the actions happening just before the active camera is drawing.
  37323. */
  37324. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37325. /**
  37326. * @hidden
  37327. * Defines the actions happening just before a render target is drawing.
  37328. */
  37329. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37330. /**
  37331. * @hidden
  37332. * Defines the actions happening just before a rendering group is drawing.
  37333. */
  37334. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37335. /**
  37336. * @hidden
  37337. * Defines the actions happening just before a mesh is drawing.
  37338. */
  37339. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37340. /**
  37341. * @hidden
  37342. * Defines the actions happening just after a mesh has been drawn.
  37343. */
  37344. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37345. /**
  37346. * @hidden
  37347. * Defines the actions happening just after a rendering group has been drawn.
  37348. */
  37349. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37350. /**
  37351. * @hidden
  37352. * Defines the actions happening just after the active camera has been drawn.
  37353. */
  37354. _afterCameraDrawStage: Stage<CameraStageAction>;
  37355. /**
  37356. * @hidden
  37357. * Defines the actions happening just after a render target has been drawn.
  37358. */
  37359. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37360. /**
  37361. * @hidden
  37362. * Defines the actions happening just after rendering all cameras and computing intersections.
  37363. */
  37364. _afterRenderStage: Stage<SimpleStageAction>;
  37365. /**
  37366. * @hidden
  37367. * Defines the actions happening when a pointer move event happens.
  37368. */
  37369. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37370. /**
  37371. * @hidden
  37372. * Defines the actions happening when a pointer down event happens.
  37373. */
  37374. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37375. /**
  37376. * @hidden
  37377. * Defines the actions happening when a pointer up event happens.
  37378. */
  37379. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37380. /**
  37381. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37382. */
  37383. private geometriesByUniqueId;
  37384. /**
  37385. * Creates a new Scene
  37386. * @param engine defines the engine to use to render this scene
  37387. * @param options defines the scene options
  37388. */
  37389. constructor(engine: Engine, options?: SceneOptions);
  37390. /**
  37391. * Gets a string idenfifying the name of the class
  37392. * @returns "Scene" string
  37393. */
  37394. getClassName(): string;
  37395. private _defaultMeshCandidates;
  37396. /**
  37397. * @hidden
  37398. */
  37399. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37400. private _defaultSubMeshCandidates;
  37401. /**
  37402. * @hidden
  37403. */
  37404. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37405. /**
  37406. * Sets the default candidate providers for the scene.
  37407. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37408. * and getCollidingSubMeshCandidates to their default function
  37409. */
  37410. setDefaultCandidateProviders(): void;
  37411. /**
  37412. * Gets the mesh that is currently under the pointer
  37413. */
  37414. get meshUnderPointer(): Nullable<AbstractMesh>;
  37415. /**
  37416. * Gets or sets the current on-screen X position of the pointer
  37417. */
  37418. get pointerX(): number;
  37419. set pointerX(value: number);
  37420. /**
  37421. * Gets or sets the current on-screen Y position of the pointer
  37422. */
  37423. get pointerY(): number;
  37424. set pointerY(value: number);
  37425. /**
  37426. * Gets the cached material (ie. the latest rendered one)
  37427. * @returns the cached material
  37428. */
  37429. getCachedMaterial(): Nullable<Material>;
  37430. /**
  37431. * Gets the cached effect (ie. the latest rendered one)
  37432. * @returns the cached effect
  37433. */
  37434. getCachedEffect(): Nullable<Effect>;
  37435. /**
  37436. * Gets the cached visibility state (ie. the latest rendered one)
  37437. * @returns the cached visibility state
  37438. */
  37439. getCachedVisibility(): Nullable<number>;
  37440. /**
  37441. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37442. * @param material defines the current material
  37443. * @param effect defines the current effect
  37444. * @param visibility defines the current visibility state
  37445. * @returns true if one parameter is not cached
  37446. */
  37447. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37448. /**
  37449. * Gets the engine associated with the scene
  37450. * @returns an Engine
  37451. */
  37452. getEngine(): Engine;
  37453. /**
  37454. * Gets the total number of vertices rendered per frame
  37455. * @returns the total number of vertices rendered per frame
  37456. */
  37457. getTotalVertices(): number;
  37458. /**
  37459. * Gets the performance counter for total vertices
  37460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37461. */
  37462. get totalVerticesPerfCounter(): PerfCounter;
  37463. /**
  37464. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37465. * @returns the total number of active indices rendered per frame
  37466. */
  37467. getActiveIndices(): number;
  37468. /**
  37469. * Gets the performance counter for active indices
  37470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37471. */
  37472. get totalActiveIndicesPerfCounter(): PerfCounter;
  37473. /**
  37474. * Gets the total number of active particles rendered per frame
  37475. * @returns the total number of active particles rendered per frame
  37476. */
  37477. getActiveParticles(): number;
  37478. /**
  37479. * Gets the performance counter for active particles
  37480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37481. */
  37482. get activeParticlesPerfCounter(): PerfCounter;
  37483. /**
  37484. * Gets the total number of active bones rendered per frame
  37485. * @returns the total number of active bones rendered per frame
  37486. */
  37487. getActiveBones(): number;
  37488. /**
  37489. * Gets the performance counter for active bones
  37490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37491. */
  37492. get activeBonesPerfCounter(): PerfCounter;
  37493. /**
  37494. * Gets the array of active meshes
  37495. * @returns an array of AbstractMesh
  37496. */
  37497. getActiveMeshes(): SmartArray<AbstractMesh>;
  37498. /**
  37499. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37500. * @returns a number
  37501. */
  37502. getAnimationRatio(): number;
  37503. /**
  37504. * Gets an unique Id for the current render phase
  37505. * @returns a number
  37506. */
  37507. getRenderId(): number;
  37508. /**
  37509. * Gets an unique Id for the current frame
  37510. * @returns a number
  37511. */
  37512. getFrameId(): number;
  37513. /** Call this function if you want to manually increment the render Id*/
  37514. incrementRenderId(): void;
  37515. private _createUbo;
  37516. /**
  37517. * Use this method to simulate a pointer move on a mesh
  37518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37521. * @returns the current scene
  37522. */
  37523. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37524. /**
  37525. * Use this method to simulate a pointer down on a mesh
  37526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37529. * @returns the current scene
  37530. */
  37531. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37532. /**
  37533. * Use this method to simulate a pointer up on a mesh
  37534. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37535. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37536. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37537. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37538. * @returns the current scene
  37539. */
  37540. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37541. /**
  37542. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37543. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37544. * @returns true if the pointer was captured
  37545. */
  37546. isPointerCaptured(pointerId?: number): boolean;
  37547. /**
  37548. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37549. * @param attachUp defines if you want to attach events to pointerup
  37550. * @param attachDown defines if you want to attach events to pointerdown
  37551. * @param attachMove defines if you want to attach events to pointermove
  37552. */
  37553. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37554. /** Detaches all event handlers*/
  37555. detachControl(): void;
  37556. /**
  37557. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37558. * Delay loaded resources are not taking in account
  37559. * @return true if all required resources are ready
  37560. */
  37561. isReady(): boolean;
  37562. /** Resets all cached information relative to material (including effect and visibility) */
  37563. resetCachedMaterial(): void;
  37564. /**
  37565. * Registers a function to be called before every frame render
  37566. * @param func defines the function to register
  37567. */
  37568. registerBeforeRender(func: () => void): void;
  37569. /**
  37570. * Unregisters a function called before every frame render
  37571. * @param func defines the function to unregister
  37572. */
  37573. unregisterBeforeRender(func: () => void): void;
  37574. /**
  37575. * Registers a function to be called after every frame render
  37576. * @param func defines the function to register
  37577. */
  37578. registerAfterRender(func: () => void): void;
  37579. /**
  37580. * Unregisters a function called after every frame render
  37581. * @param func defines the function to unregister
  37582. */
  37583. unregisterAfterRender(func: () => void): void;
  37584. private _executeOnceBeforeRender;
  37585. /**
  37586. * The provided function will run before render once and will be disposed afterwards.
  37587. * A timeout delay can be provided so that the function will be executed in N ms.
  37588. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37589. * @param func The function to be executed.
  37590. * @param timeout optional delay in ms
  37591. */
  37592. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37593. /** @hidden */
  37594. _addPendingData(data: any): void;
  37595. /** @hidden */
  37596. _removePendingData(data: any): void;
  37597. /**
  37598. * Returns the number of items waiting to be loaded
  37599. * @returns the number of items waiting to be loaded
  37600. */
  37601. getWaitingItemsCount(): number;
  37602. /**
  37603. * Returns a boolean indicating if the scene is still loading data
  37604. */
  37605. get isLoading(): boolean;
  37606. /**
  37607. * Registers a function to be executed when the scene is ready
  37608. * @param {Function} func - the function to be executed
  37609. */
  37610. executeWhenReady(func: () => void): void;
  37611. /**
  37612. * Returns a promise that resolves when the scene is ready
  37613. * @returns A promise that resolves when the scene is ready
  37614. */
  37615. whenReadyAsync(): Promise<void>;
  37616. /** @hidden */
  37617. _checkIsReady(): void;
  37618. /**
  37619. * Gets all animatable attached to the scene
  37620. */
  37621. get animatables(): Animatable[];
  37622. /**
  37623. * Resets the last animation time frame.
  37624. * Useful to override when animations start running when loading a scene for the first time.
  37625. */
  37626. resetLastAnimationTimeFrame(): void;
  37627. /**
  37628. * Gets the current view matrix
  37629. * @returns a Matrix
  37630. */
  37631. getViewMatrix(): Matrix;
  37632. /**
  37633. * Gets the current projection matrix
  37634. * @returns a Matrix
  37635. */
  37636. getProjectionMatrix(): Matrix;
  37637. /**
  37638. * Gets the current transform matrix
  37639. * @returns a Matrix made of View * Projection
  37640. */
  37641. getTransformMatrix(): Matrix;
  37642. /**
  37643. * Sets the current transform matrix
  37644. * @param viewL defines the View matrix to use
  37645. * @param projectionL defines the Projection matrix to use
  37646. * @param viewR defines the right View matrix to use (if provided)
  37647. * @param projectionR defines the right Projection matrix to use (if provided)
  37648. */
  37649. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37650. /**
  37651. * Gets the uniform buffer used to store scene data
  37652. * @returns a UniformBuffer
  37653. */
  37654. getSceneUniformBuffer(): UniformBuffer;
  37655. /**
  37656. * Gets an unique (relatively to the current scene) Id
  37657. * @returns an unique number for the scene
  37658. */
  37659. getUniqueId(): number;
  37660. /**
  37661. * Add a mesh to the list of scene's meshes
  37662. * @param newMesh defines the mesh to add
  37663. * @param recursive if all child meshes should also be added to the scene
  37664. */
  37665. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37666. /**
  37667. * Remove a mesh for the list of scene's meshes
  37668. * @param toRemove defines the mesh to remove
  37669. * @param recursive if all child meshes should also be removed from the scene
  37670. * @returns the index where the mesh was in the mesh list
  37671. */
  37672. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37673. /**
  37674. * Add a transform node to the list of scene's transform nodes
  37675. * @param newTransformNode defines the transform node to add
  37676. */
  37677. addTransformNode(newTransformNode: TransformNode): void;
  37678. /**
  37679. * Remove a transform node for the list of scene's transform nodes
  37680. * @param toRemove defines the transform node to remove
  37681. * @returns the index where the transform node was in the transform node list
  37682. */
  37683. removeTransformNode(toRemove: TransformNode): number;
  37684. /**
  37685. * Remove a skeleton for the list of scene's skeletons
  37686. * @param toRemove defines the skeleton to remove
  37687. * @returns the index where the skeleton was in the skeleton list
  37688. */
  37689. removeSkeleton(toRemove: Skeleton): number;
  37690. /**
  37691. * Remove a morph target for the list of scene's morph targets
  37692. * @param toRemove defines the morph target to remove
  37693. * @returns the index where the morph target was in the morph target list
  37694. */
  37695. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37696. /**
  37697. * Remove a light for the list of scene's lights
  37698. * @param toRemove defines the light to remove
  37699. * @returns the index where the light was in the light list
  37700. */
  37701. removeLight(toRemove: Light): number;
  37702. /**
  37703. * Remove a camera for the list of scene's cameras
  37704. * @param toRemove defines the camera to remove
  37705. * @returns the index where the camera was in the camera list
  37706. */
  37707. removeCamera(toRemove: Camera): number;
  37708. /**
  37709. * Remove a particle system for the list of scene's particle systems
  37710. * @param toRemove defines the particle system to remove
  37711. * @returns the index where the particle system was in the particle system list
  37712. */
  37713. removeParticleSystem(toRemove: IParticleSystem): number;
  37714. /**
  37715. * Remove a animation for the list of scene's animations
  37716. * @param toRemove defines the animation to remove
  37717. * @returns the index where the animation was in the animation list
  37718. */
  37719. removeAnimation(toRemove: Animation): number;
  37720. /**
  37721. * Will stop the animation of the given target
  37722. * @param target - the target
  37723. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37724. * @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)
  37725. */
  37726. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37727. /**
  37728. * Removes the given animation group from this scene.
  37729. * @param toRemove The animation group to remove
  37730. * @returns The index of the removed animation group
  37731. */
  37732. removeAnimationGroup(toRemove: AnimationGroup): number;
  37733. /**
  37734. * Removes the given multi-material from this scene.
  37735. * @param toRemove The multi-material to remove
  37736. * @returns The index of the removed multi-material
  37737. */
  37738. removeMultiMaterial(toRemove: MultiMaterial): number;
  37739. /**
  37740. * Removes the given material from this scene.
  37741. * @param toRemove The material to remove
  37742. * @returns The index of the removed material
  37743. */
  37744. removeMaterial(toRemove: Material): number;
  37745. /**
  37746. * Removes the given action manager from this scene.
  37747. * @param toRemove The action manager to remove
  37748. * @returns The index of the removed action manager
  37749. */
  37750. removeActionManager(toRemove: AbstractActionManager): number;
  37751. /**
  37752. * Removes the given texture from this scene.
  37753. * @param toRemove The texture to remove
  37754. * @returns The index of the removed texture
  37755. */
  37756. removeTexture(toRemove: BaseTexture): number;
  37757. /**
  37758. * Adds the given light to this scene
  37759. * @param newLight The light to add
  37760. */
  37761. addLight(newLight: Light): void;
  37762. /**
  37763. * Sorts the list list based on light priorities
  37764. */
  37765. sortLightsByPriority(): void;
  37766. /**
  37767. * Adds the given camera to this scene
  37768. * @param newCamera The camera to add
  37769. */
  37770. addCamera(newCamera: Camera): void;
  37771. /**
  37772. * Adds the given skeleton to this scene
  37773. * @param newSkeleton The skeleton to add
  37774. */
  37775. addSkeleton(newSkeleton: Skeleton): void;
  37776. /**
  37777. * Adds the given particle system to this scene
  37778. * @param newParticleSystem The particle system to add
  37779. */
  37780. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37781. /**
  37782. * Adds the given animation to this scene
  37783. * @param newAnimation The animation to add
  37784. */
  37785. addAnimation(newAnimation: Animation): void;
  37786. /**
  37787. * Adds the given animation group to this scene.
  37788. * @param newAnimationGroup The animation group to add
  37789. */
  37790. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37791. /**
  37792. * Adds the given multi-material to this scene
  37793. * @param newMultiMaterial The multi-material to add
  37794. */
  37795. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37796. /**
  37797. * Adds the given material to this scene
  37798. * @param newMaterial The material to add
  37799. */
  37800. addMaterial(newMaterial: Material): void;
  37801. /**
  37802. * Adds the given morph target to this scene
  37803. * @param newMorphTargetManager The morph target to add
  37804. */
  37805. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37806. /**
  37807. * Adds the given geometry to this scene
  37808. * @param newGeometry The geometry to add
  37809. */
  37810. addGeometry(newGeometry: Geometry): void;
  37811. /**
  37812. * Adds the given action manager to this scene
  37813. * @param newActionManager The action manager to add
  37814. */
  37815. addActionManager(newActionManager: AbstractActionManager): void;
  37816. /**
  37817. * Adds the given texture to this scene.
  37818. * @param newTexture The texture to add
  37819. */
  37820. addTexture(newTexture: BaseTexture): void;
  37821. /**
  37822. * Switch active camera
  37823. * @param newCamera defines the new active camera
  37824. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37825. */
  37826. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37827. /**
  37828. * sets the active camera of the scene using its ID
  37829. * @param id defines the camera's ID
  37830. * @return the new active camera or null if none found.
  37831. */
  37832. setActiveCameraByID(id: string): Nullable<Camera>;
  37833. /**
  37834. * sets the active camera of the scene using its name
  37835. * @param name defines the camera's name
  37836. * @returns the new active camera or null if none found.
  37837. */
  37838. setActiveCameraByName(name: string): Nullable<Camera>;
  37839. /**
  37840. * get an animation group using its name
  37841. * @param name defines the material's name
  37842. * @return the animation group or null if none found.
  37843. */
  37844. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37845. /**
  37846. * Get a material using its unique id
  37847. * @param uniqueId defines the material's unique id
  37848. * @return the material or null if none found.
  37849. */
  37850. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37851. /**
  37852. * get a material using its id
  37853. * @param id defines the material's ID
  37854. * @return the material or null if none found.
  37855. */
  37856. getMaterialByID(id: string): Nullable<Material>;
  37857. /**
  37858. * Gets a the last added material using a given id
  37859. * @param id defines the material's ID
  37860. * @return the last material with the given id or null if none found.
  37861. */
  37862. getLastMaterialByID(id: string): Nullable<Material>;
  37863. /**
  37864. * Gets a material using its name
  37865. * @param name defines the material's name
  37866. * @return the material or null if none found.
  37867. */
  37868. getMaterialByName(name: string): Nullable<Material>;
  37869. /**
  37870. * Get a texture using its unique id
  37871. * @param uniqueId defines the texture's unique id
  37872. * @return the texture or null if none found.
  37873. */
  37874. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37875. /**
  37876. * Gets a camera using its id
  37877. * @param id defines the id to look for
  37878. * @returns the camera or null if not found
  37879. */
  37880. getCameraByID(id: string): Nullable<Camera>;
  37881. /**
  37882. * Gets a camera using its unique id
  37883. * @param uniqueId defines the unique id to look for
  37884. * @returns the camera or null if not found
  37885. */
  37886. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37887. /**
  37888. * Gets a camera using its name
  37889. * @param name defines the camera's name
  37890. * @return the camera or null if none found.
  37891. */
  37892. getCameraByName(name: string): Nullable<Camera>;
  37893. /**
  37894. * Gets a bone using its id
  37895. * @param id defines the bone's id
  37896. * @return the bone or null if not found
  37897. */
  37898. getBoneByID(id: string): Nullable<Bone>;
  37899. /**
  37900. * Gets a bone using its id
  37901. * @param name defines the bone's name
  37902. * @return the bone or null if not found
  37903. */
  37904. getBoneByName(name: string): Nullable<Bone>;
  37905. /**
  37906. * Gets a light node using its name
  37907. * @param name defines the the light's name
  37908. * @return the light or null if none found.
  37909. */
  37910. getLightByName(name: string): Nullable<Light>;
  37911. /**
  37912. * Gets a light node using its id
  37913. * @param id defines the light's id
  37914. * @return the light or null if none found.
  37915. */
  37916. getLightByID(id: string): Nullable<Light>;
  37917. /**
  37918. * Gets a light node using its scene-generated unique ID
  37919. * @param uniqueId defines the light's unique id
  37920. * @return the light or null if none found.
  37921. */
  37922. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37923. /**
  37924. * Gets a particle system by id
  37925. * @param id defines the particle system id
  37926. * @return the corresponding system or null if none found
  37927. */
  37928. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37929. /**
  37930. * Gets a geometry using its ID
  37931. * @param id defines the geometry's id
  37932. * @return the geometry or null if none found.
  37933. */
  37934. getGeometryByID(id: string): Nullable<Geometry>;
  37935. private _getGeometryByUniqueID;
  37936. /**
  37937. * Add a new geometry to this scene
  37938. * @param geometry defines the geometry to be added to the scene.
  37939. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37940. * @return a boolean defining if the geometry was added or not
  37941. */
  37942. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37943. /**
  37944. * Removes an existing geometry
  37945. * @param geometry defines the geometry to be removed from the scene
  37946. * @return a boolean defining if the geometry was removed or not
  37947. */
  37948. removeGeometry(geometry: Geometry): boolean;
  37949. /**
  37950. * Gets the list of geometries attached to the scene
  37951. * @returns an array of Geometry
  37952. */
  37953. getGeometries(): Geometry[];
  37954. /**
  37955. * Gets the first added mesh found of a given ID
  37956. * @param id defines the id to search for
  37957. * @return the mesh found or null if not found at all
  37958. */
  37959. getMeshByID(id: string): Nullable<AbstractMesh>;
  37960. /**
  37961. * Gets a list of meshes using their id
  37962. * @param id defines the id to search for
  37963. * @returns a list of meshes
  37964. */
  37965. getMeshesByID(id: string): Array<AbstractMesh>;
  37966. /**
  37967. * Gets the first added transform node found of a given ID
  37968. * @param id defines the id to search for
  37969. * @return the found transform node or null if not found at all.
  37970. */
  37971. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37972. /**
  37973. * Gets a transform node with its auto-generated unique id
  37974. * @param uniqueId efines the unique id to search for
  37975. * @return the found transform node or null if not found at all.
  37976. */
  37977. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37978. /**
  37979. * Gets a list of transform nodes using their id
  37980. * @param id defines the id to search for
  37981. * @returns a list of transform nodes
  37982. */
  37983. getTransformNodesByID(id: string): Array<TransformNode>;
  37984. /**
  37985. * Gets a mesh with its auto-generated unique id
  37986. * @param uniqueId defines the unique id to search for
  37987. * @return the found mesh or null if not found at all.
  37988. */
  37989. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37990. /**
  37991. * Gets a the last added mesh using a given id
  37992. * @param id defines the id to search for
  37993. * @return the found mesh or null if not found at all.
  37994. */
  37995. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37996. /**
  37997. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37998. * @param id defines the id to search for
  37999. * @return the found node or null if not found at all
  38000. */
  38001. getLastEntryByID(id: string): Nullable<Node>;
  38002. /**
  38003. * Gets a node (Mesh, Camera, Light) using a given id
  38004. * @param id defines the id to search for
  38005. * @return the found node or null if not found at all
  38006. */
  38007. getNodeByID(id: string): Nullable<Node>;
  38008. /**
  38009. * Gets a node (Mesh, Camera, Light) using a given name
  38010. * @param name defines the name to search for
  38011. * @return the found node or null if not found at all.
  38012. */
  38013. getNodeByName(name: string): Nullable<Node>;
  38014. /**
  38015. * Gets a mesh using a given name
  38016. * @param name defines the name to search for
  38017. * @return the found mesh or null if not found at all.
  38018. */
  38019. getMeshByName(name: string): Nullable<AbstractMesh>;
  38020. /**
  38021. * Gets a transform node using a given name
  38022. * @param name defines the name to search for
  38023. * @return the found transform node or null if not found at all.
  38024. */
  38025. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38026. /**
  38027. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38028. * @param id defines the id to search for
  38029. * @return the found skeleton or null if not found at all.
  38030. */
  38031. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38032. /**
  38033. * Gets a skeleton using a given auto generated unique id
  38034. * @param uniqueId defines the unique id to search for
  38035. * @return the found skeleton or null if not found at all.
  38036. */
  38037. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38038. /**
  38039. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38040. * @param id defines the id to search for
  38041. * @return the found skeleton or null if not found at all.
  38042. */
  38043. getSkeletonById(id: string): Nullable<Skeleton>;
  38044. /**
  38045. * Gets a skeleton using a given name
  38046. * @param name defines the name to search for
  38047. * @return the found skeleton or null if not found at all.
  38048. */
  38049. getSkeletonByName(name: string): Nullable<Skeleton>;
  38050. /**
  38051. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38052. * @param id defines the id to search for
  38053. * @return the found morph target manager or null if not found at all.
  38054. */
  38055. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38056. /**
  38057. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38058. * @param id defines the id to search for
  38059. * @return the found morph target or null if not found at all.
  38060. */
  38061. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38062. /**
  38063. * Gets a boolean indicating if the given mesh is active
  38064. * @param mesh defines the mesh to look for
  38065. * @returns true if the mesh is in the active list
  38066. */
  38067. isActiveMesh(mesh: AbstractMesh): boolean;
  38068. /**
  38069. * Return a unique id as a string which can serve as an identifier for the scene
  38070. */
  38071. get uid(): string;
  38072. /**
  38073. * Add an externaly attached data from its key.
  38074. * This method call will fail and return false, if such key already exists.
  38075. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38076. * @param key the unique key that identifies the data
  38077. * @param data the data object to associate to the key for this Engine instance
  38078. * @return true if no such key were already present and the data was added successfully, false otherwise
  38079. */
  38080. addExternalData<T>(key: string, data: T): boolean;
  38081. /**
  38082. * Get an externaly attached data from its key
  38083. * @param key the unique key that identifies the data
  38084. * @return the associated data, if present (can be null), or undefined if not present
  38085. */
  38086. getExternalData<T>(key: string): Nullable<T>;
  38087. /**
  38088. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38089. * @param key the unique key that identifies the data
  38090. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38091. * @return the associated data, can be null if the factory returned null.
  38092. */
  38093. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38094. /**
  38095. * Remove an externaly attached data from the Engine instance
  38096. * @param key the unique key that identifies the data
  38097. * @return true if the data was successfully removed, false if it doesn't exist
  38098. */
  38099. removeExternalData(key: string): boolean;
  38100. private _evaluateSubMesh;
  38101. /**
  38102. * Clear the processed materials smart array preventing retention point in material dispose.
  38103. */
  38104. freeProcessedMaterials(): void;
  38105. private _preventFreeActiveMeshesAndRenderingGroups;
  38106. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38107. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38108. * when disposing several meshes in a row or a hierarchy of meshes.
  38109. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38110. */
  38111. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38112. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38113. /**
  38114. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38115. */
  38116. freeActiveMeshes(): void;
  38117. /**
  38118. * Clear the info related to rendering groups preventing retention points during dispose.
  38119. */
  38120. freeRenderingGroups(): void;
  38121. /** @hidden */
  38122. _isInIntermediateRendering(): boolean;
  38123. /**
  38124. * Lambda returning the list of potentially active meshes.
  38125. */
  38126. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38127. /**
  38128. * Lambda returning the list of potentially active sub meshes.
  38129. */
  38130. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38131. /**
  38132. * Lambda returning the list of potentially intersecting sub meshes.
  38133. */
  38134. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38135. /**
  38136. * Lambda returning the list of potentially colliding sub meshes.
  38137. */
  38138. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38139. private _activeMeshesFrozen;
  38140. private _skipEvaluateActiveMeshesCompletely;
  38141. /**
  38142. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38143. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38144. * @returns the current scene
  38145. */
  38146. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38147. /**
  38148. * Use this function to restart evaluating active meshes on every frame
  38149. * @returns the current scene
  38150. */
  38151. unfreezeActiveMeshes(): Scene;
  38152. private _evaluateActiveMeshes;
  38153. private _activeMesh;
  38154. /**
  38155. * Update the transform matrix to update from the current active camera
  38156. * @param force defines a boolean used to force the update even if cache is up to date
  38157. */
  38158. updateTransformMatrix(force?: boolean): void;
  38159. private _bindFrameBuffer;
  38160. /** @hidden */
  38161. _allowPostProcessClearColor: boolean;
  38162. /** @hidden */
  38163. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38164. private _processSubCameras;
  38165. private _checkIntersections;
  38166. /** @hidden */
  38167. _advancePhysicsEngineStep(step: number): void;
  38168. /**
  38169. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38170. */
  38171. getDeterministicFrameTime: () => number;
  38172. /** @hidden */
  38173. _animate(): void;
  38174. /** Execute all animations (for a frame) */
  38175. animate(): void;
  38176. /**
  38177. * Render the scene
  38178. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38179. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38180. */
  38181. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38182. /**
  38183. * Freeze all materials
  38184. * A frozen material will not be updatable but should be faster to render
  38185. */
  38186. freezeMaterials(): void;
  38187. /**
  38188. * Unfreeze all materials
  38189. * A frozen material will not be updatable but should be faster to render
  38190. */
  38191. unfreezeMaterials(): void;
  38192. /**
  38193. * Releases all held ressources
  38194. */
  38195. dispose(): void;
  38196. /**
  38197. * Gets if the scene is already disposed
  38198. */
  38199. get isDisposed(): boolean;
  38200. /**
  38201. * Call this function to reduce memory footprint of the scene.
  38202. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38203. */
  38204. clearCachedVertexData(): void;
  38205. /**
  38206. * This function will remove the local cached buffer data from texture.
  38207. * It will save memory but will prevent the texture from being rebuilt
  38208. */
  38209. cleanCachedTextureBuffer(): void;
  38210. /**
  38211. * Get the world extend vectors with an optional filter
  38212. *
  38213. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38214. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38215. */
  38216. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38217. min: Vector3;
  38218. max: Vector3;
  38219. };
  38220. /**
  38221. * Creates a ray that can be used to pick in the scene
  38222. * @param x defines the x coordinate of the origin (on-screen)
  38223. * @param y defines the y coordinate of the origin (on-screen)
  38224. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38225. * @param camera defines the camera to use for the picking
  38226. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38227. * @returns a Ray
  38228. */
  38229. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38230. /**
  38231. * Creates a ray that can be used to pick in the scene
  38232. * @param x defines the x coordinate of the origin (on-screen)
  38233. * @param y defines the y coordinate of the origin (on-screen)
  38234. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38235. * @param result defines the ray where to store the picking ray
  38236. * @param camera defines the camera to use for the picking
  38237. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38238. * @returns the current scene
  38239. */
  38240. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38241. /**
  38242. * Creates a ray that can be used to pick in the scene
  38243. * @param x defines the x coordinate of the origin (on-screen)
  38244. * @param y defines the y coordinate of the origin (on-screen)
  38245. * @param camera defines the camera to use for the picking
  38246. * @returns a Ray
  38247. */
  38248. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38249. /**
  38250. * Creates a ray that can be used to pick in the scene
  38251. * @param x defines the x coordinate of the origin (on-screen)
  38252. * @param y defines the y coordinate of the origin (on-screen)
  38253. * @param result defines the ray where to store the picking ray
  38254. * @param camera defines the camera to use for the picking
  38255. * @returns the current scene
  38256. */
  38257. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38258. /** Launch a ray to try to pick a mesh in the scene
  38259. * @param x position on screen
  38260. * @param y position on screen
  38261. * @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
  38262. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38263. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38265. * @returns a PickingInfo
  38266. */
  38267. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38268. /** Use the given ray to pick a mesh in the scene
  38269. * @param ray The ray to use to pick meshes
  38270. * @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
  38271. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38272. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38273. * @returns a PickingInfo
  38274. */
  38275. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38276. /**
  38277. * Launch a ray to try to pick a mesh in the scene
  38278. * @param x X position on screen
  38279. * @param y Y position on screen
  38280. * @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
  38281. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38282. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38283. * @returns an array of PickingInfo
  38284. */
  38285. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38286. /**
  38287. * Launch a ray to try to pick a mesh in the scene
  38288. * @param ray Ray to use
  38289. * @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
  38290. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38291. * @returns an array of PickingInfo
  38292. */
  38293. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38294. /**
  38295. * Force the value of meshUnderPointer
  38296. * @param mesh defines the mesh to use
  38297. */
  38298. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38299. /**
  38300. * Gets the mesh under the pointer
  38301. * @returns a Mesh or null if no mesh is under the pointer
  38302. */
  38303. getPointerOverMesh(): Nullable<AbstractMesh>;
  38304. /** @hidden */
  38305. _rebuildGeometries(): void;
  38306. /** @hidden */
  38307. _rebuildTextures(): void;
  38308. private _getByTags;
  38309. /**
  38310. * Get a list of meshes by tags
  38311. * @param tagsQuery defines the tags query to use
  38312. * @param forEach defines a predicate used to filter results
  38313. * @returns an array of Mesh
  38314. */
  38315. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38316. /**
  38317. * Get a list of cameras by tags
  38318. * @param tagsQuery defines the tags query to use
  38319. * @param forEach defines a predicate used to filter results
  38320. * @returns an array of Camera
  38321. */
  38322. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38323. /**
  38324. * Get a list of lights by tags
  38325. * @param tagsQuery defines the tags query to use
  38326. * @param forEach defines a predicate used to filter results
  38327. * @returns an array of Light
  38328. */
  38329. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38330. /**
  38331. * Get a list of materials by tags
  38332. * @param tagsQuery defines the tags query to use
  38333. * @param forEach defines a predicate used to filter results
  38334. * @returns an array of Material
  38335. */
  38336. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38337. /**
  38338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38339. * This allowed control for front to back rendering or reversly depending of the special needs.
  38340. *
  38341. * @param renderingGroupId The rendering group id corresponding to its index
  38342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38345. */
  38346. 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;
  38347. /**
  38348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38349. *
  38350. * @param renderingGroupId The rendering group id corresponding to its index
  38351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38352. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38353. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38354. */
  38355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38356. /**
  38357. * Gets the current auto clear configuration for one rendering group of the rendering
  38358. * manager.
  38359. * @param index the rendering group index to get the information for
  38360. * @returns The auto clear setup for the requested rendering group
  38361. */
  38362. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38363. private _blockMaterialDirtyMechanism;
  38364. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38365. get blockMaterialDirtyMechanism(): boolean;
  38366. set blockMaterialDirtyMechanism(value: boolean);
  38367. /**
  38368. * Will flag all materials as dirty to trigger new shader compilation
  38369. * @param flag defines the flag used to specify which material part must be marked as dirty
  38370. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38371. */
  38372. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38373. /** @hidden */
  38374. _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;
  38375. /** @hidden */
  38376. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38377. /** @hidden */
  38378. _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;
  38379. /** @hidden */
  38380. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38381. /** @hidden */
  38382. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38383. /** @hidden */
  38384. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38385. }
  38386. }
  38387. declare module "babylonjs/assetContainer" {
  38388. import { AbstractScene } from "babylonjs/abstractScene";
  38389. import { Scene } from "babylonjs/scene";
  38390. import { Mesh } from "babylonjs/Meshes/mesh";
  38391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38392. import { Skeleton } from "babylonjs/Bones/skeleton";
  38393. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38394. import { Animatable } from "babylonjs/Animations/animatable";
  38395. import { Nullable } from "babylonjs/types";
  38396. import { Node } from "babylonjs/node";
  38397. /**
  38398. * Set of assets to keep when moving a scene into an asset container.
  38399. */
  38400. export class KeepAssets extends AbstractScene {
  38401. }
  38402. /**
  38403. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38404. */
  38405. export class InstantiatedEntries {
  38406. /**
  38407. * List of new root nodes (eg. nodes with no parent)
  38408. */
  38409. rootNodes: TransformNode[];
  38410. /**
  38411. * List of new skeletons
  38412. */
  38413. skeletons: Skeleton[];
  38414. /**
  38415. * List of new animation groups
  38416. */
  38417. animationGroups: AnimationGroup[];
  38418. }
  38419. /**
  38420. * Container with a set of assets that can be added or removed from a scene.
  38421. */
  38422. export class AssetContainer extends AbstractScene {
  38423. private _wasAddedToScene;
  38424. /**
  38425. * The scene the AssetContainer belongs to.
  38426. */
  38427. scene: Scene;
  38428. /**
  38429. * Instantiates an AssetContainer.
  38430. * @param scene The scene the AssetContainer belongs to.
  38431. */
  38432. constructor(scene: Scene);
  38433. /**
  38434. * Instantiate or clone all meshes and add the new ones to the scene.
  38435. * Skeletons and animation groups will all be cloned
  38436. * @param nameFunction defines an optional function used to get new names for clones
  38437. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38438. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38439. */
  38440. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38441. /**
  38442. * Adds all the assets from the container to the scene.
  38443. */
  38444. addAllToScene(): void;
  38445. /**
  38446. * Removes all the assets in the container from the scene
  38447. */
  38448. removeAllFromScene(): void;
  38449. /**
  38450. * Disposes all the assets in the container
  38451. */
  38452. dispose(): void;
  38453. private _moveAssets;
  38454. /**
  38455. * Removes all the assets contained in the scene and adds them to the container.
  38456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38457. */
  38458. moveAllFromScene(keepAssets?: KeepAssets): void;
  38459. /**
  38460. * 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.
  38461. * @returns the root mesh
  38462. */
  38463. createRootMesh(): Mesh;
  38464. /**
  38465. * Merge animations from this asset container into a scene
  38466. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38467. * @param animatables set of animatables to retarget to a node from the scene
  38468. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38469. */
  38470. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38471. }
  38472. }
  38473. declare module "babylonjs/abstractScene" {
  38474. import { Scene } from "babylonjs/scene";
  38475. import { Nullable } from "babylonjs/types";
  38476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38478. import { Geometry } from "babylonjs/Meshes/geometry";
  38479. import { Skeleton } from "babylonjs/Bones/skeleton";
  38480. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38481. import { AssetContainer } from "babylonjs/assetContainer";
  38482. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38483. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38485. import { Material } from "babylonjs/Materials/material";
  38486. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38487. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38488. import { Camera } from "babylonjs/Cameras/camera";
  38489. import { Light } from "babylonjs/Lights/light";
  38490. import { Node } from "babylonjs/node";
  38491. import { Animation } from "babylonjs/Animations/animation";
  38492. /**
  38493. * Defines how the parser contract is defined.
  38494. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38495. */
  38496. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38497. /**
  38498. * Defines how the individual parser contract is defined.
  38499. * These parser can parse an individual asset
  38500. */
  38501. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38502. /**
  38503. * Base class of the scene acting as a container for the different elements composing a scene.
  38504. * This class is dynamically extended by the different components of the scene increasing
  38505. * flexibility and reducing coupling
  38506. */
  38507. export abstract class AbstractScene {
  38508. /**
  38509. * Stores the list of available parsers in the application.
  38510. */
  38511. private static _BabylonFileParsers;
  38512. /**
  38513. * Stores the list of available individual parsers in the application.
  38514. */
  38515. private static _IndividualBabylonFileParsers;
  38516. /**
  38517. * Adds a parser in the list of available ones
  38518. * @param name Defines the name of the parser
  38519. * @param parser Defines the parser to add
  38520. */
  38521. static AddParser(name: string, parser: BabylonFileParser): void;
  38522. /**
  38523. * Gets a general parser from the list of avaialble ones
  38524. * @param name Defines the name of the parser
  38525. * @returns the requested parser or null
  38526. */
  38527. static GetParser(name: string): Nullable<BabylonFileParser>;
  38528. /**
  38529. * Adds n individual parser in the list of available ones
  38530. * @param name Defines the name of the parser
  38531. * @param parser Defines the parser to add
  38532. */
  38533. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38534. /**
  38535. * Gets an individual parser from the list of avaialble ones
  38536. * @param name Defines the name of the parser
  38537. * @returns the requested parser or null
  38538. */
  38539. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38540. /**
  38541. * Parser json data and populate both a scene and its associated container object
  38542. * @param jsonData Defines the data to parse
  38543. * @param scene Defines the scene to parse the data for
  38544. * @param container Defines the container attached to the parsing sequence
  38545. * @param rootUrl Defines the root url of the data
  38546. */
  38547. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38548. /**
  38549. * Gets the list of root nodes (ie. nodes with no parent)
  38550. */
  38551. rootNodes: Node[];
  38552. /** All of the cameras added to this scene
  38553. * @see http://doc.babylonjs.com/babylon101/cameras
  38554. */
  38555. cameras: Camera[];
  38556. /**
  38557. * All of the lights added to this scene
  38558. * @see http://doc.babylonjs.com/babylon101/lights
  38559. */
  38560. lights: Light[];
  38561. /**
  38562. * All of the (abstract) meshes added to this scene
  38563. */
  38564. meshes: AbstractMesh[];
  38565. /**
  38566. * The list of skeletons added to the scene
  38567. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38568. */
  38569. skeletons: Skeleton[];
  38570. /**
  38571. * All of the particle systems added to this scene
  38572. * @see http://doc.babylonjs.com/babylon101/particles
  38573. */
  38574. particleSystems: IParticleSystem[];
  38575. /**
  38576. * Gets a list of Animations associated with the scene
  38577. */
  38578. animations: Animation[];
  38579. /**
  38580. * All of the animation groups added to this scene
  38581. * @see http://doc.babylonjs.com/how_to/group
  38582. */
  38583. animationGroups: AnimationGroup[];
  38584. /**
  38585. * All of the multi-materials added to this scene
  38586. * @see http://doc.babylonjs.com/how_to/multi_materials
  38587. */
  38588. multiMaterials: MultiMaterial[];
  38589. /**
  38590. * All of the materials added to this scene
  38591. * In the context of a Scene, it is not supposed to be modified manually.
  38592. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38593. * Note also that the order of the Material within the array is not significant and might change.
  38594. * @see http://doc.babylonjs.com/babylon101/materials
  38595. */
  38596. materials: Material[];
  38597. /**
  38598. * The list of morph target managers added to the scene
  38599. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38600. */
  38601. morphTargetManagers: MorphTargetManager[];
  38602. /**
  38603. * The list of geometries used in the scene.
  38604. */
  38605. geometries: Geometry[];
  38606. /**
  38607. * All of the tranform nodes added to this scene
  38608. * In the context of a Scene, it is not supposed to be modified manually.
  38609. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38610. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38611. * @see http://doc.babylonjs.com/how_to/transformnode
  38612. */
  38613. transformNodes: TransformNode[];
  38614. /**
  38615. * ActionManagers available on the scene.
  38616. */
  38617. actionManagers: AbstractActionManager[];
  38618. /**
  38619. * Textures to keep.
  38620. */
  38621. textures: BaseTexture[];
  38622. /**
  38623. * Environment texture for the scene
  38624. */
  38625. environmentTexture: Nullable<BaseTexture>;
  38626. /**
  38627. * @returns all meshes, lights, cameras, transformNodes and bones
  38628. */
  38629. getNodes(): Array<Node>;
  38630. }
  38631. }
  38632. declare module "babylonjs/Audio/sound" {
  38633. import { Observable } from "babylonjs/Misc/observable";
  38634. import { Vector3 } from "babylonjs/Maths/math.vector";
  38635. import { Nullable } from "babylonjs/types";
  38636. import { Scene } from "babylonjs/scene";
  38637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38638. /**
  38639. * Interface used to define options for Sound class
  38640. */
  38641. export interface ISoundOptions {
  38642. /**
  38643. * Does the sound autoplay once loaded.
  38644. */
  38645. autoplay?: boolean;
  38646. /**
  38647. * Does the sound loop after it finishes playing once.
  38648. */
  38649. loop?: boolean;
  38650. /**
  38651. * Sound's volume
  38652. */
  38653. volume?: number;
  38654. /**
  38655. * Is it a spatial sound?
  38656. */
  38657. spatialSound?: boolean;
  38658. /**
  38659. * Maximum distance to hear that sound
  38660. */
  38661. maxDistance?: number;
  38662. /**
  38663. * Uses user defined attenuation function
  38664. */
  38665. useCustomAttenuation?: boolean;
  38666. /**
  38667. * Define the roll off factor of spatial sounds.
  38668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38669. */
  38670. rolloffFactor?: number;
  38671. /**
  38672. * Define the reference distance the sound should be heard perfectly.
  38673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38674. */
  38675. refDistance?: number;
  38676. /**
  38677. * Define the distance attenuation model the sound will follow.
  38678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38679. */
  38680. distanceModel?: string;
  38681. /**
  38682. * Defines the playback speed (1 by default)
  38683. */
  38684. playbackRate?: number;
  38685. /**
  38686. * Defines if the sound is from a streaming source
  38687. */
  38688. streaming?: boolean;
  38689. /**
  38690. * Defines an optional length (in seconds) inside the sound file
  38691. */
  38692. length?: number;
  38693. /**
  38694. * Defines an optional offset (in seconds) inside the sound file
  38695. */
  38696. offset?: number;
  38697. /**
  38698. * If true, URLs will not be required to state the audio file codec to use.
  38699. */
  38700. skipCodecCheck?: boolean;
  38701. }
  38702. /**
  38703. * Defines a sound that can be played in the application.
  38704. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38706. */
  38707. export class Sound {
  38708. /**
  38709. * The name of the sound in the scene.
  38710. */
  38711. name: string;
  38712. /**
  38713. * Does the sound autoplay once loaded.
  38714. */
  38715. autoplay: boolean;
  38716. /**
  38717. * Does the sound loop after it finishes playing once.
  38718. */
  38719. loop: boolean;
  38720. /**
  38721. * Does the sound use a custom attenuation curve to simulate the falloff
  38722. * happening when the source gets further away from the camera.
  38723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38724. */
  38725. useCustomAttenuation: boolean;
  38726. /**
  38727. * The sound track id this sound belongs to.
  38728. */
  38729. soundTrackId: number;
  38730. /**
  38731. * Is this sound currently played.
  38732. */
  38733. isPlaying: boolean;
  38734. /**
  38735. * Is this sound currently paused.
  38736. */
  38737. isPaused: boolean;
  38738. /**
  38739. * Does this sound enables spatial sound.
  38740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38741. */
  38742. spatialSound: boolean;
  38743. /**
  38744. * Define the reference distance the sound should be heard perfectly.
  38745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38746. */
  38747. refDistance: number;
  38748. /**
  38749. * Define the roll off factor of spatial sounds.
  38750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38751. */
  38752. rolloffFactor: number;
  38753. /**
  38754. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38756. */
  38757. maxDistance: number;
  38758. /**
  38759. * Define the distance attenuation model the sound will follow.
  38760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38761. */
  38762. distanceModel: string;
  38763. /**
  38764. * @hidden
  38765. * Back Compat
  38766. **/
  38767. onended: () => any;
  38768. /**
  38769. * Observable event when the current playing sound finishes.
  38770. */
  38771. onEndedObservable: Observable<Sound>;
  38772. private _panningModel;
  38773. private _playbackRate;
  38774. private _streaming;
  38775. private _startTime;
  38776. private _startOffset;
  38777. private _position;
  38778. /** @hidden */
  38779. _positionInEmitterSpace: boolean;
  38780. private _localDirection;
  38781. private _volume;
  38782. private _isReadyToPlay;
  38783. private _isDirectional;
  38784. private _readyToPlayCallback;
  38785. private _audioBuffer;
  38786. private _soundSource;
  38787. private _streamingSource;
  38788. private _soundPanner;
  38789. private _soundGain;
  38790. private _inputAudioNode;
  38791. private _outputAudioNode;
  38792. private _coneInnerAngle;
  38793. private _coneOuterAngle;
  38794. private _coneOuterGain;
  38795. private _scene;
  38796. private _connectedTransformNode;
  38797. private _customAttenuationFunction;
  38798. private _registerFunc;
  38799. private _isOutputConnected;
  38800. private _htmlAudioElement;
  38801. private _urlType;
  38802. private _length?;
  38803. private _offset?;
  38804. /** @hidden */
  38805. static _SceneComponentInitialization: (scene: Scene) => void;
  38806. /**
  38807. * Create a sound and attach it to a scene
  38808. * @param name Name of your sound
  38809. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38810. * @param scene defines the scene the sound belongs to
  38811. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38812. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38813. */
  38814. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38815. /**
  38816. * Release the sound and its associated resources
  38817. */
  38818. dispose(): void;
  38819. /**
  38820. * Gets if the sounds is ready to be played or not.
  38821. * @returns true if ready, otherwise false
  38822. */
  38823. isReady(): boolean;
  38824. private _soundLoaded;
  38825. /**
  38826. * Sets the data of the sound from an audiobuffer
  38827. * @param audioBuffer The audioBuffer containing the data
  38828. */
  38829. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38830. /**
  38831. * Updates the current sounds options such as maxdistance, loop...
  38832. * @param options A JSON object containing values named as the object properties
  38833. */
  38834. updateOptions(options: ISoundOptions): void;
  38835. private _createSpatialParameters;
  38836. private _updateSpatialParameters;
  38837. /**
  38838. * Switch the panning model to HRTF:
  38839. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38841. */
  38842. switchPanningModelToHRTF(): void;
  38843. /**
  38844. * Switch the panning model to Equal Power:
  38845. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38847. */
  38848. switchPanningModelToEqualPower(): void;
  38849. private _switchPanningModel;
  38850. /**
  38851. * Connect this sound to a sound track audio node like gain...
  38852. * @param soundTrackAudioNode the sound track audio node to connect to
  38853. */
  38854. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38855. /**
  38856. * Transform this sound into a directional source
  38857. * @param coneInnerAngle Size of the inner cone in degree
  38858. * @param coneOuterAngle Size of the outer cone in degree
  38859. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38860. */
  38861. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38862. /**
  38863. * Gets or sets the inner angle for the directional cone.
  38864. */
  38865. get directionalConeInnerAngle(): number;
  38866. /**
  38867. * Gets or sets the inner angle for the directional cone.
  38868. */
  38869. set directionalConeInnerAngle(value: number);
  38870. /**
  38871. * Gets or sets the outer angle for the directional cone.
  38872. */
  38873. get directionalConeOuterAngle(): number;
  38874. /**
  38875. * Gets or sets the outer angle for the directional cone.
  38876. */
  38877. set directionalConeOuterAngle(value: number);
  38878. /**
  38879. * Sets the position of the emitter if spatial sound is enabled
  38880. * @param newPosition Defines the new posisiton
  38881. */
  38882. setPosition(newPosition: Vector3): void;
  38883. /**
  38884. * Sets the local direction of the emitter if spatial sound is enabled
  38885. * @param newLocalDirection Defines the new local direction
  38886. */
  38887. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38888. private _updateDirection;
  38889. /** @hidden */
  38890. updateDistanceFromListener(): void;
  38891. /**
  38892. * Sets a new custom attenuation function for the sound.
  38893. * @param callback Defines the function used for the attenuation
  38894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38895. */
  38896. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38897. /**
  38898. * Play the sound
  38899. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38900. * @param offset (optional) Start the sound at a specific time in seconds
  38901. * @param length (optional) Sound duration (in seconds)
  38902. */
  38903. play(time?: number, offset?: number, length?: number): void;
  38904. private _onended;
  38905. /**
  38906. * Stop the sound
  38907. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38908. */
  38909. stop(time?: number): void;
  38910. /**
  38911. * Put the sound in pause
  38912. */
  38913. pause(): void;
  38914. /**
  38915. * Sets a dedicated volume for this sounds
  38916. * @param newVolume Define the new volume of the sound
  38917. * @param time Define time for gradual change to new volume
  38918. */
  38919. setVolume(newVolume: number, time?: number): void;
  38920. /**
  38921. * Set the sound play back rate
  38922. * @param newPlaybackRate Define the playback rate the sound should be played at
  38923. */
  38924. setPlaybackRate(newPlaybackRate: number): void;
  38925. /**
  38926. * Gets the volume of the sound.
  38927. * @returns the volume of the sound
  38928. */
  38929. getVolume(): number;
  38930. /**
  38931. * Attach the sound to a dedicated mesh
  38932. * @param transformNode The transform node to connect the sound with
  38933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38934. */
  38935. attachToMesh(transformNode: TransformNode): void;
  38936. /**
  38937. * Detach the sound from the previously attached mesh
  38938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38939. */
  38940. detachFromMesh(): void;
  38941. private _onRegisterAfterWorldMatrixUpdate;
  38942. /**
  38943. * Clone the current sound in the scene.
  38944. * @returns the new sound clone
  38945. */
  38946. clone(): Nullable<Sound>;
  38947. /**
  38948. * Gets the current underlying audio buffer containing the data
  38949. * @returns the audio buffer
  38950. */
  38951. getAudioBuffer(): Nullable<AudioBuffer>;
  38952. /**
  38953. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38954. * @returns the source node
  38955. */
  38956. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38957. /**
  38958. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38959. * @returns the gain node
  38960. */
  38961. getSoundGain(): Nullable<GainNode>;
  38962. /**
  38963. * Serializes the Sound in a JSON representation
  38964. * @returns the JSON representation of the sound
  38965. */
  38966. serialize(): any;
  38967. /**
  38968. * Parse a JSON representation of a sound to innstantiate in a given scene
  38969. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38970. * @param scene Define the scene the new parsed sound should be created in
  38971. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38972. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38973. * @returns the newly parsed sound
  38974. */
  38975. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38976. }
  38977. }
  38978. declare module "babylonjs/Actions/directAudioActions" {
  38979. import { Action } from "babylonjs/Actions/action";
  38980. import { Condition } from "babylonjs/Actions/condition";
  38981. import { Sound } from "babylonjs/Audio/sound";
  38982. /**
  38983. * This defines an action helpful to play a defined sound on a triggered action.
  38984. */
  38985. export class PlaySoundAction extends Action {
  38986. private _sound;
  38987. /**
  38988. * Instantiate the action
  38989. * @param triggerOptions defines the trigger options
  38990. * @param sound defines the sound to play
  38991. * @param condition defines the trigger related conditions
  38992. */
  38993. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38994. /** @hidden */
  38995. _prepare(): void;
  38996. /**
  38997. * Execute the action and play the sound.
  38998. */
  38999. execute(): void;
  39000. /**
  39001. * Serializes the actions and its related information.
  39002. * @param parent defines the object to serialize in
  39003. * @returns the serialized object
  39004. */
  39005. serialize(parent: any): any;
  39006. }
  39007. /**
  39008. * This defines an action helpful to stop a defined sound on a triggered action.
  39009. */
  39010. export class StopSoundAction extends Action {
  39011. private _sound;
  39012. /**
  39013. * Instantiate the action
  39014. * @param triggerOptions defines the trigger options
  39015. * @param sound defines the sound to stop
  39016. * @param condition defines the trigger related conditions
  39017. */
  39018. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39019. /** @hidden */
  39020. _prepare(): void;
  39021. /**
  39022. * Execute the action and stop the sound.
  39023. */
  39024. execute(): void;
  39025. /**
  39026. * Serializes the actions and its related information.
  39027. * @param parent defines the object to serialize in
  39028. * @returns the serialized object
  39029. */
  39030. serialize(parent: any): any;
  39031. }
  39032. }
  39033. declare module "babylonjs/Actions/interpolateValueAction" {
  39034. import { Action } from "babylonjs/Actions/action";
  39035. import { Condition } from "babylonjs/Actions/condition";
  39036. import { Observable } from "babylonjs/Misc/observable";
  39037. /**
  39038. * This defines an action responsible to change the value of a property
  39039. * by interpolating between its current value and the newly set one once triggered.
  39040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39041. */
  39042. export class InterpolateValueAction extends Action {
  39043. /**
  39044. * Defines the path of the property where the value should be interpolated
  39045. */
  39046. propertyPath: string;
  39047. /**
  39048. * Defines the target value at the end of the interpolation.
  39049. */
  39050. value: any;
  39051. /**
  39052. * Defines the time it will take for the property to interpolate to the value.
  39053. */
  39054. duration: number;
  39055. /**
  39056. * Defines if the other scene animations should be stopped when the action has been triggered
  39057. */
  39058. stopOtherAnimations?: boolean;
  39059. /**
  39060. * Defines a callback raised once the interpolation animation has been done.
  39061. */
  39062. onInterpolationDone?: () => void;
  39063. /**
  39064. * Observable triggered once the interpolation animation has been done.
  39065. */
  39066. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39067. private _target;
  39068. private _effectiveTarget;
  39069. private _property;
  39070. /**
  39071. * Instantiate the action
  39072. * @param triggerOptions defines the trigger options
  39073. * @param target defines the object containing the value to interpolate
  39074. * @param propertyPath defines the path to the property in the target object
  39075. * @param value defines the target value at the end of the interpolation
  39076. * @param duration deines the time it will take for the property to interpolate to the value.
  39077. * @param condition defines the trigger related conditions
  39078. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39079. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39080. */
  39081. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39082. /** @hidden */
  39083. _prepare(): void;
  39084. /**
  39085. * Execute the action starts the value interpolation.
  39086. */
  39087. execute(): void;
  39088. /**
  39089. * Serializes the actions and its related information.
  39090. * @param parent defines the object to serialize in
  39091. * @returns the serialized object
  39092. */
  39093. serialize(parent: any): any;
  39094. }
  39095. }
  39096. declare module "babylonjs/Actions/index" {
  39097. export * from "babylonjs/Actions/abstractActionManager";
  39098. export * from "babylonjs/Actions/action";
  39099. export * from "babylonjs/Actions/actionEvent";
  39100. export * from "babylonjs/Actions/actionManager";
  39101. export * from "babylonjs/Actions/condition";
  39102. export * from "babylonjs/Actions/directActions";
  39103. export * from "babylonjs/Actions/directAudioActions";
  39104. export * from "babylonjs/Actions/interpolateValueAction";
  39105. }
  39106. declare module "babylonjs/Animations/index" {
  39107. export * from "babylonjs/Animations/animatable";
  39108. export * from "babylonjs/Animations/animation";
  39109. export * from "babylonjs/Animations/animationGroup";
  39110. export * from "babylonjs/Animations/animationPropertiesOverride";
  39111. export * from "babylonjs/Animations/easing";
  39112. export * from "babylonjs/Animations/runtimeAnimation";
  39113. export * from "babylonjs/Animations/animationEvent";
  39114. export * from "babylonjs/Animations/animationGroup";
  39115. export * from "babylonjs/Animations/animationKey";
  39116. export * from "babylonjs/Animations/animationRange";
  39117. export * from "babylonjs/Animations/animatable.interface";
  39118. }
  39119. declare module "babylonjs/Audio/soundTrack" {
  39120. import { Sound } from "babylonjs/Audio/sound";
  39121. import { Analyser } from "babylonjs/Audio/analyser";
  39122. import { Scene } from "babylonjs/scene";
  39123. /**
  39124. * Options allowed during the creation of a sound track.
  39125. */
  39126. export interface ISoundTrackOptions {
  39127. /**
  39128. * The volume the sound track should take during creation
  39129. */
  39130. volume?: number;
  39131. /**
  39132. * Define if the sound track is the main sound track of the scene
  39133. */
  39134. mainTrack?: boolean;
  39135. }
  39136. /**
  39137. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39138. * It will be also used in a future release to apply effects on a specific track.
  39139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39140. */
  39141. export class SoundTrack {
  39142. /**
  39143. * The unique identifier of the sound track in the scene.
  39144. */
  39145. id: number;
  39146. /**
  39147. * The list of sounds included in the sound track.
  39148. */
  39149. soundCollection: Array<Sound>;
  39150. private _outputAudioNode;
  39151. private _scene;
  39152. private _connectedAnalyser;
  39153. private _options;
  39154. private _isInitialized;
  39155. /**
  39156. * Creates a new sound track.
  39157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39158. * @param scene Define the scene the sound track belongs to
  39159. * @param options
  39160. */
  39161. constructor(scene: Scene, options?: ISoundTrackOptions);
  39162. private _initializeSoundTrackAudioGraph;
  39163. /**
  39164. * Release the sound track and its associated resources
  39165. */
  39166. dispose(): void;
  39167. /**
  39168. * Adds a sound to this sound track
  39169. * @param sound define the cound to add
  39170. * @ignoreNaming
  39171. */
  39172. AddSound(sound: Sound): void;
  39173. /**
  39174. * Removes a sound to this sound track
  39175. * @param sound define the cound to remove
  39176. * @ignoreNaming
  39177. */
  39178. RemoveSound(sound: Sound): void;
  39179. /**
  39180. * Set a global volume for the full sound track.
  39181. * @param newVolume Define the new volume of the sound track
  39182. */
  39183. setVolume(newVolume: number): void;
  39184. /**
  39185. * Switch the panning model to HRTF:
  39186. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39188. */
  39189. switchPanningModelToHRTF(): void;
  39190. /**
  39191. * Switch the panning model to Equal Power:
  39192. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39194. */
  39195. switchPanningModelToEqualPower(): void;
  39196. /**
  39197. * Connect the sound track to an audio analyser allowing some amazing
  39198. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39200. * @param analyser The analyser to connect to the engine
  39201. */
  39202. connectToAnalyser(analyser: Analyser): void;
  39203. }
  39204. }
  39205. declare module "babylonjs/Audio/audioSceneComponent" {
  39206. import { Sound } from "babylonjs/Audio/sound";
  39207. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39208. import { Nullable } from "babylonjs/types";
  39209. import { Vector3 } from "babylonjs/Maths/math.vector";
  39210. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39211. import { Scene } from "babylonjs/scene";
  39212. import { AbstractScene } from "babylonjs/abstractScene";
  39213. import "babylonjs/Audio/audioEngine";
  39214. module "babylonjs/abstractScene" {
  39215. interface AbstractScene {
  39216. /**
  39217. * The list of sounds used in the scene.
  39218. */
  39219. sounds: Nullable<Array<Sound>>;
  39220. }
  39221. }
  39222. module "babylonjs/scene" {
  39223. interface Scene {
  39224. /**
  39225. * @hidden
  39226. * Backing field
  39227. */
  39228. _mainSoundTrack: SoundTrack;
  39229. /**
  39230. * The main sound track played by the scene.
  39231. * It cotains your primary collection of sounds.
  39232. */
  39233. mainSoundTrack: SoundTrack;
  39234. /**
  39235. * The list of sound tracks added to the scene
  39236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39237. */
  39238. soundTracks: Nullable<Array<SoundTrack>>;
  39239. /**
  39240. * Gets a sound using a given name
  39241. * @param name defines the name to search for
  39242. * @return the found sound or null if not found at all.
  39243. */
  39244. getSoundByName(name: string): Nullable<Sound>;
  39245. /**
  39246. * Gets or sets if audio support is enabled
  39247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39248. */
  39249. audioEnabled: boolean;
  39250. /**
  39251. * Gets or sets if audio will be output to headphones
  39252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39253. */
  39254. headphone: boolean;
  39255. /**
  39256. * Gets or sets custom audio listener position provider
  39257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39258. */
  39259. audioListenerPositionProvider: Nullable<() => Vector3>;
  39260. /**
  39261. * Gets or sets a refresh rate when using 3D audio positioning
  39262. */
  39263. audioPositioningRefreshRate: number;
  39264. }
  39265. }
  39266. /**
  39267. * Defines the sound scene component responsible to manage any sounds
  39268. * in a given scene.
  39269. */
  39270. export class AudioSceneComponent implements ISceneSerializableComponent {
  39271. /**
  39272. * The component name helpfull to identify the component in the list of scene components.
  39273. */
  39274. readonly name: string;
  39275. /**
  39276. * The scene the component belongs to.
  39277. */
  39278. scene: Scene;
  39279. private _audioEnabled;
  39280. /**
  39281. * Gets whether audio is enabled or not.
  39282. * Please use related enable/disable method to switch state.
  39283. */
  39284. get audioEnabled(): boolean;
  39285. private _headphone;
  39286. /**
  39287. * Gets whether audio is outputing to headphone or not.
  39288. * Please use the according Switch methods to change output.
  39289. */
  39290. get headphone(): boolean;
  39291. /**
  39292. * Gets or sets a refresh rate when using 3D audio positioning
  39293. */
  39294. audioPositioningRefreshRate: number;
  39295. private _audioListenerPositionProvider;
  39296. /**
  39297. * Gets the current audio listener position provider
  39298. */
  39299. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39300. /**
  39301. * Sets a custom listener position for all sounds in the scene
  39302. * By default, this is the position of the first active camera
  39303. */
  39304. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39305. /**
  39306. * Creates a new instance of the component for the given scene
  39307. * @param scene Defines the scene to register the component in
  39308. */
  39309. constructor(scene: Scene);
  39310. /**
  39311. * Registers the component in a given scene
  39312. */
  39313. register(): void;
  39314. /**
  39315. * Rebuilds the elements related to this component in case of
  39316. * context lost for instance.
  39317. */
  39318. rebuild(): void;
  39319. /**
  39320. * Serializes the component data to the specified json object
  39321. * @param serializationObject The object to serialize to
  39322. */
  39323. serialize(serializationObject: any): void;
  39324. /**
  39325. * Adds all the elements from the container to the scene
  39326. * @param container the container holding the elements
  39327. */
  39328. addFromContainer(container: AbstractScene): void;
  39329. /**
  39330. * Removes all the elements in the container from the scene
  39331. * @param container contains the elements to remove
  39332. * @param dispose if the removed element should be disposed (default: false)
  39333. */
  39334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39335. /**
  39336. * Disposes the component and the associated ressources.
  39337. */
  39338. dispose(): void;
  39339. /**
  39340. * Disables audio in the associated scene.
  39341. */
  39342. disableAudio(): void;
  39343. /**
  39344. * Enables audio in the associated scene.
  39345. */
  39346. enableAudio(): void;
  39347. /**
  39348. * Switch audio to headphone output.
  39349. */
  39350. switchAudioModeForHeadphones(): void;
  39351. /**
  39352. * Switch audio to normal speakers.
  39353. */
  39354. switchAudioModeForNormalSpeakers(): void;
  39355. private _cachedCameraDirection;
  39356. private _cachedCameraPosition;
  39357. private _lastCheck;
  39358. private _afterRender;
  39359. }
  39360. }
  39361. declare module "babylonjs/Audio/weightedsound" {
  39362. import { Sound } from "babylonjs/Audio/sound";
  39363. /**
  39364. * Wraps one or more Sound objects and selects one with random weight for playback.
  39365. */
  39366. export class WeightedSound {
  39367. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39368. loop: boolean;
  39369. private _coneInnerAngle;
  39370. private _coneOuterAngle;
  39371. private _volume;
  39372. /** A Sound is currently playing. */
  39373. isPlaying: boolean;
  39374. /** A Sound is currently paused. */
  39375. isPaused: boolean;
  39376. private _sounds;
  39377. private _weights;
  39378. private _currentIndex?;
  39379. /**
  39380. * Creates a new WeightedSound from the list of sounds given.
  39381. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39382. * @param sounds Array of Sounds that will be selected from.
  39383. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39384. */
  39385. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39386. /**
  39387. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39388. */
  39389. get directionalConeInnerAngle(): number;
  39390. /**
  39391. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39392. */
  39393. set directionalConeInnerAngle(value: number);
  39394. /**
  39395. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39396. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39397. */
  39398. get directionalConeOuterAngle(): number;
  39399. /**
  39400. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39401. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39402. */
  39403. set directionalConeOuterAngle(value: number);
  39404. /**
  39405. * Playback volume.
  39406. */
  39407. get volume(): number;
  39408. /**
  39409. * Playback volume.
  39410. */
  39411. set volume(value: number);
  39412. private _onended;
  39413. /**
  39414. * Suspend playback
  39415. */
  39416. pause(): void;
  39417. /**
  39418. * Stop playback
  39419. */
  39420. stop(): void;
  39421. /**
  39422. * Start playback.
  39423. * @param startOffset Position the clip head at a specific time in seconds.
  39424. */
  39425. play(startOffset?: number): void;
  39426. }
  39427. }
  39428. declare module "babylonjs/Audio/index" {
  39429. export * from "babylonjs/Audio/analyser";
  39430. export * from "babylonjs/Audio/audioEngine";
  39431. export * from "babylonjs/Audio/audioSceneComponent";
  39432. export * from "babylonjs/Audio/sound";
  39433. export * from "babylonjs/Audio/soundTrack";
  39434. export * from "babylonjs/Audio/weightedsound";
  39435. }
  39436. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39437. import { Behavior } from "babylonjs/Behaviors/behavior";
  39438. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39439. import { BackEase } from "babylonjs/Animations/easing";
  39440. /**
  39441. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39442. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39443. */
  39444. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39445. /**
  39446. * Gets the name of the behavior.
  39447. */
  39448. get name(): string;
  39449. /**
  39450. * The easing function used by animations
  39451. */
  39452. static EasingFunction: BackEase;
  39453. /**
  39454. * The easing mode used by animations
  39455. */
  39456. static EasingMode: number;
  39457. /**
  39458. * The duration of the animation, in milliseconds
  39459. */
  39460. transitionDuration: number;
  39461. /**
  39462. * Length of the distance animated by the transition when lower radius is reached
  39463. */
  39464. lowerRadiusTransitionRange: number;
  39465. /**
  39466. * Length of the distance animated by the transition when upper radius is reached
  39467. */
  39468. upperRadiusTransitionRange: number;
  39469. private _autoTransitionRange;
  39470. /**
  39471. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39472. */
  39473. get autoTransitionRange(): boolean;
  39474. /**
  39475. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39476. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39477. */
  39478. set autoTransitionRange(value: boolean);
  39479. private _attachedCamera;
  39480. private _onAfterCheckInputsObserver;
  39481. private _onMeshTargetChangedObserver;
  39482. /**
  39483. * Initializes the behavior.
  39484. */
  39485. init(): void;
  39486. /**
  39487. * Attaches the behavior to its arc rotate camera.
  39488. * @param camera Defines the camera to attach the behavior to
  39489. */
  39490. attach(camera: ArcRotateCamera): void;
  39491. /**
  39492. * Detaches the behavior from its current arc rotate camera.
  39493. */
  39494. detach(): void;
  39495. private _radiusIsAnimating;
  39496. private _radiusBounceTransition;
  39497. private _animatables;
  39498. private _cachedWheelPrecision;
  39499. /**
  39500. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39501. * @param radiusLimit The limit to check against.
  39502. * @return Bool to indicate if at limit.
  39503. */
  39504. private _isRadiusAtLimit;
  39505. /**
  39506. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39507. * @param radiusDelta The delta by which to animate to. Can be negative.
  39508. */
  39509. private _applyBoundRadiusAnimation;
  39510. /**
  39511. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39512. */
  39513. protected _clearAnimationLocks(): void;
  39514. /**
  39515. * Stops and removes all animations that have been applied to the camera
  39516. */
  39517. stopAllAnimations(): void;
  39518. }
  39519. }
  39520. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39521. import { Behavior } from "babylonjs/Behaviors/behavior";
  39522. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39523. import { ExponentialEase } from "babylonjs/Animations/easing";
  39524. import { Nullable } from "babylonjs/types";
  39525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39526. import { Vector3 } from "babylonjs/Maths/math.vector";
  39527. /**
  39528. * 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.
  39529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39530. */
  39531. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39532. /**
  39533. * Gets the name of the behavior.
  39534. */
  39535. get name(): string;
  39536. private _mode;
  39537. private _radiusScale;
  39538. private _positionScale;
  39539. private _defaultElevation;
  39540. private _elevationReturnTime;
  39541. private _elevationReturnWaitTime;
  39542. private _zoomStopsAnimation;
  39543. private _framingTime;
  39544. /**
  39545. * The easing function used by animations
  39546. */
  39547. static EasingFunction: ExponentialEase;
  39548. /**
  39549. * The easing mode used by animations
  39550. */
  39551. static EasingMode: number;
  39552. /**
  39553. * Sets the current mode used by the behavior
  39554. */
  39555. set mode(mode: number);
  39556. /**
  39557. * Gets current mode used by the behavior.
  39558. */
  39559. get mode(): number;
  39560. /**
  39561. * Sets the scale applied to the radius (1 by default)
  39562. */
  39563. set radiusScale(radius: number);
  39564. /**
  39565. * Gets the scale applied to the radius
  39566. */
  39567. get radiusScale(): number;
  39568. /**
  39569. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39570. */
  39571. set positionScale(scale: number);
  39572. /**
  39573. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39574. */
  39575. get positionScale(): number;
  39576. /**
  39577. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39578. * behaviour is triggered, in radians.
  39579. */
  39580. set defaultElevation(elevation: number);
  39581. /**
  39582. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39583. * behaviour is triggered, in radians.
  39584. */
  39585. get defaultElevation(): number;
  39586. /**
  39587. * Sets the time (in milliseconds) taken to return to the default beta position.
  39588. * Negative value indicates camera should not return to default.
  39589. */
  39590. set elevationReturnTime(speed: number);
  39591. /**
  39592. * Gets the time (in milliseconds) taken to return to the default beta position.
  39593. * Negative value indicates camera should not return to default.
  39594. */
  39595. get elevationReturnTime(): number;
  39596. /**
  39597. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39598. */
  39599. set elevationReturnWaitTime(time: number);
  39600. /**
  39601. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39602. */
  39603. get elevationReturnWaitTime(): number;
  39604. /**
  39605. * Sets the flag that indicates if user zooming should stop animation.
  39606. */
  39607. set zoomStopsAnimation(flag: boolean);
  39608. /**
  39609. * Gets the flag that indicates if user zooming should stop animation.
  39610. */
  39611. get zoomStopsAnimation(): boolean;
  39612. /**
  39613. * Sets the transition time when framing the mesh, in milliseconds
  39614. */
  39615. set framingTime(time: number);
  39616. /**
  39617. * Gets the transition time when framing the mesh, in milliseconds
  39618. */
  39619. get framingTime(): number;
  39620. /**
  39621. * Define if the behavior should automatically change the configured
  39622. * camera limits and sensibilities.
  39623. */
  39624. autoCorrectCameraLimitsAndSensibility: boolean;
  39625. private _onPrePointerObservableObserver;
  39626. private _onAfterCheckInputsObserver;
  39627. private _onMeshTargetChangedObserver;
  39628. private _attachedCamera;
  39629. private _isPointerDown;
  39630. private _lastInteractionTime;
  39631. /**
  39632. * Initializes the behavior.
  39633. */
  39634. init(): void;
  39635. /**
  39636. * Attaches the behavior to its arc rotate camera.
  39637. * @param camera Defines the camera to attach the behavior to
  39638. */
  39639. attach(camera: ArcRotateCamera): void;
  39640. /**
  39641. * Detaches the behavior from its current arc rotate camera.
  39642. */
  39643. detach(): void;
  39644. private _animatables;
  39645. private _betaIsAnimating;
  39646. private _betaTransition;
  39647. private _radiusTransition;
  39648. private _vectorTransition;
  39649. /**
  39650. * Targets the given mesh and updates zoom level accordingly.
  39651. * @param mesh The mesh to target.
  39652. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39653. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39654. */
  39655. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39656. /**
  39657. * Targets the given mesh with its children and updates zoom level accordingly.
  39658. * @param mesh The mesh to target.
  39659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39661. */
  39662. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39663. /**
  39664. * Targets the given meshes with their children and updates zoom level accordingly.
  39665. * @param meshes The mesh to target.
  39666. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39667. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39668. */
  39669. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39670. /**
  39671. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39672. * @param minimumWorld Determines the smaller position of the bounding box extend
  39673. * @param maximumWorld Determines the bigger position of the bounding box extend
  39674. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39675. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39676. */
  39677. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39678. /**
  39679. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39680. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39681. * frustum width.
  39682. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39683. * to fully enclose the mesh in the viewing frustum.
  39684. */
  39685. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39686. /**
  39687. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39688. * is automatically returned to its default position (expected to be above ground plane).
  39689. */
  39690. private _maintainCameraAboveGround;
  39691. /**
  39692. * Returns the frustum slope based on the canvas ratio and camera FOV
  39693. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39694. */
  39695. private _getFrustumSlope;
  39696. /**
  39697. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39698. */
  39699. private _clearAnimationLocks;
  39700. /**
  39701. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39702. */
  39703. private _applyUserInteraction;
  39704. /**
  39705. * Stops and removes all animations that have been applied to the camera
  39706. */
  39707. stopAllAnimations(): void;
  39708. /**
  39709. * Gets a value indicating if the user is moving the camera
  39710. */
  39711. get isUserIsMoving(): boolean;
  39712. /**
  39713. * The camera can move all the way towards the mesh.
  39714. */
  39715. static IgnoreBoundsSizeMode: number;
  39716. /**
  39717. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39718. */
  39719. static FitFrustumSidesMode: number;
  39720. }
  39721. }
  39722. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39723. import { Nullable } from "babylonjs/types";
  39724. import { Camera } from "babylonjs/Cameras/camera";
  39725. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39726. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39727. /**
  39728. * Base class for Camera Pointer Inputs.
  39729. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39730. * for example usage.
  39731. */
  39732. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39733. /**
  39734. * Defines the camera the input is attached to.
  39735. */
  39736. abstract camera: Camera;
  39737. /**
  39738. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39739. */
  39740. protected _altKey: boolean;
  39741. protected _ctrlKey: boolean;
  39742. protected _metaKey: boolean;
  39743. protected _shiftKey: boolean;
  39744. /**
  39745. * Which mouse buttons were pressed at time of last mouse event.
  39746. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39747. */
  39748. protected _buttonsPressed: number;
  39749. /**
  39750. * Defines the buttons associated with the input to handle camera move.
  39751. */
  39752. buttons: number[];
  39753. /**
  39754. * Attach the input controls to a specific dom element to get the input from.
  39755. * @param element Defines the element the controls should be listened from
  39756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39757. */
  39758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39759. /**
  39760. * Detach the current controls from the specified dom element.
  39761. * @param element Defines the element to stop listening the inputs from
  39762. */
  39763. detachControl(element: Nullable<HTMLElement>): void;
  39764. /**
  39765. * Gets the class name of the current input.
  39766. * @returns the class name
  39767. */
  39768. getClassName(): string;
  39769. /**
  39770. * Get the friendly name associated with the input class.
  39771. * @returns the input friendly name
  39772. */
  39773. getSimpleName(): string;
  39774. /**
  39775. * Called on pointer POINTERDOUBLETAP event.
  39776. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39777. */
  39778. protected onDoubleTap(type: string): void;
  39779. /**
  39780. * Called on pointer POINTERMOVE event if only a single touch is active.
  39781. * Override this method to provide functionality.
  39782. */
  39783. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39784. /**
  39785. * Called on pointer POINTERMOVE event if multiple touches are active.
  39786. * Override this method to provide functionality.
  39787. */
  39788. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39789. /**
  39790. * Called on JS contextmenu event.
  39791. * Override this method to provide functionality.
  39792. */
  39793. protected onContextMenu(evt: PointerEvent): void;
  39794. /**
  39795. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39796. * press.
  39797. * Override this method to provide functionality.
  39798. */
  39799. protected onButtonDown(evt: PointerEvent): void;
  39800. /**
  39801. * Called each time a new POINTERUP event occurs. Ie, for each button
  39802. * release.
  39803. * Override this method to provide functionality.
  39804. */
  39805. protected onButtonUp(evt: PointerEvent): void;
  39806. /**
  39807. * Called when window becomes inactive.
  39808. * Override this method to provide functionality.
  39809. */
  39810. protected onLostFocus(): void;
  39811. private _pointerInput;
  39812. private _observer;
  39813. private _onLostFocus;
  39814. private pointA;
  39815. private pointB;
  39816. }
  39817. }
  39818. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39819. import { Nullable } from "babylonjs/types";
  39820. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39821. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39822. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39823. /**
  39824. * Manage the pointers inputs to control an arc rotate camera.
  39825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39826. */
  39827. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39828. /**
  39829. * Defines the camera the input is attached to.
  39830. */
  39831. camera: ArcRotateCamera;
  39832. /**
  39833. * Gets the class name of the current input.
  39834. * @returns the class name
  39835. */
  39836. getClassName(): string;
  39837. /**
  39838. * Defines the buttons associated with the input to handle camera move.
  39839. */
  39840. buttons: number[];
  39841. /**
  39842. * Defines the pointer angular sensibility along the X axis or how fast is
  39843. * the camera rotating.
  39844. */
  39845. angularSensibilityX: number;
  39846. /**
  39847. * Defines the pointer angular sensibility along the Y axis or how fast is
  39848. * the camera rotating.
  39849. */
  39850. angularSensibilityY: number;
  39851. /**
  39852. * Defines the pointer pinch precision or how fast is the camera zooming.
  39853. */
  39854. pinchPrecision: number;
  39855. /**
  39856. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39857. * from 0.
  39858. * It defines the percentage of current camera.radius to use as delta when
  39859. * pinch zoom is used.
  39860. */
  39861. pinchDeltaPercentage: number;
  39862. /**
  39863. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39864. * that any object in the plane at the camera's target point will scale
  39865. * perfectly with finger motion.
  39866. * Overrides pinchDeltaPercentage and pinchPrecision.
  39867. */
  39868. useNaturalPinchZoom: boolean;
  39869. /**
  39870. * Defines the pointer panning sensibility or how fast is the camera moving.
  39871. */
  39872. panningSensibility: number;
  39873. /**
  39874. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39875. */
  39876. multiTouchPanning: boolean;
  39877. /**
  39878. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39879. * zoom (pinch) through multitouch.
  39880. */
  39881. multiTouchPanAndZoom: boolean;
  39882. /**
  39883. * Revers pinch action direction.
  39884. */
  39885. pinchInwards: boolean;
  39886. private _isPanClick;
  39887. private _twoFingerActivityCount;
  39888. private _isPinching;
  39889. /**
  39890. * Called on pointer POINTERMOVE event if only a single touch is active.
  39891. */
  39892. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39893. /**
  39894. * Called on pointer POINTERDOUBLETAP event.
  39895. */
  39896. protected onDoubleTap(type: string): void;
  39897. /**
  39898. * Called on pointer POINTERMOVE event if multiple touches are active.
  39899. */
  39900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39901. /**
  39902. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39903. * press.
  39904. */
  39905. protected onButtonDown(evt: PointerEvent): void;
  39906. /**
  39907. * Called each time a new POINTERUP event occurs. Ie, for each button
  39908. * release.
  39909. */
  39910. protected onButtonUp(evt: PointerEvent): void;
  39911. /**
  39912. * Called when window becomes inactive.
  39913. */
  39914. protected onLostFocus(): void;
  39915. }
  39916. }
  39917. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39918. import { Nullable } from "babylonjs/types";
  39919. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39920. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39921. /**
  39922. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39924. */
  39925. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39926. /**
  39927. * Defines the camera the input is attached to.
  39928. */
  39929. camera: ArcRotateCamera;
  39930. /**
  39931. * Defines the list of key codes associated with the up action (increase alpha)
  39932. */
  39933. keysUp: number[];
  39934. /**
  39935. * Defines the list of key codes associated with the down action (decrease alpha)
  39936. */
  39937. keysDown: number[];
  39938. /**
  39939. * Defines the list of key codes associated with the left action (increase beta)
  39940. */
  39941. keysLeft: number[];
  39942. /**
  39943. * Defines the list of key codes associated with the right action (decrease beta)
  39944. */
  39945. keysRight: number[];
  39946. /**
  39947. * Defines the list of key codes associated with the reset action.
  39948. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39949. */
  39950. keysReset: number[];
  39951. /**
  39952. * Defines the panning sensibility of the inputs.
  39953. * (How fast is the camera panning)
  39954. */
  39955. panningSensibility: number;
  39956. /**
  39957. * Defines the zooming sensibility of the inputs.
  39958. * (How fast is the camera zooming)
  39959. */
  39960. zoomingSensibility: number;
  39961. /**
  39962. * Defines whether maintaining the alt key down switch the movement mode from
  39963. * orientation to zoom.
  39964. */
  39965. useAltToZoom: boolean;
  39966. /**
  39967. * Rotation speed of the camera
  39968. */
  39969. angularSpeed: number;
  39970. private _keys;
  39971. private _ctrlPressed;
  39972. private _altPressed;
  39973. private _onCanvasBlurObserver;
  39974. private _onKeyboardObserver;
  39975. private _engine;
  39976. private _scene;
  39977. /**
  39978. * Attach the input controls to a specific dom element to get the input from.
  39979. * @param element Defines the element the controls should be listened from
  39980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39981. */
  39982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39983. /**
  39984. * Detach the current controls from the specified dom element.
  39985. * @param element Defines the element to stop listening the inputs from
  39986. */
  39987. detachControl(element: Nullable<HTMLElement>): void;
  39988. /**
  39989. * Update the current camera state depending on the inputs that have been used this frame.
  39990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39991. */
  39992. checkInputs(): void;
  39993. /**
  39994. * Gets the class name of the current intput.
  39995. * @returns the class name
  39996. */
  39997. getClassName(): string;
  39998. /**
  39999. * Get the friendly name associated with the input class.
  40000. * @returns the input friendly name
  40001. */
  40002. getSimpleName(): string;
  40003. }
  40004. }
  40005. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40006. import { Nullable } from "babylonjs/types";
  40007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40008. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40009. /**
  40010. * Manage the mouse wheel inputs to control an arc rotate camera.
  40011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40012. */
  40013. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40014. /**
  40015. * Defines the camera the input is attached to.
  40016. */
  40017. camera: ArcRotateCamera;
  40018. /**
  40019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40020. */
  40021. wheelPrecision: number;
  40022. /**
  40023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40025. */
  40026. wheelDeltaPercentage: number;
  40027. private _wheel;
  40028. private _observer;
  40029. private computeDeltaFromMouseWheelLegacyEvent;
  40030. /**
  40031. * Attach the input controls to a specific dom element to get the input from.
  40032. * @param element Defines the element the controls should be listened from
  40033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40034. */
  40035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40036. /**
  40037. * Detach the current controls from the specified dom element.
  40038. * @param element Defines the element to stop listening the inputs from
  40039. */
  40040. detachControl(element: Nullable<HTMLElement>): void;
  40041. /**
  40042. * Gets the class name of the current intput.
  40043. * @returns the class name
  40044. */
  40045. getClassName(): string;
  40046. /**
  40047. * Get the friendly name associated with the input class.
  40048. * @returns the input friendly name
  40049. */
  40050. getSimpleName(): string;
  40051. }
  40052. }
  40053. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40054. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40055. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40056. /**
  40057. * Default Inputs manager for the ArcRotateCamera.
  40058. * It groups all the default supported inputs for ease of use.
  40059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40060. */
  40061. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40062. /**
  40063. * Instantiates a new ArcRotateCameraInputsManager.
  40064. * @param camera Defines the camera the inputs belong to
  40065. */
  40066. constructor(camera: ArcRotateCamera);
  40067. /**
  40068. * Add mouse wheel input support to the input manager.
  40069. * @returns the current input manager
  40070. */
  40071. addMouseWheel(): ArcRotateCameraInputsManager;
  40072. /**
  40073. * Add pointers input support to the input manager.
  40074. * @returns the current input manager
  40075. */
  40076. addPointers(): ArcRotateCameraInputsManager;
  40077. /**
  40078. * Add keyboard input support to the input manager.
  40079. * @returns the current input manager
  40080. */
  40081. addKeyboard(): ArcRotateCameraInputsManager;
  40082. }
  40083. }
  40084. declare module "babylonjs/Cameras/arcRotateCamera" {
  40085. import { Observable } from "babylonjs/Misc/observable";
  40086. import { Nullable } from "babylonjs/types";
  40087. import { Scene } from "babylonjs/scene";
  40088. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40090. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40091. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40092. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40093. import { Camera } from "babylonjs/Cameras/camera";
  40094. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40095. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40096. import { Collider } from "babylonjs/Collisions/collider";
  40097. /**
  40098. * This represents an orbital type of camera.
  40099. *
  40100. * 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.
  40101. * 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.
  40102. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40103. */
  40104. export class ArcRotateCamera extends TargetCamera {
  40105. /**
  40106. * Defines the rotation angle of the camera along the longitudinal axis.
  40107. */
  40108. alpha: number;
  40109. /**
  40110. * Defines the rotation angle of the camera along the latitudinal axis.
  40111. */
  40112. beta: number;
  40113. /**
  40114. * Defines the radius of the camera from it s target point.
  40115. */
  40116. radius: number;
  40117. protected _target: Vector3;
  40118. protected _targetHost: Nullable<AbstractMesh>;
  40119. /**
  40120. * Defines the target point of the camera.
  40121. * The camera looks towards it form the radius distance.
  40122. */
  40123. get target(): Vector3;
  40124. set target(value: Vector3);
  40125. /**
  40126. * Define the current local position of the camera in the scene
  40127. */
  40128. get position(): Vector3;
  40129. set position(newPosition: Vector3);
  40130. protected _upVector: Vector3;
  40131. protected _upToYMatrix: Matrix;
  40132. protected _YToUpMatrix: Matrix;
  40133. /**
  40134. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40135. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40136. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40137. */
  40138. set upVector(vec: Vector3);
  40139. get upVector(): Vector3;
  40140. /**
  40141. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40142. */
  40143. setMatUp(): void;
  40144. /**
  40145. * Current inertia value on the longitudinal axis.
  40146. * The bigger this number the longer it will take for the camera to stop.
  40147. */
  40148. inertialAlphaOffset: number;
  40149. /**
  40150. * Current inertia value on the latitudinal axis.
  40151. * The bigger this number the longer it will take for the camera to stop.
  40152. */
  40153. inertialBetaOffset: number;
  40154. /**
  40155. * Current inertia value on the radius axis.
  40156. * The bigger this number the longer it will take for the camera to stop.
  40157. */
  40158. inertialRadiusOffset: number;
  40159. /**
  40160. * Minimum allowed angle on the longitudinal axis.
  40161. * This can help limiting how the Camera is able to move in the scene.
  40162. */
  40163. lowerAlphaLimit: Nullable<number>;
  40164. /**
  40165. * Maximum allowed angle on the longitudinal axis.
  40166. * This can help limiting how the Camera is able to move in the scene.
  40167. */
  40168. upperAlphaLimit: Nullable<number>;
  40169. /**
  40170. * Minimum allowed angle on the latitudinal axis.
  40171. * This can help limiting how the Camera is able to move in the scene.
  40172. */
  40173. lowerBetaLimit: number;
  40174. /**
  40175. * Maximum allowed angle on the latitudinal axis.
  40176. * This can help limiting how the Camera is able to move in the scene.
  40177. */
  40178. upperBetaLimit: number;
  40179. /**
  40180. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40181. * This can help limiting how the Camera is able to move in the scene.
  40182. */
  40183. lowerRadiusLimit: Nullable<number>;
  40184. /**
  40185. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40186. * This can help limiting how the Camera is able to move in the scene.
  40187. */
  40188. upperRadiusLimit: Nullable<number>;
  40189. /**
  40190. * Defines the current inertia value used during panning of the camera along the X axis.
  40191. */
  40192. inertialPanningX: number;
  40193. /**
  40194. * Defines the current inertia value used during panning of the camera along the Y axis.
  40195. */
  40196. inertialPanningY: number;
  40197. /**
  40198. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40199. * Basically if your fingers moves away from more than this distance you will be considered
  40200. * in pinch mode.
  40201. */
  40202. pinchToPanMaxDistance: number;
  40203. /**
  40204. * Defines the maximum distance the camera can pan.
  40205. * This could help keeping the cammera always in your scene.
  40206. */
  40207. panningDistanceLimit: Nullable<number>;
  40208. /**
  40209. * Defines the target of the camera before paning.
  40210. */
  40211. panningOriginTarget: Vector3;
  40212. /**
  40213. * Defines the value of the inertia used during panning.
  40214. * 0 would mean stop inertia and one would mean no decelleration at all.
  40215. */
  40216. panningInertia: number;
  40217. /**
  40218. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40219. */
  40220. get angularSensibilityX(): number;
  40221. set angularSensibilityX(value: number);
  40222. /**
  40223. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40224. */
  40225. get angularSensibilityY(): number;
  40226. set angularSensibilityY(value: number);
  40227. /**
  40228. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40229. */
  40230. get pinchPrecision(): number;
  40231. set pinchPrecision(value: number);
  40232. /**
  40233. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40234. * It will be used instead of pinchDeltaPrecision if different from 0.
  40235. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40236. */
  40237. get pinchDeltaPercentage(): number;
  40238. set pinchDeltaPercentage(value: number);
  40239. /**
  40240. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40241. * and pinch delta percentage.
  40242. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40243. * that any object in the plane at the camera's target point will scale
  40244. * perfectly with finger motion.
  40245. */
  40246. get useNaturalPinchZoom(): boolean;
  40247. set useNaturalPinchZoom(value: boolean);
  40248. /**
  40249. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40250. */
  40251. get panningSensibility(): number;
  40252. set panningSensibility(value: number);
  40253. /**
  40254. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40255. */
  40256. get keysUp(): number[];
  40257. set keysUp(value: number[]);
  40258. /**
  40259. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40260. */
  40261. get keysDown(): number[];
  40262. set keysDown(value: number[]);
  40263. /**
  40264. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40265. */
  40266. get keysLeft(): number[];
  40267. set keysLeft(value: number[]);
  40268. /**
  40269. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40270. */
  40271. get keysRight(): number[];
  40272. set keysRight(value: number[]);
  40273. /**
  40274. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40275. */
  40276. get wheelPrecision(): number;
  40277. set wheelPrecision(value: number);
  40278. /**
  40279. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40280. * It will be used instead of pinchDeltaPrecision if different from 0.
  40281. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40282. */
  40283. get wheelDeltaPercentage(): number;
  40284. set wheelDeltaPercentage(value: number);
  40285. /**
  40286. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40287. */
  40288. zoomOnFactor: number;
  40289. /**
  40290. * Defines a screen offset for the camera position.
  40291. */
  40292. targetScreenOffset: Vector2;
  40293. /**
  40294. * Allows the camera to be completely reversed.
  40295. * If false the camera can not arrive upside down.
  40296. */
  40297. allowUpsideDown: boolean;
  40298. /**
  40299. * Define if double tap/click is used to restore the previously saved state of the camera.
  40300. */
  40301. useInputToRestoreState: boolean;
  40302. /** @hidden */
  40303. _viewMatrix: Matrix;
  40304. /** @hidden */
  40305. _useCtrlForPanning: boolean;
  40306. /** @hidden */
  40307. _panningMouseButton: number;
  40308. /**
  40309. * Defines the input associated to the camera.
  40310. */
  40311. inputs: ArcRotateCameraInputsManager;
  40312. /** @hidden */
  40313. _reset: () => void;
  40314. /**
  40315. * Defines the allowed panning axis.
  40316. */
  40317. panningAxis: Vector3;
  40318. protected _localDirection: Vector3;
  40319. protected _transformedDirection: Vector3;
  40320. private _bouncingBehavior;
  40321. /**
  40322. * Gets the bouncing behavior of the camera if it has been enabled.
  40323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40324. */
  40325. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40326. /**
  40327. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40329. */
  40330. get useBouncingBehavior(): boolean;
  40331. set useBouncingBehavior(value: boolean);
  40332. private _framingBehavior;
  40333. /**
  40334. * Gets the framing behavior of the camera if it has been enabled.
  40335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40336. */
  40337. get framingBehavior(): Nullable<FramingBehavior>;
  40338. /**
  40339. * Defines if the framing behavior of the camera is enabled on the camera.
  40340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40341. */
  40342. get useFramingBehavior(): boolean;
  40343. set useFramingBehavior(value: boolean);
  40344. private _autoRotationBehavior;
  40345. /**
  40346. * Gets the auto rotation behavior of the camera if it has been enabled.
  40347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40348. */
  40349. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40350. /**
  40351. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40353. */
  40354. get useAutoRotationBehavior(): boolean;
  40355. set useAutoRotationBehavior(value: boolean);
  40356. /**
  40357. * Observable triggered when the mesh target has been changed on the camera.
  40358. */
  40359. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40360. /**
  40361. * Event raised when the camera is colliding with a mesh.
  40362. */
  40363. onCollide: (collidedMesh: AbstractMesh) => void;
  40364. /**
  40365. * Defines whether the camera should check collision with the objects oh the scene.
  40366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40367. */
  40368. checkCollisions: boolean;
  40369. /**
  40370. * Defines the collision radius of the camera.
  40371. * This simulates a sphere around the camera.
  40372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40373. */
  40374. collisionRadius: Vector3;
  40375. protected _collider: Collider;
  40376. protected _previousPosition: Vector3;
  40377. protected _collisionVelocity: Vector3;
  40378. protected _newPosition: Vector3;
  40379. protected _previousAlpha: number;
  40380. protected _previousBeta: number;
  40381. protected _previousRadius: number;
  40382. protected _collisionTriggered: boolean;
  40383. protected _targetBoundingCenter: Nullable<Vector3>;
  40384. private _computationVector;
  40385. /**
  40386. * Instantiates a new ArcRotateCamera in a given scene
  40387. * @param name Defines the name of the camera
  40388. * @param alpha Defines the camera rotation along the logitudinal axis
  40389. * @param beta Defines the camera rotation along the latitudinal axis
  40390. * @param radius Defines the camera distance from its target
  40391. * @param target Defines the camera target
  40392. * @param scene Defines the scene the camera belongs to
  40393. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40394. */
  40395. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40396. /** @hidden */
  40397. _initCache(): void;
  40398. /** @hidden */
  40399. _updateCache(ignoreParentClass?: boolean): void;
  40400. protected _getTargetPosition(): Vector3;
  40401. private _storedAlpha;
  40402. private _storedBeta;
  40403. private _storedRadius;
  40404. private _storedTarget;
  40405. private _storedTargetScreenOffset;
  40406. /**
  40407. * Stores the current state of the camera (alpha, beta, radius and target)
  40408. * @returns the camera itself
  40409. */
  40410. storeState(): Camera;
  40411. /**
  40412. * @hidden
  40413. * Restored camera state. You must call storeState() first
  40414. */
  40415. _restoreStateValues(): boolean;
  40416. /** @hidden */
  40417. _isSynchronizedViewMatrix(): boolean;
  40418. /**
  40419. * Attached controls to the current camera.
  40420. * @param element Defines the element the controls should be listened from
  40421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40422. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40423. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40424. */
  40425. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40426. /**
  40427. * Detach the current controls from the camera.
  40428. * The camera will stop reacting to inputs.
  40429. * @param element Defines the element to stop listening the inputs from
  40430. */
  40431. detachControl(element: HTMLElement): void;
  40432. /** @hidden */
  40433. _checkInputs(): void;
  40434. protected _checkLimits(): void;
  40435. /**
  40436. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40437. */
  40438. rebuildAnglesAndRadius(): void;
  40439. /**
  40440. * Use a position to define the current camera related information like alpha, beta and radius
  40441. * @param position Defines the position to set the camera at
  40442. */
  40443. setPosition(position: Vector3): void;
  40444. /**
  40445. * Defines the target the camera should look at.
  40446. * This will automatically adapt alpha beta and radius to fit within the new target.
  40447. * @param target Defines the new target as a Vector or a mesh
  40448. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40449. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40450. */
  40451. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40452. /** @hidden */
  40453. _getViewMatrix(): Matrix;
  40454. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40455. /**
  40456. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40457. * @param meshes Defines the mesh to zoom on
  40458. * @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)
  40459. */
  40460. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40461. /**
  40462. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40463. * The target will be changed but the radius
  40464. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40465. * @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)
  40466. */
  40467. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40468. min: Vector3;
  40469. max: Vector3;
  40470. distance: number;
  40471. }, doNotUpdateMaxZ?: boolean): void;
  40472. /**
  40473. * @override
  40474. * Override Camera.createRigCamera
  40475. */
  40476. createRigCamera(name: string, cameraIndex: number): Camera;
  40477. /**
  40478. * @hidden
  40479. * @override
  40480. * Override Camera._updateRigCameras
  40481. */
  40482. _updateRigCameras(): void;
  40483. /**
  40484. * Destroy the camera and release the current resources hold by it.
  40485. */
  40486. dispose(): void;
  40487. /**
  40488. * Gets the current object class name.
  40489. * @return the class name
  40490. */
  40491. getClassName(): string;
  40492. }
  40493. }
  40494. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40495. import { Behavior } from "babylonjs/Behaviors/behavior";
  40496. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40497. /**
  40498. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40499. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40500. */
  40501. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40502. /**
  40503. * Gets the name of the behavior.
  40504. */
  40505. get name(): string;
  40506. private _zoomStopsAnimation;
  40507. private _idleRotationSpeed;
  40508. private _idleRotationWaitTime;
  40509. private _idleRotationSpinupTime;
  40510. /**
  40511. * Sets the flag that indicates if user zooming should stop animation.
  40512. */
  40513. set zoomStopsAnimation(flag: boolean);
  40514. /**
  40515. * Gets the flag that indicates if user zooming should stop animation.
  40516. */
  40517. get zoomStopsAnimation(): boolean;
  40518. /**
  40519. * Sets the default speed at which the camera rotates around the model.
  40520. */
  40521. set idleRotationSpeed(speed: number);
  40522. /**
  40523. * Gets the default speed at which the camera rotates around the model.
  40524. */
  40525. get idleRotationSpeed(): number;
  40526. /**
  40527. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40528. */
  40529. set idleRotationWaitTime(time: number);
  40530. /**
  40531. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40532. */
  40533. get idleRotationWaitTime(): number;
  40534. /**
  40535. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40536. */
  40537. set idleRotationSpinupTime(time: number);
  40538. /**
  40539. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40540. */
  40541. get idleRotationSpinupTime(): number;
  40542. /**
  40543. * Gets a value indicating if the camera is currently rotating because of this behavior
  40544. */
  40545. get rotationInProgress(): boolean;
  40546. private _onPrePointerObservableObserver;
  40547. private _onAfterCheckInputsObserver;
  40548. private _attachedCamera;
  40549. private _isPointerDown;
  40550. private _lastFrameTime;
  40551. private _lastInteractionTime;
  40552. private _cameraRotationSpeed;
  40553. /**
  40554. * Initializes the behavior.
  40555. */
  40556. init(): void;
  40557. /**
  40558. * Attaches the behavior to its arc rotate camera.
  40559. * @param camera Defines the camera to attach the behavior to
  40560. */
  40561. attach(camera: ArcRotateCamera): void;
  40562. /**
  40563. * Detaches the behavior from its current arc rotate camera.
  40564. */
  40565. detach(): void;
  40566. /**
  40567. * Returns true if user is scrolling.
  40568. * @return true if user is scrolling.
  40569. */
  40570. private _userIsZooming;
  40571. private _lastFrameRadius;
  40572. private _shouldAnimationStopForInteraction;
  40573. /**
  40574. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40575. */
  40576. private _applyUserInteraction;
  40577. private _userIsMoving;
  40578. }
  40579. }
  40580. declare module "babylonjs/Behaviors/Cameras/index" {
  40581. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40582. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40583. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40584. }
  40585. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40586. import { Mesh } from "babylonjs/Meshes/mesh";
  40587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40588. import { Behavior } from "babylonjs/Behaviors/behavior";
  40589. /**
  40590. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40591. */
  40592. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40593. private ui;
  40594. /**
  40595. * The name of the behavior
  40596. */
  40597. name: string;
  40598. /**
  40599. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40600. */
  40601. distanceAwayFromFace: number;
  40602. /**
  40603. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40604. */
  40605. distanceAwayFromBottomOfFace: number;
  40606. private _faceVectors;
  40607. private _target;
  40608. private _scene;
  40609. private _onRenderObserver;
  40610. private _tmpMatrix;
  40611. private _tmpVector;
  40612. /**
  40613. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40614. * @param ui The transform node that should be attched to the mesh
  40615. */
  40616. constructor(ui: TransformNode);
  40617. /**
  40618. * Initializes the behavior
  40619. */
  40620. init(): void;
  40621. private _closestFace;
  40622. private _zeroVector;
  40623. private _lookAtTmpMatrix;
  40624. private _lookAtToRef;
  40625. /**
  40626. * Attaches the AttachToBoxBehavior to the passed in mesh
  40627. * @param target The mesh that the specified node will be attached to
  40628. */
  40629. attach(target: Mesh): void;
  40630. /**
  40631. * Detaches the behavior from the mesh
  40632. */
  40633. detach(): void;
  40634. }
  40635. }
  40636. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40637. import { Behavior } from "babylonjs/Behaviors/behavior";
  40638. import { Mesh } from "babylonjs/Meshes/mesh";
  40639. /**
  40640. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40641. */
  40642. export class FadeInOutBehavior implements Behavior<Mesh> {
  40643. /**
  40644. * Time in milliseconds to delay before fading in (Default: 0)
  40645. */
  40646. delay: number;
  40647. /**
  40648. * Time in milliseconds for the mesh to fade in (Default: 300)
  40649. */
  40650. fadeInTime: number;
  40651. private _millisecondsPerFrame;
  40652. private _hovered;
  40653. private _hoverValue;
  40654. private _ownerNode;
  40655. /**
  40656. * Instatiates the FadeInOutBehavior
  40657. */
  40658. constructor();
  40659. /**
  40660. * The name of the behavior
  40661. */
  40662. get name(): string;
  40663. /**
  40664. * Initializes the behavior
  40665. */
  40666. init(): void;
  40667. /**
  40668. * Attaches the fade behavior on the passed in mesh
  40669. * @param ownerNode The mesh that will be faded in/out once attached
  40670. */
  40671. attach(ownerNode: Mesh): void;
  40672. /**
  40673. * Detaches the behavior from the mesh
  40674. */
  40675. detach(): void;
  40676. /**
  40677. * Triggers the mesh to begin fading in or out
  40678. * @param value if the object should fade in or out (true to fade in)
  40679. */
  40680. fadeIn(value: boolean): void;
  40681. private _update;
  40682. private _setAllVisibility;
  40683. }
  40684. }
  40685. declare module "babylonjs/Misc/pivotTools" {
  40686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40687. /**
  40688. * Class containing a set of static utilities functions for managing Pivots
  40689. * @hidden
  40690. */
  40691. export class PivotTools {
  40692. private static _PivotCached;
  40693. private static _OldPivotPoint;
  40694. private static _PivotTranslation;
  40695. private static _PivotTmpVector;
  40696. /** @hidden */
  40697. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40698. /** @hidden */
  40699. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40700. }
  40701. }
  40702. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40703. import { Scene } from "babylonjs/scene";
  40704. import { Vector4 } from "babylonjs/Maths/math.vector";
  40705. import { Mesh } from "babylonjs/Meshes/mesh";
  40706. import { Nullable } from "babylonjs/types";
  40707. import { Plane } from "babylonjs/Maths/math.plane";
  40708. /**
  40709. * Class containing static functions to help procedurally build meshes
  40710. */
  40711. export class PlaneBuilder {
  40712. /**
  40713. * Creates a plane mesh
  40714. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40715. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40716. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40720. * @param name defines the name of the mesh
  40721. * @param options defines the options used to create the mesh
  40722. * @param scene defines the hosting scene
  40723. * @returns the plane mesh
  40724. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40725. */
  40726. static CreatePlane(name: string, options: {
  40727. size?: number;
  40728. width?: number;
  40729. height?: number;
  40730. sideOrientation?: number;
  40731. frontUVs?: Vector4;
  40732. backUVs?: Vector4;
  40733. updatable?: boolean;
  40734. sourcePlane?: Plane;
  40735. }, scene?: Nullable<Scene>): Mesh;
  40736. }
  40737. }
  40738. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40739. import { Behavior } from "babylonjs/Behaviors/behavior";
  40740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40741. import { Observable } from "babylonjs/Misc/observable";
  40742. import { Vector3 } from "babylonjs/Maths/math.vector";
  40743. import { Ray } from "babylonjs/Culling/ray";
  40744. import "babylonjs/Meshes/Builders/planeBuilder";
  40745. /**
  40746. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40747. */
  40748. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40749. private static _AnyMouseID;
  40750. /**
  40751. * Abstract mesh the behavior is set on
  40752. */
  40753. attachedNode: AbstractMesh;
  40754. private _dragPlane;
  40755. private _scene;
  40756. private _pointerObserver;
  40757. private _beforeRenderObserver;
  40758. private static _planeScene;
  40759. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40760. /**
  40761. * 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)
  40762. */
  40763. maxDragAngle: number;
  40764. /**
  40765. * @hidden
  40766. */
  40767. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40768. /**
  40769. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40770. */
  40771. currentDraggingPointerID: number;
  40772. /**
  40773. * The last position where the pointer hit the drag plane in world space
  40774. */
  40775. lastDragPosition: Vector3;
  40776. /**
  40777. * If the behavior is currently in a dragging state
  40778. */
  40779. dragging: boolean;
  40780. /**
  40781. * 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)
  40782. */
  40783. dragDeltaRatio: number;
  40784. /**
  40785. * If the drag plane orientation should be updated during the dragging (Default: true)
  40786. */
  40787. updateDragPlane: boolean;
  40788. private _debugMode;
  40789. private _moving;
  40790. /**
  40791. * Fires each time the attached mesh is dragged with the pointer
  40792. * * delta between last drag position and current drag position in world space
  40793. * * dragDistance along the drag axis
  40794. * * dragPlaneNormal normal of the current drag plane used during the drag
  40795. * * dragPlanePoint in world space where the drag intersects the drag plane
  40796. */
  40797. onDragObservable: Observable<{
  40798. delta: Vector3;
  40799. dragPlanePoint: Vector3;
  40800. dragPlaneNormal: Vector3;
  40801. dragDistance: number;
  40802. pointerId: number;
  40803. }>;
  40804. /**
  40805. * Fires each time a drag begins (eg. mouse down on mesh)
  40806. */
  40807. onDragStartObservable: Observable<{
  40808. dragPlanePoint: Vector3;
  40809. pointerId: number;
  40810. }>;
  40811. /**
  40812. * Fires each time a drag ends (eg. mouse release after drag)
  40813. */
  40814. onDragEndObservable: Observable<{
  40815. dragPlanePoint: Vector3;
  40816. pointerId: number;
  40817. }>;
  40818. /**
  40819. * If the attached mesh should be moved when dragged
  40820. */
  40821. moveAttached: boolean;
  40822. /**
  40823. * If the drag behavior will react to drag events (Default: true)
  40824. */
  40825. enabled: boolean;
  40826. /**
  40827. * If pointer events should start and release the drag (Default: true)
  40828. */
  40829. startAndReleaseDragOnPointerEvents: boolean;
  40830. /**
  40831. * If camera controls should be detached during the drag
  40832. */
  40833. detachCameraControls: boolean;
  40834. /**
  40835. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40836. */
  40837. useObjectOrientationForDragging: boolean;
  40838. private _options;
  40839. /**
  40840. * Gets the options used by the behavior
  40841. */
  40842. get options(): {
  40843. dragAxis?: Vector3;
  40844. dragPlaneNormal?: Vector3;
  40845. };
  40846. /**
  40847. * Sets the options used by the behavior
  40848. */
  40849. set options(options: {
  40850. dragAxis?: Vector3;
  40851. dragPlaneNormal?: Vector3;
  40852. });
  40853. /**
  40854. * Creates a pointer drag behavior that can be attached to a mesh
  40855. * @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)
  40856. */
  40857. constructor(options?: {
  40858. dragAxis?: Vector3;
  40859. dragPlaneNormal?: Vector3;
  40860. });
  40861. /**
  40862. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40863. */
  40864. validateDrag: (targetPosition: Vector3) => boolean;
  40865. /**
  40866. * The name of the behavior
  40867. */
  40868. get name(): string;
  40869. /**
  40870. * Initializes the behavior
  40871. */
  40872. init(): void;
  40873. private _tmpVector;
  40874. private _alternatePickedPoint;
  40875. private _worldDragAxis;
  40876. private _targetPosition;
  40877. private _attachedElement;
  40878. /**
  40879. * Attaches the drag behavior the passed in mesh
  40880. * @param ownerNode The mesh that will be dragged around once attached
  40881. * @param predicate Predicate to use for pick filtering
  40882. */
  40883. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40884. /**
  40885. * Force relase the drag action by code.
  40886. */
  40887. releaseDrag(): void;
  40888. private _startDragRay;
  40889. private _lastPointerRay;
  40890. /**
  40891. * Simulates the start of a pointer drag event on the behavior
  40892. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40893. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40894. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40895. */
  40896. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40897. private _startDrag;
  40898. private _dragDelta;
  40899. private _moveDrag;
  40900. private _pickWithRayOnDragPlane;
  40901. private _pointA;
  40902. private _pointB;
  40903. private _pointC;
  40904. private _lineA;
  40905. private _lineB;
  40906. private _localAxis;
  40907. private _lookAt;
  40908. private _updateDragPlanePosition;
  40909. /**
  40910. * Detaches the behavior from the mesh
  40911. */
  40912. detach(): void;
  40913. }
  40914. }
  40915. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40916. import { Mesh } from "babylonjs/Meshes/mesh";
  40917. import { Behavior } from "babylonjs/Behaviors/behavior";
  40918. /**
  40919. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40920. */
  40921. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40922. private _dragBehaviorA;
  40923. private _dragBehaviorB;
  40924. private _startDistance;
  40925. private _initialScale;
  40926. private _targetScale;
  40927. private _ownerNode;
  40928. private _sceneRenderObserver;
  40929. /**
  40930. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40931. */
  40932. constructor();
  40933. /**
  40934. * The name of the behavior
  40935. */
  40936. get name(): string;
  40937. /**
  40938. * Initializes the behavior
  40939. */
  40940. init(): void;
  40941. private _getCurrentDistance;
  40942. /**
  40943. * Attaches the scale behavior the passed in mesh
  40944. * @param ownerNode The mesh that will be scaled around once attached
  40945. */
  40946. attach(ownerNode: Mesh): void;
  40947. /**
  40948. * Detaches the behavior from the mesh
  40949. */
  40950. detach(): void;
  40951. }
  40952. }
  40953. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40954. import { Behavior } from "babylonjs/Behaviors/behavior";
  40955. import { Mesh } from "babylonjs/Meshes/mesh";
  40956. import { Observable } from "babylonjs/Misc/observable";
  40957. /**
  40958. * 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
  40959. */
  40960. export class SixDofDragBehavior implements Behavior<Mesh> {
  40961. private static _virtualScene;
  40962. private _ownerNode;
  40963. private _sceneRenderObserver;
  40964. private _scene;
  40965. private _targetPosition;
  40966. private _virtualOriginMesh;
  40967. private _virtualDragMesh;
  40968. private _pointerObserver;
  40969. private _moving;
  40970. private _startingOrientation;
  40971. private _attachedElement;
  40972. /**
  40973. * 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)
  40974. */
  40975. private zDragFactor;
  40976. /**
  40977. * If the object should rotate to face the drag origin
  40978. */
  40979. rotateDraggedObject: boolean;
  40980. /**
  40981. * If the behavior is currently in a dragging state
  40982. */
  40983. dragging: boolean;
  40984. /**
  40985. * 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)
  40986. */
  40987. dragDeltaRatio: number;
  40988. /**
  40989. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40990. */
  40991. currentDraggingPointerID: number;
  40992. /**
  40993. * If camera controls should be detached during the drag
  40994. */
  40995. detachCameraControls: boolean;
  40996. /**
  40997. * Fires each time a drag starts
  40998. */
  40999. onDragStartObservable: Observable<{}>;
  41000. /**
  41001. * Fires each time a drag ends (eg. mouse release after drag)
  41002. */
  41003. onDragEndObservable: Observable<{}>;
  41004. /**
  41005. * 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
  41006. */
  41007. constructor();
  41008. /**
  41009. * The name of the behavior
  41010. */
  41011. get name(): string;
  41012. /**
  41013. * Initializes the behavior
  41014. */
  41015. init(): void;
  41016. /**
  41017. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41018. */
  41019. private get _pointerCamera();
  41020. /**
  41021. * Attaches the scale behavior the passed in mesh
  41022. * @param ownerNode The mesh that will be scaled around once attached
  41023. */
  41024. attach(ownerNode: Mesh): void;
  41025. /**
  41026. * Detaches the behavior from the mesh
  41027. */
  41028. detach(): void;
  41029. }
  41030. }
  41031. declare module "babylonjs/Behaviors/Meshes/index" {
  41032. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41033. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41034. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41035. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41036. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41037. }
  41038. declare module "babylonjs/Behaviors/index" {
  41039. export * from "babylonjs/Behaviors/behavior";
  41040. export * from "babylonjs/Behaviors/Cameras/index";
  41041. export * from "babylonjs/Behaviors/Meshes/index";
  41042. }
  41043. declare module "babylonjs/Bones/boneIKController" {
  41044. import { Bone } from "babylonjs/Bones/bone";
  41045. import { Vector3 } from "babylonjs/Maths/math.vector";
  41046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41047. import { Nullable } from "babylonjs/types";
  41048. /**
  41049. * Class used to apply inverse kinematics to bones
  41050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41051. */
  41052. export class BoneIKController {
  41053. private static _tmpVecs;
  41054. private static _tmpQuat;
  41055. private static _tmpMats;
  41056. /**
  41057. * Gets or sets the target mesh
  41058. */
  41059. targetMesh: AbstractMesh;
  41060. /** Gets or sets the mesh used as pole */
  41061. poleTargetMesh: AbstractMesh;
  41062. /**
  41063. * Gets or sets the bone used as pole
  41064. */
  41065. poleTargetBone: Nullable<Bone>;
  41066. /**
  41067. * Gets or sets the target position
  41068. */
  41069. targetPosition: Vector3;
  41070. /**
  41071. * Gets or sets the pole target position
  41072. */
  41073. poleTargetPosition: Vector3;
  41074. /**
  41075. * Gets or sets the pole target local offset
  41076. */
  41077. poleTargetLocalOffset: Vector3;
  41078. /**
  41079. * Gets or sets the pole angle
  41080. */
  41081. poleAngle: number;
  41082. /**
  41083. * Gets or sets the mesh associated with the controller
  41084. */
  41085. mesh: AbstractMesh;
  41086. /**
  41087. * 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)
  41088. */
  41089. slerpAmount: number;
  41090. private _bone1Quat;
  41091. private _bone1Mat;
  41092. private _bone2Ang;
  41093. private _bone1;
  41094. private _bone2;
  41095. private _bone1Length;
  41096. private _bone2Length;
  41097. private _maxAngle;
  41098. private _maxReach;
  41099. private _rightHandedSystem;
  41100. private _bendAxis;
  41101. private _slerping;
  41102. private _adjustRoll;
  41103. /**
  41104. * Gets or sets maximum allowed angle
  41105. */
  41106. get maxAngle(): number;
  41107. set maxAngle(value: number);
  41108. /**
  41109. * Creates a new BoneIKController
  41110. * @param mesh defines the mesh to control
  41111. * @param bone defines the bone to control
  41112. * @param options defines options to set up the controller
  41113. */
  41114. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41115. targetMesh?: AbstractMesh;
  41116. poleTargetMesh?: AbstractMesh;
  41117. poleTargetBone?: Bone;
  41118. poleTargetLocalOffset?: Vector3;
  41119. poleAngle?: number;
  41120. bendAxis?: Vector3;
  41121. maxAngle?: number;
  41122. slerpAmount?: number;
  41123. });
  41124. private _setMaxAngle;
  41125. /**
  41126. * Force the controller to update the bones
  41127. */
  41128. update(): void;
  41129. }
  41130. }
  41131. declare module "babylonjs/Bones/boneLookController" {
  41132. import { Vector3 } from "babylonjs/Maths/math.vector";
  41133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41134. import { Bone } from "babylonjs/Bones/bone";
  41135. import { Space } from "babylonjs/Maths/math.axis";
  41136. /**
  41137. * Class used to make a bone look toward a point in space
  41138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41139. */
  41140. export class BoneLookController {
  41141. private static _tmpVecs;
  41142. private static _tmpQuat;
  41143. private static _tmpMats;
  41144. /**
  41145. * The target Vector3 that the bone will look at
  41146. */
  41147. target: Vector3;
  41148. /**
  41149. * The mesh that the bone is attached to
  41150. */
  41151. mesh: AbstractMesh;
  41152. /**
  41153. * The bone that will be looking to the target
  41154. */
  41155. bone: Bone;
  41156. /**
  41157. * The up axis of the coordinate system that is used when the bone is rotated
  41158. */
  41159. upAxis: Vector3;
  41160. /**
  41161. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41162. */
  41163. upAxisSpace: Space;
  41164. /**
  41165. * Used to make an adjustment to the yaw of the bone
  41166. */
  41167. adjustYaw: number;
  41168. /**
  41169. * Used to make an adjustment to the pitch of the bone
  41170. */
  41171. adjustPitch: number;
  41172. /**
  41173. * Used to make an adjustment to the roll of the bone
  41174. */
  41175. adjustRoll: number;
  41176. /**
  41177. * 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)
  41178. */
  41179. slerpAmount: number;
  41180. private _minYaw;
  41181. private _maxYaw;
  41182. private _minPitch;
  41183. private _maxPitch;
  41184. private _minYawSin;
  41185. private _minYawCos;
  41186. private _maxYawSin;
  41187. private _maxYawCos;
  41188. private _midYawConstraint;
  41189. private _minPitchTan;
  41190. private _maxPitchTan;
  41191. private _boneQuat;
  41192. private _slerping;
  41193. private _transformYawPitch;
  41194. private _transformYawPitchInv;
  41195. private _firstFrameSkipped;
  41196. private _yawRange;
  41197. private _fowardAxis;
  41198. /**
  41199. * Gets or sets the minimum yaw angle that the bone can look to
  41200. */
  41201. get minYaw(): number;
  41202. set minYaw(value: number);
  41203. /**
  41204. * Gets or sets the maximum yaw angle that the bone can look to
  41205. */
  41206. get maxYaw(): number;
  41207. set maxYaw(value: number);
  41208. /**
  41209. * Gets or sets the minimum pitch angle that the bone can look to
  41210. */
  41211. get minPitch(): number;
  41212. set minPitch(value: number);
  41213. /**
  41214. * Gets or sets the maximum pitch angle that the bone can look to
  41215. */
  41216. get maxPitch(): number;
  41217. set maxPitch(value: number);
  41218. /**
  41219. * Create a BoneLookController
  41220. * @param mesh the mesh that the bone belongs to
  41221. * @param bone the bone that will be looking to the target
  41222. * @param target the target Vector3 to look at
  41223. * @param options optional settings:
  41224. * * maxYaw: the maximum angle the bone will yaw to
  41225. * * minYaw: the minimum angle the bone will yaw to
  41226. * * maxPitch: the maximum angle the bone will pitch to
  41227. * * minPitch: the minimum angle the bone will yaw to
  41228. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41229. * * upAxis: the up axis of the coordinate system
  41230. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41231. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41232. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41233. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41234. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41235. * * adjustRoll: used to make an adjustment to the roll of the bone
  41236. **/
  41237. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41238. maxYaw?: number;
  41239. minYaw?: number;
  41240. maxPitch?: number;
  41241. minPitch?: number;
  41242. slerpAmount?: number;
  41243. upAxis?: Vector3;
  41244. upAxisSpace?: Space;
  41245. yawAxis?: Vector3;
  41246. pitchAxis?: Vector3;
  41247. adjustYaw?: number;
  41248. adjustPitch?: number;
  41249. adjustRoll?: number;
  41250. });
  41251. /**
  41252. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41253. */
  41254. update(): void;
  41255. private _getAngleDiff;
  41256. private _getAngleBetween;
  41257. private _isAngleBetween;
  41258. }
  41259. }
  41260. declare module "babylonjs/Bones/index" {
  41261. export * from "babylonjs/Bones/bone";
  41262. export * from "babylonjs/Bones/boneIKController";
  41263. export * from "babylonjs/Bones/boneLookController";
  41264. export * from "babylonjs/Bones/skeleton";
  41265. }
  41266. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41267. import { Nullable } from "babylonjs/types";
  41268. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41270. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41271. /**
  41272. * Manage the gamepad inputs to control an arc rotate camera.
  41273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41274. */
  41275. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41276. /**
  41277. * Defines the camera the input is attached to.
  41278. */
  41279. camera: ArcRotateCamera;
  41280. /**
  41281. * Defines the gamepad the input is gathering event from.
  41282. */
  41283. gamepad: Nullable<Gamepad>;
  41284. /**
  41285. * Defines the gamepad rotation sensiblity.
  41286. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41287. */
  41288. gamepadRotationSensibility: number;
  41289. /**
  41290. * Defines the gamepad move sensiblity.
  41291. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41292. */
  41293. gamepadMoveSensibility: number;
  41294. private _yAxisScale;
  41295. /**
  41296. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41297. */
  41298. get invertYAxis(): boolean;
  41299. set invertYAxis(value: boolean);
  41300. private _onGamepadConnectedObserver;
  41301. private _onGamepadDisconnectedObserver;
  41302. /**
  41303. * Attach the input controls to a specific dom element to get the input from.
  41304. * @param element Defines the element the controls should be listened from
  41305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41306. */
  41307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41308. /**
  41309. * Detach the current controls from the specified dom element.
  41310. * @param element Defines the element to stop listening the inputs from
  41311. */
  41312. detachControl(element: Nullable<HTMLElement>): void;
  41313. /**
  41314. * Update the current camera state depending on the inputs that have been used this frame.
  41315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41316. */
  41317. checkInputs(): void;
  41318. /**
  41319. * Gets the class name of the current intput.
  41320. * @returns the class name
  41321. */
  41322. getClassName(): string;
  41323. /**
  41324. * Get the friendly name associated with the input class.
  41325. * @returns the input friendly name
  41326. */
  41327. getSimpleName(): string;
  41328. }
  41329. }
  41330. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41331. import { Nullable } from "babylonjs/types";
  41332. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41334. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41335. interface ArcRotateCameraInputsManager {
  41336. /**
  41337. * Add orientation input support to the input manager.
  41338. * @returns the current input manager
  41339. */
  41340. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41341. }
  41342. }
  41343. /**
  41344. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41346. */
  41347. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41348. /**
  41349. * Defines the camera the input is attached to.
  41350. */
  41351. camera: ArcRotateCamera;
  41352. /**
  41353. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41354. */
  41355. alphaCorrection: number;
  41356. /**
  41357. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41358. */
  41359. gammaCorrection: number;
  41360. private _alpha;
  41361. private _gamma;
  41362. private _dirty;
  41363. private _deviceOrientationHandler;
  41364. /**
  41365. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41366. */
  41367. constructor();
  41368. /**
  41369. * Attach the input controls to a specific dom element to get the input from.
  41370. * @param element Defines the element the controls should be listened from
  41371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41372. */
  41373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41374. /** @hidden */
  41375. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41376. /**
  41377. * Update the current camera state depending on the inputs that have been used this frame.
  41378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41379. */
  41380. checkInputs(): void;
  41381. /**
  41382. * Detach the current controls from the specified dom element.
  41383. * @param element Defines the element to stop listening the inputs from
  41384. */
  41385. detachControl(element: Nullable<HTMLElement>): void;
  41386. /**
  41387. * Gets the class name of the current intput.
  41388. * @returns the class name
  41389. */
  41390. getClassName(): string;
  41391. /**
  41392. * Get the friendly name associated with the input class.
  41393. * @returns the input friendly name
  41394. */
  41395. getSimpleName(): string;
  41396. }
  41397. }
  41398. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41399. import { Nullable } from "babylonjs/types";
  41400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41401. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41402. /**
  41403. * Listen to mouse events to control the camera.
  41404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41405. */
  41406. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41407. /**
  41408. * Defines the camera the input is attached to.
  41409. */
  41410. camera: FlyCamera;
  41411. /**
  41412. * Defines if touch is enabled. (Default is true.)
  41413. */
  41414. touchEnabled: boolean;
  41415. /**
  41416. * Defines the buttons associated with the input to handle camera rotation.
  41417. */
  41418. buttons: number[];
  41419. /**
  41420. * Assign buttons for Yaw control.
  41421. */
  41422. buttonsYaw: number[];
  41423. /**
  41424. * Assign buttons for Pitch control.
  41425. */
  41426. buttonsPitch: number[];
  41427. /**
  41428. * Assign buttons for Roll control.
  41429. */
  41430. buttonsRoll: number[];
  41431. /**
  41432. * Detect if any button is being pressed while mouse is moved.
  41433. * -1 = Mouse locked.
  41434. * 0 = Left button.
  41435. * 1 = Middle Button.
  41436. * 2 = Right Button.
  41437. */
  41438. activeButton: number;
  41439. /**
  41440. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41441. * Higher values reduce its sensitivity.
  41442. */
  41443. angularSensibility: number;
  41444. private _mousemoveCallback;
  41445. private _observer;
  41446. private _rollObserver;
  41447. private previousPosition;
  41448. private noPreventDefault;
  41449. private element;
  41450. /**
  41451. * Listen to mouse events to control the camera.
  41452. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41454. */
  41455. constructor(touchEnabled?: boolean);
  41456. /**
  41457. * Attach the mouse control to the HTML DOM element.
  41458. * @param element Defines the element that listens to the input events.
  41459. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41460. */
  41461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41462. /**
  41463. * Detach the current controls from the specified dom element.
  41464. * @param element Defines the element to stop listening the inputs from
  41465. */
  41466. detachControl(element: Nullable<HTMLElement>): void;
  41467. /**
  41468. * Gets the class name of the current input.
  41469. * @returns the class name.
  41470. */
  41471. getClassName(): string;
  41472. /**
  41473. * Get the friendly name associated with the input class.
  41474. * @returns the input's friendly name.
  41475. */
  41476. getSimpleName(): string;
  41477. private _pointerInput;
  41478. private _onMouseMove;
  41479. /**
  41480. * Rotate camera by mouse offset.
  41481. */
  41482. private rotateCamera;
  41483. }
  41484. }
  41485. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41486. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41487. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41488. /**
  41489. * Default Inputs manager for the FlyCamera.
  41490. * It groups all the default supported inputs for ease of use.
  41491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41492. */
  41493. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41494. /**
  41495. * Instantiates a new FlyCameraInputsManager.
  41496. * @param camera Defines the camera the inputs belong to.
  41497. */
  41498. constructor(camera: FlyCamera);
  41499. /**
  41500. * Add keyboard input support to the input manager.
  41501. * @returns the new FlyCameraKeyboardMoveInput().
  41502. */
  41503. addKeyboard(): FlyCameraInputsManager;
  41504. /**
  41505. * Add mouse input support to the input manager.
  41506. * @param touchEnabled Enable touch screen support.
  41507. * @returns the new FlyCameraMouseInput().
  41508. */
  41509. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41510. }
  41511. }
  41512. declare module "babylonjs/Cameras/flyCamera" {
  41513. import { Scene } from "babylonjs/scene";
  41514. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41516. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41517. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41518. /**
  41519. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41520. * such as in a 3D Space Shooter or a Flight Simulator.
  41521. */
  41522. export class FlyCamera extends TargetCamera {
  41523. /**
  41524. * Define the collision ellipsoid of the camera.
  41525. * This is helpful for simulating a camera body, like a player's body.
  41526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41527. */
  41528. ellipsoid: Vector3;
  41529. /**
  41530. * Define an offset for the position of the ellipsoid around the camera.
  41531. * This can be helpful if the camera is attached away from the player's body center,
  41532. * such as at its head.
  41533. */
  41534. ellipsoidOffset: Vector3;
  41535. /**
  41536. * Enable or disable collisions of the camera with the rest of the scene objects.
  41537. */
  41538. checkCollisions: boolean;
  41539. /**
  41540. * Enable or disable gravity on the camera.
  41541. */
  41542. applyGravity: boolean;
  41543. /**
  41544. * Define the current direction the camera is moving to.
  41545. */
  41546. cameraDirection: Vector3;
  41547. /**
  41548. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41549. * This overrides and empties cameraRotation.
  41550. */
  41551. rotationQuaternion: Quaternion;
  41552. /**
  41553. * Track Roll to maintain the wanted Rolling when looking around.
  41554. */
  41555. _trackRoll: number;
  41556. /**
  41557. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41558. */
  41559. rollCorrect: number;
  41560. /**
  41561. * Mimic a banked turn, Rolling the camera when Yawing.
  41562. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41563. */
  41564. bankedTurn: boolean;
  41565. /**
  41566. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41567. */
  41568. bankedTurnLimit: number;
  41569. /**
  41570. * Value of 0 disables the banked Roll.
  41571. * Value of 1 is equal to the Yaw angle in radians.
  41572. */
  41573. bankedTurnMultiplier: number;
  41574. /**
  41575. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41576. */
  41577. inputs: FlyCameraInputsManager;
  41578. /**
  41579. * Gets the input sensibility for mouse input.
  41580. * Higher values reduce sensitivity.
  41581. */
  41582. get angularSensibility(): number;
  41583. /**
  41584. * Sets the input sensibility for a mouse input.
  41585. * Higher values reduce sensitivity.
  41586. */
  41587. set angularSensibility(value: number);
  41588. /**
  41589. * Get the keys for camera movement forward.
  41590. */
  41591. get keysForward(): number[];
  41592. /**
  41593. * Set the keys for camera movement forward.
  41594. */
  41595. set keysForward(value: number[]);
  41596. /**
  41597. * Get the keys for camera movement backward.
  41598. */
  41599. get keysBackward(): number[];
  41600. set keysBackward(value: number[]);
  41601. /**
  41602. * Get the keys for camera movement up.
  41603. */
  41604. get keysUp(): number[];
  41605. /**
  41606. * Set the keys for camera movement up.
  41607. */
  41608. set keysUp(value: number[]);
  41609. /**
  41610. * Get the keys for camera movement down.
  41611. */
  41612. get keysDown(): number[];
  41613. /**
  41614. * Set the keys for camera movement down.
  41615. */
  41616. set keysDown(value: number[]);
  41617. /**
  41618. * Get the keys for camera movement left.
  41619. */
  41620. get keysLeft(): number[];
  41621. /**
  41622. * Set the keys for camera movement left.
  41623. */
  41624. set keysLeft(value: number[]);
  41625. /**
  41626. * Set the keys for camera movement right.
  41627. */
  41628. get keysRight(): number[];
  41629. /**
  41630. * Set the keys for camera movement right.
  41631. */
  41632. set keysRight(value: number[]);
  41633. /**
  41634. * Event raised when the camera collides with a mesh in the scene.
  41635. */
  41636. onCollide: (collidedMesh: AbstractMesh) => void;
  41637. private _collider;
  41638. private _needMoveForGravity;
  41639. private _oldPosition;
  41640. private _diffPosition;
  41641. private _newPosition;
  41642. /** @hidden */
  41643. _localDirection: Vector3;
  41644. /** @hidden */
  41645. _transformedDirection: Vector3;
  41646. /**
  41647. * Instantiates a FlyCamera.
  41648. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41649. * such as in a 3D Space Shooter or a Flight Simulator.
  41650. * @param name Define the name of the camera in the scene.
  41651. * @param position Define the starting position of the camera in the scene.
  41652. * @param scene Define the scene the camera belongs to.
  41653. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41654. */
  41655. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41656. /**
  41657. * Attach a control to the HTML DOM element.
  41658. * @param element Defines the element that listens to the input events.
  41659. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41660. */
  41661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41662. /**
  41663. * Detach a control from the HTML DOM element.
  41664. * The camera will stop reacting to that input.
  41665. * @param element Defines the element that listens to the input events.
  41666. */
  41667. detachControl(element: HTMLElement): void;
  41668. private _collisionMask;
  41669. /**
  41670. * Get the mask that the camera ignores in collision events.
  41671. */
  41672. get collisionMask(): number;
  41673. /**
  41674. * Set the mask that the camera ignores in collision events.
  41675. */
  41676. set collisionMask(mask: number);
  41677. /** @hidden */
  41678. _collideWithWorld(displacement: Vector3): void;
  41679. /** @hidden */
  41680. private _onCollisionPositionChange;
  41681. /** @hidden */
  41682. _checkInputs(): void;
  41683. /** @hidden */
  41684. _decideIfNeedsToMove(): boolean;
  41685. /** @hidden */
  41686. _updatePosition(): void;
  41687. /**
  41688. * Restore the Roll to its target value at the rate specified.
  41689. * @param rate - Higher means slower restoring.
  41690. * @hidden
  41691. */
  41692. restoreRoll(rate: number): void;
  41693. /**
  41694. * Destroy the camera and release the current resources held by it.
  41695. */
  41696. dispose(): void;
  41697. /**
  41698. * Get the current object class name.
  41699. * @returns the class name.
  41700. */
  41701. getClassName(): string;
  41702. }
  41703. }
  41704. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41705. import { Nullable } from "babylonjs/types";
  41706. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41707. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41708. /**
  41709. * Listen to keyboard events to control the camera.
  41710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41711. */
  41712. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41713. /**
  41714. * Defines the camera the input is attached to.
  41715. */
  41716. camera: FlyCamera;
  41717. /**
  41718. * The list of keyboard keys used to control the forward move of the camera.
  41719. */
  41720. keysForward: number[];
  41721. /**
  41722. * The list of keyboard keys used to control the backward move of the camera.
  41723. */
  41724. keysBackward: number[];
  41725. /**
  41726. * The list of keyboard keys used to control the forward move of the camera.
  41727. */
  41728. keysUp: number[];
  41729. /**
  41730. * The list of keyboard keys used to control the backward move of the camera.
  41731. */
  41732. keysDown: number[];
  41733. /**
  41734. * The list of keyboard keys used to control the right strafe move of the camera.
  41735. */
  41736. keysRight: number[];
  41737. /**
  41738. * The list of keyboard keys used to control the left strafe move of the camera.
  41739. */
  41740. keysLeft: number[];
  41741. private _keys;
  41742. private _onCanvasBlurObserver;
  41743. private _onKeyboardObserver;
  41744. private _engine;
  41745. private _scene;
  41746. /**
  41747. * Attach the input controls to a specific dom element to get the input from.
  41748. * @param element Defines the element the controls should be listened from
  41749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41750. */
  41751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41752. /**
  41753. * Detach the current controls from the specified dom element.
  41754. * @param element Defines the element to stop listening the inputs from
  41755. */
  41756. detachControl(element: Nullable<HTMLElement>): void;
  41757. /**
  41758. * Gets the class name of the current intput.
  41759. * @returns the class name
  41760. */
  41761. getClassName(): string;
  41762. /** @hidden */
  41763. _onLostFocus(e: FocusEvent): void;
  41764. /**
  41765. * Get the friendly name associated with the input class.
  41766. * @returns the input friendly name
  41767. */
  41768. getSimpleName(): string;
  41769. /**
  41770. * Update the current camera state depending on the inputs that have been used this frame.
  41771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41772. */
  41773. checkInputs(): void;
  41774. }
  41775. }
  41776. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41777. import { Nullable } from "babylonjs/types";
  41778. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41779. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41780. /**
  41781. * Manage the mouse wheel inputs to control a follow camera.
  41782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41783. */
  41784. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41785. /**
  41786. * Defines the camera the input is attached to.
  41787. */
  41788. camera: FollowCamera;
  41789. /**
  41790. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41791. */
  41792. axisControlRadius: boolean;
  41793. /**
  41794. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41795. */
  41796. axisControlHeight: boolean;
  41797. /**
  41798. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41799. */
  41800. axisControlRotation: boolean;
  41801. /**
  41802. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41803. * relation to mouseWheel events.
  41804. */
  41805. wheelPrecision: number;
  41806. /**
  41807. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41808. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41809. */
  41810. wheelDeltaPercentage: number;
  41811. private _wheel;
  41812. private _observer;
  41813. /**
  41814. * Attach the input controls to a specific dom element to get the input from.
  41815. * @param element Defines the element the controls should be listened from
  41816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41817. */
  41818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41819. /**
  41820. * Detach the current controls from the specified dom element.
  41821. * @param element Defines the element to stop listening the inputs from
  41822. */
  41823. detachControl(element: Nullable<HTMLElement>): void;
  41824. /**
  41825. * Gets the class name of the current intput.
  41826. * @returns the class name
  41827. */
  41828. getClassName(): string;
  41829. /**
  41830. * Get the friendly name associated with the input class.
  41831. * @returns the input friendly name
  41832. */
  41833. getSimpleName(): string;
  41834. }
  41835. }
  41836. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41837. import { Nullable } from "babylonjs/types";
  41838. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41839. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41840. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41841. /**
  41842. * Manage the pointers inputs to control an follow camera.
  41843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41844. */
  41845. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41846. /**
  41847. * Defines the camera the input is attached to.
  41848. */
  41849. camera: FollowCamera;
  41850. /**
  41851. * Gets the class name of the current input.
  41852. * @returns the class name
  41853. */
  41854. getClassName(): string;
  41855. /**
  41856. * Defines the pointer angular sensibility along the X axis or how fast is
  41857. * the camera rotating.
  41858. * A negative number will reverse the axis direction.
  41859. */
  41860. angularSensibilityX: number;
  41861. /**
  41862. * Defines the pointer angular sensibility along the Y axis or how fast is
  41863. * the camera rotating.
  41864. * A negative number will reverse the axis direction.
  41865. */
  41866. angularSensibilityY: number;
  41867. /**
  41868. * Defines the pointer pinch precision or how fast is the camera zooming.
  41869. * A negative number will reverse the axis direction.
  41870. */
  41871. pinchPrecision: number;
  41872. /**
  41873. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41874. * from 0.
  41875. * It defines the percentage of current camera.radius to use as delta when
  41876. * pinch zoom is used.
  41877. */
  41878. pinchDeltaPercentage: number;
  41879. /**
  41880. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41881. */
  41882. axisXControlRadius: boolean;
  41883. /**
  41884. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41885. */
  41886. axisXControlHeight: boolean;
  41887. /**
  41888. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41889. */
  41890. axisXControlRotation: boolean;
  41891. /**
  41892. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41893. */
  41894. axisYControlRadius: boolean;
  41895. /**
  41896. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41897. */
  41898. axisYControlHeight: boolean;
  41899. /**
  41900. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41901. */
  41902. axisYControlRotation: boolean;
  41903. /**
  41904. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41905. */
  41906. axisPinchControlRadius: boolean;
  41907. /**
  41908. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41909. */
  41910. axisPinchControlHeight: boolean;
  41911. /**
  41912. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41913. */
  41914. axisPinchControlRotation: boolean;
  41915. /**
  41916. * Log error messages if basic misconfiguration has occurred.
  41917. */
  41918. warningEnable: boolean;
  41919. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41921. private _warningCounter;
  41922. private _warning;
  41923. }
  41924. }
  41925. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41926. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41927. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41928. /**
  41929. * Default Inputs manager for the FollowCamera.
  41930. * It groups all the default supported inputs for ease of use.
  41931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41932. */
  41933. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41934. /**
  41935. * Instantiates a new FollowCameraInputsManager.
  41936. * @param camera Defines the camera the inputs belong to
  41937. */
  41938. constructor(camera: FollowCamera);
  41939. /**
  41940. * Add keyboard input support to the input manager.
  41941. * @returns the current input manager
  41942. */
  41943. addKeyboard(): FollowCameraInputsManager;
  41944. /**
  41945. * Add mouse wheel input support to the input manager.
  41946. * @returns the current input manager
  41947. */
  41948. addMouseWheel(): FollowCameraInputsManager;
  41949. /**
  41950. * Add pointers input support to the input manager.
  41951. * @returns the current input manager
  41952. */
  41953. addPointers(): FollowCameraInputsManager;
  41954. /**
  41955. * Add orientation input support to the input manager.
  41956. * @returns the current input manager
  41957. */
  41958. addVRDeviceOrientation(): FollowCameraInputsManager;
  41959. }
  41960. }
  41961. declare module "babylonjs/Cameras/followCamera" {
  41962. import { Nullable } from "babylonjs/types";
  41963. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41964. import { Scene } from "babylonjs/scene";
  41965. import { Vector3 } from "babylonjs/Maths/math.vector";
  41966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41967. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41968. /**
  41969. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41970. * an arc rotate version arcFollowCamera are available.
  41971. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41972. */
  41973. export class FollowCamera extends TargetCamera {
  41974. /**
  41975. * Distance the follow camera should follow an object at
  41976. */
  41977. radius: number;
  41978. /**
  41979. * Minimum allowed distance of the camera to the axis of rotation
  41980. * (The camera can not get closer).
  41981. * This can help limiting how the Camera is able to move in the scene.
  41982. */
  41983. lowerRadiusLimit: Nullable<number>;
  41984. /**
  41985. * Maximum allowed distance of the camera to the axis of rotation
  41986. * (The camera can not get further).
  41987. * This can help limiting how the Camera is able to move in the scene.
  41988. */
  41989. upperRadiusLimit: Nullable<number>;
  41990. /**
  41991. * Define a rotation offset between the camera and the object it follows
  41992. */
  41993. rotationOffset: number;
  41994. /**
  41995. * Minimum allowed angle to camera position relative to target object.
  41996. * This can help limiting how the Camera is able to move in the scene.
  41997. */
  41998. lowerRotationOffsetLimit: Nullable<number>;
  41999. /**
  42000. * Maximum allowed angle to camera position relative to target object.
  42001. * This can help limiting how the Camera is able to move in the scene.
  42002. */
  42003. upperRotationOffsetLimit: Nullable<number>;
  42004. /**
  42005. * Define a height offset between the camera and the object it follows.
  42006. * It can help following an object from the top (like a car chaing a plane)
  42007. */
  42008. heightOffset: number;
  42009. /**
  42010. * Minimum allowed height of camera position relative to target object.
  42011. * This can help limiting how the Camera is able to move in the scene.
  42012. */
  42013. lowerHeightOffsetLimit: Nullable<number>;
  42014. /**
  42015. * Maximum allowed height of camera position relative to target object.
  42016. * This can help limiting how the Camera is able to move in the scene.
  42017. */
  42018. upperHeightOffsetLimit: Nullable<number>;
  42019. /**
  42020. * Define how fast the camera can accelerate to follow it s target.
  42021. */
  42022. cameraAcceleration: number;
  42023. /**
  42024. * Define the speed limit of the camera following an object.
  42025. */
  42026. maxCameraSpeed: number;
  42027. /**
  42028. * Define the target of the camera.
  42029. */
  42030. lockedTarget: Nullable<AbstractMesh>;
  42031. /**
  42032. * Defines the input associated with the camera.
  42033. */
  42034. inputs: FollowCameraInputsManager;
  42035. /**
  42036. * Instantiates the follow camera.
  42037. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42038. * @param name Define the name of the camera in the scene
  42039. * @param position Define the position of the camera
  42040. * @param scene Define the scene the camera belong to
  42041. * @param lockedTarget Define the target of the camera
  42042. */
  42043. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42044. private _follow;
  42045. /**
  42046. * Attached controls to the current camera.
  42047. * @param element Defines the element the controls should be listened from
  42048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42049. */
  42050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42051. /**
  42052. * Detach the current controls from the camera.
  42053. * The camera will stop reacting to inputs.
  42054. * @param element Defines the element to stop listening the inputs from
  42055. */
  42056. detachControl(element: HTMLElement): void;
  42057. /** @hidden */
  42058. _checkInputs(): void;
  42059. private _checkLimits;
  42060. /**
  42061. * Gets the camera class name.
  42062. * @returns the class name
  42063. */
  42064. getClassName(): string;
  42065. }
  42066. /**
  42067. * Arc Rotate version of the follow camera.
  42068. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42069. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42070. */
  42071. export class ArcFollowCamera extends TargetCamera {
  42072. /** The longitudinal angle of the camera */
  42073. alpha: number;
  42074. /** The latitudinal angle of the camera */
  42075. beta: number;
  42076. /** The radius of the camera from its target */
  42077. radius: number;
  42078. /** Define the camera target (the messh it should follow) */
  42079. target: Nullable<AbstractMesh>;
  42080. private _cartesianCoordinates;
  42081. /**
  42082. * Instantiates a new ArcFollowCamera
  42083. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42084. * @param name Define the name of the camera
  42085. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42086. * @param beta Define the rotation angle of the camera around the elevation axis
  42087. * @param radius Define the radius of the camera from its target point
  42088. * @param target Define the target of the camera
  42089. * @param scene Define the scene the camera belongs to
  42090. */
  42091. constructor(name: string,
  42092. /** The longitudinal angle of the camera */
  42093. alpha: number,
  42094. /** The latitudinal angle of the camera */
  42095. beta: number,
  42096. /** The radius of the camera from its target */
  42097. radius: number,
  42098. /** Define the camera target (the messh it should follow) */
  42099. target: Nullable<AbstractMesh>, scene: Scene);
  42100. private _follow;
  42101. /** @hidden */
  42102. _checkInputs(): void;
  42103. /**
  42104. * Returns the class name of the object.
  42105. * It is mostly used internally for serialization purposes.
  42106. */
  42107. getClassName(): string;
  42108. }
  42109. }
  42110. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42111. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42112. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42113. import { Nullable } from "babylonjs/types";
  42114. /**
  42115. * Manage the keyboard inputs to control the movement of a follow camera.
  42116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42117. */
  42118. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42119. /**
  42120. * Defines the camera the input is attached to.
  42121. */
  42122. camera: FollowCamera;
  42123. /**
  42124. * Defines the list of key codes associated with the up action (increase heightOffset)
  42125. */
  42126. keysHeightOffsetIncr: number[];
  42127. /**
  42128. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42129. */
  42130. keysHeightOffsetDecr: number[];
  42131. /**
  42132. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42133. */
  42134. keysHeightOffsetModifierAlt: boolean;
  42135. /**
  42136. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42137. */
  42138. keysHeightOffsetModifierCtrl: boolean;
  42139. /**
  42140. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42141. */
  42142. keysHeightOffsetModifierShift: boolean;
  42143. /**
  42144. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42145. */
  42146. keysRotationOffsetIncr: number[];
  42147. /**
  42148. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42149. */
  42150. keysRotationOffsetDecr: number[];
  42151. /**
  42152. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42153. */
  42154. keysRotationOffsetModifierAlt: boolean;
  42155. /**
  42156. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42157. */
  42158. keysRotationOffsetModifierCtrl: boolean;
  42159. /**
  42160. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42161. */
  42162. keysRotationOffsetModifierShift: boolean;
  42163. /**
  42164. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42165. */
  42166. keysRadiusIncr: number[];
  42167. /**
  42168. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42169. */
  42170. keysRadiusDecr: number[];
  42171. /**
  42172. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42173. */
  42174. keysRadiusModifierAlt: boolean;
  42175. /**
  42176. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42177. */
  42178. keysRadiusModifierCtrl: boolean;
  42179. /**
  42180. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42181. */
  42182. keysRadiusModifierShift: boolean;
  42183. /**
  42184. * Defines the rate of change of heightOffset.
  42185. */
  42186. heightSensibility: number;
  42187. /**
  42188. * Defines the rate of change of rotationOffset.
  42189. */
  42190. rotationSensibility: number;
  42191. /**
  42192. * Defines the rate of change of radius.
  42193. */
  42194. radiusSensibility: number;
  42195. private _keys;
  42196. private _ctrlPressed;
  42197. private _altPressed;
  42198. private _shiftPressed;
  42199. private _onCanvasBlurObserver;
  42200. private _onKeyboardObserver;
  42201. private _engine;
  42202. private _scene;
  42203. /**
  42204. * Attach the input controls to a specific dom element to get the input from.
  42205. * @param element Defines the element the controls should be listened from
  42206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42207. */
  42208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42209. /**
  42210. * Detach the current controls from the specified dom element.
  42211. * @param element Defines the element to stop listening the inputs from
  42212. */
  42213. detachControl(element: Nullable<HTMLElement>): void;
  42214. /**
  42215. * Update the current camera state depending on the inputs that have been used this frame.
  42216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42217. */
  42218. checkInputs(): void;
  42219. /**
  42220. * Gets the class name of the current input.
  42221. * @returns the class name
  42222. */
  42223. getClassName(): string;
  42224. /**
  42225. * Get the friendly name associated with the input class.
  42226. * @returns the input friendly name
  42227. */
  42228. getSimpleName(): string;
  42229. /**
  42230. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42231. * allow modification of the heightOffset value.
  42232. */
  42233. private _modifierHeightOffset;
  42234. /**
  42235. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42236. * allow modification of the rotationOffset value.
  42237. */
  42238. private _modifierRotationOffset;
  42239. /**
  42240. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42241. * allow modification of the radius value.
  42242. */
  42243. private _modifierRadius;
  42244. }
  42245. }
  42246. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42247. import { Nullable } from "babylonjs/types";
  42248. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42249. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42250. import { Observable } from "babylonjs/Misc/observable";
  42251. module "babylonjs/Cameras/freeCameraInputsManager" {
  42252. interface FreeCameraInputsManager {
  42253. /**
  42254. * @hidden
  42255. */
  42256. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42257. /**
  42258. * Add orientation input support to the input manager.
  42259. * @returns the current input manager
  42260. */
  42261. addDeviceOrientation(): FreeCameraInputsManager;
  42262. }
  42263. }
  42264. /**
  42265. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42266. * Screen rotation is taken into account.
  42267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42268. */
  42269. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42270. private _camera;
  42271. private _screenOrientationAngle;
  42272. private _constantTranform;
  42273. private _screenQuaternion;
  42274. private _alpha;
  42275. private _beta;
  42276. private _gamma;
  42277. /**
  42278. * Can be used to detect if a device orientation sensor is available on a device
  42279. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42280. * @returns a promise that will resolve on orientation change
  42281. */
  42282. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42283. /**
  42284. * @hidden
  42285. */
  42286. _onDeviceOrientationChangedObservable: Observable<void>;
  42287. /**
  42288. * Instantiates a new input
  42289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42290. */
  42291. constructor();
  42292. /**
  42293. * Define the camera controlled by the input.
  42294. */
  42295. get camera(): FreeCamera;
  42296. set camera(camera: FreeCamera);
  42297. /**
  42298. * Attach the input controls to a specific dom element to get the input from.
  42299. * @param element Defines the element the controls should be listened from
  42300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42301. */
  42302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42303. private _orientationChanged;
  42304. private _deviceOrientation;
  42305. /**
  42306. * Detach the current controls from the specified dom element.
  42307. * @param element Defines the element to stop listening the inputs from
  42308. */
  42309. detachControl(element: Nullable<HTMLElement>): void;
  42310. /**
  42311. * Update the current camera state depending on the inputs that have been used this frame.
  42312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42313. */
  42314. checkInputs(): void;
  42315. /**
  42316. * Gets the class name of the current intput.
  42317. * @returns the class name
  42318. */
  42319. getClassName(): string;
  42320. /**
  42321. * Get the friendly name associated with the input class.
  42322. * @returns the input friendly name
  42323. */
  42324. getSimpleName(): string;
  42325. }
  42326. }
  42327. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42328. import { Nullable } from "babylonjs/types";
  42329. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42331. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42332. /**
  42333. * Manage the gamepad inputs to control a free camera.
  42334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42335. */
  42336. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42337. /**
  42338. * Define the camera the input is attached to.
  42339. */
  42340. camera: FreeCamera;
  42341. /**
  42342. * Define the Gamepad controlling the input
  42343. */
  42344. gamepad: Nullable<Gamepad>;
  42345. /**
  42346. * Defines the gamepad rotation sensiblity.
  42347. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42348. */
  42349. gamepadAngularSensibility: number;
  42350. /**
  42351. * Defines the gamepad move sensiblity.
  42352. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42353. */
  42354. gamepadMoveSensibility: number;
  42355. private _yAxisScale;
  42356. /**
  42357. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42358. */
  42359. get invertYAxis(): boolean;
  42360. set invertYAxis(value: boolean);
  42361. private _onGamepadConnectedObserver;
  42362. private _onGamepadDisconnectedObserver;
  42363. private _cameraTransform;
  42364. private _deltaTransform;
  42365. private _vector3;
  42366. private _vector2;
  42367. /**
  42368. * Attach the input controls to a specific dom element to get the input from.
  42369. * @param element Defines the element the controls should be listened from
  42370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42371. */
  42372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42373. /**
  42374. * Detach the current controls from the specified dom element.
  42375. * @param element Defines the element to stop listening the inputs from
  42376. */
  42377. detachControl(element: Nullable<HTMLElement>): void;
  42378. /**
  42379. * Update the current camera state depending on the inputs that have been used this frame.
  42380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42381. */
  42382. checkInputs(): void;
  42383. /**
  42384. * Gets the class name of the current intput.
  42385. * @returns the class name
  42386. */
  42387. getClassName(): string;
  42388. /**
  42389. * Get the friendly name associated with the input class.
  42390. * @returns the input friendly name
  42391. */
  42392. getSimpleName(): string;
  42393. }
  42394. }
  42395. declare module "babylonjs/Misc/virtualJoystick" {
  42396. import { Nullable } from "babylonjs/types";
  42397. import { Vector3 } from "babylonjs/Maths/math.vector";
  42398. /**
  42399. * Defines the potential axis of a Joystick
  42400. */
  42401. export enum JoystickAxis {
  42402. /** X axis */
  42403. X = 0,
  42404. /** Y axis */
  42405. Y = 1,
  42406. /** Z axis */
  42407. Z = 2
  42408. }
  42409. /**
  42410. * Class used to define virtual joystick (used in touch mode)
  42411. */
  42412. export class VirtualJoystick {
  42413. /**
  42414. * Gets or sets a boolean indicating that left and right values must be inverted
  42415. */
  42416. reverseLeftRight: boolean;
  42417. /**
  42418. * Gets or sets a boolean indicating that up and down values must be inverted
  42419. */
  42420. reverseUpDown: boolean;
  42421. /**
  42422. * Gets the offset value for the position (ie. the change of the position value)
  42423. */
  42424. deltaPosition: Vector3;
  42425. /**
  42426. * Gets a boolean indicating if the virtual joystick was pressed
  42427. */
  42428. pressed: boolean;
  42429. /**
  42430. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42431. */
  42432. static Canvas: Nullable<HTMLCanvasElement>;
  42433. private static _globalJoystickIndex;
  42434. private static vjCanvasContext;
  42435. private static vjCanvasWidth;
  42436. private static vjCanvasHeight;
  42437. private static halfWidth;
  42438. private _action;
  42439. private _axisTargetedByLeftAndRight;
  42440. private _axisTargetedByUpAndDown;
  42441. private _joystickSensibility;
  42442. private _inversedSensibility;
  42443. private _joystickPointerID;
  42444. private _joystickColor;
  42445. private _joystickPointerPos;
  42446. private _joystickPreviousPointerPos;
  42447. private _joystickPointerStartPos;
  42448. private _deltaJoystickVector;
  42449. private _leftJoystick;
  42450. private _touches;
  42451. private _onPointerDownHandlerRef;
  42452. private _onPointerMoveHandlerRef;
  42453. private _onPointerUpHandlerRef;
  42454. private _onResize;
  42455. /**
  42456. * Creates a new virtual joystick
  42457. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42458. */
  42459. constructor(leftJoystick?: boolean);
  42460. /**
  42461. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42462. * @param newJoystickSensibility defines the new sensibility
  42463. */
  42464. setJoystickSensibility(newJoystickSensibility: number): void;
  42465. private _onPointerDown;
  42466. private _onPointerMove;
  42467. private _onPointerUp;
  42468. /**
  42469. * Change the color of the virtual joystick
  42470. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42471. */
  42472. setJoystickColor(newColor: string): void;
  42473. /**
  42474. * Defines a callback to call when the joystick is touched
  42475. * @param action defines the callback
  42476. */
  42477. setActionOnTouch(action: () => any): void;
  42478. /**
  42479. * Defines which axis you'd like to control for left & right
  42480. * @param axis defines the axis to use
  42481. */
  42482. setAxisForLeftRight(axis: JoystickAxis): void;
  42483. /**
  42484. * Defines which axis you'd like to control for up & down
  42485. * @param axis defines the axis to use
  42486. */
  42487. setAxisForUpDown(axis: JoystickAxis): void;
  42488. private _drawVirtualJoystick;
  42489. /**
  42490. * Release internal HTML canvas
  42491. */
  42492. releaseCanvas(): void;
  42493. }
  42494. }
  42495. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42496. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42497. import { Nullable } from "babylonjs/types";
  42498. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42500. module "babylonjs/Cameras/freeCameraInputsManager" {
  42501. interface FreeCameraInputsManager {
  42502. /**
  42503. * Add virtual joystick input support to the input manager.
  42504. * @returns the current input manager
  42505. */
  42506. addVirtualJoystick(): FreeCameraInputsManager;
  42507. }
  42508. }
  42509. /**
  42510. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42512. */
  42513. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42514. /**
  42515. * Defines the camera the input is attached to.
  42516. */
  42517. camera: FreeCamera;
  42518. private _leftjoystick;
  42519. private _rightjoystick;
  42520. /**
  42521. * Gets the left stick of the virtual joystick.
  42522. * @returns The virtual Joystick
  42523. */
  42524. getLeftJoystick(): VirtualJoystick;
  42525. /**
  42526. * Gets the right stick of the virtual joystick.
  42527. * @returns The virtual Joystick
  42528. */
  42529. getRightJoystick(): VirtualJoystick;
  42530. /**
  42531. * Update the current camera state depending on the inputs that have been used this frame.
  42532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42533. */
  42534. checkInputs(): void;
  42535. /**
  42536. * Attach the input controls to a specific dom element to get the input from.
  42537. * @param element Defines the element the controls should be listened from
  42538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42539. */
  42540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42541. /**
  42542. * Detach the current controls from the specified dom element.
  42543. * @param element Defines the element to stop listening the inputs from
  42544. */
  42545. detachControl(element: Nullable<HTMLElement>): void;
  42546. /**
  42547. * Gets the class name of the current intput.
  42548. * @returns the class name
  42549. */
  42550. getClassName(): string;
  42551. /**
  42552. * Get the friendly name associated with the input class.
  42553. * @returns the input friendly name
  42554. */
  42555. getSimpleName(): string;
  42556. }
  42557. }
  42558. declare module "babylonjs/Cameras/Inputs/index" {
  42559. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42560. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42561. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42562. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42563. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42564. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42565. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42566. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42567. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42568. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42569. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42570. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42571. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42572. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42573. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42574. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42575. }
  42576. declare module "babylonjs/Cameras/touchCamera" {
  42577. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42578. import { Scene } from "babylonjs/scene";
  42579. import { Vector3 } from "babylonjs/Maths/math.vector";
  42580. /**
  42581. * This represents a FPS type of camera controlled by touch.
  42582. * This is like a universal camera minus the Gamepad controls.
  42583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42584. */
  42585. export class TouchCamera extends FreeCamera {
  42586. /**
  42587. * Defines the touch sensibility for rotation.
  42588. * The higher the faster.
  42589. */
  42590. get touchAngularSensibility(): number;
  42591. set touchAngularSensibility(value: number);
  42592. /**
  42593. * Defines the touch sensibility for move.
  42594. * The higher the faster.
  42595. */
  42596. get touchMoveSensibility(): number;
  42597. set touchMoveSensibility(value: number);
  42598. /**
  42599. * Instantiates a new touch camera.
  42600. * This represents a FPS type of camera controlled by touch.
  42601. * This is like a universal camera minus the Gamepad controls.
  42602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42603. * @param name Define the name of the camera in the scene
  42604. * @param position Define the start position of the camera in the scene
  42605. * @param scene Define the scene the camera belongs to
  42606. */
  42607. constructor(name: string, position: Vector3, scene: Scene);
  42608. /**
  42609. * Gets the current object class name.
  42610. * @return the class name
  42611. */
  42612. getClassName(): string;
  42613. /** @hidden */
  42614. _setupInputs(): void;
  42615. }
  42616. }
  42617. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42618. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42619. import { Scene } from "babylonjs/scene";
  42620. import { Vector3 } from "babylonjs/Maths/math.vector";
  42621. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42622. import { Axis } from "babylonjs/Maths/math.axis";
  42623. /**
  42624. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42625. * being tilted forward or back and left or right.
  42626. */
  42627. export class DeviceOrientationCamera extends FreeCamera {
  42628. private _initialQuaternion;
  42629. private _quaternionCache;
  42630. private _tmpDragQuaternion;
  42631. private _disablePointerInputWhenUsingDeviceOrientation;
  42632. /**
  42633. * Creates a new device orientation camera
  42634. * @param name The name of the camera
  42635. * @param position The start position camera
  42636. * @param scene The scene the camera belongs to
  42637. */
  42638. constructor(name: string, position: Vector3, scene: Scene);
  42639. /**
  42640. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42641. */
  42642. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42643. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42644. private _dragFactor;
  42645. /**
  42646. * Enabled turning on the y axis when the orientation sensor is active
  42647. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42648. */
  42649. enableHorizontalDragging(dragFactor?: number): void;
  42650. /**
  42651. * Gets the current instance class name ("DeviceOrientationCamera").
  42652. * This helps avoiding instanceof at run time.
  42653. * @returns the class name
  42654. */
  42655. getClassName(): string;
  42656. /**
  42657. * @hidden
  42658. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42659. */
  42660. _checkInputs(): void;
  42661. /**
  42662. * Reset the camera to its default orientation on the specified axis only.
  42663. * @param axis The axis to reset
  42664. */
  42665. resetToCurrentRotation(axis?: Axis): void;
  42666. }
  42667. }
  42668. declare module "babylonjs/Gamepads/xboxGamepad" {
  42669. import { Observable } from "babylonjs/Misc/observable";
  42670. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42671. /**
  42672. * Defines supported buttons for XBox360 compatible gamepads
  42673. */
  42674. export enum Xbox360Button {
  42675. /** A */
  42676. A = 0,
  42677. /** B */
  42678. B = 1,
  42679. /** X */
  42680. X = 2,
  42681. /** Y */
  42682. Y = 3,
  42683. /** Left button */
  42684. LB = 4,
  42685. /** Right button */
  42686. RB = 5,
  42687. /** Back */
  42688. Back = 8,
  42689. /** Start */
  42690. Start = 9,
  42691. /** Left stick */
  42692. LeftStick = 10,
  42693. /** Right stick */
  42694. RightStick = 11
  42695. }
  42696. /** Defines values for XBox360 DPad */
  42697. export enum Xbox360Dpad {
  42698. /** Up */
  42699. Up = 12,
  42700. /** Down */
  42701. Down = 13,
  42702. /** Left */
  42703. Left = 14,
  42704. /** Right */
  42705. Right = 15
  42706. }
  42707. /**
  42708. * Defines a XBox360 gamepad
  42709. */
  42710. export class Xbox360Pad extends Gamepad {
  42711. private _leftTrigger;
  42712. private _rightTrigger;
  42713. private _onlefttriggerchanged;
  42714. private _onrighttriggerchanged;
  42715. private _onbuttondown;
  42716. private _onbuttonup;
  42717. private _ondpaddown;
  42718. private _ondpadup;
  42719. /** Observable raised when a button is pressed */
  42720. onButtonDownObservable: Observable<Xbox360Button>;
  42721. /** Observable raised when a button is released */
  42722. onButtonUpObservable: Observable<Xbox360Button>;
  42723. /** Observable raised when a pad is pressed */
  42724. onPadDownObservable: Observable<Xbox360Dpad>;
  42725. /** Observable raised when a pad is released */
  42726. onPadUpObservable: Observable<Xbox360Dpad>;
  42727. private _buttonA;
  42728. private _buttonB;
  42729. private _buttonX;
  42730. private _buttonY;
  42731. private _buttonBack;
  42732. private _buttonStart;
  42733. private _buttonLB;
  42734. private _buttonRB;
  42735. private _buttonLeftStick;
  42736. private _buttonRightStick;
  42737. private _dPadUp;
  42738. private _dPadDown;
  42739. private _dPadLeft;
  42740. private _dPadRight;
  42741. private _isXboxOnePad;
  42742. /**
  42743. * Creates a new XBox360 gamepad object
  42744. * @param id defines the id of this gamepad
  42745. * @param index defines its index
  42746. * @param gamepad defines the internal HTML gamepad object
  42747. * @param xboxOne defines if it is a XBox One gamepad
  42748. */
  42749. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42750. /**
  42751. * Defines the callback to call when left trigger is pressed
  42752. * @param callback defines the callback to use
  42753. */
  42754. onlefttriggerchanged(callback: (value: number) => void): void;
  42755. /**
  42756. * Defines the callback to call when right trigger is pressed
  42757. * @param callback defines the callback to use
  42758. */
  42759. onrighttriggerchanged(callback: (value: number) => void): void;
  42760. /**
  42761. * Gets the left trigger value
  42762. */
  42763. get leftTrigger(): number;
  42764. /**
  42765. * Sets the left trigger value
  42766. */
  42767. set leftTrigger(newValue: number);
  42768. /**
  42769. * Gets the right trigger value
  42770. */
  42771. get rightTrigger(): number;
  42772. /**
  42773. * Sets the right trigger value
  42774. */
  42775. set rightTrigger(newValue: number);
  42776. /**
  42777. * Defines the callback to call when a button is pressed
  42778. * @param callback defines the callback to use
  42779. */
  42780. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42781. /**
  42782. * Defines the callback to call when a button is released
  42783. * @param callback defines the callback to use
  42784. */
  42785. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42786. /**
  42787. * Defines the callback to call when a pad is pressed
  42788. * @param callback defines the callback to use
  42789. */
  42790. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42791. /**
  42792. * Defines the callback to call when a pad is released
  42793. * @param callback defines the callback to use
  42794. */
  42795. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42796. private _setButtonValue;
  42797. private _setDPadValue;
  42798. /**
  42799. * Gets the value of the `A` button
  42800. */
  42801. get buttonA(): number;
  42802. /**
  42803. * Sets the value of the `A` button
  42804. */
  42805. set buttonA(value: number);
  42806. /**
  42807. * Gets the value of the `B` button
  42808. */
  42809. get buttonB(): number;
  42810. /**
  42811. * Sets the value of the `B` button
  42812. */
  42813. set buttonB(value: number);
  42814. /**
  42815. * Gets the value of the `X` button
  42816. */
  42817. get buttonX(): number;
  42818. /**
  42819. * Sets the value of the `X` button
  42820. */
  42821. set buttonX(value: number);
  42822. /**
  42823. * Gets the value of the `Y` button
  42824. */
  42825. get buttonY(): number;
  42826. /**
  42827. * Sets the value of the `Y` button
  42828. */
  42829. set buttonY(value: number);
  42830. /**
  42831. * Gets the value of the `Start` button
  42832. */
  42833. get buttonStart(): number;
  42834. /**
  42835. * Sets the value of the `Start` button
  42836. */
  42837. set buttonStart(value: number);
  42838. /**
  42839. * Gets the value of the `Back` button
  42840. */
  42841. get buttonBack(): number;
  42842. /**
  42843. * Sets the value of the `Back` button
  42844. */
  42845. set buttonBack(value: number);
  42846. /**
  42847. * Gets the value of the `Left` button
  42848. */
  42849. get buttonLB(): number;
  42850. /**
  42851. * Sets the value of the `Left` button
  42852. */
  42853. set buttonLB(value: number);
  42854. /**
  42855. * Gets the value of the `Right` button
  42856. */
  42857. get buttonRB(): number;
  42858. /**
  42859. * Sets the value of the `Right` button
  42860. */
  42861. set buttonRB(value: number);
  42862. /**
  42863. * Gets the value of the Left joystick
  42864. */
  42865. get buttonLeftStick(): number;
  42866. /**
  42867. * Sets the value of the Left joystick
  42868. */
  42869. set buttonLeftStick(value: number);
  42870. /**
  42871. * Gets the value of the Right joystick
  42872. */
  42873. get buttonRightStick(): number;
  42874. /**
  42875. * Sets the value of the Right joystick
  42876. */
  42877. set buttonRightStick(value: number);
  42878. /**
  42879. * Gets the value of D-pad up
  42880. */
  42881. get dPadUp(): number;
  42882. /**
  42883. * Sets the value of D-pad up
  42884. */
  42885. set dPadUp(value: number);
  42886. /**
  42887. * Gets the value of D-pad down
  42888. */
  42889. get dPadDown(): number;
  42890. /**
  42891. * Sets the value of D-pad down
  42892. */
  42893. set dPadDown(value: number);
  42894. /**
  42895. * Gets the value of D-pad left
  42896. */
  42897. get dPadLeft(): number;
  42898. /**
  42899. * Sets the value of D-pad left
  42900. */
  42901. set dPadLeft(value: number);
  42902. /**
  42903. * Gets the value of D-pad right
  42904. */
  42905. get dPadRight(): number;
  42906. /**
  42907. * Sets the value of D-pad right
  42908. */
  42909. set dPadRight(value: number);
  42910. /**
  42911. * Force the gamepad to synchronize with device values
  42912. */
  42913. update(): void;
  42914. /**
  42915. * Disposes the gamepad
  42916. */
  42917. dispose(): void;
  42918. }
  42919. }
  42920. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42921. import { Observable } from "babylonjs/Misc/observable";
  42922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42923. /**
  42924. * Defines supported buttons for DualShock compatible gamepads
  42925. */
  42926. export enum DualShockButton {
  42927. /** Cross */
  42928. Cross = 0,
  42929. /** Circle */
  42930. Circle = 1,
  42931. /** Square */
  42932. Square = 2,
  42933. /** Triangle */
  42934. Triangle = 3,
  42935. /** L1 */
  42936. L1 = 4,
  42937. /** R1 */
  42938. R1 = 5,
  42939. /** Share */
  42940. Share = 8,
  42941. /** Options */
  42942. Options = 9,
  42943. /** Left stick */
  42944. LeftStick = 10,
  42945. /** Right stick */
  42946. RightStick = 11
  42947. }
  42948. /** Defines values for DualShock DPad */
  42949. export enum DualShockDpad {
  42950. /** Up */
  42951. Up = 12,
  42952. /** Down */
  42953. Down = 13,
  42954. /** Left */
  42955. Left = 14,
  42956. /** Right */
  42957. Right = 15
  42958. }
  42959. /**
  42960. * Defines a DualShock gamepad
  42961. */
  42962. export class DualShockPad extends Gamepad {
  42963. private _leftTrigger;
  42964. private _rightTrigger;
  42965. private _onlefttriggerchanged;
  42966. private _onrighttriggerchanged;
  42967. private _onbuttondown;
  42968. private _onbuttonup;
  42969. private _ondpaddown;
  42970. private _ondpadup;
  42971. /** Observable raised when a button is pressed */
  42972. onButtonDownObservable: Observable<DualShockButton>;
  42973. /** Observable raised when a button is released */
  42974. onButtonUpObservable: Observable<DualShockButton>;
  42975. /** Observable raised when a pad is pressed */
  42976. onPadDownObservable: Observable<DualShockDpad>;
  42977. /** Observable raised when a pad is released */
  42978. onPadUpObservable: Observable<DualShockDpad>;
  42979. private _buttonCross;
  42980. private _buttonCircle;
  42981. private _buttonSquare;
  42982. private _buttonTriangle;
  42983. private _buttonShare;
  42984. private _buttonOptions;
  42985. private _buttonL1;
  42986. private _buttonR1;
  42987. private _buttonLeftStick;
  42988. private _buttonRightStick;
  42989. private _dPadUp;
  42990. private _dPadDown;
  42991. private _dPadLeft;
  42992. private _dPadRight;
  42993. /**
  42994. * Creates a new DualShock gamepad object
  42995. * @param id defines the id of this gamepad
  42996. * @param index defines its index
  42997. * @param gamepad defines the internal HTML gamepad object
  42998. */
  42999. constructor(id: string, index: number, gamepad: any);
  43000. /**
  43001. * Defines the callback to call when left trigger is pressed
  43002. * @param callback defines the callback to use
  43003. */
  43004. onlefttriggerchanged(callback: (value: number) => void): void;
  43005. /**
  43006. * Defines the callback to call when right trigger is pressed
  43007. * @param callback defines the callback to use
  43008. */
  43009. onrighttriggerchanged(callback: (value: number) => void): void;
  43010. /**
  43011. * Gets the left trigger value
  43012. */
  43013. get leftTrigger(): number;
  43014. /**
  43015. * Sets the left trigger value
  43016. */
  43017. set leftTrigger(newValue: number);
  43018. /**
  43019. * Gets the right trigger value
  43020. */
  43021. get rightTrigger(): number;
  43022. /**
  43023. * Sets the right trigger value
  43024. */
  43025. set rightTrigger(newValue: number);
  43026. /**
  43027. * Defines the callback to call when a button is pressed
  43028. * @param callback defines the callback to use
  43029. */
  43030. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43031. /**
  43032. * Defines the callback to call when a button is released
  43033. * @param callback defines the callback to use
  43034. */
  43035. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43036. /**
  43037. * Defines the callback to call when a pad is pressed
  43038. * @param callback defines the callback to use
  43039. */
  43040. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43041. /**
  43042. * Defines the callback to call when a pad is released
  43043. * @param callback defines the callback to use
  43044. */
  43045. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43046. private _setButtonValue;
  43047. private _setDPadValue;
  43048. /**
  43049. * Gets the value of the `Cross` button
  43050. */
  43051. get buttonCross(): number;
  43052. /**
  43053. * Sets the value of the `Cross` button
  43054. */
  43055. set buttonCross(value: number);
  43056. /**
  43057. * Gets the value of the `Circle` button
  43058. */
  43059. get buttonCircle(): number;
  43060. /**
  43061. * Sets the value of the `Circle` button
  43062. */
  43063. set buttonCircle(value: number);
  43064. /**
  43065. * Gets the value of the `Square` button
  43066. */
  43067. get buttonSquare(): number;
  43068. /**
  43069. * Sets the value of the `Square` button
  43070. */
  43071. set buttonSquare(value: number);
  43072. /**
  43073. * Gets the value of the `Triangle` button
  43074. */
  43075. get buttonTriangle(): number;
  43076. /**
  43077. * Sets the value of the `Triangle` button
  43078. */
  43079. set buttonTriangle(value: number);
  43080. /**
  43081. * Gets the value of the `Options` button
  43082. */
  43083. get buttonOptions(): number;
  43084. /**
  43085. * Sets the value of the `Options` button
  43086. */
  43087. set buttonOptions(value: number);
  43088. /**
  43089. * Gets the value of the `Share` button
  43090. */
  43091. get buttonShare(): number;
  43092. /**
  43093. * Sets the value of the `Share` button
  43094. */
  43095. set buttonShare(value: number);
  43096. /**
  43097. * Gets the value of the `L1` button
  43098. */
  43099. get buttonL1(): number;
  43100. /**
  43101. * Sets the value of the `L1` button
  43102. */
  43103. set buttonL1(value: number);
  43104. /**
  43105. * Gets the value of the `R1` button
  43106. */
  43107. get buttonR1(): number;
  43108. /**
  43109. * Sets the value of the `R1` button
  43110. */
  43111. set buttonR1(value: number);
  43112. /**
  43113. * Gets the value of the Left joystick
  43114. */
  43115. get buttonLeftStick(): number;
  43116. /**
  43117. * Sets the value of the Left joystick
  43118. */
  43119. set buttonLeftStick(value: number);
  43120. /**
  43121. * Gets the value of the Right joystick
  43122. */
  43123. get buttonRightStick(): number;
  43124. /**
  43125. * Sets the value of the Right joystick
  43126. */
  43127. set buttonRightStick(value: number);
  43128. /**
  43129. * Gets the value of D-pad up
  43130. */
  43131. get dPadUp(): number;
  43132. /**
  43133. * Sets the value of D-pad up
  43134. */
  43135. set dPadUp(value: number);
  43136. /**
  43137. * Gets the value of D-pad down
  43138. */
  43139. get dPadDown(): number;
  43140. /**
  43141. * Sets the value of D-pad down
  43142. */
  43143. set dPadDown(value: number);
  43144. /**
  43145. * Gets the value of D-pad left
  43146. */
  43147. get dPadLeft(): number;
  43148. /**
  43149. * Sets the value of D-pad left
  43150. */
  43151. set dPadLeft(value: number);
  43152. /**
  43153. * Gets the value of D-pad right
  43154. */
  43155. get dPadRight(): number;
  43156. /**
  43157. * Sets the value of D-pad right
  43158. */
  43159. set dPadRight(value: number);
  43160. /**
  43161. * Force the gamepad to synchronize with device values
  43162. */
  43163. update(): void;
  43164. /**
  43165. * Disposes the gamepad
  43166. */
  43167. dispose(): void;
  43168. }
  43169. }
  43170. declare module "babylonjs/Gamepads/gamepadManager" {
  43171. import { Observable } from "babylonjs/Misc/observable";
  43172. import { Nullable } from "babylonjs/types";
  43173. import { Scene } from "babylonjs/scene";
  43174. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43175. /**
  43176. * Manager for handling gamepads
  43177. */
  43178. export class GamepadManager {
  43179. private _scene?;
  43180. private _babylonGamepads;
  43181. private _oneGamepadConnected;
  43182. /** @hidden */
  43183. _isMonitoring: boolean;
  43184. private _gamepadEventSupported;
  43185. private _gamepadSupport?;
  43186. /**
  43187. * observable to be triggered when the gamepad controller has been connected
  43188. */
  43189. onGamepadConnectedObservable: Observable<Gamepad>;
  43190. /**
  43191. * observable to be triggered when the gamepad controller has been disconnected
  43192. */
  43193. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43194. private _onGamepadConnectedEvent;
  43195. private _onGamepadDisconnectedEvent;
  43196. /**
  43197. * Initializes the gamepad manager
  43198. * @param _scene BabylonJS scene
  43199. */
  43200. constructor(_scene?: Scene | undefined);
  43201. /**
  43202. * The gamepads in the game pad manager
  43203. */
  43204. get gamepads(): Gamepad[];
  43205. /**
  43206. * Get the gamepad controllers based on type
  43207. * @param type The type of gamepad controller
  43208. * @returns Nullable gamepad
  43209. */
  43210. getGamepadByType(type?: number): Nullable<Gamepad>;
  43211. /**
  43212. * Disposes the gamepad manager
  43213. */
  43214. dispose(): void;
  43215. private _addNewGamepad;
  43216. private _startMonitoringGamepads;
  43217. private _stopMonitoringGamepads;
  43218. /** @hidden */
  43219. _checkGamepadsStatus(): void;
  43220. private _updateGamepadObjects;
  43221. }
  43222. }
  43223. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43224. import { Nullable } from "babylonjs/types";
  43225. import { Scene } from "babylonjs/scene";
  43226. import { ISceneComponent } from "babylonjs/sceneComponent";
  43227. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43228. module "babylonjs/scene" {
  43229. interface Scene {
  43230. /** @hidden */
  43231. _gamepadManager: Nullable<GamepadManager>;
  43232. /**
  43233. * Gets the gamepad manager associated with the scene
  43234. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43235. */
  43236. gamepadManager: GamepadManager;
  43237. }
  43238. }
  43239. module "babylonjs/Cameras/freeCameraInputsManager" {
  43240. /**
  43241. * Interface representing a free camera inputs manager
  43242. */
  43243. interface FreeCameraInputsManager {
  43244. /**
  43245. * Adds gamepad input support to the FreeCameraInputsManager.
  43246. * @returns the FreeCameraInputsManager
  43247. */
  43248. addGamepad(): FreeCameraInputsManager;
  43249. }
  43250. }
  43251. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43252. /**
  43253. * Interface representing an arc rotate camera inputs manager
  43254. */
  43255. interface ArcRotateCameraInputsManager {
  43256. /**
  43257. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43258. * @returns the camera inputs manager
  43259. */
  43260. addGamepad(): ArcRotateCameraInputsManager;
  43261. }
  43262. }
  43263. /**
  43264. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43265. */
  43266. export class GamepadSystemSceneComponent implements ISceneComponent {
  43267. /**
  43268. * The component name helpfull to identify the component in the list of scene components.
  43269. */
  43270. readonly name: string;
  43271. /**
  43272. * The scene the component belongs to.
  43273. */
  43274. scene: Scene;
  43275. /**
  43276. * Creates a new instance of the component for the given scene
  43277. * @param scene Defines the scene to register the component in
  43278. */
  43279. constructor(scene: Scene);
  43280. /**
  43281. * Registers the component in a given scene
  43282. */
  43283. register(): void;
  43284. /**
  43285. * Rebuilds the elements related to this component in case of
  43286. * context lost for instance.
  43287. */
  43288. rebuild(): void;
  43289. /**
  43290. * Disposes the component and the associated ressources
  43291. */
  43292. dispose(): void;
  43293. private _beforeCameraUpdate;
  43294. }
  43295. }
  43296. declare module "babylonjs/Cameras/universalCamera" {
  43297. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43298. import { Scene } from "babylonjs/scene";
  43299. import { Vector3 } from "babylonjs/Maths/math.vector";
  43300. import "babylonjs/Gamepads/gamepadSceneComponent";
  43301. /**
  43302. * 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,
  43303. * which still works and will still be found in many Playgrounds.
  43304. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43305. */
  43306. export class UniversalCamera extends TouchCamera {
  43307. /**
  43308. * Defines the gamepad rotation sensiblity.
  43309. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43310. */
  43311. get gamepadAngularSensibility(): number;
  43312. set gamepadAngularSensibility(value: number);
  43313. /**
  43314. * Defines the gamepad move sensiblity.
  43315. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43316. */
  43317. get gamepadMoveSensibility(): number;
  43318. set gamepadMoveSensibility(value: number);
  43319. /**
  43320. * 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,
  43321. * which still works and will still be found in many Playgrounds.
  43322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43323. * @param name Define the name of the camera in the scene
  43324. * @param position Define the start position of the camera in the scene
  43325. * @param scene Define the scene the camera belongs to
  43326. */
  43327. constructor(name: string, position: Vector3, scene: Scene);
  43328. /**
  43329. * Gets the current object class name.
  43330. * @return the class name
  43331. */
  43332. getClassName(): string;
  43333. }
  43334. }
  43335. declare module "babylonjs/Cameras/gamepadCamera" {
  43336. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43337. import { Scene } from "babylonjs/scene";
  43338. import { Vector3 } from "babylonjs/Maths/math.vector";
  43339. /**
  43340. * This represents a FPS type of camera. This is only here for back compat purpose.
  43341. * Please use the UniversalCamera instead as both are identical.
  43342. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43343. */
  43344. export class GamepadCamera extends UniversalCamera {
  43345. /**
  43346. * Instantiates a new Gamepad Camera
  43347. * This represents a FPS type of camera. This is only here for back compat purpose.
  43348. * Please use the UniversalCamera instead as both are identical.
  43349. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43350. * @param name Define the name of the camera in the scene
  43351. * @param position Define the start position of the camera in the scene
  43352. * @param scene Define the scene the camera belongs to
  43353. */
  43354. constructor(name: string, position: Vector3, scene: Scene);
  43355. /**
  43356. * Gets the current object class name.
  43357. * @return the class name
  43358. */
  43359. getClassName(): string;
  43360. }
  43361. }
  43362. declare module "babylonjs/Shaders/pass.fragment" {
  43363. /** @hidden */
  43364. export var passPixelShader: {
  43365. name: string;
  43366. shader: string;
  43367. };
  43368. }
  43369. declare module "babylonjs/Shaders/passCube.fragment" {
  43370. /** @hidden */
  43371. export var passCubePixelShader: {
  43372. name: string;
  43373. shader: string;
  43374. };
  43375. }
  43376. declare module "babylonjs/PostProcesses/passPostProcess" {
  43377. import { Nullable } from "babylonjs/types";
  43378. import { Camera } from "babylonjs/Cameras/camera";
  43379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43380. import { Engine } from "babylonjs/Engines/engine";
  43381. import "babylonjs/Shaders/pass.fragment";
  43382. import "babylonjs/Shaders/passCube.fragment";
  43383. /**
  43384. * PassPostProcess which produces an output the same as it's input
  43385. */
  43386. export class PassPostProcess extends PostProcess {
  43387. /**
  43388. * Creates the PassPostProcess
  43389. * @param name The name of the effect.
  43390. * @param options The required width/height ratio to downsize to before computing the render pass.
  43391. * @param camera The camera to apply the render pass to.
  43392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43393. * @param engine The engine which the post process will be applied. (default: current engine)
  43394. * @param reusable If the post process can be reused on the same frame. (default: false)
  43395. * @param textureType The type of texture to be used when performing the post processing.
  43396. * @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)
  43397. */
  43398. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43399. }
  43400. /**
  43401. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43402. */
  43403. export class PassCubePostProcess extends PostProcess {
  43404. private _face;
  43405. /**
  43406. * Gets or sets the cube face to display.
  43407. * * 0 is +X
  43408. * * 1 is -X
  43409. * * 2 is +Y
  43410. * * 3 is -Y
  43411. * * 4 is +Z
  43412. * * 5 is -Z
  43413. */
  43414. get face(): number;
  43415. set face(value: number);
  43416. /**
  43417. * Creates the PassCubePostProcess
  43418. * @param name The name of the effect.
  43419. * @param options The required width/height ratio to downsize to before computing the render pass.
  43420. * @param camera The camera to apply the render pass to.
  43421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43422. * @param engine The engine which the post process will be applied. (default: current engine)
  43423. * @param reusable If the post process can be reused on the same frame. (default: false)
  43424. * @param textureType The type of texture to be used when performing the post processing.
  43425. * @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)
  43426. */
  43427. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43428. }
  43429. }
  43430. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43431. /** @hidden */
  43432. export var anaglyphPixelShader: {
  43433. name: string;
  43434. shader: string;
  43435. };
  43436. }
  43437. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43438. import { Engine } from "babylonjs/Engines/engine";
  43439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43440. import { Camera } from "babylonjs/Cameras/camera";
  43441. import "babylonjs/Shaders/anaglyph.fragment";
  43442. /**
  43443. * Postprocess used to generate anaglyphic rendering
  43444. */
  43445. export class AnaglyphPostProcess extends PostProcess {
  43446. private _passedProcess;
  43447. /**
  43448. * Creates a new AnaglyphPostProcess
  43449. * @param name defines postprocess name
  43450. * @param options defines creation options or target ratio scale
  43451. * @param rigCameras defines cameras using this postprocess
  43452. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43453. * @param engine defines hosting engine
  43454. * @param reusable defines if the postprocess will be reused multiple times per frame
  43455. */
  43456. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43457. }
  43458. }
  43459. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43460. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43461. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43462. import { Scene } from "babylonjs/scene";
  43463. import { Vector3 } from "babylonjs/Maths/math.vector";
  43464. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43465. /**
  43466. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43467. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43468. */
  43469. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43470. /**
  43471. * Creates a new AnaglyphArcRotateCamera
  43472. * @param name defines camera name
  43473. * @param alpha defines alpha angle (in radians)
  43474. * @param beta defines beta angle (in radians)
  43475. * @param radius defines radius
  43476. * @param target defines camera target
  43477. * @param interaxialDistance defines distance between each color axis
  43478. * @param scene defines the hosting scene
  43479. */
  43480. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43481. /**
  43482. * Gets camera class name
  43483. * @returns AnaglyphArcRotateCamera
  43484. */
  43485. getClassName(): string;
  43486. }
  43487. }
  43488. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43489. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43490. import { Scene } from "babylonjs/scene";
  43491. import { Vector3 } from "babylonjs/Maths/math.vector";
  43492. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43493. /**
  43494. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43495. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43496. */
  43497. export class AnaglyphFreeCamera extends FreeCamera {
  43498. /**
  43499. * Creates a new AnaglyphFreeCamera
  43500. * @param name defines camera name
  43501. * @param position defines initial position
  43502. * @param interaxialDistance defines distance between each color axis
  43503. * @param scene defines the hosting scene
  43504. */
  43505. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43506. /**
  43507. * Gets camera class name
  43508. * @returns AnaglyphFreeCamera
  43509. */
  43510. getClassName(): string;
  43511. }
  43512. }
  43513. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43514. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43515. import { Scene } from "babylonjs/scene";
  43516. import { Vector3 } from "babylonjs/Maths/math.vector";
  43517. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43518. /**
  43519. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43520. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43521. */
  43522. export class AnaglyphGamepadCamera extends GamepadCamera {
  43523. /**
  43524. * Creates a new AnaglyphGamepadCamera
  43525. * @param name defines camera name
  43526. * @param position defines initial position
  43527. * @param interaxialDistance defines distance between each color axis
  43528. * @param scene defines the hosting scene
  43529. */
  43530. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43531. /**
  43532. * Gets camera class name
  43533. * @returns AnaglyphGamepadCamera
  43534. */
  43535. getClassName(): string;
  43536. }
  43537. }
  43538. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43539. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43540. import { Scene } from "babylonjs/scene";
  43541. import { Vector3 } from "babylonjs/Maths/math.vector";
  43542. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43543. /**
  43544. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43545. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43546. */
  43547. export class AnaglyphUniversalCamera extends UniversalCamera {
  43548. /**
  43549. * Creates a new AnaglyphUniversalCamera
  43550. * @param name defines camera name
  43551. * @param position defines initial position
  43552. * @param interaxialDistance defines distance between each color axis
  43553. * @param scene defines the hosting scene
  43554. */
  43555. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43556. /**
  43557. * Gets camera class name
  43558. * @returns AnaglyphUniversalCamera
  43559. */
  43560. getClassName(): string;
  43561. }
  43562. }
  43563. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43564. /** @hidden */
  43565. export var stereoscopicInterlacePixelShader: {
  43566. name: string;
  43567. shader: string;
  43568. };
  43569. }
  43570. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43571. import { Camera } from "babylonjs/Cameras/camera";
  43572. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43573. import { Engine } from "babylonjs/Engines/engine";
  43574. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43575. /**
  43576. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43577. */
  43578. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43579. private _stepSize;
  43580. private _passedProcess;
  43581. /**
  43582. * Initializes a StereoscopicInterlacePostProcessI
  43583. * @param name The name of the effect.
  43584. * @param rigCameras The rig cameras to be appled to the post process
  43585. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43586. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43588. * @param engine The engine which the post process will be applied. (default: current engine)
  43589. * @param reusable If the post process can be reused on the same frame. (default: false)
  43590. */
  43591. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43592. }
  43593. /**
  43594. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43595. */
  43596. export class StereoscopicInterlacePostProcess extends PostProcess {
  43597. private _stepSize;
  43598. private _passedProcess;
  43599. /**
  43600. * Initializes a StereoscopicInterlacePostProcess
  43601. * @param name The name of the effect.
  43602. * @param rigCameras The rig cameras to be appled to the post process
  43603. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43605. * @param engine The engine which the post process will be applied. (default: current engine)
  43606. * @param reusable If the post process can be reused on the same frame. (default: false)
  43607. */
  43608. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43609. }
  43610. }
  43611. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43612. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43613. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43614. import { Scene } from "babylonjs/scene";
  43615. import { Vector3 } from "babylonjs/Maths/math.vector";
  43616. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43617. /**
  43618. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43619. * @see http://doc.babylonjs.com/features/cameras
  43620. */
  43621. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43622. /**
  43623. * Creates a new StereoscopicArcRotateCamera
  43624. * @param name defines camera name
  43625. * @param alpha defines alpha angle (in radians)
  43626. * @param beta defines beta angle (in radians)
  43627. * @param radius defines radius
  43628. * @param target defines camera target
  43629. * @param interaxialDistance defines distance between each color axis
  43630. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43631. * @param scene defines the hosting scene
  43632. */
  43633. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43634. /**
  43635. * Gets camera class name
  43636. * @returns StereoscopicArcRotateCamera
  43637. */
  43638. getClassName(): string;
  43639. }
  43640. }
  43641. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43643. import { Scene } from "babylonjs/scene";
  43644. import { Vector3 } from "babylonjs/Maths/math.vector";
  43645. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43646. /**
  43647. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43648. * @see http://doc.babylonjs.com/features/cameras
  43649. */
  43650. export class StereoscopicFreeCamera extends FreeCamera {
  43651. /**
  43652. * Creates a new StereoscopicFreeCamera
  43653. * @param name defines camera name
  43654. * @param position defines initial position
  43655. * @param interaxialDistance defines distance between each color axis
  43656. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43657. * @param scene defines the hosting scene
  43658. */
  43659. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43660. /**
  43661. * Gets camera class name
  43662. * @returns StereoscopicFreeCamera
  43663. */
  43664. getClassName(): string;
  43665. }
  43666. }
  43667. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43668. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43669. import { Scene } from "babylonjs/scene";
  43670. import { Vector3 } from "babylonjs/Maths/math.vector";
  43671. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43672. /**
  43673. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43674. * @see http://doc.babylonjs.com/features/cameras
  43675. */
  43676. export class StereoscopicGamepadCamera extends GamepadCamera {
  43677. /**
  43678. * Creates a new StereoscopicGamepadCamera
  43679. * @param name defines camera name
  43680. * @param position defines initial position
  43681. * @param interaxialDistance defines distance between each color axis
  43682. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43683. * @param scene defines the hosting scene
  43684. */
  43685. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43686. /**
  43687. * Gets camera class name
  43688. * @returns StereoscopicGamepadCamera
  43689. */
  43690. getClassName(): string;
  43691. }
  43692. }
  43693. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43694. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43695. import { Scene } from "babylonjs/scene";
  43696. import { Vector3 } from "babylonjs/Maths/math.vector";
  43697. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43698. /**
  43699. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43700. * @see http://doc.babylonjs.com/features/cameras
  43701. */
  43702. export class StereoscopicUniversalCamera extends UniversalCamera {
  43703. /**
  43704. * Creates a new StereoscopicUniversalCamera
  43705. * @param name defines camera name
  43706. * @param position defines initial position
  43707. * @param interaxialDistance defines distance between each color axis
  43708. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43709. * @param scene defines the hosting scene
  43710. */
  43711. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43712. /**
  43713. * Gets camera class name
  43714. * @returns StereoscopicUniversalCamera
  43715. */
  43716. getClassName(): string;
  43717. }
  43718. }
  43719. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43720. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43721. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43722. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43723. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43724. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43725. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43726. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43727. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43728. }
  43729. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43731. import { Scene } from "babylonjs/scene";
  43732. import { Vector3 } from "babylonjs/Maths/math.vector";
  43733. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43734. /**
  43735. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43736. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43737. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43738. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43739. */
  43740. export class VirtualJoysticksCamera extends FreeCamera {
  43741. /**
  43742. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43743. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43744. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43745. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43746. * @param name Define the name of the camera in the scene
  43747. * @param position Define the start position of the camera in the scene
  43748. * @param scene Define the scene the camera belongs to
  43749. */
  43750. constructor(name: string, position: Vector3, scene: Scene);
  43751. /**
  43752. * Gets the current object class name.
  43753. * @return the class name
  43754. */
  43755. getClassName(): string;
  43756. }
  43757. }
  43758. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43759. import { Matrix } from "babylonjs/Maths/math.vector";
  43760. /**
  43761. * This represents all the required metrics to create a VR camera.
  43762. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43763. */
  43764. export class VRCameraMetrics {
  43765. /**
  43766. * Define the horizontal resolution off the screen.
  43767. */
  43768. hResolution: number;
  43769. /**
  43770. * Define the vertical resolution off the screen.
  43771. */
  43772. vResolution: number;
  43773. /**
  43774. * Define the horizontal screen size.
  43775. */
  43776. hScreenSize: number;
  43777. /**
  43778. * Define the vertical screen size.
  43779. */
  43780. vScreenSize: number;
  43781. /**
  43782. * Define the vertical screen center position.
  43783. */
  43784. vScreenCenter: number;
  43785. /**
  43786. * Define the distance of the eyes to the screen.
  43787. */
  43788. eyeToScreenDistance: number;
  43789. /**
  43790. * Define the distance between both lenses
  43791. */
  43792. lensSeparationDistance: number;
  43793. /**
  43794. * Define the distance between both viewer's eyes.
  43795. */
  43796. interpupillaryDistance: number;
  43797. /**
  43798. * Define the distortion factor of the VR postprocess.
  43799. * Please, touch with care.
  43800. */
  43801. distortionK: number[];
  43802. /**
  43803. * Define the chromatic aberration correction factors for the VR post process.
  43804. */
  43805. chromaAbCorrection: number[];
  43806. /**
  43807. * Define the scale factor of the post process.
  43808. * The smaller the better but the slower.
  43809. */
  43810. postProcessScaleFactor: number;
  43811. /**
  43812. * Define an offset for the lens center.
  43813. */
  43814. lensCenterOffset: number;
  43815. /**
  43816. * Define if the current vr camera should compensate the distortion of the lense or not.
  43817. */
  43818. compensateDistortion: boolean;
  43819. /**
  43820. * Defines if multiview should be enabled when rendering (Default: false)
  43821. */
  43822. multiviewEnabled: boolean;
  43823. /**
  43824. * Gets the rendering aspect ratio based on the provided resolutions.
  43825. */
  43826. get aspectRatio(): number;
  43827. /**
  43828. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43829. */
  43830. get aspectRatioFov(): number;
  43831. /**
  43832. * @hidden
  43833. */
  43834. get leftHMatrix(): Matrix;
  43835. /**
  43836. * @hidden
  43837. */
  43838. get rightHMatrix(): Matrix;
  43839. /**
  43840. * @hidden
  43841. */
  43842. get leftPreViewMatrix(): Matrix;
  43843. /**
  43844. * @hidden
  43845. */
  43846. get rightPreViewMatrix(): Matrix;
  43847. /**
  43848. * Get the default VRMetrics based on the most generic setup.
  43849. * @returns the default vr metrics
  43850. */
  43851. static GetDefault(): VRCameraMetrics;
  43852. }
  43853. }
  43854. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43855. /** @hidden */
  43856. export var vrDistortionCorrectionPixelShader: {
  43857. name: string;
  43858. shader: string;
  43859. };
  43860. }
  43861. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43862. import { Camera } from "babylonjs/Cameras/camera";
  43863. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43864. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43865. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43866. /**
  43867. * VRDistortionCorrectionPostProcess used for mobile VR
  43868. */
  43869. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43870. private _isRightEye;
  43871. private _distortionFactors;
  43872. private _postProcessScaleFactor;
  43873. private _lensCenterOffset;
  43874. private _scaleIn;
  43875. private _scaleFactor;
  43876. private _lensCenter;
  43877. /**
  43878. * Initializes the VRDistortionCorrectionPostProcess
  43879. * @param name The name of the effect.
  43880. * @param camera The camera to apply the render pass to.
  43881. * @param isRightEye If this is for the right eye distortion
  43882. * @param vrMetrics All the required metrics for the VR camera
  43883. */
  43884. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43885. }
  43886. }
  43887. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43888. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43889. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43890. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43891. import { Scene } from "babylonjs/scene";
  43892. import { Vector3 } from "babylonjs/Maths/math.vector";
  43893. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43894. import "babylonjs/Cameras/RigModes/vrRigMode";
  43895. /**
  43896. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43898. */
  43899. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43900. /**
  43901. * Creates a new VRDeviceOrientationArcRotateCamera
  43902. * @param name defines camera name
  43903. * @param alpha defines the camera rotation along the logitudinal axis
  43904. * @param beta defines the camera rotation along the latitudinal axis
  43905. * @param radius defines the camera distance from its target
  43906. * @param target defines the camera target
  43907. * @param scene defines the scene the camera belongs to
  43908. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43909. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43910. */
  43911. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43912. /**
  43913. * Gets camera class name
  43914. * @returns VRDeviceOrientationArcRotateCamera
  43915. */
  43916. getClassName(): string;
  43917. }
  43918. }
  43919. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43920. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43921. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43922. import { Scene } from "babylonjs/scene";
  43923. import { Vector3 } from "babylonjs/Maths/math.vector";
  43924. import "babylonjs/Cameras/RigModes/vrRigMode";
  43925. /**
  43926. * Camera used to simulate VR rendering (based on FreeCamera)
  43927. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43928. */
  43929. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43930. /**
  43931. * Creates a new VRDeviceOrientationFreeCamera
  43932. * @param name defines camera name
  43933. * @param position defines the start position of the camera
  43934. * @param scene defines the scene the camera belongs to
  43935. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43936. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43937. */
  43938. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43939. /**
  43940. * Gets camera class name
  43941. * @returns VRDeviceOrientationFreeCamera
  43942. */
  43943. getClassName(): string;
  43944. }
  43945. }
  43946. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43947. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43948. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43949. import { Scene } from "babylonjs/scene";
  43950. import { Vector3 } from "babylonjs/Maths/math.vector";
  43951. import "babylonjs/Gamepads/gamepadSceneComponent";
  43952. /**
  43953. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43954. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43955. */
  43956. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43957. /**
  43958. * Creates a new VRDeviceOrientationGamepadCamera
  43959. * @param name defines camera name
  43960. * @param position defines the start position of the camera
  43961. * @param scene defines the scene the camera belongs to
  43962. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43963. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43964. */
  43965. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43966. /**
  43967. * Gets camera class name
  43968. * @returns VRDeviceOrientationGamepadCamera
  43969. */
  43970. getClassName(): string;
  43971. }
  43972. }
  43973. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43974. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43975. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43976. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43977. /** @hidden */
  43978. export var imageProcessingPixelShader: {
  43979. name: string;
  43980. shader: string;
  43981. };
  43982. }
  43983. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43984. import { Nullable } from "babylonjs/types";
  43985. import { Color4 } from "babylonjs/Maths/math.color";
  43986. import { Camera } from "babylonjs/Cameras/camera";
  43987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43988. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43989. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43990. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43991. import { Engine } from "babylonjs/Engines/engine";
  43992. import "babylonjs/Shaders/imageProcessing.fragment";
  43993. import "babylonjs/Shaders/postprocess.vertex";
  43994. /**
  43995. * ImageProcessingPostProcess
  43996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43997. */
  43998. export class ImageProcessingPostProcess extends PostProcess {
  43999. /**
  44000. * Default configuration related to image processing available in the PBR Material.
  44001. */
  44002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44003. /**
  44004. * Gets the image processing configuration used either in this material.
  44005. */
  44006. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44007. /**
  44008. * Sets the Default image processing configuration used either in the this material.
  44009. *
  44010. * If sets to null, the scene one is in use.
  44011. */
  44012. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44013. /**
  44014. * Keep track of the image processing observer to allow dispose and replace.
  44015. */
  44016. private _imageProcessingObserver;
  44017. /**
  44018. * Attaches a new image processing configuration to the PBR Material.
  44019. * @param configuration
  44020. */
  44021. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44022. /**
  44023. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44024. */
  44025. get colorCurves(): Nullable<ColorCurves>;
  44026. /**
  44027. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44028. */
  44029. set colorCurves(value: Nullable<ColorCurves>);
  44030. /**
  44031. * Gets wether the color curves effect is enabled.
  44032. */
  44033. get colorCurvesEnabled(): boolean;
  44034. /**
  44035. * Sets wether the color curves effect is enabled.
  44036. */
  44037. set colorCurvesEnabled(value: boolean);
  44038. /**
  44039. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44040. */
  44041. get colorGradingTexture(): Nullable<BaseTexture>;
  44042. /**
  44043. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44044. */
  44045. set colorGradingTexture(value: Nullable<BaseTexture>);
  44046. /**
  44047. * Gets wether the color grading effect is enabled.
  44048. */
  44049. get colorGradingEnabled(): boolean;
  44050. /**
  44051. * Gets wether the color grading effect is enabled.
  44052. */
  44053. set colorGradingEnabled(value: boolean);
  44054. /**
  44055. * Gets exposure used in the effect.
  44056. */
  44057. get exposure(): number;
  44058. /**
  44059. * Sets exposure used in the effect.
  44060. */
  44061. set exposure(value: number);
  44062. /**
  44063. * Gets wether tonemapping is enabled or not.
  44064. */
  44065. get toneMappingEnabled(): boolean;
  44066. /**
  44067. * Sets wether tonemapping is enabled or not
  44068. */
  44069. set toneMappingEnabled(value: boolean);
  44070. /**
  44071. * Gets the type of tone mapping effect.
  44072. */
  44073. get toneMappingType(): number;
  44074. /**
  44075. * Sets the type of tone mapping effect.
  44076. */
  44077. set toneMappingType(value: number);
  44078. /**
  44079. * Gets contrast used in the effect.
  44080. */
  44081. get contrast(): number;
  44082. /**
  44083. * Sets contrast used in the effect.
  44084. */
  44085. set contrast(value: number);
  44086. /**
  44087. * Gets Vignette stretch size.
  44088. */
  44089. get vignetteStretch(): number;
  44090. /**
  44091. * Sets Vignette stretch size.
  44092. */
  44093. set vignetteStretch(value: number);
  44094. /**
  44095. * Gets Vignette centre X Offset.
  44096. */
  44097. get vignetteCentreX(): number;
  44098. /**
  44099. * Sets Vignette centre X Offset.
  44100. */
  44101. set vignetteCentreX(value: number);
  44102. /**
  44103. * Gets Vignette centre Y Offset.
  44104. */
  44105. get vignetteCentreY(): number;
  44106. /**
  44107. * Sets Vignette centre Y Offset.
  44108. */
  44109. set vignetteCentreY(value: number);
  44110. /**
  44111. * Gets Vignette weight or intensity of the vignette effect.
  44112. */
  44113. get vignetteWeight(): number;
  44114. /**
  44115. * Sets Vignette weight or intensity of the vignette effect.
  44116. */
  44117. set vignetteWeight(value: number);
  44118. /**
  44119. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44120. * if vignetteEnabled is set to true.
  44121. */
  44122. get vignetteColor(): Color4;
  44123. /**
  44124. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44125. * if vignetteEnabled is set to true.
  44126. */
  44127. set vignetteColor(value: Color4);
  44128. /**
  44129. * Gets Camera field of view used by the Vignette effect.
  44130. */
  44131. get vignetteCameraFov(): number;
  44132. /**
  44133. * Sets Camera field of view used by the Vignette effect.
  44134. */
  44135. set vignetteCameraFov(value: number);
  44136. /**
  44137. * Gets the vignette blend mode allowing different kind of effect.
  44138. */
  44139. get vignetteBlendMode(): number;
  44140. /**
  44141. * Sets the vignette blend mode allowing different kind of effect.
  44142. */
  44143. set vignetteBlendMode(value: number);
  44144. /**
  44145. * Gets wether the vignette effect is enabled.
  44146. */
  44147. get vignetteEnabled(): boolean;
  44148. /**
  44149. * Sets wether the vignette effect is enabled.
  44150. */
  44151. set vignetteEnabled(value: boolean);
  44152. private _fromLinearSpace;
  44153. /**
  44154. * Gets wether the input of the processing is in Gamma or Linear Space.
  44155. */
  44156. get fromLinearSpace(): boolean;
  44157. /**
  44158. * Sets wether the input of the processing is in Gamma or Linear Space.
  44159. */
  44160. set fromLinearSpace(value: boolean);
  44161. /**
  44162. * Defines cache preventing GC.
  44163. */
  44164. private _defines;
  44165. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44166. /**
  44167. * "ImageProcessingPostProcess"
  44168. * @returns "ImageProcessingPostProcess"
  44169. */
  44170. getClassName(): string;
  44171. protected _updateParameters(): void;
  44172. dispose(camera?: Camera): void;
  44173. }
  44174. }
  44175. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44176. import { Scene } from "babylonjs/scene";
  44177. import { Color3 } from "babylonjs/Maths/math.color";
  44178. import { Mesh } from "babylonjs/Meshes/mesh";
  44179. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44180. import { Nullable } from "babylonjs/types";
  44181. /**
  44182. * Class containing static functions to help procedurally build meshes
  44183. */
  44184. export class GroundBuilder {
  44185. /**
  44186. * Creates a ground mesh
  44187. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44188. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44190. * @param name defines the name of the mesh
  44191. * @param options defines the options used to create the mesh
  44192. * @param scene defines the hosting scene
  44193. * @returns the ground mesh
  44194. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44195. */
  44196. static CreateGround(name: string, options: {
  44197. width?: number;
  44198. height?: number;
  44199. subdivisions?: number;
  44200. subdivisionsX?: number;
  44201. subdivisionsY?: number;
  44202. updatable?: boolean;
  44203. }, scene: any): Mesh;
  44204. /**
  44205. * Creates a tiled ground mesh
  44206. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44207. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44208. * * 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
  44209. * * 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
  44210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44211. * @param name defines the name of the mesh
  44212. * @param options defines the options used to create the mesh
  44213. * @param scene defines the hosting scene
  44214. * @returns the tiled ground mesh
  44215. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44216. */
  44217. static CreateTiledGround(name: string, options: {
  44218. xmin: number;
  44219. zmin: number;
  44220. xmax: number;
  44221. zmax: number;
  44222. subdivisions?: {
  44223. w: number;
  44224. h: number;
  44225. };
  44226. precision?: {
  44227. w: number;
  44228. h: number;
  44229. };
  44230. updatable?: boolean;
  44231. }, scene?: Nullable<Scene>): Mesh;
  44232. /**
  44233. * Creates a ground mesh from a height map
  44234. * * The parameter `url` sets the URL of the height map image resource.
  44235. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44236. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44237. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44238. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44239. * * 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.
  44240. * * 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).
  44241. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44243. * @param name defines the name of the mesh
  44244. * @param url defines the url to the height map
  44245. * @param options defines the options used to create the mesh
  44246. * @param scene defines the hosting scene
  44247. * @returns the ground mesh
  44248. * @see https://doc.babylonjs.com/babylon101/height_map
  44249. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44250. */
  44251. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44252. width?: number;
  44253. height?: number;
  44254. subdivisions?: number;
  44255. minHeight?: number;
  44256. maxHeight?: number;
  44257. colorFilter?: Color3;
  44258. alphaFilter?: number;
  44259. updatable?: boolean;
  44260. onReady?: (mesh: GroundMesh) => void;
  44261. }, scene?: Nullable<Scene>): GroundMesh;
  44262. }
  44263. }
  44264. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44265. import { Vector4 } from "babylonjs/Maths/math.vector";
  44266. import { Mesh } from "babylonjs/Meshes/mesh";
  44267. /**
  44268. * Class containing static functions to help procedurally build meshes
  44269. */
  44270. export class TorusBuilder {
  44271. /**
  44272. * Creates a torus mesh
  44273. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44274. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44275. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44279. * @param name defines the name of the mesh
  44280. * @param options defines the options used to create the mesh
  44281. * @param scene defines the hosting scene
  44282. * @returns the torus mesh
  44283. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44284. */
  44285. static CreateTorus(name: string, options: {
  44286. diameter?: number;
  44287. thickness?: number;
  44288. tessellation?: number;
  44289. updatable?: boolean;
  44290. sideOrientation?: number;
  44291. frontUVs?: Vector4;
  44292. backUVs?: Vector4;
  44293. }, scene: any): Mesh;
  44294. }
  44295. }
  44296. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44297. import { Vector4 } from "babylonjs/Maths/math.vector";
  44298. import { Color4 } from "babylonjs/Maths/math.color";
  44299. import { Mesh } from "babylonjs/Meshes/mesh";
  44300. /**
  44301. * Class containing static functions to help procedurally build meshes
  44302. */
  44303. export class CylinderBuilder {
  44304. /**
  44305. * Creates a cylinder or a cone mesh
  44306. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44307. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44308. * * 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.
  44309. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44310. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44311. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44312. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44313. * * 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).
  44314. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44315. * * 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).
  44316. * * 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
  44317. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44318. * * 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
  44319. * * 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.
  44320. * * If `enclose` is false, a ring surface is one element.
  44321. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44322. * * 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
  44323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44326. * @param name defines the name of the mesh
  44327. * @param options defines the options used to create the mesh
  44328. * @param scene defines the hosting scene
  44329. * @returns the cylinder mesh
  44330. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44331. */
  44332. static CreateCylinder(name: string, options: {
  44333. height?: number;
  44334. diameterTop?: number;
  44335. diameterBottom?: number;
  44336. diameter?: number;
  44337. tessellation?: number;
  44338. subdivisions?: number;
  44339. arc?: number;
  44340. faceColors?: Color4[];
  44341. faceUV?: Vector4[];
  44342. updatable?: boolean;
  44343. hasRings?: boolean;
  44344. enclose?: boolean;
  44345. cap?: number;
  44346. sideOrientation?: number;
  44347. frontUVs?: Vector4;
  44348. backUVs?: Vector4;
  44349. }, scene: any): Mesh;
  44350. }
  44351. }
  44352. declare module "babylonjs/XR/webXRTypes" {
  44353. import { Nullable } from "babylonjs/types";
  44354. import { IDisposable } from "babylonjs/scene";
  44355. /**
  44356. * States of the webXR experience
  44357. */
  44358. export enum WebXRState {
  44359. /**
  44360. * Transitioning to being in XR mode
  44361. */
  44362. ENTERING_XR = 0,
  44363. /**
  44364. * Transitioning to non XR mode
  44365. */
  44366. EXITING_XR = 1,
  44367. /**
  44368. * In XR mode and presenting
  44369. */
  44370. IN_XR = 2,
  44371. /**
  44372. * Not entered XR mode
  44373. */
  44374. NOT_IN_XR = 3
  44375. }
  44376. /**
  44377. * Abstraction of the XR render target
  44378. */
  44379. export interface WebXRRenderTarget extends IDisposable {
  44380. /**
  44381. * xrpresent context of the canvas which can be used to display/mirror xr content
  44382. */
  44383. canvasContext: WebGLRenderingContext;
  44384. /**
  44385. * xr layer for the canvas
  44386. */
  44387. xrLayer: Nullable<XRWebGLLayer>;
  44388. /**
  44389. * Initializes the xr layer for the session
  44390. * @param xrSession xr session
  44391. * @returns a promise that will resolve once the XR Layer has been created
  44392. */
  44393. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44394. }
  44395. }
  44396. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44397. import { Nullable } from "babylonjs/types";
  44398. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44400. /**
  44401. * COnfiguration object for WebXR output canvas
  44402. */
  44403. export class WebXRManagedOutputCanvasOptions {
  44404. /**
  44405. * An optional canvas in case you wish to create it yourself and provide it here.
  44406. * If not provided, a new canvas will be created
  44407. */
  44408. canvasElement?: HTMLCanvasElement;
  44409. /**
  44410. * Options for this XR Layer output
  44411. */
  44412. canvasOptions?: XRWebGLLayerOptions;
  44413. /**
  44414. * CSS styling for a newly created canvas (if not provided)
  44415. */
  44416. newCanvasCssStyle?: string;
  44417. /**
  44418. * Get the default values of the configuration object
  44419. * @returns default values of this configuration object
  44420. */
  44421. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44422. }
  44423. /**
  44424. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44425. */
  44426. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44427. private _options;
  44428. private _canvas;
  44429. private _engine;
  44430. /**
  44431. * Rendering context of the canvas which can be used to display/mirror xr content
  44432. */
  44433. canvasContext: WebGLRenderingContext;
  44434. /**
  44435. * xr layer for the canvas
  44436. */
  44437. xrLayer: Nullable<XRWebGLLayer>;
  44438. /**
  44439. * Initializes the canvas to be added/removed upon entering/exiting xr
  44440. * @param _xrSessionManager The XR Session manager
  44441. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44442. */
  44443. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44444. /**
  44445. * Disposes of the object
  44446. */
  44447. dispose(): void;
  44448. /**
  44449. * Initializes the xr layer for the session
  44450. * @param xrSession xr session
  44451. * @returns a promise that will resolve once the XR Layer has been created
  44452. */
  44453. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44454. private _addCanvas;
  44455. private _removeCanvas;
  44456. private _setManagedOutputCanvas;
  44457. }
  44458. }
  44459. declare module "babylonjs/XR/webXRSessionManager" {
  44460. import { Observable } from "babylonjs/Misc/observable";
  44461. import { Nullable } from "babylonjs/types";
  44462. import { IDisposable, Scene } from "babylonjs/scene";
  44463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44464. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44465. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44466. /**
  44467. * Manages an XRSession to work with Babylon's engine
  44468. * @see https://doc.babylonjs.com/how_to/webxr
  44469. */
  44470. export class WebXRSessionManager implements IDisposable {
  44471. /** The scene which the session should be created for */
  44472. scene: Scene;
  44473. private _referenceSpace;
  44474. private _rttProvider;
  44475. private _sessionEnded;
  44476. private _xrNavigator;
  44477. private baseLayer;
  44478. /**
  44479. * The base reference space from which the session started. good if you want to reset your
  44480. * reference space
  44481. */
  44482. baseReferenceSpace: XRReferenceSpace;
  44483. /**
  44484. * Current XR frame
  44485. */
  44486. currentFrame: Nullable<XRFrame>;
  44487. /** WebXR timestamp updated every frame */
  44488. currentTimestamp: number;
  44489. /**
  44490. * Used just in case of a failure to initialize an immersive session.
  44491. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44492. */
  44493. defaultHeightCompensation: number;
  44494. /**
  44495. * Fires every time a new xrFrame arrives which can be used to update the camera
  44496. */
  44497. onXRFrameObservable: Observable<XRFrame>;
  44498. /**
  44499. * Fires when the reference space changed
  44500. */
  44501. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44502. /**
  44503. * Fires when the xr session is ended either by the device or manually done
  44504. */
  44505. onXRSessionEnded: Observable<any>;
  44506. /**
  44507. * Fires when the xr session is ended either by the device or manually done
  44508. */
  44509. onXRSessionInit: Observable<XRSession>;
  44510. /**
  44511. * Underlying xr session
  44512. */
  44513. session: XRSession;
  44514. /**
  44515. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44516. * or get the offset the player is currently at.
  44517. */
  44518. viewerReferenceSpace: XRReferenceSpace;
  44519. /**
  44520. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44521. * @param scene The scene which the session should be created for
  44522. */
  44523. constructor(
  44524. /** The scene which the session should be created for */
  44525. scene: Scene);
  44526. /**
  44527. * The current reference space used in this session. This reference space can constantly change!
  44528. * It is mainly used to offset the camera's position.
  44529. */
  44530. get referenceSpace(): XRReferenceSpace;
  44531. /**
  44532. * Set a new reference space and triggers the observable
  44533. */
  44534. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44535. /**
  44536. * Disposes of the session manager
  44537. */
  44538. dispose(): void;
  44539. /**
  44540. * Stops the xrSession and restores the render loop
  44541. * @returns Promise which resolves after it exits XR
  44542. */
  44543. exitXRAsync(): Promise<void>;
  44544. /**
  44545. * Gets the correct render target texture to be rendered this frame for this eye
  44546. * @param eye the eye for which to get the render target
  44547. * @returns the render target for the specified eye
  44548. */
  44549. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44550. /**
  44551. * Creates a WebXRRenderTarget object for the XR session
  44552. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44553. * @param options optional options to provide when creating a new render target
  44554. * @returns a WebXR render target to which the session can render
  44555. */
  44556. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44557. /**
  44558. * Initializes the manager
  44559. * After initialization enterXR can be called to start an XR session
  44560. * @returns Promise which resolves after it is initialized
  44561. */
  44562. initializeAsync(): Promise<void>;
  44563. /**
  44564. * Initializes an xr session
  44565. * @param xrSessionMode mode to initialize
  44566. * @param xrSessionInit defines optional and required values to pass to the session builder
  44567. * @returns a promise which will resolve once the session has been initialized
  44568. */
  44569. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44570. /**
  44571. * Checks if a session would be supported for the creation options specified
  44572. * @param sessionMode session mode to check if supported eg. immersive-vr
  44573. * @returns A Promise that resolves to true if supported and false if not
  44574. */
  44575. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44576. /**
  44577. * Resets the reference space to the one started the session
  44578. */
  44579. resetReferenceSpace(): void;
  44580. /**
  44581. * Starts rendering to the xr layer
  44582. */
  44583. runXRRenderLoop(): void;
  44584. /**
  44585. * Sets the reference space on the xr session
  44586. * @param referenceSpaceType space to set
  44587. * @returns a promise that will resolve once the reference space has been set
  44588. */
  44589. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44590. /**
  44591. * Updates the render state of the session
  44592. * @param state state to set
  44593. * @returns a promise that resolves once the render state has been updated
  44594. */
  44595. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44596. /**
  44597. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44598. * @param sessionMode defines the session to test
  44599. * @returns a promise with boolean as final value
  44600. */
  44601. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44602. private _createRenderTargetTexture;
  44603. }
  44604. }
  44605. declare module "babylonjs/XR/webXRCamera" {
  44606. import { Scene } from "babylonjs/scene";
  44607. import { Camera } from "babylonjs/Cameras/camera";
  44608. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44609. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44610. /**
  44611. * WebXR Camera which holds the views for the xrSession
  44612. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44613. */
  44614. export class WebXRCamera extends FreeCamera {
  44615. private _xrSessionManager;
  44616. private _firstFrame;
  44617. private _referenceQuaternion;
  44618. private _referencedPosition;
  44619. private _xrInvPositionCache;
  44620. private _xrInvQuaternionCache;
  44621. /**
  44622. * Should position compensation execute on first frame.
  44623. * This is used when copying the position from a native (non XR) camera
  44624. */
  44625. compensateOnFirstFrame: boolean;
  44626. /**
  44627. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44628. * @param name the name of the camera
  44629. * @param scene the scene to add the camera to
  44630. * @param _xrSessionManager a constructed xr session manager
  44631. */
  44632. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44633. /**
  44634. * Return the user's height, unrelated to the current ground.
  44635. * This will be the y position of this camera, when ground level is 0.
  44636. */
  44637. get realWorldHeight(): number;
  44638. /** @hidden */
  44639. _updateForDualEyeDebugging(): void;
  44640. /**
  44641. * Sets this camera's transformation based on a non-vr camera
  44642. * @param otherCamera the non-vr camera to copy the transformation from
  44643. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44644. */
  44645. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44646. /**
  44647. * Gets the current instance class name ("WebXRCamera").
  44648. * @returns the class name
  44649. */
  44650. getClassName(): string;
  44651. private _updateFromXRSession;
  44652. private _updateNumberOfRigCameras;
  44653. private _updateReferenceSpace;
  44654. private _updateReferenceSpaceOffset;
  44655. }
  44656. }
  44657. declare module "babylonjs/XR/webXRFeaturesManager" {
  44658. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44659. import { IDisposable } from "babylonjs/scene";
  44660. /**
  44661. * Defining the interface required for a (webxr) feature
  44662. */
  44663. export interface IWebXRFeature extends IDisposable {
  44664. /**
  44665. * Is this feature attached
  44666. */
  44667. attached: boolean;
  44668. /**
  44669. * Should auto-attach be disabled?
  44670. */
  44671. disableAutoAttach: boolean;
  44672. /**
  44673. * Attach the feature to the session
  44674. * Will usually be called by the features manager
  44675. *
  44676. * @param force should attachment be forced (even when already attached)
  44677. * @returns true if successful.
  44678. */
  44679. attach(force?: boolean): boolean;
  44680. /**
  44681. * Detach the feature from the session
  44682. * Will usually be called by the features manager
  44683. *
  44684. * @returns true if successful.
  44685. */
  44686. detach(): boolean;
  44687. }
  44688. /**
  44689. * A list of the currently available features without referencing them
  44690. */
  44691. export class WebXRFeatureName {
  44692. /**
  44693. * The name of the anchor system feature
  44694. */
  44695. static ANCHOR_SYSTEM: string;
  44696. /**
  44697. * The name of the background remover feature
  44698. */
  44699. static BACKGROUND_REMOVER: string;
  44700. /**
  44701. * The name of the hit test feature
  44702. */
  44703. static HIT_TEST: string;
  44704. /**
  44705. * physics impostors for xr controllers feature
  44706. */
  44707. static PHYSICS_CONTROLLERS: string;
  44708. /**
  44709. * The name of the plane detection feature
  44710. */
  44711. static PLANE_DETECTION: string;
  44712. /**
  44713. * The name of the pointer selection feature
  44714. */
  44715. static POINTER_SELECTION: string;
  44716. /**
  44717. * The name of the teleportation feature
  44718. */
  44719. static TELEPORTATION: string;
  44720. }
  44721. /**
  44722. * Defining the constructor of a feature. Used to register the modules.
  44723. */
  44724. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44725. /**
  44726. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44727. * It is mainly used in AR sessions.
  44728. *
  44729. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44730. */
  44731. export class WebXRFeaturesManager implements IDisposable {
  44732. private _xrSessionManager;
  44733. private static readonly _AvailableFeatures;
  44734. private _features;
  44735. /**
  44736. * constructs a new features manages.
  44737. *
  44738. * @param _xrSessionManager an instance of WebXRSessionManager
  44739. */
  44740. constructor(_xrSessionManager: WebXRSessionManager);
  44741. /**
  44742. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44743. * Mainly used internally.
  44744. *
  44745. * @param featureName the name of the feature to register
  44746. * @param constructorFunction the function used to construct the module
  44747. * @param version the (babylon) version of the module
  44748. * @param stable is that a stable version of this module
  44749. */
  44750. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44751. /**
  44752. * Returns a constructor of a specific feature.
  44753. *
  44754. * @param featureName the name of the feature to construct
  44755. * @param version the version of the feature to load
  44756. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44757. * @param options optional options provided to the module.
  44758. * @returns a function that, when called, will return a new instance of this feature
  44759. */
  44760. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44761. /**
  44762. * Can be used to return the list of features currently registered
  44763. *
  44764. * @returns an Array of available features
  44765. */
  44766. static GetAvailableFeatures(): string[];
  44767. /**
  44768. * Gets the versions available for a specific feature
  44769. * @param featureName the name of the feature
  44770. * @returns an array with the available versions
  44771. */
  44772. static GetAvailableVersions(featureName: string): string[];
  44773. /**
  44774. * Return the latest unstable version of this feature
  44775. * @param featureName the name of the feature to search
  44776. * @returns the version number. if not found will return -1
  44777. */
  44778. static GetLatestVersionOfFeature(featureName: string): number;
  44779. /**
  44780. * Return the latest stable version of this feature
  44781. * @param featureName the name of the feature to search
  44782. * @returns the version number. if not found will return -1
  44783. */
  44784. static GetStableVersionOfFeature(featureName: string): number;
  44785. /**
  44786. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44787. * Can be used during a session to start a feature
  44788. * @param featureName the name of feature to attach
  44789. */
  44790. attachFeature(featureName: string): void;
  44791. /**
  44792. * Can be used inside a session or when the session ends to detach a specific feature
  44793. * @param featureName the name of the feature to detach
  44794. */
  44795. detachFeature(featureName: string): void;
  44796. /**
  44797. * Used to disable an already-enabled feature
  44798. * The feature will be disposed and will be recreated once enabled.
  44799. * @param featureName the feature to disable
  44800. * @returns true if disable was successful
  44801. */
  44802. disableFeature(featureName: string | {
  44803. Name: string;
  44804. }): boolean;
  44805. /**
  44806. * dispose this features manager
  44807. */
  44808. dispose(): void;
  44809. /**
  44810. * 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.
  44811. * 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.
  44812. *
  44813. * @param featureName the name of the feature to load or the class of the feature
  44814. * @param version optional version to load. if not provided the latest version will be enabled
  44815. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44816. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44817. * @returns a new constructed feature or throws an error if feature not found.
  44818. */
  44819. enableFeature(featureName: string | {
  44820. Name: string;
  44821. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44822. /**
  44823. * get the implementation of an enabled feature.
  44824. * @param featureName the name of the feature to load
  44825. * @returns the feature class, if found
  44826. */
  44827. getEnabledFeature(featureName: string): IWebXRFeature;
  44828. /**
  44829. * Get the list of enabled features
  44830. * @returns an array of enabled features
  44831. */
  44832. getEnabledFeatures(): string[];
  44833. }
  44834. }
  44835. declare module "babylonjs/XR/webXRExperienceHelper" {
  44836. import { Observable } from "babylonjs/Misc/observable";
  44837. import { IDisposable, Scene } from "babylonjs/scene";
  44838. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44839. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44840. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44841. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44842. /**
  44843. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44844. * @see https://doc.babylonjs.com/how_to/webxr
  44845. */
  44846. export class WebXRExperienceHelper implements IDisposable {
  44847. private scene;
  44848. private _nonVRCamera;
  44849. private _originalSceneAutoClear;
  44850. private _supported;
  44851. /**
  44852. * Camera used to render xr content
  44853. */
  44854. camera: WebXRCamera;
  44855. /** A features manager for this xr session */
  44856. featuresManager: WebXRFeaturesManager;
  44857. /**
  44858. * Observers registered here will be triggered after the camera's initial transformation is set
  44859. * This can be used to set a different ground level or an extra rotation.
  44860. *
  44861. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44862. * to the position set after this observable is done executing.
  44863. */
  44864. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44865. /**
  44866. * Fires when the state of the experience helper has changed
  44867. */
  44868. onStateChangedObservable: Observable<WebXRState>;
  44869. /** Session manager used to keep track of xr session */
  44870. sessionManager: WebXRSessionManager;
  44871. /**
  44872. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44873. */
  44874. state: WebXRState;
  44875. /**
  44876. * Creates a WebXRExperienceHelper
  44877. * @param scene The scene the helper should be created in
  44878. */
  44879. private constructor();
  44880. /**
  44881. * Creates the experience helper
  44882. * @param scene the scene to attach the experience helper to
  44883. * @returns a promise for the experience helper
  44884. */
  44885. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44886. /**
  44887. * Disposes of the experience helper
  44888. */
  44889. dispose(): void;
  44890. /**
  44891. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44892. * @param sessionMode options for the XR session
  44893. * @param referenceSpaceType frame of reference of the XR session
  44894. * @param renderTarget the output canvas that will be used to enter XR mode
  44895. * @returns promise that resolves after xr mode has entered
  44896. */
  44897. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44898. /**
  44899. * Exits XR mode and returns the scene to its original state
  44900. * @returns promise that resolves after xr mode has exited
  44901. */
  44902. exitXRAsync(): Promise<void>;
  44903. private _nonXRToXRCamera;
  44904. private _setState;
  44905. }
  44906. }
  44907. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44908. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44909. import { Observable } from "babylonjs/Misc/observable";
  44910. import { IDisposable } from "babylonjs/scene";
  44911. /**
  44912. * X-Y values for axes in WebXR
  44913. */
  44914. export interface IWebXRMotionControllerAxesValue {
  44915. /**
  44916. * The value of the x axis
  44917. */
  44918. x: number;
  44919. /**
  44920. * The value of the y-axis
  44921. */
  44922. y: number;
  44923. }
  44924. /**
  44925. * changed / previous values for the values of this component
  44926. */
  44927. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44928. /**
  44929. * current (this frame) value
  44930. */
  44931. current: T;
  44932. /**
  44933. * previous (last change) value
  44934. */
  44935. previous: T;
  44936. }
  44937. /**
  44938. * Represents changes in the component between current frame and last values recorded
  44939. */
  44940. export interface IWebXRMotionControllerComponentChanges {
  44941. /**
  44942. * will be populated with previous and current values if axes changed
  44943. */
  44944. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44945. /**
  44946. * will be populated with previous and current values if pressed changed
  44947. */
  44948. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44949. /**
  44950. * will be populated with previous and current values if touched changed
  44951. */
  44952. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44953. /**
  44954. * will be populated with previous and current values if value changed
  44955. */
  44956. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44957. }
  44958. /**
  44959. * This class represents a single component (for example button or thumbstick) of a motion controller
  44960. */
  44961. export class WebXRControllerComponent implements IDisposable {
  44962. /**
  44963. * the id of this component
  44964. */
  44965. id: string;
  44966. /**
  44967. * the type of the component
  44968. */
  44969. type: MotionControllerComponentType;
  44970. private _buttonIndex;
  44971. private _axesIndices;
  44972. private _axes;
  44973. private _changes;
  44974. private _currentValue;
  44975. private _hasChanges;
  44976. private _pressed;
  44977. private _touched;
  44978. /**
  44979. * button component type
  44980. */
  44981. static BUTTON_TYPE: MotionControllerComponentType;
  44982. /**
  44983. * squeeze component type
  44984. */
  44985. static SQUEEZE_TYPE: MotionControllerComponentType;
  44986. /**
  44987. * Thumbstick component type
  44988. */
  44989. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44990. /**
  44991. * Touchpad component type
  44992. */
  44993. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44994. /**
  44995. * trigger component type
  44996. */
  44997. static TRIGGER_TYPE: MotionControllerComponentType;
  44998. /**
  44999. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45000. * the axes data changes
  45001. */
  45002. onAxisValueChangedObservable: Observable<{
  45003. x: number;
  45004. y: number;
  45005. }>;
  45006. /**
  45007. * Observers registered here will be triggered when the state of a button changes
  45008. * State change is either pressed / touched / value
  45009. */
  45010. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45011. /**
  45012. * Creates a new component for a motion controller.
  45013. * It is created by the motion controller itself
  45014. *
  45015. * @param id the id of this component
  45016. * @param type the type of the component
  45017. * @param _buttonIndex index in the buttons array of the gamepad
  45018. * @param _axesIndices indices of the values in the axes array of the gamepad
  45019. */
  45020. constructor(
  45021. /**
  45022. * the id of this component
  45023. */
  45024. id: string,
  45025. /**
  45026. * the type of the component
  45027. */
  45028. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45029. /**
  45030. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45031. */
  45032. get axes(): IWebXRMotionControllerAxesValue;
  45033. /**
  45034. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45035. */
  45036. get changes(): IWebXRMotionControllerComponentChanges;
  45037. /**
  45038. * Return whether or not the component changed the last frame
  45039. */
  45040. get hasChanges(): boolean;
  45041. /**
  45042. * is the button currently pressed
  45043. */
  45044. get pressed(): boolean;
  45045. /**
  45046. * is the button currently touched
  45047. */
  45048. get touched(): boolean;
  45049. /**
  45050. * Get the current value of this component
  45051. */
  45052. get value(): number;
  45053. /**
  45054. * Dispose this component
  45055. */
  45056. dispose(): void;
  45057. /**
  45058. * Are there axes correlating to this component
  45059. * @return true is axes data is available
  45060. */
  45061. isAxes(): boolean;
  45062. /**
  45063. * Is this component a button (hence - pressable)
  45064. * @returns true if can be pressed
  45065. */
  45066. isButton(): boolean;
  45067. /**
  45068. * update this component using the gamepad object it is in. Called on every frame
  45069. * @param nativeController the native gamepad controller object
  45070. */
  45071. update(nativeController: IMinimalMotionControllerObject): void;
  45072. }
  45073. }
  45074. declare module "babylonjs/Loading/sceneLoader" {
  45075. import { Observable } from "babylonjs/Misc/observable";
  45076. import { Nullable } from "babylonjs/types";
  45077. import { Scene } from "babylonjs/scene";
  45078. import { Engine } from "babylonjs/Engines/engine";
  45079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45080. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45081. import { AssetContainer } from "babylonjs/assetContainer";
  45082. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45083. import { Skeleton } from "babylonjs/Bones/skeleton";
  45084. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45085. import { WebRequest } from "babylonjs/Misc/webRequest";
  45086. /**
  45087. * Class used to represent data loading progression
  45088. */
  45089. export class SceneLoaderProgressEvent {
  45090. /** defines if data length to load can be evaluated */
  45091. readonly lengthComputable: boolean;
  45092. /** defines the loaded data length */
  45093. readonly loaded: number;
  45094. /** defines the data length to load */
  45095. readonly total: number;
  45096. /**
  45097. * Create a new progress event
  45098. * @param lengthComputable defines if data length to load can be evaluated
  45099. * @param loaded defines the loaded data length
  45100. * @param total defines the data length to load
  45101. */
  45102. constructor(
  45103. /** defines if data length to load can be evaluated */
  45104. lengthComputable: boolean,
  45105. /** defines the loaded data length */
  45106. loaded: number,
  45107. /** defines the data length to load */
  45108. total: number);
  45109. /**
  45110. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45111. * @param event defines the source event
  45112. * @returns a new SceneLoaderProgressEvent
  45113. */
  45114. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45115. }
  45116. /**
  45117. * Interface used by SceneLoader plugins to define supported file extensions
  45118. */
  45119. export interface ISceneLoaderPluginExtensions {
  45120. /**
  45121. * Defines the list of supported extensions
  45122. */
  45123. [extension: string]: {
  45124. isBinary: boolean;
  45125. };
  45126. }
  45127. /**
  45128. * Interface used by SceneLoader plugin factory
  45129. */
  45130. export interface ISceneLoaderPluginFactory {
  45131. /**
  45132. * Defines the name of the factory
  45133. */
  45134. name: string;
  45135. /**
  45136. * Function called to create a new plugin
  45137. * @return the new plugin
  45138. */
  45139. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45140. /**
  45141. * The callback that returns true if the data can be directly loaded.
  45142. * @param data string containing the file data
  45143. * @returns if the data can be loaded directly
  45144. */
  45145. canDirectLoad?(data: string): boolean;
  45146. }
  45147. /**
  45148. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45149. */
  45150. export interface ISceneLoaderPluginBase {
  45151. /**
  45152. * The friendly name of this plugin.
  45153. */
  45154. name: string;
  45155. /**
  45156. * The file extensions supported by this plugin.
  45157. */
  45158. extensions: string | ISceneLoaderPluginExtensions;
  45159. /**
  45160. * The callback called when loading from a url.
  45161. * @param scene scene loading this url
  45162. * @param url url to load
  45163. * @param onSuccess callback called when the file successfully loads
  45164. * @param onProgress callback called while file is loading (if the server supports this mode)
  45165. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45166. * @param onError callback called when the file fails to load
  45167. * @returns a file request object
  45168. */
  45169. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45170. /**
  45171. * The callback called when loading from a file object.
  45172. * @param scene scene loading this file
  45173. * @param file defines the file to load
  45174. * @param onSuccess defines the callback to call when data is loaded
  45175. * @param onProgress defines the callback to call during loading process
  45176. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45177. * @param onError defines the callback to call when an error occurs
  45178. * @returns a file request object
  45179. */
  45180. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45181. /**
  45182. * The callback that returns true if the data can be directly loaded.
  45183. * @param data string containing the file data
  45184. * @returns if the data can be loaded directly
  45185. */
  45186. canDirectLoad?(data: string): boolean;
  45187. /**
  45188. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45189. * @param scene scene loading this data
  45190. * @param data string containing the data
  45191. * @returns data to pass to the plugin
  45192. */
  45193. directLoad?(scene: Scene, data: string): any;
  45194. /**
  45195. * The callback that allows custom handling of the root url based on the response url.
  45196. * @param rootUrl the original root url
  45197. * @param responseURL the response url if available
  45198. * @returns the new root url
  45199. */
  45200. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45201. }
  45202. /**
  45203. * Interface used to define a SceneLoader plugin
  45204. */
  45205. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45206. /**
  45207. * Import meshes into a scene.
  45208. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45209. * @param scene The scene to import into
  45210. * @param data The data to import
  45211. * @param rootUrl The root url for scene and resources
  45212. * @param meshes The meshes array to import into
  45213. * @param particleSystems The particle systems array to import into
  45214. * @param skeletons The skeletons array to import into
  45215. * @param onError The callback when import fails
  45216. * @returns True if successful or false otherwise
  45217. */
  45218. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45219. /**
  45220. * Load into a scene.
  45221. * @param scene The scene to load into
  45222. * @param data The data to import
  45223. * @param rootUrl The root url for scene and resources
  45224. * @param onError The callback when import fails
  45225. * @returns True if successful or false otherwise
  45226. */
  45227. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45228. /**
  45229. * Load into an asset container.
  45230. * @param scene The scene to load into
  45231. * @param data The data to import
  45232. * @param rootUrl The root url for scene and resources
  45233. * @param onError The callback when import fails
  45234. * @returns The loaded asset container
  45235. */
  45236. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45237. }
  45238. /**
  45239. * Interface used to define an async SceneLoader plugin
  45240. */
  45241. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45242. /**
  45243. * Import meshes into a scene.
  45244. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45245. * @param scene The scene to import into
  45246. * @param data The data to import
  45247. * @param rootUrl The root url for scene and resources
  45248. * @param onProgress The callback when the load progresses
  45249. * @param fileName Defines the name of the file to load
  45250. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45251. */
  45252. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45253. meshes: AbstractMesh[];
  45254. particleSystems: IParticleSystem[];
  45255. skeletons: Skeleton[];
  45256. animationGroups: AnimationGroup[];
  45257. }>;
  45258. /**
  45259. * Load into a scene.
  45260. * @param scene The scene to load into
  45261. * @param data The data to import
  45262. * @param rootUrl The root url for scene and resources
  45263. * @param onProgress The callback when the load progresses
  45264. * @param fileName Defines the name of the file to load
  45265. * @returns Nothing
  45266. */
  45267. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45268. /**
  45269. * Load into an asset container.
  45270. * @param scene The scene to load into
  45271. * @param data The data to import
  45272. * @param rootUrl The root url for scene and resources
  45273. * @param onProgress The callback when the load progresses
  45274. * @param fileName Defines the name of the file to load
  45275. * @returns The loaded asset container
  45276. */
  45277. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45278. }
  45279. /**
  45280. * Mode that determines how to handle old animation groups before loading new ones.
  45281. */
  45282. export enum SceneLoaderAnimationGroupLoadingMode {
  45283. /**
  45284. * Reset all old animations to initial state then dispose them.
  45285. */
  45286. Clean = 0,
  45287. /**
  45288. * Stop all old animations.
  45289. */
  45290. Stop = 1,
  45291. /**
  45292. * Restart old animations from first frame.
  45293. */
  45294. Sync = 2,
  45295. /**
  45296. * Old animations remains untouched.
  45297. */
  45298. NoSync = 3
  45299. }
  45300. /**
  45301. * Class used to load scene from various file formats using registered plugins
  45302. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45303. */
  45304. export class SceneLoader {
  45305. /**
  45306. * No logging while loading
  45307. */
  45308. static readonly NO_LOGGING: number;
  45309. /**
  45310. * Minimal logging while loading
  45311. */
  45312. static readonly MINIMAL_LOGGING: number;
  45313. /**
  45314. * Summary logging while loading
  45315. */
  45316. static readonly SUMMARY_LOGGING: number;
  45317. /**
  45318. * Detailled logging while loading
  45319. */
  45320. static readonly DETAILED_LOGGING: number;
  45321. /**
  45322. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45323. */
  45324. static get ForceFullSceneLoadingForIncremental(): boolean;
  45325. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45326. /**
  45327. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45328. */
  45329. static get ShowLoadingScreen(): boolean;
  45330. static set ShowLoadingScreen(value: boolean);
  45331. /**
  45332. * Defines the current logging level (while loading the scene)
  45333. * @ignorenaming
  45334. */
  45335. static get loggingLevel(): number;
  45336. static set loggingLevel(value: number);
  45337. /**
  45338. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45339. */
  45340. static get CleanBoneMatrixWeights(): boolean;
  45341. static set CleanBoneMatrixWeights(value: boolean);
  45342. /**
  45343. * Event raised when a plugin is used to load a scene
  45344. */
  45345. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45346. private static _registeredPlugins;
  45347. private static _getDefaultPlugin;
  45348. private static _getPluginForExtension;
  45349. private static _getPluginForDirectLoad;
  45350. private static _getPluginForFilename;
  45351. private static _getDirectLoad;
  45352. private static _loadData;
  45353. private static _getFileInfo;
  45354. /**
  45355. * Gets a plugin that can load the given extension
  45356. * @param extension defines the extension to load
  45357. * @returns a plugin or null if none works
  45358. */
  45359. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45360. /**
  45361. * Gets a boolean indicating that the given extension can be loaded
  45362. * @param extension defines the extension to load
  45363. * @returns true if the extension is supported
  45364. */
  45365. static IsPluginForExtensionAvailable(extension: string): boolean;
  45366. /**
  45367. * Adds a new plugin to the list of registered plugins
  45368. * @param plugin defines the plugin to add
  45369. */
  45370. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45371. /**
  45372. * Import meshes into a scene
  45373. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45374. * @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)
  45375. * @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)
  45376. * @param scene the instance of BABYLON.Scene to append to
  45377. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45378. * @param onProgress a callback with a progress event for each file being loaded
  45379. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45380. * @param pluginExtension the extension used to determine the plugin
  45381. * @returns The loaded plugin
  45382. */
  45383. 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>;
  45384. /**
  45385. * Import meshes into a scene
  45386. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45387. * @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)
  45388. * @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)
  45389. * @param scene the instance of BABYLON.Scene to append to
  45390. * @param onProgress a callback with a progress event for each file being loaded
  45391. * @param pluginExtension the extension used to determine the plugin
  45392. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45393. */
  45394. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45395. meshes: AbstractMesh[];
  45396. particleSystems: IParticleSystem[];
  45397. skeletons: Skeleton[];
  45398. animationGroups: AnimationGroup[];
  45399. }>;
  45400. /**
  45401. * Load a scene
  45402. * @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)
  45403. * @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)
  45404. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45405. * @param onSuccess a callback with the scene when import succeeds
  45406. * @param onProgress a callback with a progress event for each file being loaded
  45407. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45408. * @param pluginExtension the extension used to determine the plugin
  45409. * @returns The loaded plugin
  45410. */
  45411. 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>;
  45412. /**
  45413. * Load a scene
  45414. * @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)
  45415. * @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)
  45416. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45417. * @param onProgress a callback with a progress event for each file being loaded
  45418. * @param pluginExtension the extension used to determine the plugin
  45419. * @returns The loaded scene
  45420. */
  45421. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45422. /**
  45423. * Append a scene
  45424. * @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)
  45425. * @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)
  45426. * @param scene is the instance of BABYLON.Scene to append to
  45427. * @param onSuccess a callback with the scene when import succeeds
  45428. * @param onProgress a callback with a progress event for each file being loaded
  45429. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45430. * @param pluginExtension the extension used to determine the plugin
  45431. * @returns The loaded plugin
  45432. */
  45433. 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>;
  45434. /**
  45435. * Append a scene
  45436. * @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)
  45437. * @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)
  45438. * @param scene is the instance of BABYLON.Scene to append to
  45439. * @param onProgress a callback with a progress event for each file being loaded
  45440. * @param pluginExtension the extension used to determine the plugin
  45441. * @returns The given scene
  45442. */
  45443. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45444. /**
  45445. * Load a scene into an asset container
  45446. * @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)
  45447. * @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)
  45448. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45449. * @param onSuccess a callback with the scene when import succeeds
  45450. * @param onProgress a callback with a progress event for each file being loaded
  45451. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45452. * @param pluginExtension the extension used to determine the plugin
  45453. * @returns The loaded plugin
  45454. */
  45455. 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>;
  45456. /**
  45457. * Load a scene into an asset container
  45458. * @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)
  45459. * @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)
  45460. * @param scene is the instance of Scene to append to
  45461. * @param onProgress a callback with a progress event for each file being loaded
  45462. * @param pluginExtension the extension used to determine the plugin
  45463. * @returns The loaded asset container
  45464. */
  45465. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45466. /**
  45467. * Import animations from a file into a scene
  45468. * @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)
  45469. * @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)
  45470. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45471. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45472. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45473. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45474. * @param onSuccess a callback with the scene when import succeeds
  45475. * @param onProgress a callback with a progress event for each file being loaded
  45476. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45477. */
  45478. 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;
  45479. /**
  45480. * Import animations from a file into a scene
  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 or a File object (default: empty string)
  45483. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45484. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45485. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45486. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45487. * @param onSuccess a callback with the scene when import succeeds
  45488. * @param onProgress a callback with a progress event for each file being loaded
  45489. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45490. * @returns the updated scene with imported animations
  45491. */
  45492. 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>;
  45493. }
  45494. }
  45495. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45496. import { IDisposable, Scene } from "babylonjs/scene";
  45497. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45498. import { Observable } from "babylonjs/Misc/observable";
  45499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45500. import { Nullable } from "babylonjs/types";
  45501. /**
  45502. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45503. */
  45504. export type MotionControllerHandness = "none" | "left" | "right";
  45505. /**
  45506. * The type of components available in motion controllers.
  45507. * This is not the name of the component.
  45508. */
  45509. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45510. /**
  45511. * The state of a controller component
  45512. */
  45513. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45514. /**
  45515. * The schema of motion controller layout.
  45516. * No object will be initialized using this interface
  45517. * This is used just to define the profile.
  45518. */
  45519. export interface IMotionControllerLayout {
  45520. /**
  45521. * Path to load the assets. Usually relative to the base path
  45522. */
  45523. assetPath: string;
  45524. /**
  45525. * Available components (unsorted)
  45526. */
  45527. components: {
  45528. /**
  45529. * A map of component Ids
  45530. */
  45531. [componentId: string]: {
  45532. /**
  45533. * The type of input the component outputs
  45534. */
  45535. type: MotionControllerComponentType;
  45536. /**
  45537. * The indices of this component in the gamepad object
  45538. */
  45539. gamepadIndices: {
  45540. /**
  45541. * Index of button
  45542. */
  45543. button?: number;
  45544. /**
  45545. * If available, index of x-axis
  45546. */
  45547. xAxis?: number;
  45548. /**
  45549. * If available, index of y-axis
  45550. */
  45551. yAxis?: number;
  45552. };
  45553. /**
  45554. * The mesh's root node name
  45555. */
  45556. rootNodeName: string;
  45557. /**
  45558. * Animation definitions for this model
  45559. */
  45560. visualResponses: {
  45561. [stateKey: string]: {
  45562. /**
  45563. * What property will be animated
  45564. */
  45565. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45566. /**
  45567. * What states influence this visual response
  45568. */
  45569. states: MotionControllerComponentStateType[];
  45570. /**
  45571. * Type of animation - movement or visibility
  45572. */
  45573. valueNodeProperty: "transform" | "visibility";
  45574. /**
  45575. * Base node name to move. Its position will be calculated according to the min and max nodes
  45576. */
  45577. valueNodeName?: string;
  45578. /**
  45579. * Minimum movement node
  45580. */
  45581. minNodeName?: string;
  45582. /**
  45583. * Max movement node
  45584. */
  45585. maxNodeName?: string;
  45586. };
  45587. };
  45588. /**
  45589. * If touch enabled, what is the name of node to display user feedback
  45590. */
  45591. touchPointNodeName?: string;
  45592. };
  45593. };
  45594. /**
  45595. * Is it xr standard mapping or not
  45596. */
  45597. gamepadMapping: "" | "xr-standard";
  45598. /**
  45599. * Base root node of this entire model
  45600. */
  45601. rootNodeName: string;
  45602. /**
  45603. * Defines the main button component id
  45604. */
  45605. selectComponentId: string;
  45606. }
  45607. /**
  45608. * A definition for the layout map in the input profile
  45609. */
  45610. export interface IMotionControllerLayoutMap {
  45611. /**
  45612. * Layouts with handness type as a key
  45613. */
  45614. [handness: string]: IMotionControllerLayout;
  45615. }
  45616. /**
  45617. * The XR Input profile schema
  45618. * Profiles can be found here:
  45619. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45620. */
  45621. export interface IMotionControllerProfile {
  45622. /**
  45623. * fallback profiles for this profileId
  45624. */
  45625. fallbackProfileIds: string[];
  45626. /**
  45627. * The layout map, with handness as key
  45628. */
  45629. layouts: IMotionControllerLayoutMap;
  45630. /**
  45631. * The id of this profile
  45632. * correlates to the profile(s) in the xrInput.profiles array
  45633. */
  45634. profileId: string;
  45635. }
  45636. /**
  45637. * A helper-interface for the 3 meshes needed for controller button animation
  45638. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45639. */
  45640. export interface IMotionControllerButtonMeshMap {
  45641. /**
  45642. * the mesh that defines the pressed value mesh position.
  45643. * This is used to find the max-position of this button
  45644. */
  45645. pressedMesh: AbstractMesh;
  45646. /**
  45647. * the mesh that defines the unpressed value mesh position.
  45648. * This is used to find the min (or initial) position of this button
  45649. */
  45650. unpressedMesh: AbstractMesh;
  45651. /**
  45652. * The mesh that will be changed when value changes
  45653. */
  45654. valueMesh: AbstractMesh;
  45655. }
  45656. /**
  45657. * A helper-interface for the 3 meshes needed for controller axis animation.
  45658. * This will be expanded when touchpad animations are fully supported
  45659. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45660. */
  45661. export interface IMotionControllerMeshMap {
  45662. /**
  45663. * the mesh that defines the maximum value mesh position.
  45664. */
  45665. maxMesh?: AbstractMesh;
  45666. /**
  45667. * the mesh that defines the minimum value mesh position.
  45668. */
  45669. minMesh?: AbstractMesh;
  45670. /**
  45671. * The mesh that will be changed when axis value changes
  45672. */
  45673. valueMesh: AbstractMesh;
  45674. }
  45675. /**
  45676. * The elements needed for change-detection of the gamepad objects in motion controllers
  45677. */
  45678. export interface IMinimalMotionControllerObject {
  45679. /**
  45680. * Available axes of this controller
  45681. */
  45682. axes: number[];
  45683. /**
  45684. * An array of available buttons
  45685. */
  45686. buttons: Array<{
  45687. /**
  45688. * Value of the button/trigger
  45689. */
  45690. value: number;
  45691. /**
  45692. * If the button/trigger is currently touched
  45693. */
  45694. touched: boolean;
  45695. /**
  45696. * If the button/trigger is currently pressed
  45697. */
  45698. pressed: boolean;
  45699. }>;
  45700. }
  45701. /**
  45702. * An Abstract Motion controller
  45703. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45704. * Each component has an observable to check for changes in value and state
  45705. */
  45706. export abstract class WebXRAbstractMotionController implements IDisposable {
  45707. protected scene: Scene;
  45708. protected layout: IMotionControllerLayout;
  45709. /**
  45710. * The gamepad object correlating to this controller
  45711. */
  45712. gamepadObject: IMinimalMotionControllerObject;
  45713. /**
  45714. * handness (left/right/none) of this controller
  45715. */
  45716. handness: MotionControllerHandness;
  45717. private _initComponent;
  45718. private _modelReady;
  45719. /**
  45720. * A map of components (WebXRControllerComponent) in this motion controller
  45721. * Components have a ComponentType and can also have both button and axis definitions
  45722. */
  45723. readonly components: {
  45724. [id: string]: WebXRControllerComponent;
  45725. };
  45726. /**
  45727. * Disable the model's animation. Can be set at any time.
  45728. */
  45729. disableAnimation: boolean;
  45730. /**
  45731. * Observers registered here will be triggered when the model of this controller is done loading
  45732. */
  45733. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45734. /**
  45735. * The profile id of this motion controller
  45736. */
  45737. abstract profileId: string;
  45738. /**
  45739. * The root mesh of the model. It is null if the model was not yet initialized
  45740. */
  45741. rootMesh: Nullable<AbstractMesh>;
  45742. /**
  45743. * constructs a new abstract motion controller
  45744. * @param scene the scene to which the model of the controller will be added
  45745. * @param layout The profile layout to load
  45746. * @param gamepadObject The gamepad object correlating to this controller
  45747. * @param handness handness (left/right/none) of this controller
  45748. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45749. */
  45750. constructor(scene: Scene, layout: IMotionControllerLayout,
  45751. /**
  45752. * The gamepad object correlating to this controller
  45753. */
  45754. gamepadObject: IMinimalMotionControllerObject,
  45755. /**
  45756. * handness (left/right/none) of this controller
  45757. */
  45758. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45759. /**
  45760. * Dispose this controller, the model mesh and all its components
  45761. */
  45762. dispose(): void;
  45763. /**
  45764. * Returns all components of specific type
  45765. * @param type the type to search for
  45766. * @return an array of components with this type
  45767. */
  45768. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45769. /**
  45770. * get a component based an its component id as defined in layout.components
  45771. * @param id the id of the component
  45772. * @returns the component correlates to the id or undefined if not found
  45773. */
  45774. getComponent(id: string): WebXRControllerComponent;
  45775. /**
  45776. * Get the list of components available in this motion controller
  45777. * @returns an array of strings correlating to available components
  45778. */
  45779. getComponentIds(): string[];
  45780. /**
  45781. * Get the first component of specific type
  45782. * @param type type of component to find
  45783. * @return a controller component or null if not found
  45784. */
  45785. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45786. /**
  45787. * Get the main (Select) component of this controller as defined in the layout
  45788. * @returns the main component of this controller
  45789. */
  45790. getMainComponent(): WebXRControllerComponent;
  45791. /**
  45792. * Loads the model correlating to this controller
  45793. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45794. * @returns A promise fulfilled with the result of the model loading
  45795. */
  45796. loadModel(): Promise<boolean>;
  45797. /**
  45798. * Update this model using the current XRFrame
  45799. * @param xrFrame the current xr frame to use and update the model
  45800. */
  45801. updateFromXRFrame(xrFrame: XRFrame): void;
  45802. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45803. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45804. /**
  45805. * Moves the axis on the controller mesh based on its current state
  45806. * @param axis the index of the axis
  45807. * @param axisValue the value of the axis which determines the meshes new position
  45808. * @hidden
  45809. */
  45810. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45811. /**
  45812. * Update the model itself with the current frame data
  45813. * @param xrFrame the frame to use for updating the model mesh
  45814. */
  45815. protected updateModel(xrFrame: XRFrame): void;
  45816. /**
  45817. * Get the filename and path for this controller's model
  45818. * @returns a map of filename and path
  45819. */
  45820. protected abstract _getFilenameAndPath(): {
  45821. filename: string;
  45822. path: string;
  45823. };
  45824. /**
  45825. * This function is called before the mesh is loaded. It checks for loading constraints.
  45826. * For example, this function can check if the GLB loader is available
  45827. * If this function returns false, the generic controller will be loaded instead
  45828. * @returns Is the client ready to load the mesh
  45829. */
  45830. protected abstract _getModelLoadingConstraints(): boolean;
  45831. /**
  45832. * This function will be called after the model was successfully loaded and can be used
  45833. * for mesh transformations before it is available for the user
  45834. * @param meshes the loaded meshes
  45835. */
  45836. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45837. /**
  45838. * Set the root mesh for this controller. Important for the WebXR controller class
  45839. * @param meshes the loaded meshes
  45840. */
  45841. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45842. /**
  45843. * A function executed each frame that updates the mesh (if needed)
  45844. * @param xrFrame the current xrFrame
  45845. */
  45846. protected abstract _updateModel(xrFrame: XRFrame): void;
  45847. private _getGenericFilenameAndPath;
  45848. private _getGenericParentMesh;
  45849. }
  45850. }
  45851. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45852. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45854. import { Scene } from "babylonjs/scene";
  45855. /**
  45856. * A generic trigger-only motion controller for WebXR
  45857. */
  45858. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45859. /**
  45860. * Static version of the profile id of this controller
  45861. */
  45862. static ProfileId: string;
  45863. profileId: string;
  45864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45865. protected _getFilenameAndPath(): {
  45866. filename: string;
  45867. path: string;
  45868. };
  45869. protected _getModelLoadingConstraints(): boolean;
  45870. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45872. protected _updateModel(): void;
  45873. }
  45874. }
  45875. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45876. import { Vector4 } from "babylonjs/Maths/math.vector";
  45877. import { Mesh } from "babylonjs/Meshes/mesh";
  45878. import { Scene } from "babylonjs/scene";
  45879. import { Nullable } from "babylonjs/types";
  45880. /**
  45881. * Class containing static functions to help procedurally build meshes
  45882. */
  45883. export class SphereBuilder {
  45884. /**
  45885. * Creates a sphere mesh
  45886. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45887. * * 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`)
  45888. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45889. * * 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
  45890. * * 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)
  45891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45894. * @param name defines the name of the mesh
  45895. * @param options defines the options used to create the mesh
  45896. * @param scene defines the hosting scene
  45897. * @returns the sphere mesh
  45898. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45899. */
  45900. static CreateSphere(name: string, options: {
  45901. segments?: number;
  45902. diameter?: number;
  45903. diameterX?: number;
  45904. diameterY?: number;
  45905. diameterZ?: number;
  45906. arc?: number;
  45907. slice?: number;
  45908. sideOrientation?: number;
  45909. frontUVs?: Vector4;
  45910. backUVs?: Vector4;
  45911. updatable?: boolean;
  45912. }, scene?: Nullable<Scene>): Mesh;
  45913. }
  45914. }
  45915. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45917. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45918. import { Scene } from "babylonjs/scene";
  45919. /**
  45920. * A profiled motion controller has its profile loaded from an online repository.
  45921. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45922. */
  45923. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45924. private _repositoryUrl;
  45925. private _buttonMeshMapping;
  45926. private _touchDots;
  45927. /**
  45928. * The profile ID of this controller. Will be populated when the controller initializes.
  45929. */
  45930. profileId: string;
  45931. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45932. dispose(): void;
  45933. protected _getFilenameAndPath(): {
  45934. filename: string;
  45935. path: string;
  45936. };
  45937. protected _getModelLoadingConstraints(): boolean;
  45938. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45939. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45940. protected _updateModel(_xrFrame: XRFrame): void;
  45941. }
  45942. }
  45943. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45944. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45945. import { Scene } from "babylonjs/scene";
  45946. /**
  45947. * A construction function type to create a new controller based on an xrInput object
  45948. */
  45949. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45950. /**
  45951. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45952. *
  45953. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45954. * it should be replaced with auto-loaded controllers.
  45955. *
  45956. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45957. */
  45958. export class WebXRMotionControllerManager {
  45959. private static _AvailableControllers;
  45960. private static _Fallbacks;
  45961. private static _ProfileLoadingPromises;
  45962. private static _ProfilesList;
  45963. /**
  45964. * The base URL of the online controller repository. Can be changed at any time.
  45965. */
  45966. static BaseRepositoryUrl: string;
  45967. /**
  45968. * Which repository gets priority - local or online
  45969. */
  45970. static PrioritizeOnlineRepository: boolean;
  45971. /**
  45972. * Use the online repository, or use only locally-defined controllers
  45973. */
  45974. static UseOnlineRepository: boolean;
  45975. /**
  45976. * Clear the cache used for profile loading and reload when requested again
  45977. */
  45978. static ClearProfilesCache(): void;
  45979. /**
  45980. * Register the default fallbacks.
  45981. * This function is called automatically when this file is imported.
  45982. */
  45983. static DefaultFallbacks(): void;
  45984. /**
  45985. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45986. * @param profileId the profile to which a fallback needs to be found
  45987. * @return an array with corresponding fallback profiles
  45988. */
  45989. static FindFallbackWithProfileId(profileId: string): string[];
  45990. /**
  45991. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45992. * The order of search:
  45993. *
  45994. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45995. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45996. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45997. * 4) return the generic trigger controller if none were found
  45998. *
  45999. * @param xrInput the xrInput to which a new controller is initialized
  46000. * @param scene the scene to which the model will be added
  46001. * @param forceProfile force a certain profile for this controller
  46002. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46003. */
  46004. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46005. /**
  46006. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46007. *
  46008. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46009. *
  46010. * @param type the profile type to register
  46011. * @param constructFunction the function to be called when loading this profile
  46012. */
  46013. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46014. /**
  46015. * Register a fallback to a specific profile.
  46016. * @param profileId the profileId that will receive the fallbacks
  46017. * @param fallbacks A list of fallback profiles
  46018. */
  46019. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46020. /**
  46021. * Will update the list of profiles available in the repository
  46022. * @return a promise that resolves to a map of profiles available online
  46023. */
  46024. static UpdateProfilesList(): Promise<{
  46025. [profile: string]: string;
  46026. }>;
  46027. private static _LoadProfileFromRepository;
  46028. private static _LoadProfilesFromAvailableControllers;
  46029. }
  46030. }
  46031. declare module "babylonjs/XR/webXRInputSource" {
  46032. import { Observable } from "babylonjs/Misc/observable";
  46033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46034. import { Ray } from "babylonjs/Culling/ray";
  46035. import { Scene } from "babylonjs/scene";
  46036. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46037. /**
  46038. * Configuration options for the WebXR controller creation
  46039. */
  46040. export interface IWebXRControllerOptions {
  46041. /**
  46042. * Should the controller mesh be animated when a user interacts with it
  46043. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46044. */
  46045. disableMotionControllerAnimation?: boolean;
  46046. /**
  46047. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46048. */
  46049. doNotLoadControllerMesh?: boolean;
  46050. /**
  46051. * Force a specific controller type for this controller.
  46052. * This can be used when creating your own profile or when testing different controllers
  46053. */
  46054. forceControllerProfile?: string;
  46055. }
  46056. /**
  46057. * Represents an XR controller
  46058. */
  46059. export class WebXRInputSource {
  46060. private _scene;
  46061. /** The underlying input source for the controller */
  46062. inputSource: XRInputSource;
  46063. private _options;
  46064. private _tmpQuaternion;
  46065. private _tmpVector;
  46066. private _uniqueId;
  46067. /**
  46068. * 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
  46069. */
  46070. grip?: AbstractMesh;
  46071. /**
  46072. * If available, this is the gamepad object related to this controller.
  46073. * Using this object it is possible to get click events and trackpad changes of the
  46074. * webxr controller that is currently being used.
  46075. */
  46076. motionController?: WebXRAbstractMotionController;
  46077. /**
  46078. * Event that fires when the controller is removed/disposed.
  46079. * The object provided as event data is this controller, after associated assets were disposed.
  46080. * uniqueId is still available.
  46081. */
  46082. onDisposeObservable: Observable<WebXRInputSource>;
  46083. /**
  46084. * Will be triggered when the mesh associated with the motion controller is done loading.
  46085. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46086. * A shortened version of controller -> motion controller -> on mesh loaded.
  46087. */
  46088. onMeshLoadedObservable: Observable<AbstractMesh>;
  46089. /**
  46090. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46091. */
  46092. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46093. /**
  46094. * Pointer which can be used to select objects or attach a visible laser to
  46095. */
  46096. pointer: AbstractMesh;
  46097. /**
  46098. * Creates the controller
  46099. * @see https://doc.babylonjs.com/how_to/webxr
  46100. * @param _scene the scene which the controller should be associated to
  46101. * @param inputSource the underlying input source for the controller
  46102. * @param _options options for this controller creation
  46103. */
  46104. constructor(_scene: Scene,
  46105. /** The underlying input source for the controller */
  46106. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46107. /**
  46108. * Get this controllers unique id
  46109. */
  46110. get uniqueId(): string;
  46111. /**
  46112. * Disposes of the object
  46113. */
  46114. dispose(): void;
  46115. /**
  46116. * Gets a world space ray coming from the pointer or grip
  46117. * @param result the resulting ray
  46118. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46119. */
  46120. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46121. /**
  46122. * Updates the controller pose based on the given XRFrame
  46123. * @param xrFrame xr frame to update the pose with
  46124. * @param referenceSpace reference space to use
  46125. */
  46126. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46127. }
  46128. }
  46129. declare module "babylonjs/XR/webXRInput" {
  46130. import { Observable } from "babylonjs/Misc/observable";
  46131. import { IDisposable } from "babylonjs/scene";
  46132. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46133. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46134. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46135. /**
  46136. * The schema for initialization options of the XR Input class
  46137. */
  46138. export interface IWebXRInputOptions {
  46139. /**
  46140. * If set to true no model will be automatically loaded
  46141. */
  46142. doNotLoadControllerMeshes?: boolean;
  46143. /**
  46144. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46145. * If not found, the xr input profile data will be used.
  46146. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46147. */
  46148. forceInputProfile?: string;
  46149. /**
  46150. * Do not send a request to the controller repository to load the profile.
  46151. *
  46152. * Instead, use the controllers available in babylon itself.
  46153. */
  46154. disableOnlineControllerRepository?: boolean;
  46155. /**
  46156. * A custom URL for the controllers repository
  46157. */
  46158. customControllersRepositoryURL?: string;
  46159. /**
  46160. * Should the controller model's components not move according to the user input
  46161. */
  46162. disableControllerAnimation?: boolean;
  46163. }
  46164. /**
  46165. * XR input used to track XR inputs such as controllers/rays
  46166. */
  46167. export class WebXRInput implements IDisposable {
  46168. /**
  46169. * the xr session manager for this session
  46170. */
  46171. xrSessionManager: WebXRSessionManager;
  46172. /**
  46173. * the WebXR camera for this session. Mainly used for teleportation
  46174. */
  46175. xrCamera: WebXRCamera;
  46176. private readonly options;
  46177. /**
  46178. * XR controllers being tracked
  46179. */
  46180. controllers: Array<WebXRInputSource>;
  46181. private _frameObserver;
  46182. private _sessionEndedObserver;
  46183. private _sessionInitObserver;
  46184. /**
  46185. * Event when a controller has been connected/added
  46186. */
  46187. onControllerAddedObservable: Observable<WebXRInputSource>;
  46188. /**
  46189. * Event when a controller has been removed/disconnected
  46190. */
  46191. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46192. /**
  46193. * Initializes the WebXRInput
  46194. * @param xrSessionManager the xr session manager for this session
  46195. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46196. * @param options = initialization options for this xr input
  46197. */
  46198. constructor(
  46199. /**
  46200. * the xr session manager for this session
  46201. */
  46202. xrSessionManager: WebXRSessionManager,
  46203. /**
  46204. * the WebXR camera for this session. Mainly used for teleportation
  46205. */
  46206. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46207. private _onInputSourcesChange;
  46208. private _addAndRemoveControllers;
  46209. /**
  46210. * Disposes of the object
  46211. */
  46212. dispose(): void;
  46213. }
  46214. }
  46215. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46216. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46217. import { Observable, EventState } from "babylonjs/Misc/observable";
  46218. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46219. /**
  46220. * This is the base class for all WebXR features.
  46221. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46222. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46223. */
  46224. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46225. protected _xrSessionManager: WebXRSessionManager;
  46226. private _attached;
  46227. private _removeOnDetach;
  46228. /**
  46229. * Should auto-attach be disabled?
  46230. */
  46231. disableAutoAttach: boolean;
  46232. /**
  46233. * Construct a new (abstract) WebXR feature
  46234. * @param _xrSessionManager the xr session manager for this feature
  46235. */
  46236. constructor(_xrSessionManager: WebXRSessionManager);
  46237. /**
  46238. * Is this feature attached
  46239. */
  46240. get attached(): boolean;
  46241. /**
  46242. * attach this feature
  46243. *
  46244. * @param force should attachment be forced (even when already attached)
  46245. * @returns true if successful, false is failed or already attached
  46246. */
  46247. attach(force?: boolean): boolean;
  46248. /**
  46249. * detach this feature.
  46250. *
  46251. * @returns true if successful, false if failed or already detached
  46252. */
  46253. detach(): boolean;
  46254. /**
  46255. * Dispose this feature and all of the resources attached
  46256. */
  46257. dispose(): void;
  46258. /**
  46259. * This is used to register callbacks that will automatically be removed when detach is called.
  46260. * @param observable the observable to which the observer will be attached
  46261. * @param callback the callback to register
  46262. */
  46263. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46264. /**
  46265. * Code in this function will be executed on each xrFrame received from the browser.
  46266. * This function will not execute after the feature is detached.
  46267. * @param _xrFrame the current frame
  46268. */
  46269. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46270. }
  46271. }
  46272. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46273. import { IDisposable, Scene } from "babylonjs/scene";
  46274. import { Nullable } from "babylonjs/types";
  46275. import { Observable } from "babylonjs/Misc/observable";
  46276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46277. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46278. import { Camera } from "babylonjs/Cameras/camera";
  46279. /**
  46280. * Renders a layer on top of an existing scene
  46281. */
  46282. export class UtilityLayerRenderer implements IDisposable {
  46283. /** the original scene that will be rendered on top of */
  46284. originalScene: Scene;
  46285. private _pointerCaptures;
  46286. private _lastPointerEvents;
  46287. private static _DefaultUtilityLayer;
  46288. private static _DefaultKeepDepthUtilityLayer;
  46289. private _sharedGizmoLight;
  46290. private _renderCamera;
  46291. /**
  46292. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46293. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46294. * @returns the camera that is used when rendering the utility layer
  46295. */
  46296. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46297. /**
  46298. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46299. * @param cam the camera that should be used when rendering the utility layer
  46300. */
  46301. setRenderCamera(cam: Nullable<Camera>): void;
  46302. /**
  46303. * @hidden
  46304. * Light which used by gizmos to get light shading
  46305. */
  46306. _getSharedGizmoLight(): HemisphericLight;
  46307. /**
  46308. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46309. */
  46310. pickUtilitySceneFirst: boolean;
  46311. /**
  46312. * 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)
  46313. */
  46314. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46315. /**
  46316. * 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)
  46317. */
  46318. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46319. /**
  46320. * The scene that is rendered on top of the original scene
  46321. */
  46322. utilityLayerScene: Scene;
  46323. /**
  46324. * If the utility layer should automatically be rendered on top of existing scene
  46325. */
  46326. shouldRender: boolean;
  46327. /**
  46328. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46329. */
  46330. onlyCheckPointerDownEvents: boolean;
  46331. /**
  46332. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46333. */
  46334. processAllEvents: boolean;
  46335. /**
  46336. * Observable raised when the pointer move from the utility layer scene to the main scene
  46337. */
  46338. onPointerOutObservable: Observable<number>;
  46339. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46340. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46341. private _afterRenderObserver;
  46342. private _sceneDisposeObserver;
  46343. private _originalPointerObserver;
  46344. /**
  46345. * Instantiates a UtilityLayerRenderer
  46346. * @param originalScene the original scene that will be rendered on top of
  46347. * @param handleEvents boolean indicating if the utility layer should handle events
  46348. */
  46349. constructor(
  46350. /** the original scene that will be rendered on top of */
  46351. originalScene: Scene, handleEvents?: boolean);
  46352. private _notifyObservers;
  46353. /**
  46354. * Renders the utility layers scene on top of the original scene
  46355. */
  46356. render(): void;
  46357. /**
  46358. * Disposes of the renderer
  46359. */
  46360. dispose(): void;
  46361. private _updateCamera;
  46362. }
  46363. }
  46364. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46365. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46367. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46368. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46369. import { Scene } from "babylonjs/scene";
  46370. import { Nullable } from "babylonjs/types";
  46371. import { Color3 } from "babylonjs/Maths/math.color";
  46372. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46373. /**
  46374. * Options interface for the pointer selection module
  46375. */
  46376. export interface IWebXRControllerPointerSelectionOptions {
  46377. /**
  46378. * if provided, this scene will be used to render meshes.
  46379. */
  46380. customUtilityLayerScene?: Scene;
  46381. /**
  46382. * 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)
  46383. * If not disabled, the last picked point will be used to execute a pointer up event
  46384. * If disabled, pointer up event will be triggered right after the pointer down event.
  46385. * Used in screen and gaze target ray mode only
  46386. */
  46387. disablePointerUpOnTouchOut: boolean;
  46388. /**
  46389. * For gaze mode (time to select instead of press)
  46390. */
  46391. forceGazeMode: boolean;
  46392. /**
  46393. * 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
  46394. * to start a new countdown to the pointer down event.
  46395. * Defaults to 1.
  46396. */
  46397. gazeModePointerMovedFactor?: number;
  46398. /**
  46399. * Different button type to use instead of the main component
  46400. */
  46401. overrideButtonId?: string;
  46402. /**
  46403. * use this rendering group id for the meshes (optional)
  46404. */
  46405. renderingGroupId?: number;
  46406. /**
  46407. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46408. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46409. * 3000 means 3 seconds between pointing at something and selecting it
  46410. */
  46411. timeToSelect?: number;
  46412. /**
  46413. * Should meshes created here be added to a utility layer or the main scene
  46414. */
  46415. useUtilityLayer?: boolean;
  46416. /**
  46417. * the xr input to use with this pointer selection
  46418. */
  46419. xrInput: WebXRInput;
  46420. }
  46421. /**
  46422. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46423. */
  46424. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46425. private readonly _options;
  46426. private static _idCounter;
  46427. private _attachController;
  46428. private _controllers;
  46429. private _scene;
  46430. private _tmpVectorForPickCompare;
  46431. /**
  46432. * The module's name
  46433. */
  46434. static readonly Name: string;
  46435. /**
  46436. * The (Babylon) version of this module.
  46437. * This is an integer representing the implementation version.
  46438. * This number does not correspond to the WebXR specs version
  46439. */
  46440. static readonly Version: number;
  46441. /**
  46442. * Disable lighting on the laser pointer (so it will always be visible)
  46443. */
  46444. disablePointerLighting: boolean;
  46445. /**
  46446. * Disable lighting on the selection mesh (so it will always be visible)
  46447. */
  46448. disableSelectionMeshLighting: boolean;
  46449. /**
  46450. * Should the laser pointer be displayed
  46451. */
  46452. displayLaserPointer: boolean;
  46453. /**
  46454. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46455. */
  46456. displaySelectionMesh: boolean;
  46457. /**
  46458. * This color will be set to the laser pointer when selection is triggered
  46459. */
  46460. laserPointerPickedColor: Color3;
  46461. /**
  46462. * Default color of the laser pointer
  46463. */
  46464. lasterPointerDefaultColor: Color3;
  46465. /**
  46466. * default color of the selection ring
  46467. */
  46468. selectionMeshDefaultColor: Color3;
  46469. /**
  46470. * This color will be applied to the selection ring when selection is triggered
  46471. */
  46472. selectionMeshPickedColor: Color3;
  46473. /**
  46474. * Optional filter to be used for ray selection. This predicate shares behavior with
  46475. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46476. */
  46477. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46478. /**
  46479. * constructs a new background remover module
  46480. * @param _xrSessionManager the session manager for this module
  46481. * @param _options read-only options to be used in this module
  46482. */
  46483. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46484. /**
  46485. * attach this feature
  46486. * Will usually be called by the features manager
  46487. *
  46488. * @returns true if successful.
  46489. */
  46490. attach(): boolean;
  46491. /**
  46492. * detach this feature.
  46493. * Will usually be called by the features manager
  46494. *
  46495. * @returns true if successful.
  46496. */
  46497. detach(): boolean;
  46498. /**
  46499. * Will get the mesh under a specific pointer.
  46500. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46501. * @param controllerId the controllerId to check
  46502. * @returns The mesh under pointer or null if no mesh is under the pointer
  46503. */
  46504. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46505. /**
  46506. * Get the xr controller that correlates to the pointer id in the pointer event
  46507. *
  46508. * @param id the pointer id to search for
  46509. * @returns the controller that correlates to this id or null if not found
  46510. */
  46511. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46512. protected _onXRFrame(_xrFrame: XRFrame): void;
  46513. private _attachGazeMode;
  46514. private _attachScreenRayMode;
  46515. private _attachTrackedPointerRayMode;
  46516. private _convertNormalToDirectionOfRay;
  46517. private _detachController;
  46518. private _generateNewMeshPair;
  46519. private _pickingMoved;
  46520. private _updatePointerDistance;
  46521. }
  46522. }
  46523. declare module "babylonjs/XR/webXREnterExitUI" {
  46524. import { Nullable } from "babylonjs/types";
  46525. import { Observable } from "babylonjs/Misc/observable";
  46526. import { IDisposable, Scene } from "babylonjs/scene";
  46527. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46528. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46529. /**
  46530. * Button which can be used to enter a different mode of XR
  46531. */
  46532. export class WebXREnterExitUIButton {
  46533. /** button element */
  46534. element: HTMLElement;
  46535. /** XR initialization options for the button */
  46536. sessionMode: XRSessionMode;
  46537. /** Reference space type */
  46538. referenceSpaceType: XRReferenceSpaceType;
  46539. /**
  46540. * Creates a WebXREnterExitUIButton
  46541. * @param element button element
  46542. * @param sessionMode XR initialization session mode
  46543. * @param referenceSpaceType the type of reference space to be used
  46544. */
  46545. constructor(
  46546. /** button element */
  46547. element: HTMLElement,
  46548. /** XR initialization options for the button */
  46549. sessionMode: XRSessionMode,
  46550. /** Reference space type */
  46551. referenceSpaceType: XRReferenceSpaceType);
  46552. /**
  46553. * Extendable function which can be used to update the button's visuals when the state changes
  46554. * @param activeButton the current active button in the UI
  46555. */
  46556. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46557. }
  46558. /**
  46559. * Options to create the webXR UI
  46560. */
  46561. export class WebXREnterExitUIOptions {
  46562. /**
  46563. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46564. */
  46565. customButtons?: Array<WebXREnterExitUIButton>;
  46566. /**
  46567. * A reference space type to use when creating the default button.
  46568. * Default is local-floor
  46569. */
  46570. referenceSpaceType?: XRReferenceSpaceType;
  46571. /**
  46572. * Context to enter xr with
  46573. */
  46574. renderTarget?: Nullable<WebXRRenderTarget>;
  46575. /**
  46576. * A session mode to use when creating the default button.
  46577. * Default is immersive-vr
  46578. */
  46579. sessionMode?: XRSessionMode;
  46580. }
  46581. /**
  46582. * UI to allow the user to enter/exit XR mode
  46583. */
  46584. export class WebXREnterExitUI implements IDisposable {
  46585. private scene;
  46586. /** version of the options passed to this UI */
  46587. options: WebXREnterExitUIOptions;
  46588. private _activeButton;
  46589. private _buttons;
  46590. private _overlay;
  46591. /**
  46592. * Fired every time the active button is changed.
  46593. *
  46594. * When xr is entered via a button that launches xr that button will be the callback parameter
  46595. *
  46596. * When exiting xr the callback parameter will be null)
  46597. */
  46598. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46599. /**
  46600. *
  46601. * @param scene babylon scene object to use
  46602. * @param options (read-only) version of the options passed to this UI
  46603. */
  46604. private constructor();
  46605. /**
  46606. * Creates UI to allow the user to enter/exit XR mode
  46607. * @param scene the scene to add the ui to
  46608. * @param helper the xr experience helper to enter/exit xr with
  46609. * @param options options to configure the UI
  46610. * @returns the created ui
  46611. */
  46612. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46613. /**
  46614. * Disposes of the XR UI component
  46615. */
  46616. dispose(): void;
  46617. private _updateButtons;
  46618. }
  46619. }
  46620. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46621. import { Vector3 } from "babylonjs/Maths/math.vector";
  46622. import { Color4 } from "babylonjs/Maths/math.color";
  46623. import { Nullable } from "babylonjs/types";
  46624. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46625. import { Scene } from "babylonjs/scene";
  46626. /**
  46627. * Class containing static functions to help procedurally build meshes
  46628. */
  46629. export class LinesBuilder {
  46630. /**
  46631. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46632. * * 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
  46633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46634. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46635. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46636. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46638. * * 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
  46639. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46642. * @param name defines the name of the new line system
  46643. * @param options defines the options used to create the line system
  46644. * @param scene defines the hosting scene
  46645. * @returns a new line system mesh
  46646. */
  46647. static CreateLineSystem(name: string, options: {
  46648. lines: Vector3[][];
  46649. updatable?: boolean;
  46650. instance?: Nullable<LinesMesh>;
  46651. colors?: Nullable<Color4[][]>;
  46652. useVertexAlpha?: boolean;
  46653. }, scene: Nullable<Scene>): LinesMesh;
  46654. /**
  46655. * Creates a line mesh
  46656. * 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
  46657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46658. * * The parameter `points` is an array successive Vector3
  46659. * * 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
  46660. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46661. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46662. * * When updating an instance, remember that only point positions can change, not the number of points
  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#lines
  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 mesh
  46669. */
  46670. static CreateLines(name: string, options: {
  46671. points: Vector3[];
  46672. updatable?: boolean;
  46673. instance?: Nullable<LinesMesh>;
  46674. colors?: Color4[];
  46675. useVertexAlpha?: boolean;
  46676. }, scene?: Nullable<Scene>): LinesMesh;
  46677. /**
  46678. * Creates a dashed line mesh
  46679. * * 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
  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 parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46683. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46684. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46685. * * 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
  46686. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46687. * * When updating an instance, remember that only point positions can change, not the number of points
  46688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46689. * @param name defines the name of the mesh
  46690. * @param options defines the options used to create the mesh
  46691. * @param scene defines the hosting scene
  46692. * @returns the dashed line mesh
  46693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46694. */
  46695. static CreateDashedLines(name: string, options: {
  46696. points: Vector3[];
  46697. dashSize?: number;
  46698. gapSize?: number;
  46699. dashNb?: number;
  46700. updatable?: boolean;
  46701. instance?: LinesMesh;
  46702. useVertexAlpha?: boolean;
  46703. }, scene?: Nullable<Scene>): LinesMesh;
  46704. }
  46705. }
  46706. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46707. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46708. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46709. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46711. import { Vector3 } from "babylonjs/Maths/math.vector";
  46712. import { Material } from "babylonjs/Materials/material";
  46713. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46714. import { Scene } from "babylonjs/scene";
  46715. /**
  46716. * The options container for the teleportation module
  46717. */
  46718. export interface IWebXRTeleportationOptions {
  46719. /**
  46720. * if provided, this scene will be used to render meshes.
  46721. */
  46722. customUtilityLayerScene?: Scene;
  46723. /**
  46724. * Values to configure the default target mesh
  46725. */
  46726. defaultTargetMeshOptions?: {
  46727. /**
  46728. * Fill color of the teleportation area
  46729. */
  46730. teleportationFillColor?: string;
  46731. /**
  46732. * Border color for the teleportation area
  46733. */
  46734. teleportationBorderColor?: string;
  46735. /**
  46736. * Disable the mesh's animation sequence
  46737. */
  46738. disableAnimation?: boolean;
  46739. /**
  46740. * Disable lighting on the material or the ring and arrow
  46741. */
  46742. disableLighting?: boolean;
  46743. /**
  46744. * Override the default material of the torus and arrow
  46745. */
  46746. torusArrowMaterial?: Material;
  46747. };
  46748. /**
  46749. * A list of meshes to use as floor meshes.
  46750. * Meshes can be added and removed after initializing the feature using the
  46751. * addFloorMesh and removeFloorMesh functions
  46752. * If empty, rotation will still work
  46753. */
  46754. floorMeshes?: AbstractMesh[];
  46755. /**
  46756. * use this rendering group id for the meshes (optional)
  46757. */
  46758. renderingGroupId?: number;
  46759. /**
  46760. * Should teleportation move only to snap points
  46761. */
  46762. snapPointsOnly?: boolean;
  46763. /**
  46764. * An array of points to which the teleportation will snap to.
  46765. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46766. */
  46767. snapPositions?: Vector3[];
  46768. /**
  46769. * How close should the teleportation ray be in order to snap to position.
  46770. * Default to 0.8 units (meters)
  46771. */
  46772. snapToPositionRadius?: number;
  46773. /**
  46774. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46775. * If you want to support rotation, make sure your mesh has a direction indicator.
  46776. *
  46777. * When left untouched, the default mesh will be initialized.
  46778. */
  46779. teleportationTargetMesh?: AbstractMesh;
  46780. /**
  46781. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46782. */
  46783. timeToTeleport?: number;
  46784. /**
  46785. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46786. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46787. */
  46788. useMainComponentOnly?: boolean;
  46789. /**
  46790. * Should meshes created here be added to a utility layer or the main scene
  46791. */
  46792. useUtilityLayer?: boolean;
  46793. /**
  46794. * Babylon XR Input class for controller
  46795. */
  46796. xrInput: WebXRInput;
  46797. }
  46798. /**
  46799. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46800. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46801. * the input of the attached controllers.
  46802. */
  46803. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46804. private _options;
  46805. private _controllers;
  46806. private _currentTeleportationControllerId;
  46807. private _floorMeshes;
  46808. private _quadraticBezierCurve;
  46809. private _selectionFeature;
  46810. private _snapToPositions;
  46811. private _snappedToPoint;
  46812. private _teleportationRingMaterial?;
  46813. private _tmpRay;
  46814. private _tmpVector;
  46815. /**
  46816. * The module's name
  46817. */
  46818. static readonly Name: string;
  46819. /**
  46820. * The (Babylon) version of this module.
  46821. * This is an integer representing the implementation version.
  46822. * This number does not correspond to the webxr specs version
  46823. */
  46824. static readonly Version: number;
  46825. /**
  46826. * Is movement backwards enabled
  46827. */
  46828. backwardsMovementEnabled: boolean;
  46829. /**
  46830. * Distance to travel when moving backwards
  46831. */
  46832. backwardsTeleportationDistance: number;
  46833. /**
  46834. * The distance from the user to the inspection point in the direction of the controller
  46835. * A higher number will allow the user to move further
  46836. * defaults to 5 (meters, in xr units)
  46837. */
  46838. parabolicCheckRadius: number;
  46839. /**
  46840. * Should the module support parabolic ray on top of direct ray
  46841. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46842. * Very helpful when moving between floors / different heights
  46843. */
  46844. parabolicRayEnabled: boolean;
  46845. /**
  46846. * How much rotation should be applied when rotating right and left
  46847. */
  46848. rotationAngle: number;
  46849. /**
  46850. * Is rotation enabled when moving forward?
  46851. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46852. */
  46853. rotationEnabled: boolean;
  46854. /**
  46855. * constructs a new anchor system
  46856. * @param _xrSessionManager an instance of WebXRSessionManager
  46857. * @param _options configuration object for this feature
  46858. */
  46859. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46860. /**
  46861. * Get the snapPointsOnly flag
  46862. */
  46863. get snapPointsOnly(): boolean;
  46864. /**
  46865. * Sets the snapPointsOnly flag
  46866. * @param snapToPoints should teleportation be exclusively to snap points
  46867. */
  46868. set snapPointsOnly(snapToPoints: boolean);
  46869. /**
  46870. * Add a new mesh to the floor meshes array
  46871. * @param mesh the mesh to use as floor mesh
  46872. */
  46873. addFloorMesh(mesh: AbstractMesh): void;
  46874. /**
  46875. * Add a new snap-to point to fix teleportation to this position
  46876. * @param newSnapPoint The new Snap-To point
  46877. */
  46878. addSnapPoint(newSnapPoint: Vector3): void;
  46879. attach(): boolean;
  46880. detach(): boolean;
  46881. dispose(): void;
  46882. /**
  46883. * Remove a mesh from the floor meshes array
  46884. * @param mesh the mesh to remove
  46885. */
  46886. removeFloorMesh(mesh: AbstractMesh): void;
  46887. /**
  46888. * Remove a mesh from the floor meshes array using its name
  46889. * @param name the mesh name to remove
  46890. */
  46891. removeFloorMeshByName(name: string): void;
  46892. /**
  46893. * 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
  46894. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46895. * @returns was the point found and removed or not
  46896. */
  46897. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46898. /**
  46899. * This function sets a selection feature that will be disabled when
  46900. * the forward ray is shown and will be reattached when hidden.
  46901. * This is used to remove the selection rays when moving.
  46902. * @param selectionFeature the feature to disable when forward movement is enabled
  46903. */
  46904. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46905. protected _onXRFrame(_xrFrame: XRFrame): void;
  46906. private _attachController;
  46907. private _createDefaultTargetMesh;
  46908. private _detachController;
  46909. private _findClosestSnapPointWithRadius;
  46910. private _setTargetMeshPosition;
  46911. private _setTargetMeshVisibility;
  46912. private _showParabolicPath;
  46913. private _teleportForward;
  46914. }
  46915. }
  46916. declare module "babylonjs/XR/webXRDefaultExperience" {
  46917. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46918. import { Scene } from "babylonjs/scene";
  46919. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46920. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46921. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46922. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46924. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46925. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46926. /**
  46927. * Options for the default xr helper
  46928. */
  46929. export class WebXRDefaultExperienceOptions {
  46930. /**
  46931. * Enable or disable default UI to enter XR
  46932. */
  46933. disableDefaultUI?: boolean;
  46934. /**
  46935. * Should teleportation not initialize. defaults to false.
  46936. */
  46937. disableTeleportation?: boolean;
  46938. /**
  46939. * Floor meshes that will be used for teleport
  46940. */
  46941. floorMeshes?: Array<AbstractMesh>;
  46942. /**
  46943. * If set to true, the first frame will not be used to reset position
  46944. * The first frame is mainly used when copying transformation from the old camera
  46945. * Mainly used in AR
  46946. */
  46947. ignoreNativeCameraTransformation?: boolean;
  46948. /**
  46949. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46950. */
  46951. inputOptions?: IWebXRInputOptions;
  46952. /**
  46953. * optional configuration for the output canvas
  46954. */
  46955. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46956. /**
  46957. * optional UI options. This can be used among other to change session mode and reference space type
  46958. */
  46959. uiOptions?: WebXREnterExitUIOptions;
  46960. /**
  46961. * When loading teleportation and pointer select, use stable versions instead of latest.
  46962. */
  46963. useStablePlugins?: boolean;
  46964. }
  46965. /**
  46966. * Default experience which provides a similar setup to the previous webVRExperience
  46967. */
  46968. export class WebXRDefaultExperience {
  46969. /**
  46970. * Base experience
  46971. */
  46972. baseExperience: WebXRExperienceHelper;
  46973. /**
  46974. * Enables ui for entering/exiting xr
  46975. */
  46976. enterExitUI: WebXREnterExitUI;
  46977. /**
  46978. * Input experience extension
  46979. */
  46980. input: WebXRInput;
  46981. /**
  46982. * Enables laser pointer and selection
  46983. */
  46984. pointerSelection: WebXRControllerPointerSelection;
  46985. /**
  46986. * Default target xr should render to
  46987. */
  46988. renderTarget: WebXRRenderTarget;
  46989. /**
  46990. * Enables teleportation
  46991. */
  46992. teleportation: WebXRMotionControllerTeleportation;
  46993. private constructor();
  46994. /**
  46995. * Creates the default xr experience
  46996. * @param scene scene
  46997. * @param options options for basic configuration
  46998. * @returns resulting WebXRDefaultExperience
  46999. */
  47000. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47001. /**
  47002. * DIsposes of the experience helper
  47003. */
  47004. dispose(): void;
  47005. }
  47006. }
  47007. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47008. import { Observable } from "babylonjs/Misc/observable";
  47009. import { Nullable } from "babylonjs/types";
  47010. import { Camera } from "babylonjs/Cameras/camera";
  47011. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47012. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47013. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47014. import { Scene } from "babylonjs/scene";
  47015. import { Vector3 } from "babylonjs/Maths/math.vector";
  47016. import { Color3 } from "babylonjs/Maths/math.color";
  47017. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47019. import { Mesh } from "babylonjs/Meshes/mesh";
  47020. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47021. import { EasingFunction } from "babylonjs/Animations/easing";
  47022. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47023. import "babylonjs/Meshes/Builders/groundBuilder";
  47024. import "babylonjs/Meshes/Builders/torusBuilder";
  47025. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47026. import "babylonjs/Gamepads/gamepadSceneComponent";
  47027. import "babylonjs/Animations/animatable";
  47028. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47029. /**
  47030. * Options to modify the vr teleportation behavior.
  47031. */
  47032. export interface VRTeleportationOptions {
  47033. /**
  47034. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47035. */
  47036. floorMeshName?: string;
  47037. /**
  47038. * A list of meshes to be used as the teleportation floor. (default: empty)
  47039. */
  47040. floorMeshes?: Mesh[];
  47041. /**
  47042. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47043. */
  47044. teleportationMode?: number;
  47045. /**
  47046. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47047. */
  47048. teleportationTime?: number;
  47049. /**
  47050. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47051. */
  47052. teleportationSpeed?: number;
  47053. /**
  47054. * The easing function used in the animation or null for Linear. (default CircleEase)
  47055. */
  47056. easingFunction?: EasingFunction;
  47057. }
  47058. /**
  47059. * Options to modify the vr experience helper's behavior.
  47060. */
  47061. export interface VRExperienceHelperOptions extends WebVROptions {
  47062. /**
  47063. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47064. */
  47065. createDeviceOrientationCamera?: boolean;
  47066. /**
  47067. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47068. */
  47069. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47070. /**
  47071. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47072. */
  47073. laserToggle?: boolean;
  47074. /**
  47075. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47076. */
  47077. floorMeshes?: Mesh[];
  47078. /**
  47079. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47080. */
  47081. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47082. /**
  47083. * Defines if WebXR should be used instead of WebVR (if available)
  47084. */
  47085. useXR?: boolean;
  47086. }
  47087. /**
  47088. * Event containing information after VR has been entered
  47089. */
  47090. export class OnAfterEnteringVRObservableEvent {
  47091. /**
  47092. * If entering vr was successful
  47093. */
  47094. success: boolean;
  47095. }
  47096. /**
  47097. * Helps to quickly add VR support to an existing scene.
  47098. * See http://doc.babylonjs.com/how_to/webvr_helper
  47099. */
  47100. export class VRExperienceHelper {
  47101. /** Options to modify the vr experience helper's behavior. */
  47102. webVROptions: VRExperienceHelperOptions;
  47103. private _scene;
  47104. private _position;
  47105. private _btnVR;
  47106. private _btnVRDisplayed;
  47107. private _webVRsupported;
  47108. private _webVRready;
  47109. private _webVRrequesting;
  47110. private _webVRpresenting;
  47111. private _hasEnteredVR;
  47112. private _fullscreenVRpresenting;
  47113. private _inputElement;
  47114. private _webVRCamera;
  47115. private _vrDeviceOrientationCamera;
  47116. private _deviceOrientationCamera;
  47117. private _existingCamera;
  47118. private _onKeyDown;
  47119. private _onVrDisplayPresentChange;
  47120. private _onVRDisplayChanged;
  47121. private _onVRRequestPresentStart;
  47122. private _onVRRequestPresentComplete;
  47123. /**
  47124. * 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)
  47125. */
  47126. enableGazeEvenWhenNoPointerLock: boolean;
  47127. /**
  47128. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47129. */
  47130. exitVROnDoubleTap: boolean;
  47131. /**
  47132. * Observable raised right before entering VR.
  47133. */
  47134. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47135. /**
  47136. * Observable raised when entering VR has completed.
  47137. */
  47138. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47139. /**
  47140. * Observable raised when exiting VR.
  47141. */
  47142. onExitingVRObservable: Observable<VRExperienceHelper>;
  47143. /**
  47144. * Observable raised when controller mesh is loaded.
  47145. */
  47146. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47147. /** Return this.onEnteringVRObservable
  47148. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47149. */
  47150. get onEnteringVR(): Observable<VRExperienceHelper>;
  47151. /** Return this.onExitingVRObservable
  47152. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47153. */
  47154. get onExitingVR(): Observable<VRExperienceHelper>;
  47155. /** Return this.onControllerMeshLoadedObservable
  47156. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47157. */
  47158. get onControllerMeshLoaded(): Observable<WebVRController>;
  47159. private _rayLength;
  47160. private _useCustomVRButton;
  47161. private _teleportationRequested;
  47162. private _teleportActive;
  47163. private _floorMeshName;
  47164. private _floorMeshesCollection;
  47165. private _teleportationMode;
  47166. private _teleportationTime;
  47167. private _teleportationSpeed;
  47168. private _teleportationEasing;
  47169. private _rotationAllowed;
  47170. private _teleportBackwardsVector;
  47171. private _teleportationTarget;
  47172. private _isDefaultTeleportationTarget;
  47173. private _postProcessMove;
  47174. private _teleportationFillColor;
  47175. private _teleportationBorderColor;
  47176. private _rotationAngle;
  47177. private _haloCenter;
  47178. private _cameraGazer;
  47179. private _padSensibilityUp;
  47180. private _padSensibilityDown;
  47181. private _leftController;
  47182. private _rightController;
  47183. private _gazeColor;
  47184. private _laserColor;
  47185. private _pickedLaserColor;
  47186. private _pickedGazeColor;
  47187. /**
  47188. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47189. */
  47190. onNewMeshSelected: Observable<AbstractMesh>;
  47191. /**
  47192. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47193. * This observable will provide the mesh and the controller used to select the mesh
  47194. */
  47195. onMeshSelectedWithController: Observable<{
  47196. mesh: AbstractMesh;
  47197. controller: WebVRController;
  47198. }>;
  47199. /**
  47200. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47201. */
  47202. onNewMeshPicked: Observable<PickingInfo>;
  47203. private _circleEase;
  47204. /**
  47205. * Observable raised before camera teleportation
  47206. */
  47207. onBeforeCameraTeleport: Observable<Vector3>;
  47208. /**
  47209. * Observable raised after camera teleportation
  47210. */
  47211. onAfterCameraTeleport: Observable<Vector3>;
  47212. /**
  47213. * Observable raised when current selected mesh gets unselected
  47214. */
  47215. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47216. private _raySelectionPredicate;
  47217. /**
  47218. * To be optionaly changed by user to define custom ray selection
  47219. */
  47220. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47221. /**
  47222. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47223. */
  47224. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47225. /**
  47226. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47227. */
  47228. teleportationEnabled: boolean;
  47229. private _defaultHeight;
  47230. private _teleportationInitialized;
  47231. private _interactionsEnabled;
  47232. private _interactionsRequested;
  47233. private _displayGaze;
  47234. private _displayLaserPointer;
  47235. /**
  47236. * The mesh used to display where the user is going to teleport.
  47237. */
  47238. get teleportationTarget(): Mesh;
  47239. /**
  47240. * Sets the mesh to be used to display where the user is going to teleport.
  47241. */
  47242. set teleportationTarget(value: Mesh);
  47243. /**
  47244. * 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
  47245. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47246. * See http://doc.babylonjs.com/resources/baking_transformations
  47247. */
  47248. get gazeTrackerMesh(): Mesh;
  47249. set gazeTrackerMesh(value: Mesh);
  47250. /**
  47251. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47252. */
  47253. updateGazeTrackerScale: boolean;
  47254. /**
  47255. * If the gaze trackers color should be updated when selecting meshes
  47256. */
  47257. updateGazeTrackerColor: boolean;
  47258. /**
  47259. * If the controller laser color should be updated when selecting meshes
  47260. */
  47261. updateControllerLaserColor: boolean;
  47262. /**
  47263. * The gaze tracking mesh corresponding to the left controller
  47264. */
  47265. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47266. /**
  47267. * The gaze tracking mesh corresponding to the right controller
  47268. */
  47269. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47270. /**
  47271. * If the ray of the gaze should be displayed.
  47272. */
  47273. get displayGaze(): boolean;
  47274. /**
  47275. * Sets if the ray of the gaze should be displayed.
  47276. */
  47277. set displayGaze(value: boolean);
  47278. /**
  47279. * If the ray of the LaserPointer should be displayed.
  47280. */
  47281. get displayLaserPointer(): boolean;
  47282. /**
  47283. * Sets if the ray of the LaserPointer should be displayed.
  47284. */
  47285. set displayLaserPointer(value: boolean);
  47286. /**
  47287. * The deviceOrientationCamera used as the camera when not in VR.
  47288. */
  47289. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47290. /**
  47291. * Based on the current WebVR support, returns the current VR camera used.
  47292. */
  47293. get currentVRCamera(): Nullable<Camera>;
  47294. /**
  47295. * The webVRCamera which is used when in VR.
  47296. */
  47297. get webVRCamera(): WebVRFreeCamera;
  47298. /**
  47299. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47300. */
  47301. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47302. /**
  47303. * The html button that is used to trigger entering into VR.
  47304. */
  47305. get vrButton(): Nullable<HTMLButtonElement>;
  47306. private get _teleportationRequestInitiated();
  47307. /**
  47308. * Defines whether or not Pointer lock should be requested when switching to
  47309. * full screen.
  47310. */
  47311. requestPointerLockOnFullScreen: boolean;
  47312. /**
  47313. * If asking to force XR, this will be populated with the default xr experience
  47314. */
  47315. xr: WebXRDefaultExperience;
  47316. /**
  47317. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47318. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47319. */
  47320. xrTestDone: boolean;
  47321. /**
  47322. * Instantiates a VRExperienceHelper.
  47323. * Helps to quickly add VR support to an existing scene.
  47324. * @param scene The scene the VRExperienceHelper belongs to.
  47325. * @param webVROptions Options to modify the vr experience helper's behavior.
  47326. */
  47327. constructor(scene: Scene,
  47328. /** Options to modify the vr experience helper's behavior. */
  47329. webVROptions?: VRExperienceHelperOptions);
  47330. private completeVRInit;
  47331. private _onDefaultMeshLoaded;
  47332. private _onResize;
  47333. private _onFullscreenChange;
  47334. /**
  47335. * Gets a value indicating if we are currently in VR mode.
  47336. */
  47337. get isInVRMode(): boolean;
  47338. private onVrDisplayPresentChange;
  47339. private onVRDisplayChanged;
  47340. private moveButtonToBottomRight;
  47341. private displayVRButton;
  47342. private updateButtonVisibility;
  47343. private _cachedAngularSensibility;
  47344. /**
  47345. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47346. * Otherwise, will use the fullscreen API.
  47347. */
  47348. enterVR(): void;
  47349. /**
  47350. * Attempt to exit VR, or fullscreen.
  47351. */
  47352. exitVR(): void;
  47353. /**
  47354. * The position of the vr experience helper.
  47355. */
  47356. get position(): Vector3;
  47357. /**
  47358. * Sets the position of the vr experience helper.
  47359. */
  47360. set position(value: Vector3);
  47361. /**
  47362. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47363. */
  47364. enableInteractions(): void;
  47365. private get _noControllerIsActive();
  47366. private beforeRender;
  47367. private _isTeleportationFloor;
  47368. /**
  47369. * Adds a floor mesh to be used for teleportation.
  47370. * @param floorMesh the mesh to be used for teleportation.
  47371. */
  47372. addFloorMesh(floorMesh: Mesh): void;
  47373. /**
  47374. * Removes a floor mesh from being used for teleportation.
  47375. * @param floorMesh the mesh to be removed.
  47376. */
  47377. removeFloorMesh(floorMesh: Mesh): void;
  47378. /**
  47379. * Enables interactions and teleportation using the VR controllers and gaze.
  47380. * @param vrTeleportationOptions options to modify teleportation behavior.
  47381. */
  47382. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47383. private _onNewGamepadConnected;
  47384. private _tryEnableInteractionOnController;
  47385. private _onNewGamepadDisconnected;
  47386. private _enableInteractionOnController;
  47387. private _checkTeleportWithRay;
  47388. private _checkRotate;
  47389. private _checkTeleportBackwards;
  47390. private _enableTeleportationOnController;
  47391. private _createTeleportationCircles;
  47392. private _displayTeleportationTarget;
  47393. private _hideTeleportationTarget;
  47394. private _rotateCamera;
  47395. private _moveTeleportationSelectorTo;
  47396. private _workingVector;
  47397. private _workingQuaternion;
  47398. private _workingMatrix;
  47399. /**
  47400. * Time Constant Teleportation Mode
  47401. */
  47402. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47403. /**
  47404. * Speed Constant Teleportation Mode
  47405. */
  47406. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47407. /**
  47408. * Teleports the users feet to the desired location
  47409. * @param location The location where the user's feet should be placed
  47410. */
  47411. teleportCamera(location: Vector3): void;
  47412. private _convertNormalToDirectionOfRay;
  47413. private _castRayAndSelectObject;
  47414. private _notifySelectedMeshUnselected;
  47415. /**
  47416. * Permanently set new colors for the laser pointer
  47417. * @param color the new laser color
  47418. * @param pickedColor the new laser color when picked mesh detected
  47419. */
  47420. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47421. /**
  47422. * Set lighting enabled / disabled on the laser pointer of both controllers
  47423. * @param enabled should the lighting be enabled on the laser pointer
  47424. */
  47425. setLaserLightingState(enabled?: boolean): void;
  47426. /**
  47427. * Permanently set new colors for the gaze pointer
  47428. * @param color the new gaze color
  47429. * @param pickedColor the new gaze color when picked mesh detected
  47430. */
  47431. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47432. /**
  47433. * Sets the color of the laser ray from the vr controllers.
  47434. * @param color new color for the ray.
  47435. */
  47436. changeLaserColor(color: Color3): void;
  47437. /**
  47438. * Sets the color of the ray from the vr headsets gaze.
  47439. * @param color new color for the ray.
  47440. */
  47441. changeGazeColor(color: Color3): void;
  47442. /**
  47443. * Exits VR and disposes of the vr experience helper
  47444. */
  47445. dispose(): void;
  47446. /**
  47447. * Gets the name of the VRExperienceHelper class
  47448. * @returns "VRExperienceHelper"
  47449. */
  47450. getClassName(): string;
  47451. }
  47452. }
  47453. declare module "babylonjs/Cameras/VR/index" {
  47454. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47455. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47456. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47457. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47458. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47459. export * from "babylonjs/Cameras/VR/webVRCamera";
  47460. }
  47461. declare module "babylonjs/Cameras/RigModes/index" {
  47462. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47463. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47464. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47465. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47466. }
  47467. declare module "babylonjs/Cameras/index" {
  47468. export * from "babylonjs/Cameras/Inputs/index";
  47469. export * from "babylonjs/Cameras/cameraInputsManager";
  47470. export * from "babylonjs/Cameras/camera";
  47471. export * from "babylonjs/Cameras/targetCamera";
  47472. export * from "babylonjs/Cameras/freeCamera";
  47473. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47474. export * from "babylonjs/Cameras/touchCamera";
  47475. export * from "babylonjs/Cameras/arcRotateCamera";
  47476. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47477. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47478. export * from "babylonjs/Cameras/flyCamera";
  47479. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47480. export * from "babylonjs/Cameras/followCamera";
  47481. export * from "babylonjs/Cameras/followCameraInputsManager";
  47482. export * from "babylonjs/Cameras/gamepadCamera";
  47483. export * from "babylonjs/Cameras/Stereoscopic/index";
  47484. export * from "babylonjs/Cameras/universalCamera";
  47485. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47486. export * from "babylonjs/Cameras/VR/index";
  47487. export * from "babylonjs/Cameras/RigModes/index";
  47488. }
  47489. declare module "babylonjs/Collisions/index" {
  47490. export * from "babylonjs/Collisions/collider";
  47491. export * from "babylonjs/Collisions/collisionCoordinator";
  47492. export * from "babylonjs/Collisions/pickingInfo";
  47493. export * from "babylonjs/Collisions/intersectionInfo";
  47494. export * from "babylonjs/Collisions/meshCollisionData";
  47495. }
  47496. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47497. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47498. import { Vector3 } from "babylonjs/Maths/math.vector";
  47499. import { Ray } from "babylonjs/Culling/ray";
  47500. import { Plane } from "babylonjs/Maths/math.plane";
  47501. /**
  47502. * Contains an array of blocks representing the octree
  47503. */
  47504. export interface IOctreeContainer<T> {
  47505. /**
  47506. * Blocks within the octree
  47507. */
  47508. blocks: Array<OctreeBlock<T>>;
  47509. }
  47510. /**
  47511. * Class used to store a cell in an octree
  47512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47513. */
  47514. export class OctreeBlock<T> {
  47515. /**
  47516. * Gets the content of the current block
  47517. */
  47518. entries: T[];
  47519. /**
  47520. * Gets the list of block children
  47521. */
  47522. blocks: Array<OctreeBlock<T>>;
  47523. private _depth;
  47524. private _maxDepth;
  47525. private _capacity;
  47526. private _minPoint;
  47527. private _maxPoint;
  47528. private _boundingVectors;
  47529. private _creationFunc;
  47530. /**
  47531. * Creates a new block
  47532. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47533. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47534. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47535. * @param depth defines the current depth of this block in the octree
  47536. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47537. * @param creationFunc defines a callback to call when an element is added to the block
  47538. */
  47539. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47540. /**
  47541. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47542. */
  47543. get capacity(): number;
  47544. /**
  47545. * Gets the minimum vector (in world space) of the block's bounding box
  47546. */
  47547. get minPoint(): Vector3;
  47548. /**
  47549. * Gets the maximum vector (in world space) of the block's bounding box
  47550. */
  47551. get maxPoint(): Vector3;
  47552. /**
  47553. * Add a new element to this block
  47554. * @param entry defines the element to add
  47555. */
  47556. addEntry(entry: T): void;
  47557. /**
  47558. * Remove an element from this block
  47559. * @param entry defines the element to remove
  47560. */
  47561. removeEntry(entry: T): void;
  47562. /**
  47563. * Add an array of elements to this block
  47564. * @param entries defines the array of elements to add
  47565. */
  47566. addEntries(entries: T[]): void;
  47567. /**
  47568. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47569. * @param frustumPlanes defines the frustum planes to test
  47570. * @param selection defines the array to store current content if selection is positive
  47571. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47572. */
  47573. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47574. /**
  47575. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47576. * @param sphereCenter defines the bounding sphere center
  47577. * @param sphereRadius defines the bounding sphere radius
  47578. * @param selection defines the array to store current content if selection is positive
  47579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47580. */
  47581. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47582. /**
  47583. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47584. * @param ray defines the ray to test with
  47585. * @param selection defines the array to store current content if selection is positive
  47586. */
  47587. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47588. /**
  47589. * Subdivide the content into child blocks (this block will then be empty)
  47590. */
  47591. createInnerBlocks(): void;
  47592. /**
  47593. * @hidden
  47594. */
  47595. 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;
  47596. }
  47597. }
  47598. declare module "babylonjs/Culling/Octrees/octree" {
  47599. import { SmartArray } from "babylonjs/Misc/smartArray";
  47600. import { Vector3 } from "babylonjs/Maths/math.vector";
  47601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47603. import { Ray } from "babylonjs/Culling/ray";
  47604. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47605. import { Plane } from "babylonjs/Maths/math.plane";
  47606. /**
  47607. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47608. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47609. */
  47610. export class Octree<T> {
  47611. /** 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.) */
  47612. maxDepth: number;
  47613. /**
  47614. * Blocks within the octree containing objects
  47615. */
  47616. blocks: Array<OctreeBlock<T>>;
  47617. /**
  47618. * Content stored in the octree
  47619. */
  47620. dynamicContent: T[];
  47621. private _maxBlockCapacity;
  47622. private _selectionContent;
  47623. private _creationFunc;
  47624. /**
  47625. * Creates a octree
  47626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47627. * @param creationFunc function to be used to instatiate the octree
  47628. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47629. * @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.)
  47630. */
  47631. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47632. /** 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.) */
  47633. maxDepth?: number);
  47634. /**
  47635. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47636. * @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);
  47637. * @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);
  47638. * @param entries meshes to be added to the octree blocks
  47639. */
  47640. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47641. /**
  47642. * Adds a mesh to the octree
  47643. * @param entry Mesh to add to the octree
  47644. */
  47645. addMesh(entry: T): void;
  47646. /**
  47647. * Remove an element from the octree
  47648. * @param entry defines the element to remove
  47649. */
  47650. removeMesh(entry: T): void;
  47651. /**
  47652. * Selects an array of meshes within the frustum
  47653. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47654. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47655. * @returns array of meshes within the frustum
  47656. */
  47657. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47658. /**
  47659. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47660. * @param sphereCenter defines the bounding sphere center
  47661. * @param sphereRadius defines the bounding sphere radius
  47662. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47663. * @returns an array of objects that intersect the sphere
  47664. */
  47665. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47666. /**
  47667. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47668. * @param ray defines the ray to test with
  47669. * @returns array of intersected objects
  47670. */
  47671. intersectsRay(ray: Ray): SmartArray<T>;
  47672. /**
  47673. * Adds a mesh into the octree block if it intersects the block
  47674. */
  47675. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47676. /**
  47677. * Adds a submesh into the octree block if it intersects the block
  47678. */
  47679. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47680. }
  47681. }
  47682. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47683. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47684. import { Scene } from "babylonjs/scene";
  47685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47687. import { Ray } from "babylonjs/Culling/ray";
  47688. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47689. import { Collider } from "babylonjs/Collisions/collider";
  47690. module "babylonjs/scene" {
  47691. interface Scene {
  47692. /**
  47693. * @hidden
  47694. * Backing Filed
  47695. */
  47696. _selectionOctree: Octree<AbstractMesh>;
  47697. /**
  47698. * Gets the octree used to boost mesh selection (picking)
  47699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47700. */
  47701. selectionOctree: Octree<AbstractMesh>;
  47702. /**
  47703. * Creates or updates the octree used to boost selection (picking)
  47704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47705. * @param maxCapacity defines the maximum capacity per leaf
  47706. * @param maxDepth defines the maximum depth of the octree
  47707. * @returns an octree of AbstractMesh
  47708. */
  47709. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47710. }
  47711. }
  47712. module "babylonjs/Meshes/abstractMesh" {
  47713. interface AbstractMesh {
  47714. /**
  47715. * @hidden
  47716. * Backing Field
  47717. */
  47718. _submeshesOctree: Octree<SubMesh>;
  47719. /**
  47720. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47721. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47722. * @param maxCapacity defines the maximum size of each block (64 by default)
  47723. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47724. * @returns the new octree
  47725. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47727. */
  47728. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47729. }
  47730. }
  47731. /**
  47732. * Defines the octree scene component responsible to manage any octrees
  47733. * in a given scene.
  47734. */
  47735. export class OctreeSceneComponent {
  47736. /**
  47737. * The component name help to identify the component in the list of scene components.
  47738. */
  47739. readonly name: string;
  47740. /**
  47741. * The scene the component belongs to.
  47742. */
  47743. scene: Scene;
  47744. /**
  47745. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47746. */
  47747. readonly checksIsEnabled: boolean;
  47748. /**
  47749. * Creates a new instance of the component for the given scene
  47750. * @param scene Defines the scene to register the component in
  47751. */
  47752. constructor(scene: Scene);
  47753. /**
  47754. * Registers the component in a given scene
  47755. */
  47756. register(): void;
  47757. /**
  47758. * Return the list of active meshes
  47759. * @returns the list of active meshes
  47760. */
  47761. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47762. /**
  47763. * Return the list of active sub meshes
  47764. * @param mesh The mesh to get the candidates sub meshes from
  47765. * @returns the list of active sub meshes
  47766. */
  47767. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47768. private _tempRay;
  47769. /**
  47770. * Return the list of sub meshes intersecting with a given local ray
  47771. * @param mesh defines the mesh to find the submesh for
  47772. * @param localRay defines the ray in local space
  47773. * @returns the list of intersecting sub meshes
  47774. */
  47775. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47776. /**
  47777. * Return the list of sub meshes colliding with a collider
  47778. * @param mesh defines the mesh to find the submesh for
  47779. * @param collider defines the collider to evaluate the collision against
  47780. * @returns the list of colliding sub meshes
  47781. */
  47782. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47783. /**
  47784. * Rebuilds the elements related to this component in case of
  47785. * context lost for instance.
  47786. */
  47787. rebuild(): void;
  47788. /**
  47789. * Disposes the component and the associated ressources.
  47790. */
  47791. dispose(): void;
  47792. }
  47793. }
  47794. declare module "babylonjs/Culling/Octrees/index" {
  47795. export * from "babylonjs/Culling/Octrees/octree";
  47796. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47797. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47798. }
  47799. declare module "babylonjs/Culling/index" {
  47800. export * from "babylonjs/Culling/boundingBox";
  47801. export * from "babylonjs/Culling/boundingInfo";
  47802. export * from "babylonjs/Culling/boundingSphere";
  47803. export * from "babylonjs/Culling/Octrees/index";
  47804. export * from "babylonjs/Culling/ray";
  47805. }
  47806. declare module "babylonjs/Gizmos/gizmo" {
  47807. import { Nullable } from "babylonjs/types";
  47808. import { IDisposable } from "babylonjs/scene";
  47809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47810. import { Mesh } from "babylonjs/Meshes/mesh";
  47811. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47812. /**
  47813. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47814. */
  47815. export class Gizmo implements IDisposable {
  47816. /** The utility layer the gizmo will be added to */
  47817. gizmoLayer: UtilityLayerRenderer;
  47818. /**
  47819. * The root mesh of the gizmo
  47820. */
  47821. _rootMesh: Mesh;
  47822. private _attachedMesh;
  47823. /**
  47824. * Ratio for the scale of the gizmo (Default: 1)
  47825. */
  47826. scaleRatio: number;
  47827. /**
  47828. * If a custom mesh has been set (Default: false)
  47829. */
  47830. protected _customMeshSet: boolean;
  47831. /**
  47832. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47833. * * When set, interactions will be enabled
  47834. */
  47835. get attachedMesh(): Nullable<AbstractMesh>;
  47836. set attachedMesh(value: Nullable<AbstractMesh>);
  47837. /**
  47838. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47839. * @param mesh The mesh to replace the default mesh of the gizmo
  47840. */
  47841. setCustomMesh(mesh: Mesh): void;
  47842. /**
  47843. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47844. */
  47845. updateGizmoRotationToMatchAttachedMesh: boolean;
  47846. /**
  47847. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47848. */
  47849. updateGizmoPositionToMatchAttachedMesh: boolean;
  47850. /**
  47851. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47852. */
  47853. updateScale: boolean;
  47854. protected _interactionsEnabled: boolean;
  47855. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47856. private _beforeRenderObserver;
  47857. private _tempVector;
  47858. /**
  47859. * Creates a gizmo
  47860. * @param gizmoLayer The utility layer the gizmo will be added to
  47861. */
  47862. constructor(
  47863. /** The utility layer the gizmo will be added to */
  47864. gizmoLayer?: UtilityLayerRenderer);
  47865. /**
  47866. * Updates the gizmo to match the attached mesh's position/rotation
  47867. */
  47868. protected _update(): void;
  47869. /**
  47870. * Disposes of the gizmo
  47871. */
  47872. dispose(): void;
  47873. }
  47874. }
  47875. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47876. import { Observable } from "babylonjs/Misc/observable";
  47877. import { Nullable } from "babylonjs/types";
  47878. import { Vector3 } from "babylonjs/Maths/math.vector";
  47879. import { Color3 } from "babylonjs/Maths/math.color";
  47880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47882. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47885. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47886. import { Scene } from "babylonjs/scene";
  47887. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47888. /**
  47889. * Single plane drag gizmo
  47890. */
  47891. export class PlaneDragGizmo extends Gizmo {
  47892. /**
  47893. * Drag behavior responsible for the gizmos dragging interactions
  47894. */
  47895. dragBehavior: PointerDragBehavior;
  47896. private _pointerObserver;
  47897. /**
  47898. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47899. */
  47900. snapDistance: number;
  47901. /**
  47902. * Event that fires each time the gizmo snaps to a new location.
  47903. * * snapDistance is the the change in distance
  47904. */
  47905. onSnapObservable: Observable<{
  47906. snapDistance: number;
  47907. }>;
  47908. private _plane;
  47909. private _coloredMaterial;
  47910. private _hoverMaterial;
  47911. private _isEnabled;
  47912. private _parent;
  47913. /** @hidden */
  47914. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47915. /** @hidden */
  47916. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47917. /**
  47918. * Creates a PlaneDragGizmo
  47919. * @param gizmoLayer The utility layer the gizmo will be added to
  47920. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47921. * @param color The color of the gizmo
  47922. */
  47923. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47925. /**
  47926. * If the gizmo is enabled
  47927. */
  47928. set isEnabled(value: boolean);
  47929. get isEnabled(): boolean;
  47930. /**
  47931. * Disposes of the gizmo
  47932. */
  47933. dispose(): void;
  47934. }
  47935. }
  47936. declare module "babylonjs/Gizmos/positionGizmo" {
  47937. import { Observable } from "babylonjs/Misc/observable";
  47938. import { Nullable } from "babylonjs/types";
  47939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47940. import { Mesh } from "babylonjs/Meshes/mesh";
  47941. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47942. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47943. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47944. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47945. /**
  47946. * Gizmo that enables dragging a mesh along 3 axis
  47947. */
  47948. export class PositionGizmo extends Gizmo {
  47949. /**
  47950. * Internal gizmo used for interactions on the x axis
  47951. */
  47952. xGizmo: AxisDragGizmo;
  47953. /**
  47954. * Internal gizmo used for interactions on the y axis
  47955. */
  47956. yGizmo: AxisDragGizmo;
  47957. /**
  47958. * Internal gizmo used for interactions on the z axis
  47959. */
  47960. zGizmo: AxisDragGizmo;
  47961. /**
  47962. * Internal gizmo used for interactions on the yz plane
  47963. */
  47964. xPlaneGizmo: PlaneDragGizmo;
  47965. /**
  47966. * Internal gizmo used for interactions on the xz plane
  47967. */
  47968. yPlaneGizmo: PlaneDragGizmo;
  47969. /**
  47970. * Internal gizmo used for interactions on the xy plane
  47971. */
  47972. zPlaneGizmo: PlaneDragGizmo;
  47973. /**
  47974. * private variables
  47975. */
  47976. private _meshAttached;
  47977. private _updateGizmoRotationToMatchAttachedMesh;
  47978. private _snapDistance;
  47979. private _scaleRatio;
  47980. /** Fires an event when any of it's sub gizmos are dragged */
  47981. onDragStartObservable: Observable<unknown>;
  47982. /** Fires an event when any of it's sub gizmos are released from dragging */
  47983. onDragEndObservable: Observable<unknown>;
  47984. /**
  47985. * If set to true, planar drag is enabled
  47986. */
  47987. private _planarGizmoEnabled;
  47988. get attachedMesh(): Nullable<AbstractMesh>;
  47989. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47990. /**
  47991. * Creates a PositionGizmo
  47992. * @param gizmoLayer The utility layer the gizmo will be added to
  47993. */
  47994. constructor(gizmoLayer?: UtilityLayerRenderer);
  47995. /**
  47996. * If the planar drag gizmo is enabled
  47997. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47998. */
  47999. set planarGizmoEnabled(value: boolean);
  48000. get planarGizmoEnabled(): boolean;
  48001. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48002. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48003. /**
  48004. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48005. */
  48006. set snapDistance(value: number);
  48007. get snapDistance(): number;
  48008. /**
  48009. * Ratio for the scale of the gizmo (Default: 1)
  48010. */
  48011. set scaleRatio(value: number);
  48012. get scaleRatio(): number;
  48013. /**
  48014. * Disposes of the gizmo
  48015. */
  48016. dispose(): void;
  48017. /**
  48018. * CustomMeshes are not supported by this gizmo
  48019. * @param mesh The mesh to replace the default mesh of the gizmo
  48020. */
  48021. setCustomMesh(mesh: Mesh): void;
  48022. }
  48023. }
  48024. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48025. import { Observable } from "babylonjs/Misc/observable";
  48026. import { Nullable } from "babylonjs/types";
  48027. import { Vector3 } from "babylonjs/Maths/math.vector";
  48028. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48030. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48031. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48032. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48033. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48034. import { Scene } from "babylonjs/scene";
  48035. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48036. import { Color3 } from "babylonjs/Maths/math.color";
  48037. /**
  48038. * Single axis drag gizmo
  48039. */
  48040. export class AxisDragGizmo extends Gizmo {
  48041. /**
  48042. * Drag behavior responsible for the gizmos dragging interactions
  48043. */
  48044. dragBehavior: PointerDragBehavior;
  48045. private _pointerObserver;
  48046. /**
  48047. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48048. */
  48049. snapDistance: number;
  48050. /**
  48051. * Event that fires each time the gizmo snaps to a new location.
  48052. * * snapDistance is the the change in distance
  48053. */
  48054. onSnapObservable: Observable<{
  48055. snapDistance: number;
  48056. }>;
  48057. private _isEnabled;
  48058. private _parent;
  48059. private _arrow;
  48060. private _coloredMaterial;
  48061. private _hoverMaterial;
  48062. /** @hidden */
  48063. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48064. /** @hidden */
  48065. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48066. /**
  48067. * Creates an AxisDragGizmo
  48068. * @param gizmoLayer The utility layer the gizmo will be added to
  48069. * @param dragAxis The axis which the gizmo will be able to drag on
  48070. * @param color The color of the gizmo
  48071. */
  48072. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48073. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48074. /**
  48075. * If the gizmo is enabled
  48076. */
  48077. set isEnabled(value: boolean);
  48078. get isEnabled(): boolean;
  48079. /**
  48080. * Disposes of the gizmo
  48081. */
  48082. dispose(): void;
  48083. }
  48084. }
  48085. declare module "babylonjs/Debug/axesViewer" {
  48086. import { Vector3 } from "babylonjs/Maths/math.vector";
  48087. import { Nullable } from "babylonjs/types";
  48088. import { Scene } from "babylonjs/scene";
  48089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48090. /**
  48091. * The Axes viewer will show 3 axes in a specific point in space
  48092. */
  48093. export class AxesViewer {
  48094. private _xAxis;
  48095. private _yAxis;
  48096. private _zAxis;
  48097. private _scaleLinesFactor;
  48098. private _instanced;
  48099. /**
  48100. * Gets the hosting scene
  48101. */
  48102. scene: Scene;
  48103. /**
  48104. * Gets or sets a number used to scale line length
  48105. */
  48106. scaleLines: number;
  48107. /** Gets the node hierarchy used to render x-axis */
  48108. get xAxis(): TransformNode;
  48109. /** Gets the node hierarchy used to render y-axis */
  48110. get yAxis(): TransformNode;
  48111. /** Gets the node hierarchy used to render z-axis */
  48112. get zAxis(): TransformNode;
  48113. /**
  48114. * Creates a new AxesViewer
  48115. * @param scene defines the hosting scene
  48116. * @param scaleLines defines a number used to scale line length (1 by default)
  48117. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48118. * @param xAxis defines the node hierarchy used to render the x-axis
  48119. * @param yAxis defines the node hierarchy used to render the y-axis
  48120. * @param zAxis defines the node hierarchy used to render the z-axis
  48121. */
  48122. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48123. /**
  48124. * Force the viewer to update
  48125. * @param position defines the position of the viewer
  48126. * @param xaxis defines the x axis of the viewer
  48127. * @param yaxis defines the y axis of the viewer
  48128. * @param zaxis defines the z axis of the viewer
  48129. */
  48130. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48131. /**
  48132. * Creates an instance of this axes viewer.
  48133. * @returns a new axes viewer with instanced meshes
  48134. */
  48135. createInstance(): AxesViewer;
  48136. /** Releases resources */
  48137. dispose(): void;
  48138. private static _SetRenderingGroupId;
  48139. }
  48140. }
  48141. declare module "babylonjs/Debug/boneAxesViewer" {
  48142. import { Nullable } from "babylonjs/types";
  48143. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48144. import { Vector3 } from "babylonjs/Maths/math.vector";
  48145. import { Mesh } from "babylonjs/Meshes/mesh";
  48146. import { Bone } from "babylonjs/Bones/bone";
  48147. import { Scene } from "babylonjs/scene";
  48148. /**
  48149. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48150. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48151. */
  48152. export class BoneAxesViewer extends AxesViewer {
  48153. /**
  48154. * Gets or sets the target mesh where to display the axes viewer
  48155. */
  48156. mesh: Nullable<Mesh>;
  48157. /**
  48158. * Gets or sets the target bone where to display the axes viewer
  48159. */
  48160. bone: Nullable<Bone>;
  48161. /** Gets current position */
  48162. pos: Vector3;
  48163. /** Gets direction of X axis */
  48164. xaxis: Vector3;
  48165. /** Gets direction of Y axis */
  48166. yaxis: Vector3;
  48167. /** Gets direction of Z axis */
  48168. zaxis: Vector3;
  48169. /**
  48170. * Creates a new BoneAxesViewer
  48171. * @param scene defines the hosting scene
  48172. * @param bone defines the target bone
  48173. * @param mesh defines the target mesh
  48174. * @param scaleLines defines a scaling factor for line length (1 by default)
  48175. */
  48176. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48177. /**
  48178. * Force the viewer to update
  48179. */
  48180. update(): void;
  48181. /** Releases resources */
  48182. dispose(): void;
  48183. }
  48184. }
  48185. declare module "babylonjs/Debug/debugLayer" {
  48186. import { Scene } from "babylonjs/scene";
  48187. /**
  48188. * Interface used to define scene explorer extensibility option
  48189. */
  48190. export interface IExplorerExtensibilityOption {
  48191. /**
  48192. * Define the option label
  48193. */
  48194. label: string;
  48195. /**
  48196. * Defines the action to execute on click
  48197. */
  48198. action: (entity: any) => void;
  48199. }
  48200. /**
  48201. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48202. */
  48203. export interface IExplorerExtensibilityGroup {
  48204. /**
  48205. * Defines a predicate to test if a given type mut be extended
  48206. */
  48207. predicate: (entity: any) => boolean;
  48208. /**
  48209. * Gets the list of options added to a type
  48210. */
  48211. entries: IExplorerExtensibilityOption[];
  48212. }
  48213. /**
  48214. * Interface used to define the options to use to create the Inspector
  48215. */
  48216. export interface IInspectorOptions {
  48217. /**
  48218. * Display in overlay mode (default: false)
  48219. */
  48220. overlay?: boolean;
  48221. /**
  48222. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48223. */
  48224. globalRoot?: HTMLElement;
  48225. /**
  48226. * Display the Scene explorer
  48227. */
  48228. showExplorer?: boolean;
  48229. /**
  48230. * Display the property inspector
  48231. */
  48232. showInspector?: boolean;
  48233. /**
  48234. * Display in embed mode (both panes on the right)
  48235. */
  48236. embedMode?: boolean;
  48237. /**
  48238. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48239. */
  48240. handleResize?: boolean;
  48241. /**
  48242. * Allow the panes to popup (default: true)
  48243. */
  48244. enablePopup?: boolean;
  48245. /**
  48246. * Allow the panes to be closed by users (default: true)
  48247. */
  48248. enableClose?: boolean;
  48249. /**
  48250. * Optional list of extensibility entries
  48251. */
  48252. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48253. /**
  48254. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48255. */
  48256. inspectorURL?: string;
  48257. /**
  48258. * Optional initial tab (default to DebugLayerTab.Properties)
  48259. */
  48260. initialTab?: DebugLayerTab;
  48261. }
  48262. module "babylonjs/scene" {
  48263. interface Scene {
  48264. /**
  48265. * @hidden
  48266. * Backing field
  48267. */
  48268. _debugLayer: DebugLayer;
  48269. /**
  48270. * Gets the debug layer (aka Inspector) associated with the scene
  48271. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48272. */
  48273. debugLayer: DebugLayer;
  48274. }
  48275. }
  48276. /**
  48277. * Enum of inspector action tab
  48278. */
  48279. export enum DebugLayerTab {
  48280. /**
  48281. * Properties tag (default)
  48282. */
  48283. Properties = 0,
  48284. /**
  48285. * Debug tab
  48286. */
  48287. Debug = 1,
  48288. /**
  48289. * Statistics tab
  48290. */
  48291. Statistics = 2,
  48292. /**
  48293. * Tools tab
  48294. */
  48295. Tools = 3,
  48296. /**
  48297. * Settings tab
  48298. */
  48299. Settings = 4
  48300. }
  48301. /**
  48302. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48303. * what is happening in your scene
  48304. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48305. */
  48306. export class DebugLayer {
  48307. /**
  48308. * Define the url to get the inspector script from.
  48309. * By default it uses the babylonjs CDN.
  48310. * @ignoreNaming
  48311. */
  48312. static InspectorURL: string;
  48313. private _scene;
  48314. private BJSINSPECTOR;
  48315. private _onPropertyChangedObservable?;
  48316. /**
  48317. * Observable triggered when a property is changed through the inspector.
  48318. */
  48319. get onPropertyChangedObservable(): any;
  48320. /**
  48321. * Instantiates a new debug layer.
  48322. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48323. * what is happening in your scene
  48324. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48325. * @param scene Defines the scene to inspect
  48326. */
  48327. constructor(scene: Scene);
  48328. /** Creates the inspector window. */
  48329. private _createInspector;
  48330. /**
  48331. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48332. * @param entity defines the entity to select
  48333. * @param lineContainerTitle defines the specific block to highlight
  48334. */
  48335. select(entity: any, lineContainerTitle?: string): void;
  48336. /** Get the inspector from bundle or global */
  48337. private _getGlobalInspector;
  48338. /**
  48339. * Get if the inspector is visible or not.
  48340. * @returns true if visible otherwise, false
  48341. */
  48342. isVisible(): boolean;
  48343. /**
  48344. * Hide the inspector and close its window.
  48345. */
  48346. hide(): void;
  48347. /**
  48348. * Launch the debugLayer.
  48349. * @param config Define the configuration of the inspector
  48350. * @return a promise fulfilled when the debug layer is visible
  48351. */
  48352. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48353. }
  48354. }
  48355. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48356. import { Nullable } from "babylonjs/types";
  48357. import { Scene } from "babylonjs/scene";
  48358. import { Vector4 } from "babylonjs/Maths/math.vector";
  48359. import { Color4 } from "babylonjs/Maths/math.color";
  48360. import { Mesh } from "babylonjs/Meshes/mesh";
  48361. /**
  48362. * Class containing static functions to help procedurally build meshes
  48363. */
  48364. export class BoxBuilder {
  48365. /**
  48366. * Creates a box mesh
  48367. * * The parameter `size` sets the size (float) of each box side (default 1)
  48368. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48369. * * 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)
  48370. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48374. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48375. * @param name defines the name of the mesh
  48376. * @param options defines the options used to create the mesh
  48377. * @param scene defines the hosting scene
  48378. * @returns the box mesh
  48379. */
  48380. static CreateBox(name: string, options: {
  48381. size?: number;
  48382. width?: number;
  48383. height?: number;
  48384. depth?: number;
  48385. faceUV?: Vector4[];
  48386. faceColors?: Color4[];
  48387. sideOrientation?: number;
  48388. frontUVs?: Vector4;
  48389. backUVs?: Vector4;
  48390. wrap?: boolean;
  48391. topBaseAt?: number;
  48392. bottomBaseAt?: number;
  48393. updatable?: boolean;
  48394. }, scene?: Nullable<Scene>): Mesh;
  48395. }
  48396. }
  48397. declare module "babylonjs/Debug/physicsViewer" {
  48398. import { Nullable } from "babylonjs/types";
  48399. import { Scene } from "babylonjs/scene";
  48400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48401. import { Mesh } from "babylonjs/Meshes/mesh";
  48402. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48403. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48404. /**
  48405. * Used to show the physics impostor around the specific mesh
  48406. */
  48407. export class PhysicsViewer {
  48408. /** @hidden */
  48409. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48410. /** @hidden */
  48411. protected _meshes: Array<Nullable<AbstractMesh>>;
  48412. /** @hidden */
  48413. protected _scene: Nullable<Scene>;
  48414. /** @hidden */
  48415. protected _numMeshes: number;
  48416. /** @hidden */
  48417. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48418. private _renderFunction;
  48419. private _utilityLayer;
  48420. private _debugBoxMesh;
  48421. private _debugSphereMesh;
  48422. private _debugCylinderMesh;
  48423. private _debugMaterial;
  48424. private _debugMeshMeshes;
  48425. /**
  48426. * Creates a new PhysicsViewer
  48427. * @param scene defines the hosting scene
  48428. */
  48429. constructor(scene: Scene);
  48430. /** @hidden */
  48431. protected _updateDebugMeshes(): void;
  48432. /**
  48433. * Renders a specified physic impostor
  48434. * @param impostor defines the impostor to render
  48435. * @param targetMesh defines the mesh represented by the impostor
  48436. * @returns the new debug mesh used to render the impostor
  48437. */
  48438. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48439. /**
  48440. * Hides a specified physic impostor
  48441. * @param impostor defines the impostor to hide
  48442. */
  48443. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48444. private _getDebugMaterial;
  48445. private _getDebugBoxMesh;
  48446. private _getDebugSphereMesh;
  48447. private _getDebugCylinderMesh;
  48448. private _getDebugMeshMesh;
  48449. private _getDebugMesh;
  48450. /** Releases all resources */
  48451. dispose(): void;
  48452. }
  48453. }
  48454. declare module "babylonjs/Debug/rayHelper" {
  48455. import { Nullable } from "babylonjs/types";
  48456. import { Ray } from "babylonjs/Culling/ray";
  48457. import { Vector3 } from "babylonjs/Maths/math.vector";
  48458. import { Color3 } from "babylonjs/Maths/math.color";
  48459. import { Scene } from "babylonjs/scene";
  48460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48461. import "babylonjs/Meshes/Builders/linesBuilder";
  48462. /**
  48463. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48464. * in order to better appreciate the issue one might have.
  48465. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48466. */
  48467. export class RayHelper {
  48468. /**
  48469. * Defines the ray we are currently tryin to visualize.
  48470. */
  48471. ray: Nullable<Ray>;
  48472. private _renderPoints;
  48473. private _renderLine;
  48474. private _renderFunction;
  48475. private _scene;
  48476. private _updateToMeshFunction;
  48477. private _attachedToMesh;
  48478. private _meshSpaceDirection;
  48479. private _meshSpaceOrigin;
  48480. /**
  48481. * Helper function to create a colored helper in a scene in one line.
  48482. * @param ray Defines the ray we are currently tryin to visualize
  48483. * @param scene Defines the scene the ray is used in
  48484. * @param color Defines the color we want to see the ray in
  48485. * @returns The newly created ray helper.
  48486. */
  48487. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48488. /**
  48489. * Instantiate a new ray helper.
  48490. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48491. * in order to better appreciate the issue one might have.
  48492. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48493. * @param ray Defines the ray we are currently tryin to visualize
  48494. */
  48495. constructor(ray: Ray);
  48496. /**
  48497. * Shows the ray we are willing to debug.
  48498. * @param scene Defines the scene the ray needs to be rendered in
  48499. * @param color Defines the color the ray needs to be rendered in
  48500. */
  48501. show(scene: Scene, color?: Color3): void;
  48502. /**
  48503. * Hides the ray we are debugging.
  48504. */
  48505. hide(): void;
  48506. private _render;
  48507. /**
  48508. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48509. * @param mesh Defines the mesh we want the helper attached to
  48510. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48511. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48512. * @param length Defines the length of the ray
  48513. */
  48514. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48515. /**
  48516. * Detach the ray helper from the mesh it has previously been attached to.
  48517. */
  48518. detachFromMesh(): void;
  48519. private _updateToMesh;
  48520. /**
  48521. * Dispose the helper and release its associated resources.
  48522. */
  48523. dispose(): void;
  48524. }
  48525. }
  48526. declare module "babylonjs/Debug/skeletonViewer" {
  48527. import { Color3 } from "babylonjs/Maths/math.color";
  48528. import { Scene } from "babylonjs/scene";
  48529. import { Nullable } from "babylonjs/types";
  48530. import { Skeleton } from "babylonjs/Bones/skeleton";
  48531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48532. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48533. /**
  48534. * Class used to render a debug view of a given skeleton
  48535. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48536. */
  48537. export class SkeletonViewer {
  48538. /** defines the skeleton to render */
  48539. skeleton: Skeleton;
  48540. /** defines the mesh attached to the skeleton */
  48541. mesh: AbstractMesh;
  48542. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48543. autoUpdateBonesMatrices: boolean;
  48544. /** defines the rendering group id to use with the viewer */
  48545. renderingGroupId: number;
  48546. /** Gets or sets the color used to render the skeleton */
  48547. color: Color3;
  48548. private _scene;
  48549. private _debugLines;
  48550. private _debugMesh;
  48551. private _isEnabled;
  48552. private _renderFunction;
  48553. private _utilityLayer;
  48554. /**
  48555. * Returns the mesh used to render the bones
  48556. */
  48557. get debugMesh(): Nullable<LinesMesh>;
  48558. /**
  48559. * Creates a new SkeletonViewer
  48560. * @param skeleton defines the skeleton to render
  48561. * @param mesh defines the mesh attached to the skeleton
  48562. * @param scene defines the hosting scene
  48563. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48564. * @param renderingGroupId defines the rendering group id to use with the viewer
  48565. */
  48566. constructor(
  48567. /** defines the skeleton to render */
  48568. skeleton: Skeleton,
  48569. /** defines the mesh attached to the skeleton */
  48570. mesh: AbstractMesh, scene: Scene,
  48571. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48572. autoUpdateBonesMatrices?: boolean,
  48573. /** defines the rendering group id to use with the viewer */
  48574. renderingGroupId?: number);
  48575. /** Gets or sets a boolean indicating if the viewer is enabled */
  48576. set isEnabled(value: boolean);
  48577. get isEnabled(): boolean;
  48578. private _getBonePosition;
  48579. private _getLinesForBonesWithLength;
  48580. private _getLinesForBonesNoLength;
  48581. /** Update the viewer to sync with current skeleton state */
  48582. update(): void;
  48583. /** Release associated resources */
  48584. dispose(): void;
  48585. }
  48586. }
  48587. declare module "babylonjs/Debug/index" {
  48588. export * from "babylonjs/Debug/axesViewer";
  48589. export * from "babylonjs/Debug/boneAxesViewer";
  48590. export * from "babylonjs/Debug/debugLayer";
  48591. export * from "babylonjs/Debug/physicsViewer";
  48592. export * from "babylonjs/Debug/rayHelper";
  48593. export * from "babylonjs/Debug/skeletonViewer";
  48594. }
  48595. declare module "babylonjs/Engines/nullEngine" {
  48596. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48597. import { Engine } from "babylonjs/Engines/engine";
  48598. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48599. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48601. import { Effect } from "babylonjs/Materials/effect";
  48602. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48603. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48604. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48605. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48606. /**
  48607. * Options to create the null engine
  48608. */
  48609. export class NullEngineOptions {
  48610. /**
  48611. * Render width (Default: 512)
  48612. */
  48613. renderWidth: number;
  48614. /**
  48615. * Render height (Default: 256)
  48616. */
  48617. renderHeight: number;
  48618. /**
  48619. * Texture size (Default: 512)
  48620. */
  48621. textureSize: number;
  48622. /**
  48623. * If delta time between frames should be constant
  48624. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48625. */
  48626. deterministicLockstep: boolean;
  48627. /**
  48628. * Maximum about of steps between frames (Default: 4)
  48629. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48630. */
  48631. lockstepMaxSteps: number;
  48632. }
  48633. /**
  48634. * The null engine class provides support for headless version of babylon.js.
  48635. * This can be used in server side scenario or for testing purposes
  48636. */
  48637. export class NullEngine extends Engine {
  48638. private _options;
  48639. /**
  48640. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48642. * @returns true if engine is in deterministic lock step mode
  48643. */
  48644. isDeterministicLockStep(): boolean;
  48645. /**
  48646. * Gets the max steps when engine is running in deterministic lock step
  48647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48648. * @returns the max steps
  48649. */
  48650. getLockstepMaxSteps(): number;
  48651. /**
  48652. * Gets the current hardware scaling level.
  48653. * By default the hardware scaling level is computed from the window device ratio.
  48654. * 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.
  48655. * @returns a number indicating the current hardware scaling level
  48656. */
  48657. getHardwareScalingLevel(): number;
  48658. constructor(options?: NullEngineOptions);
  48659. /**
  48660. * Creates a vertex buffer
  48661. * @param vertices the data for the vertex buffer
  48662. * @returns the new WebGL static buffer
  48663. */
  48664. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48665. /**
  48666. * Creates a new index buffer
  48667. * @param indices defines the content of the index buffer
  48668. * @param updatable defines if the index buffer must be updatable
  48669. * @returns a new webGL buffer
  48670. */
  48671. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48672. /**
  48673. * Clear the current render buffer or the current render target (if any is set up)
  48674. * @param color defines the color to use
  48675. * @param backBuffer defines if the back buffer must be cleared
  48676. * @param depth defines if the depth buffer must be cleared
  48677. * @param stencil defines if the stencil buffer must be cleared
  48678. */
  48679. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48680. /**
  48681. * Gets the current render width
  48682. * @param useScreen defines if screen size must be used (or the current render target if any)
  48683. * @returns a number defining the current render width
  48684. */
  48685. getRenderWidth(useScreen?: boolean): number;
  48686. /**
  48687. * Gets the current render height
  48688. * @param useScreen defines if screen size must be used (or the current render target if any)
  48689. * @returns a number defining the current render height
  48690. */
  48691. getRenderHeight(useScreen?: boolean): number;
  48692. /**
  48693. * Set the WebGL's viewport
  48694. * @param viewport defines the viewport element to be used
  48695. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48696. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48697. */
  48698. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48699. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48700. /**
  48701. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48702. * @param pipelineContext defines the pipeline context to use
  48703. * @param uniformsNames defines the list of uniform names
  48704. * @returns an array of webGL uniform locations
  48705. */
  48706. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48707. /**
  48708. * Gets the lsit of active attributes for a given webGL program
  48709. * @param pipelineContext defines the pipeline context to use
  48710. * @param attributesNames defines the list of attribute names to get
  48711. * @returns an array of indices indicating the offset of each attribute
  48712. */
  48713. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48714. /**
  48715. * Binds an effect to the webGL context
  48716. * @param effect defines the effect to bind
  48717. */
  48718. bindSamplers(effect: Effect): void;
  48719. /**
  48720. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48721. * @param effect defines the effect to activate
  48722. */
  48723. enableEffect(effect: Effect): void;
  48724. /**
  48725. * Set various states to the webGL context
  48726. * @param culling defines backface culling state
  48727. * @param zOffset defines the value to apply to zOffset (0 by default)
  48728. * @param force defines if states must be applied even if cache is up to date
  48729. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48730. */
  48731. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48732. /**
  48733. * Set the value of an uniform to an array of int32
  48734. * @param uniform defines the webGL uniform location where to store the value
  48735. * @param array defines the array of int32 to store
  48736. */
  48737. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48738. /**
  48739. * Set the value of an uniform to an array of int32 (stored as vec2)
  48740. * @param uniform defines the webGL uniform location where to store the value
  48741. * @param array defines the array of int32 to store
  48742. */
  48743. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48744. /**
  48745. * Set the value of an uniform to an array of int32 (stored as vec3)
  48746. * @param uniform defines the webGL uniform location where to store the value
  48747. * @param array defines the array of int32 to store
  48748. */
  48749. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48750. /**
  48751. * Set the value of an uniform to an array of int32 (stored as vec4)
  48752. * @param uniform defines the webGL uniform location where to store the value
  48753. * @param array defines the array of int32 to store
  48754. */
  48755. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48756. /**
  48757. * Set the value of an uniform to an array of float32
  48758. * @param uniform defines the webGL uniform location where to store the value
  48759. * @param array defines the array of float32 to store
  48760. */
  48761. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48762. /**
  48763. * Set the value of an uniform to an array of float32 (stored as vec2)
  48764. * @param uniform defines the webGL uniform location where to store the value
  48765. * @param array defines the array of float32 to store
  48766. */
  48767. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48768. /**
  48769. * Set the value of an uniform to an array of float32 (stored as vec3)
  48770. * @param uniform defines the webGL uniform location where to store the value
  48771. * @param array defines the array of float32 to store
  48772. */
  48773. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48774. /**
  48775. * Set the value of an uniform to an array of float32 (stored as vec4)
  48776. * @param uniform defines the webGL uniform location where to store the value
  48777. * @param array defines the array of float32 to store
  48778. */
  48779. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48780. /**
  48781. * Set the value of an uniform to an array of number
  48782. * @param uniform defines the webGL uniform location where to store the value
  48783. * @param array defines the array of number to store
  48784. */
  48785. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48786. /**
  48787. * Set the value of an uniform to an array of number (stored as vec2)
  48788. * @param uniform defines the webGL uniform location where to store the value
  48789. * @param array defines the array of number to store
  48790. */
  48791. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48792. /**
  48793. * Set the value of an uniform to an array of number (stored as vec3)
  48794. * @param uniform defines the webGL uniform location where to store the value
  48795. * @param array defines the array of number to store
  48796. */
  48797. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48798. /**
  48799. * Set the value of an uniform to an array of number (stored as vec4)
  48800. * @param uniform defines the webGL uniform location where to store the value
  48801. * @param array defines the array of number to store
  48802. */
  48803. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48804. /**
  48805. * Set the value of an uniform to an array of float32 (stored as matrices)
  48806. * @param uniform defines the webGL uniform location where to store the value
  48807. * @param matrices defines the array of float32 to store
  48808. */
  48809. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48810. /**
  48811. * Set the value of an uniform to a matrix (3x3)
  48812. * @param uniform defines the webGL uniform location where to store the value
  48813. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48814. */
  48815. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48816. /**
  48817. * Set the value of an uniform to a matrix (2x2)
  48818. * @param uniform defines the webGL uniform location where to store the value
  48819. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48820. */
  48821. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48822. /**
  48823. * Set the value of an uniform to a number (float)
  48824. * @param uniform defines the webGL uniform location where to store the value
  48825. * @param value defines the float number to store
  48826. */
  48827. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48828. /**
  48829. * Set the value of an uniform to a vec2
  48830. * @param uniform defines the webGL uniform location where to store the value
  48831. * @param x defines the 1st component of the value
  48832. * @param y defines the 2nd component of the value
  48833. */
  48834. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48835. /**
  48836. * Set the value of an uniform to a vec3
  48837. * @param uniform defines the webGL uniform location where to store the value
  48838. * @param x defines the 1st component of the value
  48839. * @param y defines the 2nd component of the value
  48840. * @param z defines the 3rd component of the value
  48841. */
  48842. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48843. /**
  48844. * Set the value of an uniform to a boolean
  48845. * @param uniform defines the webGL uniform location where to store the value
  48846. * @param bool defines the boolean to store
  48847. */
  48848. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48849. /**
  48850. * Set the value of an uniform to a vec4
  48851. * @param uniform defines the webGL uniform location where to store the value
  48852. * @param x defines the 1st component of the value
  48853. * @param y defines the 2nd component of the value
  48854. * @param z defines the 3rd component of the value
  48855. * @param w defines the 4th component of the value
  48856. */
  48857. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48858. /**
  48859. * Sets the current alpha mode
  48860. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48861. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48863. */
  48864. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48865. /**
  48866. * Bind webGl buffers directly to the webGL context
  48867. * @param vertexBuffers defines the vertex buffer to bind
  48868. * @param indexBuffer defines the index buffer to bind
  48869. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48870. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48871. * @param effect defines the effect associated with the vertex buffer
  48872. */
  48873. bindBuffers(vertexBuffers: {
  48874. [key: string]: VertexBuffer;
  48875. }, indexBuffer: DataBuffer, effect: Effect): void;
  48876. /**
  48877. * Force the entire cache to be cleared
  48878. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48879. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48880. */
  48881. wipeCaches(bruteForce?: boolean): void;
  48882. /**
  48883. * Send a draw order
  48884. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48885. * @param indexStart defines the starting index
  48886. * @param indexCount defines the number of index to draw
  48887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48888. */
  48889. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48890. /**
  48891. * Draw a list of indexed primitives
  48892. * @param fillMode defines the primitive to use
  48893. * @param indexStart defines the starting index
  48894. * @param indexCount defines the number of index to draw
  48895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48896. */
  48897. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48898. /**
  48899. * Draw a list of unindexed primitives
  48900. * @param fillMode defines the primitive to use
  48901. * @param verticesStart defines the index of first vertex to draw
  48902. * @param verticesCount defines the count of vertices to draw
  48903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48904. */
  48905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48906. /** @hidden */
  48907. _createTexture(): WebGLTexture;
  48908. /** @hidden */
  48909. _releaseTexture(texture: InternalTexture): void;
  48910. /**
  48911. * Usually called from Texture.ts.
  48912. * Passed information to create a WebGLTexture
  48913. * @param urlArg defines a value which contains one of the following:
  48914. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48915. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48916. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48917. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48918. * @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)
  48919. * @param scene needed for loading to the correct scene
  48920. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48921. * @param onLoad optional callback to be called upon successful completion
  48922. * @param onError optional callback to be called upon failure
  48923. * @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
  48924. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48925. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48926. * @param forcedExtension defines the extension to use to pick the right loader
  48927. * @param mimeType defines an optional mime type
  48928. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48929. */
  48930. 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;
  48931. /**
  48932. * Creates a new render target texture
  48933. * @param size defines the size of the texture
  48934. * @param options defines the options used to create the texture
  48935. * @returns a new render target texture stored in an InternalTexture
  48936. */
  48937. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48938. /**
  48939. * Update the sampling mode of a given texture
  48940. * @param samplingMode defines the required sampling mode
  48941. * @param texture defines the texture to update
  48942. */
  48943. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48944. /**
  48945. * Binds the frame buffer to the specified texture.
  48946. * @param texture The texture to render to or null for the default canvas
  48947. * @param faceIndex The face of the texture to render to in case of cube texture
  48948. * @param requiredWidth The width of the target to render to
  48949. * @param requiredHeight The height of the target to render to
  48950. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48951. * @param lodLevel defines le lod level to bind to the frame buffer
  48952. */
  48953. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48954. /**
  48955. * Unbind the current render target texture from the webGL context
  48956. * @param texture defines the render target texture to unbind
  48957. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48958. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48959. */
  48960. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48961. /**
  48962. * Creates a dynamic vertex buffer
  48963. * @param vertices the data for the dynamic vertex buffer
  48964. * @returns the new WebGL dynamic buffer
  48965. */
  48966. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48967. /**
  48968. * Update the content of a dynamic texture
  48969. * @param texture defines the texture to update
  48970. * @param canvas defines the canvas containing the source
  48971. * @param invertY defines if data must be stored with Y axis inverted
  48972. * @param premulAlpha defines if alpha is stored as premultiplied
  48973. * @param format defines the format of the data
  48974. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48975. */
  48976. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48977. /**
  48978. * Gets a boolean indicating if all created effects are ready
  48979. * @returns true if all effects are ready
  48980. */
  48981. areAllEffectsReady(): boolean;
  48982. /**
  48983. * @hidden
  48984. * Get the current error code of the webGL context
  48985. * @returns the error code
  48986. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48987. */
  48988. getError(): number;
  48989. /** @hidden */
  48990. _getUnpackAlignement(): number;
  48991. /** @hidden */
  48992. _unpackFlipY(value: boolean): void;
  48993. /**
  48994. * Update a dynamic index buffer
  48995. * @param indexBuffer defines the target index buffer
  48996. * @param indices defines the data to update
  48997. * @param offset defines the offset in the target index buffer where update should start
  48998. */
  48999. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49000. /**
  49001. * Updates a dynamic vertex buffer.
  49002. * @param vertexBuffer the vertex buffer to update
  49003. * @param vertices the data used to update the vertex buffer
  49004. * @param byteOffset the byte offset of the data (optional)
  49005. * @param byteLength the byte length of the data (optional)
  49006. */
  49007. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49008. /** @hidden */
  49009. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49010. /** @hidden */
  49011. _bindTexture(channel: number, texture: InternalTexture): void;
  49012. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49013. /**
  49014. * 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
  49015. */
  49016. releaseEffects(): void;
  49017. displayLoadingUI(): void;
  49018. hideLoadingUI(): void;
  49019. /** @hidden */
  49020. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49021. /** @hidden */
  49022. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49023. /** @hidden */
  49024. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49025. /** @hidden */
  49026. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49027. }
  49028. }
  49029. declare module "babylonjs/Instrumentation/timeToken" {
  49030. import { Nullable } from "babylonjs/types";
  49031. /**
  49032. * @hidden
  49033. **/
  49034. export class _TimeToken {
  49035. _startTimeQuery: Nullable<WebGLQuery>;
  49036. _endTimeQuery: Nullable<WebGLQuery>;
  49037. _timeElapsedQuery: Nullable<WebGLQuery>;
  49038. _timeElapsedQueryEnded: boolean;
  49039. }
  49040. }
  49041. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49042. import { Nullable, int } from "babylonjs/types";
  49043. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49044. /** @hidden */
  49045. export class _OcclusionDataStorage {
  49046. /** @hidden */
  49047. occlusionInternalRetryCounter: number;
  49048. /** @hidden */
  49049. isOcclusionQueryInProgress: boolean;
  49050. /** @hidden */
  49051. isOccluded: boolean;
  49052. /** @hidden */
  49053. occlusionRetryCount: number;
  49054. /** @hidden */
  49055. occlusionType: number;
  49056. /** @hidden */
  49057. occlusionQueryAlgorithmType: number;
  49058. }
  49059. module "babylonjs/Engines/engine" {
  49060. interface Engine {
  49061. /**
  49062. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49063. * @return the new query
  49064. */
  49065. createQuery(): WebGLQuery;
  49066. /**
  49067. * Delete and release a webGL query
  49068. * @param query defines the query to delete
  49069. * @return the current engine
  49070. */
  49071. deleteQuery(query: WebGLQuery): Engine;
  49072. /**
  49073. * Check if a given query has resolved and got its value
  49074. * @param query defines the query to check
  49075. * @returns true if the query got its value
  49076. */
  49077. isQueryResultAvailable(query: WebGLQuery): boolean;
  49078. /**
  49079. * Gets the value of a given query
  49080. * @param query defines the query to check
  49081. * @returns the value of the query
  49082. */
  49083. getQueryResult(query: WebGLQuery): number;
  49084. /**
  49085. * Initiates an occlusion query
  49086. * @param algorithmType defines the algorithm to use
  49087. * @param query defines the query to use
  49088. * @returns the current engine
  49089. * @see http://doc.babylonjs.com/features/occlusionquery
  49090. */
  49091. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49092. /**
  49093. * Ends an occlusion query
  49094. * @see http://doc.babylonjs.com/features/occlusionquery
  49095. * @param algorithmType defines the algorithm to use
  49096. * @returns the current engine
  49097. */
  49098. endOcclusionQuery(algorithmType: number): Engine;
  49099. /**
  49100. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49101. * Please note that only one query can be issued at a time
  49102. * @returns a time token used to track the time span
  49103. */
  49104. startTimeQuery(): Nullable<_TimeToken>;
  49105. /**
  49106. * Ends a time query
  49107. * @param token defines the token used to measure the time span
  49108. * @returns the time spent (in ns)
  49109. */
  49110. endTimeQuery(token: _TimeToken): int;
  49111. /** @hidden */
  49112. _currentNonTimestampToken: Nullable<_TimeToken>;
  49113. /** @hidden */
  49114. _createTimeQuery(): WebGLQuery;
  49115. /** @hidden */
  49116. _deleteTimeQuery(query: WebGLQuery): void;
  49117. /** @hidden */
  49118. _getGlAlgorithmType(algorithmType: number): number;
  49119. /** @hidden */
  49120. _getTimeQueryResult(query: WebGLQuery): any;
  49121. /** @hidden */
  49122. _getTimeQueryAvailability(query: WebGLQuery): any;
  49123. }
  49124. }
  49125. module "babylonjs/Meshes/abstractMesh" {
  49126. interface AbstractMesh {
  49127. /**
  49128. * Backing filed
  49129. * @hidden
  49130. */
  49131. __occlusionDataStorage: _OcclusionDataStorage;
  49132. /**
  49133. * Access property
  49134. * @hidden
  49135. */
  49136. _occlusionDataStorage: _OcclusionDataStorage;
  49137. /**
  49138. * 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.
  49139. * The default value is -1 which means don't break the query and wait till the result
  49140. * @see http://doc.babylonjs.com/features/occlusionquery
  49141. */
  49142. occlusionRetryCount: number;
  49143. /**
  49144. * 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:
  49145. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49146. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49147. * * 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.
  49148. * @see http://doc.babylonjs.com/features/occlusionquery
  49149. */
  49150. occlusionType: number;
  49151. /**
  49152. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49153. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49154. * * 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.
  49155. * @see http://doc.babylonjs.com/features/occlusionquery
  49156. */
  49157. occlusionQueryAlgorithmType: number;
  49158. /**
  49159. * 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
  49160. * @see http://doc.babylonjs.com/features/occlusionquery
  49161. */
  49162. isOccluded: boolean;
  49163. /**
  49164. * Flag to check the progress status of the query
  49165. * @see http://doc.babylonjs.com/features/occlusionquery
  49166. */
  49167. isOcclusionQueryInProgress: boolean;
  49168. }
  49169. }
  49170. }
  49171. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49172. import { Nullable } from "babylonjs/types";
  49173. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49174. /** @hidden */
  49175. export var _forceTransformFeedbackToBundle: boolean;
  49176. module "babylonjs/Engines/engine" {
  49177. interface Engine {
  49178. /**
  49179. * Creates a webGL transform feedback object
  49180. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49181. * @returns the webGL transform feedback object
  49182. */
  49183. createTransformFeedback(): WebGLTransformFeedback;
  49184. /**
  49185. * Delete a webGL transform feedback object
  49186. * @param value defines the webGL transform feedback object to delete
  49187. */
  49188. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49189. /**
  49190. * Bind a webGL transform feedback object to the webgl context
  49191. * @param value defines the webGL transform feedback object to bind
  49192. */
  49193. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49194. /**
  49195. * Begins a transform feedback operation
  49196. * @param usePoints defines if points or triangles must be used
  49197. */
  49198. beginTransformFeedback(usePoints: boolean): void;
  49199. /**
  49200. * Ends a transform feedback operation
  49201. */
  49202. endTransformFeedback(): void;
  49203. /**
  49204. * Specify the varyings to use with transform feedback
  49205. * @param program defines the associated webGL program
  49206. * @param value defines the list of strings representing the varying names
  49207. */
  49208. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49209. /**
  49210. * Bind a webGL buffer for a transform feedback operation
  49211. * @param value defines the webGL buffer to bind
  49212. */
  49213. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49214. }
  49215. }
  49216. }
  49217. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49218. import { Scene } from "babylonjs/scene";
  49219. import { Engine } from "babylonjs/Engines/engine";
  49220. import { Texture } from "babylonjs/Materials/Textures/texture";
  49221. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49222. import "babylonjs/Engines/Extensions/engine.multiRender";
  49223. /**
  49224. * Creation options of the multi render target texture.
  49225. */
  49226. export interface IMultiRenderTargetOptions {
  49227. /**
  49228. * Define if the texture needs to create mip maps after render.
  49229. */
  49230. generateMipMaps?: boolean;
  49231. /**
  49232. * Define the types of all the draw buffers we want to create
  49233. */
  49234. types?: number[];
  49235. /**
  49236. * Define the sampling modes of all the draw buffers we want to create
  49237. */
  49238. samplingModes?: number[];
  49239. /**
  49240. * Define if a depth buffer is required
  49241. */
  49242. generateDepthBuffer?: boolean;
  49243. /**
  49244. * Define if a stencil buffer is required
  49245. */
  49246. generateStencilBuffer?: boolean;
  49247. /**
  49248. * Define if a depth texture is required instead of a depth buffer
  49249. */
  49250. generateDepthTexture?: boolean;
  49251. /**
  49252. * Define the number of desired draw buffers
  49253. */
  49254. textureCount?: number;
  49255. /**
  49256. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49257. */
  49258. doNotChangeAspectRatio?: boolean;
  49259. /**
  49260. * Define the default type of the buffers we are creating
  49261. */
  49262. defaultType?: number;
  49263. }
  49264. /**
  49265. * A multi render target, like a render target provides the ability to render to a texture.
  49266. * Unlike the render target, it can render to several draw buffers in one draw.
  49267. * This is specially interesting in deferred rendering or for any effects requiring more than
  49268. * just one color from a single pass.
  49269. */
  49270. export class MultiRenderTarget extends RenderTargetTexture {
  49271. private _internalTextures;
  49272. private _textures;
  49273. private _multiRenderTargetOptions;
  49274. /**
  49275. * Get if draw buffers are currently supported by the used hardware and browser.
  49276. */
  49277. get isSupported(): boolean;
  49278. /**
  49279. * Get the list of textures generated by the multi render target.
  49280. */
  49281. get textures(): Texture[];
  49282. /**
  49283. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49284. */
  49285. get depthTexture(): Texture;
  49286. /**
  49287. * Set the wrapping mode on U of all the textures we are rendering to.
  49288. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49289. */
  49290. set wrapU(wrap: number);
  49291. /**
  49292. * Set the wrapping mode on V of all the textures we are rendering to.
  49293. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49294. */
  49295. set wrapV(wrap: number);
  49296. /**
  49297. * Instantiate a new multi render target texture.
  49298. * A multi render target, like a render target provides the ability to render to a texture.
  49299. * Unlike the render target, it can render to several draw buffers in one draw.
  49300. * This is specially interesting in deferred rendering or for any effects requiring more than
  49301. * just one color from a single pass.
  49302. * @param name Define the name of the texture
  49303. * @param size Define the size of the buffers to render to
  49304. * @param count Define the number of target we are rendering into
  49305. * @param scene Define the scene the texture belongs to
  49306. * @param options Define the options used to create the multi render target
  49307. */
  49308. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49309. /** @hidden */
  49310. _rebuild(): void;
  49311. private _createInternalTextures;
  49312. private _createTextures;
  49313. /**
  49314. * Define the number of samples used if MSAA is enabled.
  49315. */
  49316. get samples(): number;
  49317. set samples(value: number);
  49318. /**
  49319. * Resize all the textures in the multi render target.
  49320. * Be carrefull as it will recreate all the data in the new texture.
  49321. * @param size Define the new size
  49322. */
  49323. resize(size: any): void;
  49324. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49325. /**
  49326. * Dispose the render targets and their associated resources
  49327. */
  49328. dispose(): void;
  49329. /**
  49330. * Release all the underlying texture used as draw buffers.
  49331. */
  49332. releaseInternalTextures(): void;
  49333. }
  49334. }
  49335. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49337. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49338. import { Nullable } from "babylonjs/types";
  49339. module "babylonjs/Engines/thinEngine" {
  49340. interface ThinEngine {
  49341. /**
  49342. * Unbind a list of render target textures from the webGL context
  49343. * This is used only when drawBuffer extension or webGL2 are active
  49344. * @param textures defines the render target textures to unbind
  49345. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49346. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49347. */
  49348. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49349. /**
  49350. * Create a multi render target texture
  49351. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49352. * @param size defines the size of the texture
  49353. * @param options defines the creation options
  49354. * @returns the cube texture as an InternalTexture
  49355. */
  49356. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49357. /**
  49358. * Update the sample count for a given multiple render target texture
  49359. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49360. * @param textures defines the textures to update
  49361. * @param samples defines the sample count to set
  49362. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49363. */
  49364. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49365. }
  49366. }
  49367. }
  49368. declare module "babylonjs/Engines/Extensions/engine.views" {
  49369. import { Camera } from "babylonjs/Cameras/camera";
  49370. import { Nullable } from "babylonjs/types";
  49371. /**
  49372. * Class used to define an additional view for the engine
  49373. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49374. */
  49375. export class EngineView {
  49376. /** Defines the canvas where to render the view */
  49377. target: HTMLCanvasElement;
  49378. /** Defines an optional camera used to render the view (will use active camera else) */
  49379. camera?: Camera;
  49380. }
  49381. module "babylonjs/Engines/engine" {
  49382. interface Engine {
  49383. /**
  49384. * Gets or sets the HTML element to use for attaching events
  49385. */
  49386. inputElement: Nullable<HTMLElement>;
  49387. /**
  49388. * Gets the current engine view
  49389. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49390. */
  49391. activeView: Nullable<EngineView>;
  49392. /** Gets or sets the list of views */
  49393. views: EngineView[];
  49394. /**
  49395. * Register a new child canvas
  49396. * @param canvas defines the canvas to register
  49397. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49398. * @returns the associated view
  49399. */
  49400. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49401. /**
  49402. * Remove a registered child canvas
  49403. * @param canvas defines the canvas to remove
  49404. * @returns the current engine
  49405. */
  49406. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49407. }
  49408. }
  49409. }
  49410. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49411. import { Nullable } from "babylonjs/types";
  49412. module "babylonjs/Engines/engine" {
  49413. interface Engine {
  49414. /** @hidden */
  49415. _excludedCompressedTextures: string[];
  49416. /** @hidden */
  49417. _textureFormatInUse: string;
  49418. /**
  49419. * Gets the list of texture formats supported
  49420. */
  49421. readonly texturesSupported: Array<string>;
  49422. /**
  49423. * Gets the texture format in use
  49424. */
  49425. readonly textureFormatInUse: Nullable<string>;
  49426. /**
  49427. * Set the compressed texture extensions or file names to skip.
  49428. *
  49429. * @param skippedFiles defines the list of those texture files you want to skip
  49430. * Example: [".dds", ".env", "myfile.png"]
  49431. */
  49432. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49433. /**
  49434. * Set the compressed texture format to use, based on the formats you have, and the formats
  49435. * supported by the hardware / browser.
  49436. *
  49437. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49438. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49439. * to API arguments needed to compressed textures. This puts the burden on the container
  49440. * generator to house the arcane code for determining these for current & future formats.
  49441. *
  49442. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49443. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49444. *
  49445. * Note: The result of this call is not taken into account when a texture is base64.
  49446. *
  49447. * @param formatsAvailable defines the list of those format families you have created
  49448. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49449. *
  49450. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49451. * @returns The extension selected.
  49452. */
  49453. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49454. }
  49455. }
  49456. }
  49457. declare module "babylonjs/Engines/Extensions/index" {
  49458. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49459. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49460. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49461. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49462. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49463. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49464. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49465. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49466. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49467. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49468. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49469. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49470. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49471. export * from "babylonjs/Engines/Extensions/engine.views";
  49472. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49473. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49474. }
  49475. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49476. import { Nullable } from "babylonjs/types";
  49477. /**
  49478. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49479. */
  49480. export interface CubeMapInfo {
  49481. /**
  49482. * The pixel array for the front face.
  49483. * This is stored in format, left to right, up to down format.
  49484. */
  49485. front: Nullable<ArrayBufferView>;
  49486. /**
  49487. * The pixel array for the back face.
  49488. * This is stored in format, left to right, up to down format.
  49489. */
  49490. back: Nullable<ArrayBufferView>;
  49491. /**
  49492. * The pixel array for the left face.
  49493. * This is stored in format, left to right, up to down format.
  49494. */
  49495. left: Nullable<ArrayBufferView>;
  49496. /**
  49497. * The pixel array for the right face.
  49498. * This is stored in format, left to right, up to down format.
  49499. */
  49500. right: Nullable<ArrayBufferView>;
  49501. /**
  49502. * The pixel array for the up face.
  49503. * This is stored in format, left to right, up to down format.
  49504. */
  49505. up: Nullable<ArrayBufferView>;
  49506. /**
  49507. * The pixel array for the down face.
  49508. * This is stored in format, left to right, up to down format.
  49509. */
  49510. down: Nullable<ArrayBufferView>;
  49511. /**
  49512. * The size of the cubemap stored.
  49513. *
  49514. * Each faces will be size * size pixels.
  49515. */
  49516. size: number;
  49517. /**
  49518. * The format of the texture.
  49519. *
  49520. * RGBA, RGB.
  49521. */
  49522. format: number;
  49523. /**
  49524. * The type of the texture data.
  49525. *
  49526. * UNSIGNED_INT, FLOAT.
  49527. */
  49528. type: number;
  49529. /**
  49530. * Specifies whether the texture is in gamma space.
  49531. */
  49532. gammaSpace: boolean;
  49533. }
  49534. /**
  49535. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49536. */
  49537. export class PanoramaToCubeMapTools {
  49538. private static FACE_FRONT;
  49539. private static FACE_BACK;
  49540. private static FACE_RIGHT;
  49541. private static FACE_LEFT;
  49542. private static FACE_DOWN;
  49543. private static FACE_UP;
  49544. /**
  49545. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49546. *
  49547. * @param float32Array The source data.
  49548. * @param inputWidth The width of the input panorama.
  49549. * @param inputHeight The height of the input panorama.
  49550. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49551. * @return The cubemap data
  49552. */
  49553. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49554. private static CreateCubemapTexture;
  49555. private static CalcProjectionSpherical;
  49556. }
  49557. }
  49558. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49559. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49561. import { Nullable } from "babylonjs/types";
  49562. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49563. /**
  49564. * Helper class dealing with the extraction of spherical polynomial dataArray
  49565. * from a cube map.
  49566. */
  49567. export class CubeMapToSphericalPolynomialTools {
  49568. private static FileFaces;
  49569. /**
  49570. * Converts a texture to the according Spherical Polynomial data.
  49571. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49572. *
  49573. * @param texture The texture to extract the information from.
  49574. * @return The Spherical Polynomial data.
  49575. */
  49576. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49577. /**
  49578. * Converts a cubemap to the according Spherical Polynomial data.
  49579. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49580. *
  49581. * @param cubeInfo The Cube map to extract the information from.
  49582. * @return The Spherical Polynomial data.
  49583. */
  49584. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49585. }
  49586. }
  49587. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49588. import { Nullable } from "babylonjs/types";
  49589. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49590. module "babylonjs/Materials/Textures/baseTexture" {
  49591. interface BaseTexture {
  49592. /**
  49593. * Get the polynomial representation of the texture data.
  49594. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49595. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49596. */
  49597. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49598. }
  49599. }
  49600. }
  49601. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49603. /** @hidden */
  49604. export var rgbdEncodePixelShader: {
  49605. name: string;
  49606. shader: string;
  49607. };
  49608. }
  49609. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49611. /** @hidden */
  49612. export var rgbdDecodePixelShader: {
  49613. name: string;
  49614. shader: string;
  49615. };
  49616. }
  49617. declare module "babylonjs/Misc/environmentTextureTools" {
  49618. import { Nullable } from "babylonjs/types";
  49619. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49621. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49622. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49623. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49624. import "babylonjs/Shaders/rgbdEncode.fragment";
  49625. import "babylonjs/Shaders/rgbdDecode.fragment";
  49626. /**
  49627. * Raw texture data and descriptor sufficient for WebGL texture upload
  49628. */
  49629. export interface EnvironmentTextureInfo {
  49630. /**
  49631. * Version of the environment map
  49632. */
  49633. version: number;
  49634. /**
  49635. * Width of image
  49636. */
  49637. width: number;
  49638. /**
  49639. * Irradiance information stored in the file.
  49640. */
  49641. irradiance: any;
  49642. /**
  49643. * Specular information stored in the file.
  49644. */
  49645. specular: any;
  49646. }
  49647. /**
  49648. * Defines One Image in the file. It requires only the position in the file
  49649. * as well as the length.
  49650. */
  49651. interface BufferImageData {
  49652. /**
  49653. * Length of the image data.
  49654. */
  49655. length: number;
  49656. /**
  49657. * Position of the data from the null terminator delimiting the end of the JSON.
  49658. */
  49659. position: number;
  49660. }
  49661. /**
  49662. * Defines the specular data enclosed in the file.
  49663. * This corresponds to the version 1 of the data.
  49664. */
  49665. export interface EnvironmentTextureSpecularInfoV1 {
  49666. /**
  49667. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49668. */
  49669. specularDataPosition?: number;
  49670. /**
  49671. * This contains all the images data needed to reconstruct the cubemap.
  49672. */
  49673. mipmaps: Array<BufferImageData>;
  49674. /**
  49675. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49676. */
  49677. lodGenerationScale: number;
  49678. }
  49679. /**
  49680. * Sets of helpers addressing the serialization and deserialization of environment texture
  49681. * stored in a BabylonJS env file.
  49682. * Those files are usually stored as .env files.
  49683. */
  49684. export class EnvironmentTextureTools {
  49685. /**
  49686. * Magic number identifying the env file.
  49687. */
  49688. private static _MagicBytes;
  49689. /**
  49690. * Gets the environment info from an env file.
  49691. * @param data The array buffer containing the .env bytes.
  49692. * @returns the environment file info (the json header) if successfully parsed.
  49693. */
  49694. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49695. /**
  49696. * Creates an environment texture from a loaded cube texture.
  49697. * @param texture defines the cube texture to convert in env file
  49698. * @return a promise containing the environment data if succesfull.
  49699. */
  49700. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49701. /**
  49702. * Creates a JSON representation of the spherical data.
  49703. * @param texture defines the texture containing the polynomials
  49704. * @return the JSON representation of the spherical info
  49705. */
  49706. private static _CreateEnvTextureIrradiance;
  49707. /**
  49708. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49709. * @param data the image data
  49710. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49711. * @return the views described by info providing access to the underlying buffer
  49712. */
  49713. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49714. /**
  49715. * Uploads the texture info contained in the env file to the GPU.
  49716. * @param texture defines the internal texture to upload to
  49717. * @param data defines the data to load
  49718. * @param info defines the texture info retrieved through the GetEnvInfo method
  49719. * @returns a promise
  49720. */
  49721. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49722. private static _OnImageReadyAsync;
  49723. /**
  49724. * Uploads the levels of image data to the GPU.
  49725. * @param texture defines the internal texture to upload to
  49726. * @param imageData defines the array buffer views of image data [mipmap][face]
  49727. * @returns a promise
  49728. */
  49729. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49730. /**
  49731. * Uploads spherical polynomials information to the texture.
  49732. * @param texture defines the texture we are trying to upload the information to
  49733. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49734. */
  49735. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49736. /** @hidden */
  49737. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49738. }
  49739. }
  49740. declare module "babylonjs/Maths/math.vertexFormat" {
  49741. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49742. /**
  49743. * Contains position and normal vectors for a vertex
  49744. */
  49745. export class PositionNormalVertex {
  49746. /** the position of the vertex (defaut: 0,0,0) */
  49747. position: Vector3;
  49748. /** the normal of the vertex (defaut: 0,1,0) */
  49749. normal: Vector3;
  49750. /**
  49751. * Creates a PositionNormalVertex
  49752. * @param position the position of the vertex (defaut: 0,0,0)
  49753. * @param normal the normal of the vertex (defaut: 0,1,0)
  49754. */
  49755. constructor(
  49756. /** the position of the vertex (defaut: 0,0,0) */
  49757. position?: Vector3,
  49758. /** the normal of the vertex (defaut: 0,1,0) */
  49759. normal?: Vector3);
  49760. /**
  49761. * Clones the PositionNormalVertex
  49762. * @returns the cloned PositionNormalVertex
  49763. */
  49764. clone(): PositionNormalVertex;
  49765. }
  49766. /**
  49767. * Contains position, normal and uv vectors for a vertex
  49768. */
  49769. export class PositionNormalTextureVertex {
  49770. /** the position of the vertex (defaut: 0,0,0) */
  49771. position: Vector3;
  49772. /** the normal of the vertex (defaut: 0,1,0) */
  49773. normal: Vector3;
  49774. /** the uv of the vertex (default: 0,0) */
  49775. uv: Vector2;
  49776. /**
  49777. * Creates a PositionNormalTextureVertex
  49778. * @param position the position of the vertex (defaut: 0,0,0)
  49779. * @param normal the normal of the vertex (defaut: 0,1,0)
  49780. * @param uv the uv of the vertex (default: 0,0)
  49781. */
  49782. constructor(
  49783. /** the position of the vertex (defaut: 0,0,0) */
  49784. position?: Vector3,
  49785. /** the normal of the vertex (defaut: 0,1,0) */
  49786. normal?: Vector3,
  49787. /** the uv of the vertex (default: 0,0) */
  49788. uv?: Vector2);
  49789. /**
  49790. * Clones the PositionNormalTextureVertex
  49791. * @returns the cloned PositionNormalTextureVertex
  49792. */
  49793. clone(): PositionNormalTextureVertex;
  49794. }
  49795. }
  49796. declare module "babylonjs/Maths/math" {
  49797. export * from "babylonjs/Maths/math.axis";
  49798. export * from "babylonjs/Maths/math.color";
  49799. export * from "babylonjs/Maths/math.constants";
  49800. export * from "babylonjs/Maths/math.frustum";
  49801. export * from "babylonjs/Maths/math.path";
  49802. export * from "babylonjs/Maths/math.plane";
  49803. export * from "babylonjs/Maths/math.size";
  49804. export * from "babylonjs/Maths/math.vector";
  49805. export * from "babylonjs/Maths/math.vertexFormat";
  49806. export * from "babylonjs/Maths/math.viewport";
  49807. }
  49808. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49809. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49810. /** @hidden */
  49811. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49812. private _genericAttributeLocation;
  49813. private _varyingLocationCount;
  49814. private _varyingLocationMap;
  49815. private _replacements;
  49816. private _textureCount;
  49817. private _uniforms;
  49818. lineProcessor(line: string): string;
  49819. attributeProcessor(attribute: string): string;
  49820. varyingProcessor(varying: string, isFragment: boolean): string;
  49821. uniformProcessor(uniform: string): string;
  49822. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49823. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49824. }
  49825. }
  49826. declare module "babylonjs/Engines/nativeEngine" {
  49827. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49828. import { Engine } from "babylonjs/Engines/engine";
  49829. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49832. import { Effect } from "babylonjs/Materials/effect";
  49833. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49834. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49835. import { IColor4Like } from "babylonjs/Maths/math.like";
  49836. import { Scene } from "babylonjs/scene";
  49837. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49838. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49839. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49840. /**
  49841. * Container for accessors for natively-stored mesh data buffers.
  49842. */
  49843. class NativeDataBuffer extends DataBuffer {
  49844. /**
  49845. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49846. */
  49847. nativeIndexBuffer?: any;
  49848. /**
  49849. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49850. */
  49851. nativeVertexBuffer?: any;
  49852. }
  49853. /** @hidden */
  49854. class NativeTexture extends InternalTexture {
  49855. getInternalTexture(): InternalTexture;
  49856. getViewCount(): number;
  49857. }
  49858. /** @hidden */
  49859. export class NativeEngine extends Engine {
  49860. private readonly _native;
  49861. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49862. private readonly INVALID_HANDLE;
  49863. getHardwareScalingLevel(): number;
  49864. constructor();
  49865. /**
  49866. * Can be used to override the current requestAnimationFrame requester.
  49867. * @hidden
  49868. */
  49869. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49870. /**
  49871. * Override default engine behavior.
  49872. * @param color
  49873. * @param backBuffer
  49874. * @param depth
  49875. * @param stencil
  49876. */
  49877. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49878. /**
  49879. * Gets host document
  49880. * @returns the host document object
  49881. */
  49882. getHostDocument(): Nullable<Document>;
  49883. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49884. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49885. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49886. recordVertexArrayObject(vertexBuffers: {
  49887. [key: string]: VertexBuffer;
  49888. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49889. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49890. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49891. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49892. /**
  49893. * Draw a list of indexed primitives
  49894. * @param fillMode defines the primitive to use
  49895. * @param indexStart defines the starting index
  49896. * @param indexCount defines the number of index to draw
  49897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49898. */
  49899. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49900. /**
  49901. * Draw a list of unindexed primitives
  49902. * @param fillMode defines the primitive to use
  49903. * @param verticesStart defines the index of first vertex to draw
  49904. * @param verticesCount defines the count of vertices to draw
  49905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49906. */
  49907. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49908. createPipelineContext(): IPipelineContext;
  49909. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49910. /** @hidden */
  49911. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49912. /** @hidden */
  49913. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49914. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49915. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49916. protected _setProgram(program: WebGLProgram): void;
  49917. _releaseEffect(effect: Effect): void;
  49918. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49919. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49920. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49921. bindSamplers(effect: Effect): void;
  49922. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49923. getRenderWidth(useScreen?: boolean): number;
  49924. getRenderHeight(useScreen?: boolean): number;
  49925. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49926. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49927. /**
  49928. * Set the z offset to apply to current rendering
  49929. * @param value defines the offset to apply
  49930. */
  49931. setZOffset(value: number): void;
  49932. /**
  49933. * Gets the current value of the zOffset
  49934. * @returns the current zOffset state
  49935. */
  49936. getZOffset(): number;
  49937. /**
  49938. * Enable or disable depth buffering
  49939. * @param enable defines the state to set
  49940. */
  49941. setDepthBuffer(enable: boolean): void;
  49942. /**
  49943. * Gets a boolean indicating if depth writing is enabled
  49944. * @returns the current depth writing state
  49945. */
  49946. getDepthWrite(): boolean;
  49947. /**
  49948. * Enable or disable depth writing
  49949. * @param enable defines the state to set
  49950. */
  49951. setDepthWrite(enable: boolean): void;
  49952. /**
  49953. * Enable or disable color writing
  49954. * @param enable defines the state to set
  49955. */
  49956. setColorWrite(enable: boolean): void;
  49957. /**
  49958. * Gets a boolean indicating if color writing is enabled
  49959. * @returns the current color writing state
  49960. */
  49961. getColorWrite(): boolean;
  49962. /**
  49963. * Sets alpha constants used by some alpha blending modes
  49964. * @param r defines the red component
  49965. * @param g defines the green component
  49966. * @param b defines the blue component
  49967. * @param a defines the alpha component
  49968. */
  49969. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49970. /**
  49971. * Sets the current alpha mode
  49972. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49973. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49974. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49975. */
  49976. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49977. /**
  49978. * Gets the current alpha mode
  49979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49980. * @returns the current alpha mode
  49981. */
  49982. getAlphaMode(): number;
  49983. setInt(uniform: WebGLUniformLocation, int: number): void;
  49984. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49985. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49986. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49987. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49988. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49989. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49990. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49991. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49992. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49993. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49994. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49995. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49996. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49997. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49998. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49999. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50000. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50002. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50003. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50004. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50005. wipeCaches(bruteForce?: boolean): void;
  50006. _createTexture(): WebGLTexture;
  50007. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50008. /**
  50009. * Usually called from Texture.ts.
  50010. * Passed information to create a WebGLTexture
  50011. * @param urlArg defines a value which contains one of the following:
  50012. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50013. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50014. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50015. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50016. * @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)
  50017. * @param scene needed for loading to the correct scene
  50018. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50019. * @param onLoad optional callback to be called upon successful completion
  50020. * @param onError optional callback to be called upon failure
  50021. * @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
  50022. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50023. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50024. * @param forcedExtension defines the extension to use to pick the right loader
  50025. * @param mimeType defines an optional mime type
  50026. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50027. */
  50028. 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;
  50029. /**
  50030. * Creates a cube texture
  50031. * @param rootUrl defines the url where the files to load is located
  50032. * @param scene defines the current scene
  50033. * @param files defines the list of files to load (1 per face)
  50034. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50035. * @param onLoad defines an optional callback raised when the texture is loaded
  50036. * @param onError defines an optional callback raised if there is an issue to load the texture
  50037. * @param format defines the format of the data
  50038. * @param forcedExtension defines the extension to use to pick the right loader
  50039. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50040. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50041. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50042. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50043. * @returns the cube texture as an InternalTexture
  50044. */
  50045. 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;
  50046. private _getSamplingFilter;
  50047. private static _GetNativeTextureFormat;
  50048. createRenderTargetTexture(size: number | {
  50049. width: number;
  50050. height: number;
  50051. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50052. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50053. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50054. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50055. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50056. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50057. /**
  50058. * Updates a dynamic vertex buffer.
  50059. * @param vertexBuffer the vertex buffer to update
  50060. * @param data the data used to update the vertex buffer
  50061. * @param byteOffset the byte offset of the data (optional)
  50062. * @param byteLength the byte length of the data (optional)
  50063. */
  50064. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50065. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50066. private _updateAnisotropicLevel;
  50067. private _getAddressMode;
  50068. /** @hidden */
  50069. _bindTexture(channel: number, texture: InternalTexture): void;
  50070. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50071. releaseEffects(): void;
  50072. /** @hidden */
  50073. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50074. /** @hidden */
  50075. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50076. /** @hidden */
  50077. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50078. /** @hidden */
  50079. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50080. }
  50081. }
  50082. declare module "babylonjs/Engines/index" {
  50083. export * from "babylonjs/Engines/constants";
  50084. export * from "babylonjs/Engines/engineCapabilities";
  50085. export * from "babylonjs/Engines/instancingAttributeInfo";
  50086. export * from "babylonjs/Engines/thinEngine";
  50087. export * from "babylonjs/Engines/engine";
  50088. export * from "babylonjs/Engines/engineStore";
  50089. export * from "babylonjs/Engines/nullEngine";
  50090. export * from "babylonjs/Engines/Extensions/index";
  50091. export * from "babylonjs/Engines/IPipelineContext";
  50092. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50093. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50094. export * from "babylonjs/Engines/nativeEngine";
  50095. }
  50096. declare module "babylonjs/Events/clipboardEvents" {
  50097. /**
  50098. * Gather the list of clipboard event types as constants.
  50099. */
  50100. export class ClipboardEventTypes {
  50101. /**
  50102. * The clipboard event is fired when a copy command is active (pressed).
  50103. */
  50104. static readonly COPY: number;
  50105. /**
  50106. * The clipboard event is fired when a cut command is active (pressed).
  50107. */
  50108. static readonly CUT: number;
  50109. /**
  50110. * The clipboard event is fired when a paste command is active (pressed).
  50111. */
  50112. static readonly PASTE: number;
  50113. }
  50114. /**
  50115. * This class is used to store clipboard related info for the onClipboardObservable event.
  50116. */
  50117. export class ClipboardInfo {
  50118. /**
  50119. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50120. */
  50121. type: number;
  50122. /**
  50123. * Defines the related dom event
  50124. */
  50125. event: ClipboardEvent;
  50126. /**
  50127. *Creates an instance of ClipboardInfo.
  50128. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50129. * @param event Defines the related dom event
  50130. */
  50131. constructor(
  50132. /**
  50133. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50134. */
  50135. type: number,
  50136. /**
  50137. * Defines the related dom event
  50138. */
  50139. event: ClipboardEvent);
  50140. /**
  50141. * Get the clipboard event's type from the keycode.
  50142. * @param keyCode Defines the keyCode for the current keyboard event.
  50143. * @return {number}
  50144. */
  50145. static GetTypeFromCharacter(keyCode: number): number;
  50146. }
  50147. }
  50148. declare module "babylonjs/Events/index" {
  50149. export * from "babylonjs/Events/keyboardEvents";
  50150. export * from "babylonjs/Events/pointerEvents";
  50151. export * from "babylonjs/Events/clipboardEvents";
  50152. }
  50153. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50154. import { Scene } from "babylonjs/scene";
  50155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50156. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50157. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50158. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50159. /**
  50160. * Google Daydream controller
  50161. */
  50162. export class DaydreamController extends WebVRController {
  50163. /**
  50164. * Base Url for the controller model.
  50165. */
  50166. static MODEL_BASE_URL: string;
  50167. /**
  50168. * File name for the controller model.
  50169. */
  50170. static MODEL_FILENAME: string;
  50171. /**
  50172. * Gamepad Id prefix used to identify Daydream Controller.
  50173. */
  50174. static readonly GAMEPAD_ID_PREFIX: string;
  50175. /**
  50176. * Creates a new DaydreamController from a gamepad
  50177. * @param vrGamepad the gamepad that the controller should be created from
  50178. */
  50179. constructor(vrGamepad: any);
  50180. /**
  50181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50182. * @param scene scene in which to add meshes
  50183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50184. */
  50185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50186. /**
  50187. * Called once for each button that changed state since the last frame
  50188. * @param buttonIdx Which button index changed
  50189. * @param state New state of the button
  50190. * @param changes Which properties on the state changed since last frame
  50191. */
  50192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50193. }
  50194. }
  50195. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50196. import { Scene } from "babylonjs/scene";
  50197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50198. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50200. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50201. /**
  50202. * Gear VR Controller
  50203. */
  50204. export class GearVRController extends WebVRController {
  50205. /**
  50206. * Base Url for the controller model.
  50207. */
  50208. static MODEL_BASE_URL: string;
  50209. /**
  50210. * File name for the controller model.
  50211. */
  50212. static MODEL_FILENAME: string;
  50213. /**
  50214. * Gamepad Id prefix used to identify this controller.
  50215. */
  50216. static readonly GAMEPAD_ID_PREFIX: string;
  50217. private readonly _buttonIndexToObservableNameMap;
  50218. /**
  50219. * Creates a new GearVRController from a gamepad
  50220. * @param vrGamepad the gamepad that the controller should be created from
  50221. */
  50222. constructor(vrGamepad: any);
  50223. /**
  50224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50225. * @param scene scene in which to add meshes
  50226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50227. */
  50228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50229. /**
  50230. * Called once for each button that changed state since the last frame
  50231. * @param buttonIdx Which button index changed
  50232. * @param state New state of the button
  50233. * @param changes Which properties on the state changed since last frame
  50234. */
  50235. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50236. }
  50237. }
  50238. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50239. import { Scene } from "babylonjs/scene";
  50240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50241. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50242. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50243. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50244. /**
  50245. * Generic Controller
  50246. */
  50247. export class GenericController extends WebVRController {
  50248. /**
  50249. * Base Url for the controller model.
  50250. */
  50251. static readonly MODEL_BASE_URL: string;
  50252. /**
  50253. * File name for the controller model.
  50254. */
  50255. static readonly MODEL_FILENAME: string;
  50256. /**
  50257. * Creates a new GenericController from a gamepad
  50258. * @param vrGamepad the gamepad that the controller should be created from
  50259. */
  50260. constructor(vrGamepad: any);
  50261. /**
  50262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50263. * @param scene scene in which to add meshes
  50264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50265. */
  50266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50267. /**
  50268. * Called once for each button that changed state since the last frame
  50269. * @param buttonIdx Which button index changed
  50270. * @param state New state of the button
  50271. * @param changes Which properties on the state changed since last frame
  50272. */
  50273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50274. }
  50275. }
  50276. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50277. import { Observable } from "babylonjs/Misc/observable";
  50278. import { Scene } from "babylonjs/scene";
  50279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50280. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50281. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50282. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50283. /**
  50284. * Oculus Touch Controller
  50285. */
  50286. export class OculusTouchController extends WebVRController {
  50287. /**
  50288. * Base Url for the controller model.
  50289. */
  50290. static MODEL_BASE_URL: string;
  50291. /**
  50292. * File name for the left controller model.
  50293. */
  50294. static MODEL_LEFT_FILENAME: string;
  50295. /**
  50296. * File name for the right controller model.
  50297. */
  50298. static MODEL_RIGHT_FILENAME: string;
  50299. /**
  50300. * Base Url for the Quest controller model.
  50301. */
  50302. static QUEST_MODEL_BASE_URL: string;
  50303. /**
  50304. * @hidden
  50305. * If the controllers are running on a device that needs the updated Quest controller models
  50306. */
  50307. static _IsQuest: boolean;
  50308. /**
  50309. * Fired when the secondary trigger on this controller is modified
  50310. */
  50311. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50312. /**
  50313. * Fired when the thumb rest on this controller is modified
  50314. */
  50315. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50316. /**
  50317. * Creates a new OculusTouchController from a gamepad
  50318. * @param vrGamepad the gamepad that the controller should be created from
  50319. */
  50320. constructor(vrGamepad: any);
  50321. /**
  50322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50323. * @param scene scene in which to add meshes
  50324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50325. */
  50326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50327. /**
  50328. * Fired when the A button on this controller is modified
  50329. */
  50330. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50331. /**
  50332. * Fired when the B button on this controller is modified
  50333. */
  50334. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50335. /**
  50336. * Fired when the X button on this controller is modified
  50337. */
  50338. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50339. /**
  50340. * Fired when the Y button on this controller is modified
  50341. */
  50342. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50343. /**
  50344. * Called once for each button that changed state since the last frame
  50345. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50346. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50347. * 2) secondary trigger (same)
  50348. * 3) A (right) X (left), touch, pressed = value
  50349. * 4) B / Y
  50350. * 5) thumb rest
  50351. * @param buttonIdx Which button index changed
  50352. * @param state New state of the button
  50353. * @param changes Which properties on the state changed since last frame
  50354. */
  50355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50356. }
  50357. }
  50358. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50359. import { Scene } from "babylonjs/scene";
  50360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50361. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50362. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50363. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50364. import { Observable } from "babylonjs/Misc/observable";
  50365. /**
  50366. * Vive Controller
  50367. */
  50368. export class ViveController extends WebVRController {
  50369. /**
  50370. * Base Url for the controller model.
  50371. */
  50372. static MODEL_BASE_URL: string;
  50373. /**
  50374. * File name for the controller model.
  50375. */
  50376. static MODEL_FILENAME: string;
  50377. /**
  50378. * Creates a new ViveController from a gamepad
  50379. * @param vrGamepad the gamepad that the controller should be created from
  50380. */
  50381. constructor(vrGamepad: any);
  50382. /**
  50383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50384. * @param scene scene in which to add meshes
  50385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50386. */
  50387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50388. /**
  50389. * Fired when the left button on this controller is modified
  50390. */
  50391. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50392. /**
  50393. * Fired when the right button on this controller is modified
  50394. */
  50395. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50396. /**
  50397. * Fired when the menu button on this controller is modified
  50398. */
  50399. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50400. /**
  50401. * Called once for each button that changed state since the last frame
  50402. * Vive mapping:
  50403. * 0: touchpad
  50404. * 1: trigger
  50405. * 2: left AND right buttons
  50406. * 3: menu button
  50407. * @param buttonIdx Which button index changed
  50408. * @param state New state of the button
  50409. * @param changes Which properties on the state changed since last frame
  50410. */
  50411. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50412. }
  50413. }
  50414. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50415. import { Observable } from "babylonjs/Misc/observable";
  50416. import { Scene } from "babylonjs/scene";
  50417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50418. import { Ray } from "babylonjs/Culling/ray";
  50419. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50420. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50421. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50422. /**
  50423. * Defines the WindowsMotionController object that the state of the windows motion controller
  50424. */
  50425. export class WindowsMotionController extends WebVRController {
  50426. /**
  50427. * The base url used to load the left and right controller models
  50428. */
  50429. static MODEL_BASE_URL: string;
  50430. /**
  50431. * The name of the left controller model file
  50432. */
  50433. static MODEL_LEFT_FILENAME: string;
  50434. /**
  50435. * The name of the right controller model file
  50436. */
  50437. static MODEL_RIGHT_FILENAME: string;
  50438. /**
  50439. * The controller name prefix for this controller type
  50440. */
  50441. static readonly GAMEPAD_ID_PREFIX: string;
  50442. /**
  50443. * The controller id pattern for this controller type
  50444. */
  50445. private static readonly GAMEPAD_ID_PATTERN;
  50446. private _loadedMeshInfo;
  50447. protected readonly _mapping: {
  50448. buttons: string[];
  50449. buttonMeshNames: {
  50450. trigger: string;
  50451. menu: string;
  50452. grip: string;
  50453. thumbstick: string;
  50454. trackpad: string;
  50455. };
  50456. buttonObservableNames: {
  50457. trigger: string;
  50458. menu: string;
  50459. grip: string;
  50460. thumbstick: string;
  50461. trackpad: string;
  50462. };
  50463. axisMeshNames: string[];
  50464. pointingPoseMeshName: string;
  50465. };
  50466. /**
  50467. * Fired when the trackpad on this controller is clicked
  50468. */
  50469. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50470. /**
  50471. * Fired when the trackpad on this controller is modified
  50472. */
  50473. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50474. /**
  50475. * The current x and y values of this controller's trackpad
  50476. */
  50477. trackpad: StickValues;
  50478. /**
  50479. * Creates a new WindowsMotionController from a gamepad
  50480. * @param vrGamepad the gamepad that the controller should be created from
  50481. */
  50482. constructor(vrGamepad: any);
  50483. /**
  50484. * Fired when the trigger on this controller is modified
  50485. */
  50486. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50487. /**
  50488. * Fired when the menu button on this controller is modified
  50489. */
  50490. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50491. /**
  50492. * Fired when the grip button on this controller is modified
  50493. */
  50494. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50495. /**
  50496. * Fired when the thumbstick button on this controller is modified
  50497. */
  50498. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50499. /**
  50500. * Fired when the touchpad button on this controller is modified
  50501. */
  50502. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50503. /**
  50504. * Fired when the touchpad values on this controller are modified
  50505. */
  50506. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50507. protected _updateTrackpad(): void;
  50508. /**
  50509. * Called once per frame by the engine.
  50510. */
  50511. update(): void;
  50512. /**
  50513. * Called once for each button that changed state since the last frame
  50514. * @param buttonIdx Which button index changed
  50515. * @param state New state of the button
  50516. * @param changes Which properties on the state changed since last frame
  50517. */
  50518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50519. /**
  50520. * Moves the buttons on the controller mesh based on their current state
  50521. * @param buttonName the name of the button to move
  50522. * @param buttonValue the value of the button which determines the buttons new position
  50523. */
  50524. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50525. /**
  50526. * Moves the axis on the controller mesh based on its current state
  50527. * @param axis the index of the axis
  50528. * @param axisValue the value of the axis which determines the meshes new position
  50529. * @hidden
  50530. */
  50531. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50532. /**
  50533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50534. * @param scene scene in which to add meshes
  50535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50536. */
  50537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50538. /**
  50539. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50540. * can be transformed by button presses and axes values, based on this._mapping.
  50541. *
  50542. * @param scene scene in which the meshes exist
  50543. * @param meshes list of meshes that make up the controller model to process
  50544. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50545. */
  50546. private processModel;
  50547. private createMeshInfo;
  50548. /**
  50549. * Gets the ray of the controller in the direction the controller is pointing
  50550. * @param length the length the resulting ray should be
  50551. * @returns a ray in the direction the controller is pointing
  50552. */
  50553. getForwardRay(length?: number): Ray;
  50554. /**
  50555. * Disposes of the controller
  50556. */
  50557. dispose(): void;
  50558. }
  50559. /**
  50560. * This class represents a new windows motion controller in XR.
  50561. */
  50562. export class XRWindowsMotionController extends WindowsMotionController {
  50563. /**
  50564. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50565. */
  50566. protected readonly _mapping: {
  50567. buttons: string[];
  50568. buttonMeshNames: {
  50569. trigger: string;
  50570. menu: string;
  50571. grip: string;
  50572. thumbstick: string;
  50573. trackpad: string;
  50574. };
  50575. buttonObservableNames: {
  50576. trigger: string;
  50577. menu: string;
  50578. grip: string;
  50579. thumbstick: string;
  50580. trackpad: string;
  50581. };
  50582. axisMeshNames: string[];
  50583. pointingPoseMeshName: string;
  50584. };
  50585. /**
  50586. * Construct a new XR-Based windows motion controller
  50587. *
  50588. * @param gamepadInfo the gamepad object from the browser
  50589. */
  50590. constructor(gamepadInfo: any);
  50591. /**
  50592. * holds the thumbstick values (X,Y)
  50593. */
  50594. thumbstickValues: StickValues;
  50595. /**
  50596. * Fired when the thumbstick on this controller is clicked
  50597. */
  50598. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50599. /**
  50600. * Fired when the thumbstick on this controller is modified
  50601. */
  50602. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50603. /**
  50604. * Fired when the touchpad button on this controller is modified
  50605. */
  50606. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50607. /**
  50608. * Fired when the touchpad values on this controller are modified
  50609. */
  50610. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50611. /**
  50612. * Fired when the thumbstick button on this controller is modified
  50613. * here to prevent breaking changes
  50614. */
  50615. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50616. /**
  50617. * updating the thumbstick(!) and not the trackpad.
  50618. * This is named this way due to the difference between WebVR and XR and to avoid
  50619. * changing the parent class.
  50620. */
  50621. protected _updateTrackpad(): void;
  50622. /**
  50623. * Disposes the class with joy
  50624. */
  50625. dispose(): void;
  50626. }
  50627. }
  50628. declare module "babylonjs/Gamepads/Controllers/index" {
  50629. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50630. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50631. export * from "babylonjs/Gamepads/Controllers/genericController";
  50632. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50633. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50634. export * from "babylonjs/Gamepads/Controllers/viveController";
  50635. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50636. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50637. }
  50638. declare module "babylonjs/Gamepads/index" {
  50639. export * from "babylonjs/Gamepads/Controllers/index";
  50640. export * from "babylonjs/Gamepads/gamepad";
  50641. export * from "babylonjs/Gamepads/gamepadManager";
  50642. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50643. export * from "babylonjs/Gamepads/xboxGamepad";
  50644. export * from "babylonjs/Gamepads/dualShockGamepad";
  50645. }
  50646. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50647. import { Scene } from "babylonjs/scene";
  50648. import { Vector4 } from "babylonjs/Maths/math.vector";
  50649. import { Color4 } from "babylonjs/Maths/math.color";
  50650. import { Mesh } from "babylonjs/Meshes/mesh";
  50651. import { Nullable } from "babylonjs/types";
  50652. /**
  50653. * Class containing static functions to help procedurally build meshes
  50654. */
  50655. export class PolyhedronBuilder {
  50656. /**
  50657. * Creates a polyhedron mesh
  50658. * * 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
  50659. * * The parameter `size` (positive float, default 1) sets the polygon size
  50660. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50661. * * 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`
  50662. * * 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
  50663. * * 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)`)
  50664. * * 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
  50665. * * 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
  50666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50669. * @param name defines the name of the mesh
  50670. * @param options defines the options used to create the mesh
  50671. * @param scene defines the hosting scene
  50672. * @returns the polyhedron mesh
  50673. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50674. */
  50675. static CreatePolyhedron(name: string, options: {
  50676. type?: number;
  50677. size?: number;
  50678. sizeX?: number;
  50679. sizeY?: number;
  50680. sizeZ?: number;
  50681. custom?: any;
  50682. faceUV?: Vector4[];
  50683. faceColors?: Color4[];
  50684. flat?: boolean;
  50685. updatable?: boolean;
  50686. sideOrientation?: number;
  50687. frontUVs?: Vector4;
  50688. backUVs?: Vector4;
  50689. }, scene?: Nullable<Scene>): Mesh;
  50690. }
  50691. }
  50692. declare module "babylonjs/Gizmos/scaleGizmo" {
  50693. import { Observable } from "babylonjs/Misc/observable";
  50694. import { Nullable } from "babylonjs/types";
  50695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50696. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50697. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50698. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50699. /**
  50700. * Gizmo that enables scaling a mesh along 3 axis
  50701. */
  50702. export class ScaleGizmo extends Gizmo {
  50703. /**
  50704. * Internal gizmo used for interactions on the x axis
  50705. */
  50706. xGizmo: AxisScaleGizmo;
  50707. /**
  50708. * Internal gizmo used for interactions on the y axis
  50709. */
  50710. yGizmo: AxisScaleGizmo;
  50711. /**
  50712. * Internal gizmo used for interactions on the z axis
  50713. */
  50714. zGizmo: AxisScaleGizmo;
  50715. /**
  50716. * Internal gizmo used to scale all axis equally
  50717. */
  50718. uniformScaleGizmo: AxisScaleGizmo;
  50719. private _meshAttached;
  50720. private _updateGizmoRotationToMatchAttachedMesh;
  50721. private _snapDistance;
  50722. private _scaleRatio;
  50723. private _uniformScalingMesh;
  50724. private _octahedron;
  50725. private _sensitivity;
  50726. /** Fires an event when any of it's sub gizmos are dragged */
  50727. onDragStartObservable: Observable<unknown>;
  50728. /** Fires an event when any of it's sub gizmos are released from dragging */
  50729. onDragEndObservable: Observable<unknown>;
  50730. get attachedMesh(): Nullable<AbstractMesh>;
  50731. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50732. /**
  50733. * Creates a ScaleGizmo
  50734. * @param gizmoLayer The utility layer the gizmo will be added to
  50735. */
  50736. constructor(gizmoLayer?: UtilityLayerRenderer);
  50737. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50738. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50739. /**
  50740. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50741. */
  50742. set snapDistance(value: number);
  50743. get snapDistance(): number;
  50744. /**
  50745. * Ratio for the scale of the gizmo (Default: 1)
  50746. */
  50747. set scaleRatio(value: number);
  50748. get scaleRatio(): number;
  50749. /**
  50750. * Sensitivity factor for dragging (Default: 1)
  50751. */
  50752. set sensitivity(value: number);
  50753. get sensitivity(): number;
  50754. /**
  50755. * Disposes of the gizmo
  50756. */
  50757. dispose(): void;
  50758. }
  50759. }
  50760. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50761. import { Observable } from "babylonjs/Misc/observable";
  50762. import { Nullable } from "babylonjs/types";
  50763. import { Vector3 } from "babylonjs/Maths/math.vector";
  50764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50765. import { Mesh } from "babylonjs/Meshes/mesh";
  50766. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50767. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50769. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50770. import { Color3 } from "babylonjs/Maths/math.color";
  50771. /**
  50772. * Single axis scale gizmo
  50773. */
  50774. export class AxisScaleGizmo extends Gizmo {
  50775. /**
  50776. * Drag behavior responsible for the gizmos dragging interactions
  50777. */
  50778. dragBehavior: PointerDragBehavior;
  50779. private _pointerObserver;
  50780. /**
  50781. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50782. */
  50783. snapDistance: number;
  50784. /**
  50785. * Event that fires each time the gizmo snaps to a new location.
  50786. * * snapDistance is the the change in distance
  50787. */
  50788. onSnapObservable: Observable<{
  50789. snapDistance: number;
  50790. }>;
  50791. /**
  50792. * If the scaling operation should be done on all axis (default: false)
  50793. */
  50794. uniformScaling: boolean;
  50795. /**
  50796. * Custom sensitivity value for the drag strength
  50797. */
  50798. sensitivity: number;
  50799. private _isEnabled;
  50800. private _parent;
  50801. private _arrow;
  50802. private _coloredMaterial;
  50803. private _hoverMaterial;
  50804. /**
  50805. * Creates an AxisScaleGizmo
  50806. * @param gizmoLayer The utility layer the gizmo will be added to
  50807. * @param dragAxis The axis which the gizmo will be able to scale on
  50808. * @param color The color of the gizmo
  50809. */
  50810. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50812. /**
  50813. * If the gizmo is enabled
  50814. */
  50815. set isEnabled(value: boolean);
  50816. get isEnabled(): boolean;
  50817. /**
  50818. * Disposes of the gizmo
  50819. */
  50820. dispose(): void;
  50821. /**
  50822. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50823. * @param mesh The mesh to replace the default mesh of the gizmo
  50824. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50825. */
  50826. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50827. }
  50828. }
  50829. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50830. import { Observable } from "babylonjs/Misc/observable";
  50831. import { Nullable } from "babylonjs/types";
  50832. import { Vector3 } from "babylonjs/Maths/math.vector";
  50833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50834. import { Mesh } from "babylonjs/Meshes/mesh";
  50835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50837. import { Color3 } from "babylonjs/Maths/math.color";
  50838. import "babylonjs/Meshes/Builders/boxBuilder";
  50839. /**
  50840. * Bounding box gizmo
  50841. */
  50842. export class BoundingBoxGizmo extends Gizmo {
  50843. private _lineBoundingBox;
  50844. private _rotateSpheresParent;
  50845. private _scaleBoxesParent;
  50846. private _boundingDimensions;
  50847. private _renderObserver;
  50848. private _pointerObserver;
  50849. private _scaleDragSpeed;
  50850. private _tmpQuaternion;
  50851. private _tmpVector;
  50852. private _tmpRotationMatrix;
  50853. /**
  50854. * 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)
  50855. */
  50856. ignoreChildren: boolean;
  50857. /**
  50858. * 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)
  50859. */
  50860. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50861. /**
  50862. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50863. */
  50864. rotationSphereSize: number;
  50865. /**
  50866. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50867. */
  50868. scaleBoxSize: number;
  50869. /**
  50870. * 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)
  50871. */
  50872. fixedDragMeshScreenSize: boolean;
  50873. /**
  50874. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50875. */
  50876. fixedDragMeshScreenSizeDistanceFactor: number;
  50877. /**
  50878. * Fired when a rotation sphere or scale box is dragged
  50879. */
  50880. onDragStartObservable: Observable<{}>;
  50881. /**
  50882. * Fired when a scale box is dragged
  50883. */
  50884. onScaleBoxDragObservable: Observable<{}>;
  50885. /**
  50886. * Fired when a scale box drag is ended
  50887. */
  50888. onScaleBoxDragEndObservable: Observable<{}>;
  50889. /**
  50890. * Fired when a rotation sphere is dragged
  50891. */
  50892. onRotationSphereDragObservable: Observable<{}>;
  50893. /**
  50894. * Fired when a rotation sphere drag is ended
  50895. */
  50896. onRotationSphereDragEndObservable: Observable<{}>;
  50897. /**
  50898. * 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)
  50899. */
  50900. scalePivot: Nullable<Vector3>;
  50901. /**
  50902. * Mesh used as a pivot to rotate the attached mesh
  50903. */
  50904. private _anchorMesh;
  50905. private _existingMeshScale;
  50906. private _dragMesh;
  50907. private pointerDragBehavior;
  50908. private coloredMaterial;
  50909. private hoverColoredMaterial;
  50910. /**
  50911. * Sets the color of the bounding box gizmo
  50912. * @param color the color to set
  50913. */
  50914. setColor(color: Color3): void;
  50915. /**
  50916. * Creates an BoundingBoxGizmo
  50917. * @param gizmoLayer The utility layer the gizmo will be added to
  50918. * @param color The color of the gizmo
  50919. */
  50920. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50922. private _selectNode;
  50923. /**
  50924. * Updates the bounding box information for the Gizmo
  50925. */
  50926. updateBoundingBox(): void;
  50927. private _updateRotationSpheres;
  50928. private _updateScaleBoxes;
  50929. /**
  50930. * Enables rotation on the specified axis and disables rotation on the others
  50931. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50932. */
  50933. setEnabledRotationAxis(axis: string): void;
  50934. /**
  50935. * Enables/disables scaling
  50936. * @param enable if scaling should be enabled
  50937. * @param homogeneousScaling defines if scaling should only be homogeneous
  50938. */
  50939. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50940. private _updateDummy;
  50941. /**
  50942. * Enables a pointer drag behavior on the bounding box of the gizmo
  50943. */
  50944. enableDragBehavior(): void;
  50945. /**
  50946. * Disposes of the gizmo
  50947. */
  50948. dispose(): void;
  50949. /**
  50950. * 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)
  50951. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50952. * @returns the bounding box mesh with the passed in mesh as a child
  50953. */
  50954. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50955. /**
  50956. * CustomMeshes are not supported by this gizmo
  50957. * @param mesh The mesh to replace the default mesh of the gizmo
  50958. */
  50959. setCustomMesh(mesh: Mesh): void;
  50960. }
  50961. }
  50962. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50963. import { Observable } from "babylonjs/Misc/observable";
  50964. import { Nullable } from "babylonjs/types";
  50965. import { Vector3 } from "babylonjs/Maths/math.vector";
  50966. import { Color3 } from "babylonjs/Maths/math.color";
  50967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50968. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50969. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50970. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50971. import "babylonjs/Meshes/Builders/linesBuilder";
  50972. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50973. /**
  50974. * Single plane rotation gizmo
  50975. */
  50976. export class PlaneRotationGizmo extends Gizmo {
  50977. /**
  50978. * Drag behavior responsible for the gizmos dragging interactions
  50979. */
  50980. dragBehavior: PointerDragBehavior;
  50981. private _pointerObserver;
  50982. /**
  50983. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50984. */
  50985. snapDistance: number;
  50986. /**
  50987. * Event that fires each time the gizmo snaps to a new location.
  50988. * * snapDistance is the the change in distance
  50989. */
  50990. onSnapObservable: Observable<{
  50991. snapDistance: number;
  50992. }>;
  50993. private _isEnabled;
  50994. private _parent;
  50995. /**
  50996. * Creates a PlaneRotationGizmo
  50997. * @param gizmoLayer The utility layer the gizmo will be added to
  50998. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50999. * @param color The color of the gizmo
  51000. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51001. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51002. */
  51003. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51005. /**
  51006. * If the gizmo is enabled
  51007. */
  51008. set isEnabled(value: boolean);
  51009. get isEnabled(): boolean;
  51010. /**
  51011. * Disposes of the gizmo
  51012. */
  51013. dispose(): void;
  51014. }
  51015. }
  51016. declare module "babylonjs/Gizmos/rotationGizmo" {
  51017. import { Observable } from "babylonjs/Misc/observable";
  51018. import { Nullable } from "babylonjs/types";
  51019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51020. import { Mesh } from "babylonjs/Meshes/mesh";
  51021. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51022. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51023. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51024. /**
  51025. * Gizmo that enables rotating a mesh along 3 axis
  51026. */
  51027. export class RotationGizmo extends Gizmo {
  51028. /**
  51029. * Internal gizmo used for interactions on the x axis
  51030. */
  51031. xGizmo: PlaneRotationGizmo;
  51032. /**
  51033. * Internal gizmo used for interactions on the y axis
  51034. */
  51035. yGizmo: PlaneRotationGizmo;
  51036. /**
  51037. * Internal gizmo used for interactions on the z axis
  51038. */
  51039. zGizmo: PlaneRotationGizmo;
  51040. /** Fires an event when any of it's sub gizmos are dragged */
  51041. onDragStartObservable: Observable<unknown>;
  51042. /** Fires an event when any of it's sub gizmos are released from dragging */
  51043. onDragEndObservable: Observable<unknown>;
  51044. private _meshAttached;
  51045. get attachedMesh(): Nullable<AbstractMesh>;
  51046. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51047. /**
  51048. * Creates a RotationGizmo
  51049. * @param gizmoLayer The utility layer the gizmo will be added to
  51050. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51051. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51052. */
  51053. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51054. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51055. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51056. /**
  51057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51058. */
  51059. set snapDistance(value: number);
  51060. get snapDistance(): number;
  51061. /**
  51062. * Ratio for the scale of the gizmo (Default: 1)
  51063. */
  51064. set scaleRatio(value: number);
  51065. get scaleRatio(): number;
  51066. /**
  51067. * Disposes of the gizmo
  51068. */
  51069. dispose(): void;
  51070. /**
  51071. * CustomMeshes are not supported by this gizmo
  51072. * @param mesh The mesh to replace the default mesh of the gizmo
  51073. */
  51074. setCustomMesh(mesh: Mesh): void;
  51075. }
  51076. }
  51077. declare module "babylonjs/Gizmos/gizmoManager" {
  51078. import { Observable } from "babylonjs/Misc/observable";
  51079. import { Nullable } from "babylonjs/types";
  51080. import { Scene, IDisposable } from "babylonjs/scene";
  51081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51082. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51083. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51084. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51085. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51086. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51087. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51088. /**
  51089. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51090. */
  51091. export class GizmoManager implements IDisposable {
  51092. private scene;
  51093. /**
  51094. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51095. */
  51096. gizmos: {
  51097. positionGizmo: Nullable<PositionGizmo>;
  51098. rotationGizmo: Nullable<RotationGizmo>;
  51099. scaleGizmo: Nullable<ScaleGizmo>;
  51100. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51101. };
  51102. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51103. clearGizmoOnEmptyPointerEvent: boolean;
  51104. /** Fires an event when the manager is attached to a mesh */
  51105. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51106. private _gizmosEnabled;
  51107. private _pointerObserver;
  51108. private _attachedMesh;
  51109. private _boundingBoxColor;
  51110. private _defaultUtilityLayer;
  51111. private _defaultKeepDepthUtilityLayer;
  51112. /**
  51113. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51114. */
  51115. boundingBoxDragBehavior: SixDofDragBehavior;
  51116. /**
  51117. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51118. */
  51119. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51120. /**
  51121. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51122. */
  51123. usePointerToAttachGizmos: boolean;
  51124. /**
  51125. * Utility layer that the bounding box gizmo belongs to
  51126. */
  51127. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51128. /**
  51129. * Utility layer that all gizmos besides bounding box belong to
  51130. */
  51131. get utilityLayer(): UtilityLayerRenderer;
  51132. /**
  51133. * Instatiates a gizmo manager
  51134. * @param scene the scene to overlay the gizmos on top of
  51135. */
  51136. constructor(scene: Scene);
  51137. /**
  51138. * Attaches a set of gizmos to the specified mesh
  51139. * @param mesh The mesh the gizmo's should be attached to
  51140. */
  51141. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51142. /**
  51143. * If the position gizmo is enabled
  51144. */
  51145. set positionGizmoEnabled(value: boolean);
  51146. get positionGizmoEnabled(): boolean;
  51147. /**
  51148. * If the rotation gizmo is enabled
  51149. */
  51150. set rotationGizmoEnabled(value: boolean);
  51151. get rotationGizmoEnabled(): boolean;
  51152. /**
  51153. * If the scale gizmo is enabled
  51154. */
  51155. set scaleGizmoEnabled(value: boolean);
  51156. get scaleGizmoEnabled(): boolean;
  51157. /**
  51158. * If the boundingBox gizmo is enabled
  51159. */
  51160. set boundingBoxGizmoEnabled(value: boolean);
  51161. get boundingBoxGizmoEnabled(): boolean;
  51162. /**
  51163. * Disposes of the gizmo manager
  51164. */
  51165. dispose(): void;
  51166. }
  51167. }
  51168. declare module "babylonjs/Lights/directionalLight" {
  51169. import { Camera } from "babylonjs/Cameras/camera";
  51170. import { Scene } from "babylonjs/scene";
  51171. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51173. import { Light } from "babylonjs/Lights/light";
  51174. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51175. import { Effect } from "babylonjs/Materials/effect";
  51176. /**
  51177. * A directional light is defined by a direction (what a surprise!).
  51178. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51179. * 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.
  51180. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51181. */
  51182. export class DirectionalLight extends ShadowLight {
  51183. private _shadowFrustumSize;
  51184. /**
  51185. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51186. */
  51187. get shadowFrustumSize(): number;
  51188. /**
  51189. * Specifies a fix frustum size for the shadow generation.
  51190. */
  51191. set shadowFrustumSize(value: number);
  51192. private _shadowOrthoScale;
  51193. /**
  51194. * Gets the shadow projection scale against the optimal computed one.
  51195. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51196. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51197. */
  51198. get shadowOrthoScale(): number;
  51199. /**
  51200. * Sets the shadow projection scale against the optimal computed one.
  51201. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51202. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51203. */
  51204. set shadowOrthoScale(value: number);
  51205. /**
  51206. * Automatically compute the projection matrix to best fit (including all the casters)
  51207. * on each frame.
  51208. */
  51209. autoUpdateExtends: boolean;
  51210. /**
  51211. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51212. * on each frame. autoUpdateExtends must be set to true for this to work
  51213. */
  51214. autoCalcShadowZBounds: boolean;
  51215. private _orthoLeft;
  51216. private _orthoRight;
  51217. private _orthoTop;
  51218. private _orthoBottom;
  51219. /**
  51220. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51221. * The directional light is emitted from everywhere in the given direction.
  51222. * It can cast shadows.
  51223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51224. * @param name The friendly name of the light
  51225. * @param direction The direction of the light
  51226. * @param scene The scene the light belongs to
  51227. */
  51228. constructor(name: string, direction: Vector3, scene: Scene);
  51229. /**
  51230. * Returns the string "DirectionalLight".
  51231. * @return The class name
  51232. */
  51233. getClassName(): string;
  51234. /**
  51235. * Returns the integer 1.
  51236. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51237. */
  51238. getTypeID(): number;
  51239. /**
  51240. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51241. * Returns the DirectionalLight Shadow projection matrix.
  51242. */
  51243. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51244. /**
  51245. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51246. * Returns the DirectionalLight Shadow projection matrix.
  51247. */
  51248. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51249. /**
  51250. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51251. * Returns the DirectionalLight Shadow projection matrix.
  51252. */
  51253. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51254. protected _buildUniformLayout(): void;
  51255. /**
  51256. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51257. * @param effect The effect to update
  51258. * @param lightIndex The index of the light in the effect to update
  51259. * @returns The directional light
  51260. */
  51261. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51262. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51263. /**
  51264. * Gets the minZ used for shadow according to both the scene and the light.
  51265. *
  51266. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51267. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51268. * @param activeCamera The camera we are returning the min for
  51269. * @returns the depth min z
  51270. */
  51271. getDepthMinZ(activeCamera: Camera): number;
  51272. /**
  51273. * Gets the maxZ used for shadow according to both the scene and the light.
  51274. *
  51275. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51276. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51277. * @param activeCamera The camera we are returning the max for
  51278. * @returns the depth max z
  51279. */
  51280. getDepthMaxZ(activeCamera: Camera): number;
  51281. /**
  51282. * Prepares the list of defines specific to the light type.
  51283. * @param defines the list of defines
  51284. * @param lightIndex defines the index of the light for the effect
  51285. */
  51286. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51287. }
  51288. }
  51289. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51290. import { Mesh } from "babylonjs/Meshes/mesh";
  51291. /**
  51292. * Class containing static functions to help procedurally build meshes
  51293. */
  51294. export class HemisphereBuilder {
  51295. /**
  51296. * Creates a hemisphere mesh
  51297. * @param name defines the name of the mesh
  51298. * @param options defines the options used to create the mesh
  51299. * @param scene defines the hosting scene
  51300. * @returns the hemisphere mesh
  51301. */
  51302. static CreateHemisphere(name: string, options: {
  51303. segments?: number;
  51304. diameter?: number;
  51305. sideOrientation?: number;
  51306. }, scene: any): Mesh;
  51307. }
  51308. }
  51309. declare module "babylonjs/Lights/spotLight" {
  51310. import { Nullable } from "babylonjs/types";
  51311. import { Scene } from "babylonjs/scene";
  51312. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51314. import { Effect } from "babylonjs/Materials/effect";
  51315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51316. import { Light } from "babylonjs/Lights/light";
  51317. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51318. /**
  51319. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51320. * These values define a cone of light starting from the position, emitting toward the direction.
  51321. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51322. * and the exponent defines the speed of the decay of the light with distance (reach).
  51323. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51324. */
  51325. export class SpotLight extends ShadowLight {
  51326. private _angle;
  51327. private _innerAngle;
  51328. private _cosHalfAngle;
  51329. private _lightAngleScale;
  51330. private _lightAngleOffset;
  51331. /**
  51332. * Gets the cone angle of the spot light in Radians.
  51333. */
  51334. get angle(): number;
  51335. /**
  51336. * Sets the cone angle of the spot light in Radians.
  51337. */
  51338. set angle(value: number);
  51339. /**
  51340. * Only used in gltf falloff mode, this defines the angle where
  51341. * the directional falloff will start before cutting at angle which could be seen
  51342. * as outer angle.
  51343. */
  51344. get innerAngle(): number;
  51345. /**
  51346. * Only used in gltf falloff mode, this defines the angle where
  51347. * the directional falloff will start before cutting at angle which could be seen
  51348. * as outer angle.
  51349. */
  51350. set innerAngle(value: number);
  51351. private _shadowAngleScale;
  51352. /**
  51353. * Allows scaling the angle of the light for shadow generation only.
  51354. */
  51355. get shadowAngleScale(): number;
  51356. /**
  51357. * Allows scaling the angle of the light for shadow generation only.
  51358. */
  51359. set shadowAngleScale(value: number);
  51360. /**
  51361. * The light decay speed with the distance from the emission spot.
  51362. */
  51363. exponent: number;
  51364. private _projectionTextureMatrix;
  51365. /**
  51366. * Allows reading the projecton texture
  51367. */
  51368. get projectionTextureMatrix(): Matrix;
  51369. protected _projectionTextureLightNear: number;
  51370. /**
  51371. * Gets the near clip of the Spotlight for texture projection.
  51372. */
  51373. get projectionTextureLightNear(): number;
  51374. /**
  51375. * Sets the near clip of the Spotlight for texture projection.
  51376. */
  51377. set projectionTextureLightNear(value: number);
  51378. protected _projectionTextureLightFar: number;
  51379. /**
  51380. * Gets the far clip of the Spotlight for texture projection.
  51381. */
  51382. get projectionTextureLightFar(): number;
  51383. /**
  51384. * Sets the far clip of the Spotlight for texture projection.
  51385. */
  51386. set projectionTextureLightFar(value: number);
  51387. protected _projectionTextureUpDirection: Vector3;
  51388. /**
  51389. * Gets the Up vector of the Spotlight for texture projection.
  51390. */
  51391. get projectionTextureUpDirection(): Vector3;
  51392. /**
  51393. * Sets the Up vector of the Spotlight for texture projection.
  51394. */
  51395. set projectionTextureUpDirection(value: Vector3);
  51396. private _projectionTexture;
  51397. /**
  51398. * Gets the projection texture of the light.
  51399. */
  51400. get projectionTexture(): Nullable<BaseTexture>;
  51401. /**
  51402. * Sets the projection texture of the light.
  51403. */
  51404. set projectionTexture(value: Nullable<BaseTexture>);
  51405. private _projectionTextureViewLightDirty;
  51406. private _projectionTextureProjectionLightDirty;
  51407. private _projectionTextureDirty;
  51408. private _projectionTextureViewTargetVector;
  51409. private _projectionTextureViewLightMatrix;
  51410. private _projectionTextureProjectionLightMatrix;
  51411. private _projectionTextureScalingMatrix;
  51412. /**
  51413. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51414. * It can cast shadows.
  51415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51416. * @param name The light friendly name
  51417. * @param position The position of the spot light in the scene
  51418. * @param direction The direction of the light in the scene
  51419. * @param angle The cone angle of the light in Radians
  51420. * @param exponent The light decay speed with the distance from the emission spot
  51421. * @param scene The scene the lights belongs to
  51422. */
  51423. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51424. /**
  51425. * Returns the string "SpotLight".
  51426. * @returns the class name
  51427. */
  51428. getClassName(): string;
  51429. /**
  51430. * Returns the integer 2.
  51431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51432. */
  51433. getTypeID(): number;
  51434. /**
  51435. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51436. */
  51437. protected _setDirection(value: Vector3): void;
  51438. /**
  51439. * Overrides the position setter to recompute the projection texture view light Matrix.
  51440. */
  51441. protected _setPosition(value: Vector3): void;
  51442. /**
  51443. * 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.
  51444. * Returns the SpotLight.
  51445. */
  51446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51447. protected _computeProjectionTextureViewLightMatrix(): void;
  51448. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51449. /**
  51450. * Main function for light texture projection matrix computing.
  51451. */
  51452. protected _computeProjectionTextureMatrix(): void;
  51453. protected _buildUniformLayout(): void;
  51454. private _computeAngleValues;
  51455. /**
  51456. * Sets the passed Effect "effect" with the Light textures.
  51457. * @param effect The effect to update
  51458. * @param lightIndex The index of the light in the effect to update
  51459. * @returns The light
  51460. */
  51461. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51462. /**
  51463. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51464. * @param effect The effect to update
  51465. * @param lightIndex The index of the light in the effect to update
  51466. * @returns The spot light
  51467. */
  51468. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51469. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51470. /**
  51471. * Disposes the light and the associated resources.
  51472. */
  51473. dispose(): void;
  51474. /**
  51475. * Prepares the list of defines specific to the light type.
  51476. * @param defines the list of defines
  51477. * @param lightIndex defines the index of the light for the effect
  51478. */
  51479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51480. }
  51481. }
  51482. declare module "babylonjs/Gizmos/lightGizmo" {
  51483. import { Nullable } from "babylonjs/types";
  51484. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51486. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51487. import { Light } from "babylonjs/Lights/light";
  51488. /**
  51489. * Gizmo that enables viewing a light
  51490. */
  51491. export class LightGizmo extends Gizmo {
  51492. private _lightMesh;
  51493. private _material;
  51494. private _cachedPosition;
  51495. private _cachedForward;
  51496. private _attachedMeshParent;
  51497. /**
  51498. * Creates a LightGizmo
  51499. * @param gizmoLayer The utility layer the gizmo will be added to
  51500. */
  51501. constructor(gizmoLayer?: UtilityLayerRenderer);
  51502. private _light;
  51503. /**
  51504. * The light that the gizmo is attached to
  51505. */
  51506. set light(light: Nullable<Light>);
  51507. get light(): Nullable<Light>;
  51508. /**
  51509. * Gets the material used to render the light gizmo
  51510. */
  51511. get material(): StandardMaterial;
  51512. /**
  51513. * @hidden
  51514. * Updates the gizmo to match the attached mesh's position/rotation
  51515. */
  51516. protected _update(): void;
  51517. private static _Scale;
  51518. /**
  51519. * Creates the lines for a light mesh
  51520. */
  51521. private static _CreateLightLines;
  51522. /**
  51523. * Disposes of the light gizmo
  51524. */
  51525. dispose(): void;
  51526. private static _CreateHemisphericLightMesh;
  51527. private static _CreatePointLightMesh;
  51528. private static _CreateSpotLightMesh;
  51529. private static _CreateDirectionalLightMesh;
  51530. }
  51531. }
  51532. declare module "babylonjs/Gizmos/index" {
  51533. export * from "babylonjs/Gizmos/axisDragGizmo";
  51534. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51535. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51536. export * from "babylonjs/Gizmos/gizmo";
  51537. export * from "babylonjs/Gizmos/gizmoManager";
  51538. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51539. export * from "babylonjs/Gizmos/positionGizmo";
  51540. export * from "babylonjs/Gizmos/rotationGizmo";
  51541. export * from "babylonjs/Gizmos/scaleGizmo";
  51542. export * from "babylonjs/Gizmos/lightGizmo";
  51543. export * from "babylonjs/Gizmos/planeDragGizmo";
  51544. }
  51545. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51546. /** @hidden */
  51547. export var backgroundFragmentDeclaration: {
  51548. name: string;
  51549. shader: string;
  51550. };
  51551. }
  51552. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51553. /** @hidden */
  51554. export var backgroundUboDeclaration: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module "babylonjs/Shaders/background.fragment" {
  51560. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51561. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51562. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51564. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51565. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51567. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51568. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51570. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51571. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51572. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51573. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51574. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51575. /** @hidden */
  51576. export var backgroundPixelShader: {
  51577. name: string;
  51578. shader: string;
  51579. };
  51580. }
  51581. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51582. /** @hidden */
  51583. export var backgroundVertexDeclaration: {
  51584. name: string;
  51585. shader: string;
  51586. };
  51587. }
  51588. declare module "babylonjs/Shaders/background.vertex" {
  51589. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51590. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51592. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51594. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51595. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51596. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51597. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51598. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51599. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51601. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51602. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51603. /** @hidden */
  51604. export var backgroundVertexShader: {
  51605. name: string;
  51606. shader: string;
  51607. };
  51608. }
  51609. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51610. import { Nullable, int, float } from "babylonjs/types";
  51611. import { Scene } from "babylonjs/scene";
  51612. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51613. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51615. import { Mesh } from "babylonjs/Meshes/mesh";
  51616. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51617. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51618. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51620. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51621. import { Color3 } from "babylonjs/Maths/math.color";
  51622. import "babylonjs/Shaders/background.fragment";
  51623. import "babylonjs/Shaders/background.vertex";
  51624. /**
  51625. * Background material used to create an efficient environement around your scene.
  51626. */
  51627. export class BackgroundMaterial extends PushMaterial {
  51628. /**
  51629. * Standard reflectance value at parallel view angle.
  51630. */
  51631. static StandardReflectance0: number;
  51632. /**
  51633. * Standard reflectance value at grazing angle.
  51634. */
  51635. static StandardReflectance90: number;
  51636. protected _primaryColor: Color3;
  51637. /**
  51638. * Key light Color (multiply against the environement texture)
  51639. */
  51640. primaryColor: Color3;
  51641. protected __perceptualColor: Nullable<Color3>;
  51642. /**
  51643. * Experimental Internal Use Only.
  51644. *
  51645. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51646. * This acts as a helper to set the primary color to a more "human friendly" value.
  51647. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51648. * output color as close as possible from the chosen value.
  51649. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51650. * part of lighting setup.)
  51651. */
  51652. get _perceptualColor(): Nullable<Color3>;
  51653. set _perceptualColor(value: Nullable<Color3>);
  51654. protected _primaryColorShadowLevel: float;
  51655. /**
  51656. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51657. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51658. */
  51659. get primaryColorShadowLevel(): float;
  51660. set primaryColorShadowLevel(value: float);
  51661. protected _primaryColorHighlightLevel: float;
  51662. /**
  51663. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51664. * The primary color is used at the level chosen to define what the white area would look.
  51665. */
  51666. get primaryColorHighlightLevel(): float;
  51667. set primaryColorHighlightLevel(value: float);
  51668. protected _reflectionTexture: Nullable<BaseTexture>;
  51669. /**
  51670. * Reflection Texture used in the material.
  51671. * Should be author in a specific way for the best result (refer to the documentation).
  51672. */
  51673. reflectionTexture: Nullable<BaseTexture>;
  51674. protected _reflectionBlur: float;
  51675. /**
  51676. * Reflection Texture level of blur.
  51677. *
  51678. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51679. * texture twice.
  51680. */
  51681. reflectionBlur: float;
  51682. protected _diffuseTexture: Nullable<BaseTexture>;
  51683. /**
  51684. * Diffuse Texture used in the material.
  51685. * Should be author in a specific way for the best result (refer to the documentation).
  51686. */
  51687. diffuseTexture: Nullable<BaseTexture>;
  51688. protected _shadowLights: Nullable<IShadowLight[]>;
  51689. /**
  51690. * Specify the list of lights casting shadow on the material.
  51691. * All scene shadow lights will be included if null.
  51692. */
  51693. shadowLights: Nullable<IShadowLight[]>;
  51694. protected _shadowLevel: float;
  51695. /**
  51696. * Helps adjusting the shadow to a softer level if required.
  51697. * 0 means black shadows and 1 means no shadows.
  51698. */
  51699. shadowLevel: float;
  51700. protected _sceneCenter: Vector3;
  51701. /**
  51702. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51703. * It is usually zero but might be interesting to modify according to your setup.
  51704. */
  51705. sceneCenter: Vector3;
  51706. protected _opacityFresnel: boolean;
  51707. /**
  51708. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51709. * This helps ensuring a nice transition when the camera goes under the ground.
  51710. */
  51711. opacityFresnel: boolean;
  51712. protected _reflectionFresnel: boolean;
  51713. /**
  51714. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51715. * This helps adding a mirror texture on the ground.
  51716. */
  51717. reflectionFresnel: boolean;
  51718. protected _reflectionFalloffDistance: number;
  51719. /**
  51720. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51721. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51722. */
  51723. reflectionFalloffDistance: number;
  51724. protected _reflectionAmount: number;
  51725. /**
  51726. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51727. */
  51728. reflectionAmount: number;
  51729. protected _reflectionReflectance0: number;
  51730. /**
  51731. * This specifies the weight of the reflection at grazing angle.
  51732. */
  51733. reflectionReflectance0: number;
  51734. protected _reflectionReflectance90: number;
  51735. /**
  51736. * This specifies the weight of the reflection at a perpendicular point of view.
  51737. */
  51738. reflectionReflectance90: number;
  51739. /**
  51740. * Sets the reflection reflectance fresnel values according to the default standard
  51741. * empirically know to work well :-)
  51742. */
  51743. set reflectionStandardFresnelWeight(value: number);
  51744. protected _useRGBColor: boolean;
  51745. /**
  51746. * Helps to directly use the maps channels instead of their level.
  51747. */
  51748. useRGBColor: boolean;
  51749. protected _enableNoise: boolean;
  51750. /**
  51751. * This helps reducing the banding effect that could occur on the background.
  51752. */
  51753. enableNoise: boolean;
  51754. /**
  51755. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51756. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51757. * Recommended to be keep at 1.0 except for special cases.
  51758. */
  51759. get fovMultiplier(): number;
  51760. set fovMultiplier(value: number);
  51761. private _fovMultiplier;
  51762. /**
  51763. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51764. */
  51765. useEquirectangularFOV: boolean;
  51766. private _maxSimultaneousLights;
  51767. /**
  51768. * Number of Simultaneous lights allowed on the material.
  51769. */
  51770. maxSimultaneousLights: int;
  51771. /**
  51772. * Default configuration related to image processing available in the Background Material.
  51773. */
  51774. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51775. /**
  51776. * Keep track of the image processing observer to allow dispose and replace.
  51777. */
  51778. private _imageProcessingObserver;
  51779. /**
  51780. * Attaches a new image processing configuration to the PBR Material.
  51781. * @param configuration (if null the scene configuration will be use)
  51782. */
  51783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51784. /**
  51785. * Gets the image processing configuration used either in this material.
  51786. */
  51787. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51788. /**
  51789. * Sets the Default image processing configuration used either in the this material.
  51790. *
  51791. * If sets to null, the scene one is in use.
  51792. */
  51793. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51794. /**
  51795. * Gets wether the color curves effect is enabled.
  51796. */
  51797. get cameraColorCurvesEnabled(): boolean;
  51798. /**
  51799. * Sets wether the color curves effect is enabled.
  51800. */
  51801. set cameraColorCurvesEnabled(value: boolean);
  51802. /**
  51803. * Gets wether the color grading effect is enabled.
  51804. */
  51805. get cameraColorGradingEnabled(): boolean;
  51806. /**
  51807. * Gets wether the color grading effect is enabled.
  51808. */
  51809. set cameraColorGradingEnabled(value: boolean);
  51810. /**
  51811. * Gets wether tonemapping is enabled or not.
  51812. */
  51813. get cameraToneMappingEnabled(): boolean;
  51814. /**
  51815. * Sets wether tonemapping is enabled or not
  51816. */
  51817. set cameraToneMappingEnabled(value: boolean);
  51818. /**
  51819. * The camera exposure used on this material.
  51820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51821. * This corresponds to a photographic exposure.
  51822. */
  51823. get cameraExposure(): float;
  51824. /**
  51825. * The camera exposure used on this material.
  51826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51827. * This corresponds to a photographic exposure.
  51828. */
  51829. set cameraExposure(value: float);
  51830. /**
  51831. * Gets The camera contrast used on this material.
  51832. */
  51833. get cameraContrast(): float;
  51834. /**
  51835. * Sets The camera contrast used on this material.
  51836. */
  51837. set cameraContrast(value: float);
  51838. /**
  51839. * Gets the Color Grading 2D Lookup Texture.
  51840. */
  51841. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51842. /**
  51843. * Sets the Color Grading 2D Lookup Texture.
  51844. */
  51845. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51846. /**
  51847. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51848. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51849. * 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;
  51850. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51851. */
  51852. get cameraColorCurves(): Nullable<ColorCurves>;
  51853. /**
  51854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51856. * 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;
  51857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51858. */
  51859. set cameraColorCurves(value: Nullable<ColorCurves>);
  51860. /**
  51861. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51862. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51863. */
  51864. switchToBGR: boolean;
  51865. private _renderTargets;
  51866. private _reflectionControls;
  51867. private _white;
  51868. private _primaryShadowColor;
  51869. private _primaryHighlightColor;
  51870. /**
  51871. * Instantiates a Background Material in the given scene
  51872. * @param name The friendly name of the material
  51873. * @param scene The scene to add the material to
  51874. */
  51875. constructor(name: string, scene: Scene);
  51876. /**
  51877. * Gets a boolean indicating that current material needs to register RTT
  51878. */
  51879. get hasRenderTargetTextures(): boolean;
  51880. /**
  51881. * The entire material has been created in order to prevent overdraw.
  51882. * @returns false
  51883. */
  51884. needAlphaTesting(): boolean;
  51885. /**
  51886. * The entire material has been created in order to prevent overdraw.
  51887. * @returns true if blending is enable
  51888. */
  51889. needAlphaBlending(): boolean;
  51890. /**
  51891. * Checks wether the material is ready to be rendered for a given mesh.
  51892. * @param mesh The mesh to render
  51893. * @param subMesh The submesh to check against
  51894. * @param useInstances Specify wether or not the material is used with instances
  51895. * @returns true if all the dependencies are ready (Textures, Effects...)
  51896. */
  51897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51898. /**
  51899. * Compute the primary color according to the chosen perceptual color.
  51900. */
  51901. private _computePrimaryColorFromPerceptualColor;
  51902. /**
  51903. * Compute the highlights and shadow colors according to their chosen levels.
  51904. */
  51905. private _computePrimaryColors;
  51906. /**
  51907. * Build the uniform buffer used in the material.
  51908. */
  51909. buildUniformLayout(): void;
  51910. /**
  51911. * Unbind the material.
  51912. */
  51913. unbind(): void;
  51914. /**
  51915. * Bind only the world matrix to the material.
  51916. * @param world The world matrix to bind.
  51917. */
  51918. bindOnlyWorldMatrix(world: Matrix): void;
  51919. /**
  51920. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51921. * @param world The world matrix to bind.
  51922. * @param subMesh The submesh to bind for.
  51923. */
  51924. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51925. /**
  51926. * Checks to see if a texture is used in the material.
  51927. * @param texture - Base texture to use.
  51928. * @returns - Boolean specifying if a texture is used in the material.
  51929. */
  51930. hasTexture(texture: BaseTexture): boolean;
  51931. /**
  51932. * Dispose the material.
  51933. * @param forceDisposeEffect Force disposal of the associated effect.
  51934. * @param forceDisposeTextures Force disposal of the associated textures.
  51935. */
  51936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51937. /**
  51938. * Clones the material.
  51939. * @param name The cloned name.
  51940. * @returns The cloned material.
  51941. */
  51942. clone(name: string): BackgroundMaterial;
  51943. /**
  51944. * Serializes the current material to its JSON representation.
  51945. * @returns The JSON representation.
  51946. */
  51947. serialize(): any;
  51948. /**
  51949. * Gets the class name of the material
  51950. * @returns "BackgroundMaterial"
  51951. */
  51952. getClassName(): string;
  51953. /**
  51954. * Parse a JSON input to create back a background material.
  51955. * @param source The JSON data to parse
  51956. * @param scene The scene to create the parsed material in
  51957. * @param rootUrl The root url of the assets the material depends upon
  51958. * @returns the instantiated BackgroundMaterial.
  51959. */
  51960. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51961. }
  51962. }
  51963. declare module "babylonjs/Helpers/environmentHelper" {
  51964. import { Observable } from "babylonjs/Misc/observable";
  51965. import { Nullable } from "babylonjs/types";
  51966. import { Scene } from "babylonjs/scene";
  51967. import { Vector3 } from "babylonjs/Maths/math.vector";
  51968. import { Color3 } from "babylonjs/Maths/math.color";
  51969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51970. import { Mesh } from "babylonjs/Meshes/mesh";
  51971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51972. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51973. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51974. import "babylonjs/Meshes/Builders/planeBuilder";
  51975. import "babylonjs/Meshes/Builders/boxBuilder";
  51976. /**
  51977. * Represents the different options available during the creation of
  51978. * a Environment helper.
  51979. *
  51980. * This can control the default ground, skybox and image processing setup of your scene.
  51981. */
  51982. export interface IEnvironmentHelperOptions {
  51983. /**
  51984. * Specifies whether or not to create a ground.
  51985. * True by default.
  51986. */
  51987. createGround: boolean;
  51988. /**
  51989. * Specifies the ground size.
  51990. * 15 by default.
  51991. */
  51992. groundSize: number;
  51993. /**
  51994. * The texture used on the ground for the main color.
  51995. * Comes from the BabylonJS CDN by default.
  51996. *
  51997. * Remarks: Can be either a texture or a url.
  51998. */
  51999. groundTexture: string | BaseTexture;
  52000. /**
  52001. * The color mixed in the ground texture by default.
  52002. * BabylonJS clearColor by default.
  52003. */
  52004. groundColor: Color3;
  52005. /**
  52006. * Specifies the ground opacity.
  52007. * 1 by default.
  52008. */
  52009. groundOpacity: number;
  52010. /**
  52011. * Enables the ground to receive shadows.
  52012. * True by default.
  52013. */
  52014. enableGroundShadow: boolean;
  52015. /**
  52016. * Helps preventing the shadow to be fully black on the ground.
  52017. * 0.5 by default.
  52018. */
  52019. groundShadowLevel: number;
  52020. /**
  52021. * Creates a mirror texture attach to the ground.
  52022. * false by default.
  52023. */
  52024. enableGroundMirror: boolean;
  52025. /**
  52026. * Specifies the ground mirror size ratio.
  52027. * 0.3 by default as the default kernel is 64.
  52028. */
  52029. groundMirrorSizeRatio: number;
  52030. /**
  52031. * Specifies the ground mirror blur kernel size.
  52032. * 64 by default.
  52033. */
  52034. groundMirrorBlurKernel: number;
  52035. /**
  52036. * Specifies the ground mirror visibility amount.
  52037. * 1 by default
  52038. */
  52039. groundMirrorAmount: number;
  52040. /**
  52041. * Specifies the ground mirror reflectance weight.
  52042. * This uses the standard weight of the background material to setup the fresnel effect
  52043. * of the mirror.
  52044. * 1 by default.
  52045. */
  52046. groundMirrorFresnelWeight: number;
  52047. /**
  52048. * Specifies the ground mirror Falloff distance.
  52049. * This can helps reducing the size of the reflection.
  52050. * 0 by Default.
  52051. */
  52052. groundMirrorFallOffDistance: number;
  52053. /**
  52054. * Specifies the ground mirror texture type.
  52055. * Unsigned Int by Default.
  52056. */
  52057. groundMirrorTextureType: number;
  52058. /**
  52059. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52060. * the shown objects.
  52061. */
  52062. groundYBias: number;
  52063. /**
  52064. * Specifies whether or not to create a skybox.
  52065. * True by default.
  52066. */
  52067. createSkybox: boolean;
  52068. /**
  52069. * Specifies the skybox size.
  52070. * 20 by default.
  52071. */
  52072. skyboxSize: number;
  52073. /**
  52074. * The texture used on the skybox for the main color.
  52075. * Comes from the BabylonJS CDN by default.
  52076. *
  52077. * Remarks: Can be either a texture or a url.
  52078. */
  52079. skyboxTexture: string | BaseTexture;
  52080. /**
  52081. * The color mixed in the skybox texture by default.
  52082. * BabylonJS clearColor by default.
  52083. */
  52084. skyboxColor: Color3;
  52085. /**
  52086. * The background rotation around the Y axis of the scene.
  52087. * This helps aligning the key lights of your scene with the background.
  52088. * 0 by default.
  52089. */
  52090. backgroundYRotation: number;
  52091. /**
  52092. * Compute automatically the size of the elements to best fit with the scene.
  52093. */
  52094. sizeAuto: boolean;
  52095. /**
  52096. * Default position of the rootMesh if autoSize is not true.
  52097. */
  52098. rootPosition: Vector3;
  52099. /**
  52100. * Sets up the image processing in the scene.
  52101. * true by default.
  52102. */
  52103. setupImageProcessing: boolean;
  52104. /**
  52105. * The texture used as your environment texture in the scene.
  52106. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52107. *
  52108. * Remarks: Can be either a texture or a url.
  52109. */
  52110. environmentTexture: string | BaseTexture;
  52111. /**
  52112. * The value of the exposure to apply to the scene.
  52113. * 0.6 by default if setupImageProcessing is true.
  52114. */
  52115. cameraExposure: number;
  52116. /**
  52117. * The value of the contrast to apply to the scene.
  52118. * 1.6 by default if setupImageProcessing is true.
  52119. */
  52120. cameraContrast: number;
  52121. /**
  52122. * Specifies whether or not tonemapping should be enabled in the scene.
  52123. * true by default if setupImageProcessing is true.
  52124. */
  52125. toneMappingEnabled: boolean;
  52126. }
  52127. /**
  52128. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52129. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52130. * It also helps with the default setup of your imageProcessing configuration.
  52131. */
  52132. export class EnvironmentHelper {
  52133. /**
  52134. * Default ground texture URL.
  52135. */
  52136. private static _groundTextureCDNUrl;
  52137. /**
  52138. * Default skybox texture URL.
  52139. */
  52140. private static _skyboxTextureCDNUrl;
  52141. /**
  52142. * Default environment texture URL.
  52143. */
  52144. private static _environmentTextureCDNUrl;
  52145. /**
  52146. * Creates the default options for the helper.
  52147. */
  52148. private static _getDefaultOptions;
  52149. private _rootMesh;
  52150. /**
  52151. * Gets the root mesh created by the helper.
  52152. */
  52153. get rootMesh(): Mesh;
  52154. private _skybox;
  52155. /**
  52156. * Gets the skybox created by the helper.
  52157. */
  52158. get skybox(): Nullable<Mesh>;
  52159. private _skyboxTexture;
  52160. /**
  52161. * Gets the skybox texture created by the helper.
  52162. */
  52163. get skyboxTexture(): Nullable<BaseTexture>;
  52164. private _skyboxMaterial;
  52165. /**
  52166. * Gets the skybox material created by the helper.
  52167. */
  52168. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52169. private _ground;
  52170. /**
  52171. * Gets the ground mesh created by the helper.
  52172. */
  52173. get ground(): Nullable<Mesh>;
  52174. private _groundTexture;
  52175. /**
  52176. * Gets the ground texture created by the helper.
  52177. */
  52178. get groundTexture(): Nullable<BaseTexture>;
  52179. private _groundMirror;
  52180. /**
  52181. * Gets the ground mirror created by the helper.
  52182. */
  52183. get groundMirror(): Nullable<MirrorTexture>;
  52184. /**
  52185. * Gets the ground mirror render list to helps pushing the meshes
  52186. * you wish in the ground reflection.
  52187. */
  52188. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52189. private _groundMaterial;
  52190. /**
  52191. * Gets the ground material created by the helper.
  52192. */
  52193. get groundMaterial(): Nullable<BackgroundMaterial>;
  52194. /**
  52195. * Stores the creation options.
  52196. */
  52197. private readonly _scene;
  52198. private _options;
  52199. /**
  52200. * This observable will be notified with any error during the creation of the environment,
  52201. * mainly texture creation errors.
  52202. */
  52203. onErrorObservable: Observable<{
  52204. message?: string;
  52205. exception?: any;
  52206. }>;
  52207. /**
  52208. * constructor
  52209. * @param options Defines the options we want to customize the helper
  52210. * @param scene The scene to add the material to
  52211. */
  52212. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52213. /**
  52214. * Updates the background according to the new options
  52215. * @param options
  52216. */
  52217. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52218. /**
  52219. * Sets the primary color of all the available elements.
  52220. * @param color the main color to affect to the ground and the background
  52221. */
  52222. setMainColor(color: Color3): void;
  52223. /**
  52224. * Setup the image processing according to the specified options.
  52225. */
  52226. private _setupImageProcessing;
  52227. /**
  52228. * Setup the environment texture according to the specified options.
  52229. */
  52230. private _setupEnvironmentTexture;
  52231. /**
  52232. * Setup the background according to the specified options.
  52233. */
  52234. private _setupBackground;
  52235. /**
  52236. * Get the scene sizes according to the setup.
  52237. */
  52238. private _getSceneSize;
  52239. /**
  52240. * Setup the ground according to the specified options.
  52241. */
  52242. private _setupGround;
  52243. /**
  52244. * Setup the ground material according to the specified options.
  52245. */
  52246. private _setupGroundMaterial;
  52247. /**
  52248. * Setup the ground diffuse texture according to the specified options.
  52249. */
  52250. private _setupGroundDiffuseTexture;
  52251. /**
  52252. * Setup the ground mirror texture according to the specified options.
  52253. */
  52254. private _setupGroundMirrorTexture;
  52255. /**
  52256. * Setup the ground to receive the mirror texture.
  52257. */
  52258. private _setupMirrorInGroundMaterial;
  52259. /**
  52260. * Setup the skybox according to the specified options.
  52261. */
  52262. private _setupSkybox;
  52263. /**
  52264. * Setup the skybox material according to the specified options.
  52265. */
  52266. private _setupSkyboxMaterial;
  52267. /**
  52268. * Setup the skybox reflection texture according to the specified options.
  52269. */
  52270. private _setupSkyboxReflectionTexture;
  52271. private _errorHandler;
  52272. /**
  52273. * Dispose all the elements created by the Helper.
  52274. */
  52275. dispose(): void;
  52276. }
  52277. }
  52278. declare module "babylonjs/Helpers/photoDome" {
  52279. import { Observable } from "babylonjs/Misc/observable";
  52280. import { Nullable } from "babylonjs/types";
  52281. import { Scene } from "babylonjs/scene";
  52282. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52283. import { Mesh } from "babylonjs/Meshes/mesh";
  52284. import { Texture } from "babylonjs/Materials/Textures/texture";
  52285. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52286. import "babylonjs/Meshes/Builders/sphereBuilder";
  52287. /**
  52288. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52289. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52290. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52291. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52292. */
  52293. export class PhotoDome extends TransformNode {
  52294. /**
  52295. * Define the image as a Monoscopic panoramic 360 image.
  52296. */
  52297. static readonly MODE_MONOSCOPIC: number;
  52298. /**
  52299. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52300. */
  52301. static readonly MODE_TOPBOTTOM: number;
  52302. /**
  52303. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52304. */
  52305. static readonly MODE_SIDEBYSIDE: number;
  52306. private _useDirectMapping;
  52307. /**
  52308. * The texture being displayed on the sphere
  52309. */
  52310. protected _photoTexture: Texture;
  52311. /**
  52312. * Gets or sets the texture being displayed on the sphere
  52313. */
  52314. get photoTexture(): Texture;
  52315. set photoTexture(value: Texture);
  52316. /**
  52317. * Observable raised when an error occured while loading the 360 image
  52318. */
  52319. onLoadErrorObservable: Observable<string>;
  52320. /**
  52321. * The skybox material
  52322. */
  52323. protected _material: BackgroundMaterial;
  52324. /**
  52325. * The surface used for the skybox
  52326. */
  52327. protected _mesh: Mesh;
  52328. /**
  52329. * Gets the mesh used for the skybox.
  52330. */
  52331. get mesh(): Mesh;
  52332. /**
  52333. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52334. * Also see the options.resolution property.
  52335. */
  52336. get fovMultiplier(): number;
  52337. set fovMultiplier(value: number);
  52338. private _imageMode;
  52339. /**
  52340. * Gets or set the current video mode for the video. It can be:
  52341. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52342. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52343. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52344. */
  52345. get imageMode(): number;
  52346. set imageMode(value: number);
  52347. /**
  52348. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52349. * @param name Element's name, child elements will append suffixes for their own names.
  52350. * @param urlsOfPhoto defines the url of the photo to display
  52351. * @param options defines an object containing optional or exposed sub element properties
  52352. * @param onError defines a callback called when an error occured while loading the texture
  52353. */
  52354. constructor(name: string, urlOfPhoto: string, options: {
  52355. resolution?: number;
  52356. size?: number;
  52357. useDirectMapping?: boolean;
  52358. faceForward?: boolean;
  52359. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52360. private _onBeforeCameraRenderObserver;
  52361. private _changeImageMode;
  52362. /**
  52363. * Releases resources associated with this node.
  52364. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52365. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52366. */
  52367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52368. }
  52369. }
  52370. declare module "babylonjs/Misc/rgbdTextureTools" {
  52371. import "babylonjs/Shaders/rgbdDecode.fragment";
  52372. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52373. import { Texture } from "babylonjs/Materials/Textures/texture";
  52374. /**
  52375. * Class used to host RGBD texture specific utilities
  52376. */
  52377. export class RGBDTextureTools {
  52378. /**
  52379. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52380. * @param texture the texture to expand.
  52381. */
  52382. static ExpandRGBDTexture(texture: Texture): void;
  52383. }
  52384. }
  52385. declare module "babylonjs/Misc/brdfTextureTools" {
  52386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52387. import { Scene } from "babylonjs/scene";
  52388. /**
  52389. * Class used to host texture specific utilities
  52390. */
  52391. export class BRDFTextureTools {
  52392. /**
  52393. * Prevents texture cache collision
  52394. */
  52395. private static _instanceNumber;
  52396. /**
  52397. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52398. * @param scene defines the hosting scene
  52399. * @returns the environment BRDF texture
  52400. */
  52401. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52402. private static _environmentBRDFBase64Texture;
  52403. }
  52404. }
  52405. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52406. import { Nullable } from "babylonjs/types";
  52407. import { Color3 } from "babylonjs/Maths/math.color";
  52408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52409. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52410. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52411. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52412. import { Engine } from "babylonjs/Engines/engine";
  52413. import { Scene } from "babylonjs/scene";
  52414. /**
  52415. * @hidden
  52416. */
  52417. export interface IMaterialClearCoatDefines {
  52418. CLEARCOAT: boolean;
  52419. CLEARCOAT_DEFAULTIOR: boolean;
  52420. CLEARCOAT_TEXTURE: boolean;
  52421. CLEARCOAT_TEXTUREDIRECTUV: number;
  52422. CLEARCOAT_BUMP: boolean;
  52423. CLEARCOAT_BUMPDIRECTUV: number;
  52424. CLEARCOAT_TINT: boolean;
  52425. CLEARCOAT_TINT_TEXTURE: boolean;
  52426. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52427. /** @hidden */
  52428. _areTexturesDirty: boolean;
  52429. }
  52430. /**
  52431. * Define the code related to the clear coat parameters of the pbr material.
  52432. */
  52433. export class PBRClearCoatConfiguration {
  52434. /**
  52435. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52436. * The default fits with a polyurethane material.
  52437. */
  52438. private static readonly _DefaultIndexOfRefraction;
  52439. private _isEnabled;
  52440. /**
  52441. * Defines if the clear coat is enabled in the material.
  52442. */
  52443. isEnabled: boolean;
  52444. /**
  52445. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52446. */
  52447. intensity: number;
  52448. /**
  52449. * Defines the clear coat layer roughness.
  52450. */
  52451. roughness: number;
  52452. private _indexOfRefraction;
  52453. /**
  52454. * Defines the index of refraction of the clear coat.
  52455. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52456. * The default fits with a polyurethane material.
  52457. * Changing the default value is more performance intensive.
  52458. */
  52459. indexOfRefraction: number;
  52460. private _texture;
  52461. /**
  52462. * Stores the clear coat values in a texture.
  52463. */
  52464. texture: Nullable<BaseTexture>;
  52465. private _bumpTexture;
  52466. /**
  52467. * Define the clear coat specific bump texture.
  52468. */
  52469. bumpTexture: Nullable<BaseTexture>;
  52470. private _isTintEnabled;
  52471. /**
  52472. * Defines if the clear coat tint is enabled in the material.
  52473. */
  52474. isTintEnabled: boolean;
  52475. /**
  52476. * Defines the clear coat tint of the material.
  52477. * This is only use if tint is enabled
  52478. */
  52479. tintColor: Color3;
  52480. /**
  52481. * Defines the distance at which the tint color should be found in the
  52482. * clear coat media.
  52483. * This is only use if tint is enabled
  52484. */
  52485. tintColorAtDistance: number;
  52486. /**
  52487. * Defines the clear coat layer thickness.
  52488. * This is only use if tint is enabled
  52489. */
  52490. tintThickness: number;
  52491. private _tintTexture;
  52492. /**
  52493. * Stores the clear tint values in a texture.
  52494. * rgb is tint
  52495. * a is a thickness factor
  52496. */
  52497. tintTexture: Nullable<BaseTexture>;
  52498. /** @hidden */
  52499. private _internalMarkAllSubMeshesAsTexturesDirty;
  52500. /** @hidden */
  52501. _markAllSubMeshesAsTexturesDirty(): void;
  52502. /**
  52503. * Instantiate a new istance of clear coat configuration.
  52504. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52505. */
  52506. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52507. /**
  52508. * Gets wehter the submesh is ready to be used or not.
  52509. * @param defines the list of "defines" to update.
  52510. * @param scene defines the scene the material belongs to.
  52511. * @param engine defines the engine the material belongs to.
  52512. * @param disableBumpMap defines wether the material disables bump or not.
  52513. * @returns - boolean indicating that the submesh is ready or not.
  52514. */
  52515. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52516. /**
  52517. * Checks to see if a texture is used in the material.
  52518. * @param defines the list of "defines" to update.
  52519. * @param scene defines the scene to the material belongs to.
  52520. */
  52521. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52522. /**
  52523. * Binds the material data.
  52524. * @param uniformBuffer defines the Uniform buffer to fill in.
  52525. * @param scene defines the scene the material belongs to.
  52526. * @param engine defines the engine the material belongs to.
  52527. * @param disableBumpMap defines wether the material disables bump or not.
  52528. * @param isFrozen defines wether the material is frozen or not.
  52529. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52530. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52531. */
  52532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52533. /**
  52534. * Checks to see if a texture is used in the material.
  52535. * @param texture - Base texture to use.
  52536. * @returns - Boolean specifying if a texture is used in the material.
  52537. */
  52538. hasTexture(texture: BaseTexture): boolean;
  52539. /**
  52540. * Returns an array of the actively used textures.
  52541. * @param activeTextures Array of BaseTextures
  52542. */
  52543. getActiveTextures(activeTextures: BaseTexture[]): void;
  52544. /**
  52545. * Returns the animatable textures.
  52546. * @param animatables Array of animatable textures.
  52547. */
  52548. getAnimatables(animatables: IAnimatable[]): void;
  52549. /**
  52550. * Disposes the resources of the material.
  52551. * @param forceDisposeTextures - Forces the disposal of all textures.
  52552. */
  52553. dispose(forceDisposeTextures?: boolean): void;
  52554. /**
  52555. * Get the current class name of the texture useful for serialization or dynamic coding.
  52556. * @returns "PBRClearCoatConfiguration"
  52557. */
  52558. getClassName(): string;
  52559. /**
  52560. * Add fallbacks to the effect fallbacks list.
  52561. * @param defines defines the Base texture to use.
  52562. * @param fallbacks defines the current fallback list.
  52563. * @param currentRank defines the current fallback rank.
  52564. * @returns the new fallback rank.
  52565. */
  52566. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52567. /**
  52568. * Add the required uniforms to the current list.
  52569. * @param uniforms defines the current uniform list.
  52570. */
  52571. static AddUniforms(uniforms: string[]): void;
  52572. /**
  52573. * Add the required samplers to the current list.
  52574. * @param samplers defines the current sampler list.
  52575. */
  52576. static AddSamplers(samplers: string[]): void;
  52577. /**
  52578. * Add the required uniforms to the current buffer.
  52579. * @param uniformBuffer defines the current uniform buffer.
  52580. */
  52581. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52582. /**
  52583. * Makes a duplicate of the current configuration into another one.
  52584. * @param clearCoatConfiguration define the config where to copy the info
  52585. */
  52586. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52587. /**
  52588. * Serializes this clear coat configuration.
  52589. * @returns - An object with the serialized config.
  52590. */
  52591. serialize(): any;
  52592. /**
  52593. * Parses a anisotropy Configuration from a serialized object.
  52594. * @param source - Serialized object.
  52595. * @param scene Defines the scene we are parsing for
  52596. * @param rootUrl Defines the rootUrl to load from
  52597. */
  52598. parse(source: any, scene: Scene, rootUrl: string): void;
  52599. }
  52600. }
  52601. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52602. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52604. import { Vector2 } from "babylonjs/Maths/math.vector";
  52605. import { Scene } from "babylonjs/scene";
  52606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52607. import { Nullable } from "babylonjs/types";
  52608. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52609. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52610. /**
  52611. * @hidden
  52612. */
  52613. export interface IMaterialAnisotropicDefines {
  52614. ANISOTROPIC: boolean;
  52615. ANISOTROPIC_TEXTURE: boolean;
  52616. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52617. MAINUV1: boolean;
  52618. _areTexturesDirty: boolean;
  52619. _needUVs: boolean;
  52620. }
  52621. /**
  52622. * Define the code related to the anisotropic parameters of the pbr material.
  52623. */
  52624. export class PBRAnisotropicConfiguration {
  52625. private _isEnabled;
  52626. /**
  52627. * Defines if the anisotropy is enabled in the material.
  52628. */
  52629. isEnabled: boolean;
  52630. /**
  52631. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52632. */
  52633. intensity: number;
  52634. /**
  52635. * Defines if the effect is along the tangents, bitangents or in between.
  52636. * By default, the effect is "strectching" the highlights along the tangents.
  52637. */
  52638. direction: Vector2;
  52639. private _texture;
  52640. /**
  52641. * Stores the anisotropy values in a texture.
  52642. * rg is direction (like normal from -1 to 1)
  52643. * b is a intensity
  52644. */
  52645. texture: Nullable<BaseTexture>;
  52646. /** @hidden */
  52647. private _internalMarkAllSubMeshesAsTexturesDirty;
  52648. /** @hidden */
  52649. _markAllSubMeshesAsTexturesDirty(): void;
  52650. /**
  52651. * Instantiate a new istance of anisotropy configuration.
  52652. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52653. */
  52654. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52655. /**
  52656. * Specifies that the submesh is ready to be used.
  52657. * @param defines the list of "defines" to update.
  52658. * @param scene defines the scene the material belongs to.
  52659. * @returns - boolean indicating that the submesh is ready or not.
  52660. */
  52661. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52662. /**
  52663. * Checks to see if a texture is used in the material.
  52664. * @param defines the list of "defines" to update.
  52665. * @param mesh the mesh we are preparing the defines for.
  52666. * @param scene defines the scene the material belongs to.
  52667. */
  52668. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52669. /**
  52670. * Binds the material data.
  52671. * @param uniformBuffer defines the Uniform buffer to fill in.
  52672. * @param scene defines the scene the material belongs to.
  52673. * @param isFrozen defines wether the material is frozen or not.
  52674. */
  52675. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52676. /**
  52677. * Checks to see if a texture is used in the material.
  52678. * @param texture - Base texture to use.
  52679. * @returns - Boolean specifying if a texture is used in the material.
  52680. */
  52681. hasTexture(texture: BaseTexture): boolean;
  52682. /**
  52683. * Returns an array of the actively used textures.
  52684. * @param activeTextures Array of BaseTextures
  52685. */
  52686. getActiveTextures(activeTextures: BaseTexture[]): void;
  52687. /**
  52688. * Returns the animatable textures.
  52689. * @param animatables Array of animatable textures.
  52690. */
  52691. getAnimatables(animatables: IAnimatable[]): void;
  52692. /**
  52693. * Disposes the resources of the material.
  52694. * @param forceDisposeTextures - Forces the disposal of all textures.
  52695. */
  52696. dispose(forceDisposeTextures?: boolean): void;
  52697. /**
  52698. * Get the current class name of the texture useful for serialization or dynamic coding.
  52699. * @returns "PBRAnisotropicConfiguration"
  52700. */
  52701. getClassName(): string;
  52702. /**
  52703. * Add fallbacks to the effect fallbacks list.
  52704. * @param defines defines the Base texture to use.
  52705. * @param fallbacks defines the current fallback list.
  52706. * @param currentRank defines the current fallback rank.
  52707. * @returns the new fallback rank.
  52708. */
  52709. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52710. /**
  52711. * Add the required uniforms to the current list.
  52712. * @param uniforms defines the current uniform list.
  52713. */
  52714. static AddUniforms(uniforms: string[]): void;
  52715. /**
  52716. * Add the required uniforms to the current buffer.
  52717. * @param uniformBuffer defines the current uniform buffer.
  52718. */
  52719. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52720. /**
  52721. * Add the required samplers to the current list.
  52722. * @param samplers defines the current sampler list.
  52723. */
  52724. static AddSamplers(samplers: string[]): void;
  52725. /**
  52726. * Makes a duplicate of the current configuration into another one.
  52727. * @param anisotropicConfiguration define the config where to copy the info
  52728. */
  52729. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52730. /**
  52731. * Serializes this anisotropy configuration.
  52732. * @returns - An object with the serialized config.
  52733. */
  52734. serialize(): any;
  52735. /**
  52736. * Parses a anisotropy Configuration from a serialized object.
  52737. * @param source - Serialized object.
  52738. * @param scene Defines the scene we are parsing for
  52739. * @param rootUrl Defines the rootUrl to load from
  52740. */
  52741. parse(source: any, scene: Scene, rootUrl: string): void;
  52742. }
  52743. }
  52744. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52745. import { Scene } from "babylonjs/scene";
  52746. /**
  52747. * @hidden
  52748. */
  52749. export interface IMaterialBRDFDefines {
  52750. BRDF_V_HEIGHT_CORRELATED: boolean;
  52751. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52752. SPHERICAL_HARMONICS: boolean;
  52753. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52754. /** @hidden */
  52755. _areMiscDirty: boolean;
  52756. }
  52757. /**
  52758. * Define the code related to the BRDF parameters of the pbr material.
  52759. */
  52760. export class PBRBRDFConfiguration {
  52761. /**
  52762. * Default value used for the energy conservation.
  52763. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52764. */
  52765. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52766. /**
  52767. * Default value used for the Smith Visibility Height Correlated mode.
  52768. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52769. */
  52770. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52771. /**
  52772. * Default value used for the IBL diffuse part.
  52773. * This can help switching back to the polynomials mode globally which is a tiny bit
  52774. * less GPU intensive at the drawback of a lower quality.
  52775. */
  52776. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52777. /**
  52778. * Default value used for activating energy conservation for the specular workflow.
  52779. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52780. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52781. */
  52782. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52783. private _useEnergyConservation;
  52784. /**
  52785. * Defines if the material uses energy conservation.
  52786. */
  52787. useEnergyConservation: boolean;
  52788. private _useSmithVisibilityHeightCorrelated;
  52789. /**
  52790. * LEGACY Mode set to false
  52791. * Defines if the material uses height smith correlated visibility term.
  52792. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52793. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52794. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52795. * Not relying on height correlated will also disable energy conservation.
  52796. */
  52797. useSmithVisibilityHeightCorrelated: boolean;
  52798. private _useSphericalHarmonics;
  52799. /**
  52800. * LEGACY Mode set to false
  52801. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52802. * diffuse part of the IBL.
  52803. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52804. * to the ground truth.
  52805. */
  52806. useSphericalHarmonics: boolean;
  52807. private _useSpecularGlossinessInputEnergyConservation;
  52808. /**
  52809. * Defines if the material uses energy conservation, when the specular workflow is active.
  52810. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52811. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52812. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52813. */
  52814. useSpecularGlossinessInputEnergyConservation: boolean;
  52815. /** @hidden */
  52816. private _internalMarkAllSubMeshesAsMiscDirty;
  52817. /** @hidden */
  52818. _markAllSubMeshesAsMiscDirty(): void;
  52819. /**
  52820. * Instantiate a new istance of clear coat configuration.
  52821. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52822. */
  52823. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52824. /**
  52825. * Checks to see if a texture is used in the material.
  52826. * @param defines the list of "defines" to update.
  52827. */
  52828. prepareDefines(defines: IMaterialBRDFDefines): void;
  52829. /**
  52830. * Get the current class name of the texture useful for serialization or dynamic coding.
  52831. * @returns "PBRClearCoatConfiguration"
  52832. */
  52833. getClassName(): string;
  52834. /**
  52835. * Makes a duplicate of the current configuration into another one.
  52836. * @param brdfConfiguration define the config where to copy the info
  52837. */
  52838. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52839. /**
  52840. * Serializes this BRDF configuration.
  52841. * @returns - An object with the serialized config.
  52842. */
  52843. serialize(): any;
  52844. /**
  52845. * Parses a anisotropy Configuration from a serialized object.
  52846. * @param source - Serialized object.
  52847. * @param scene Defines the scene we are parsing for
  52848. * @param rootUrl Defines the rootUrl to load from
  52849. */
  52850. parse(source: any, scene: Scene, rootUrl: string): void;
  52851. }
  52852. }
  52853. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52854. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52855. import { Color3 } from "babylonjs/Maths/math.color";
  52856. import { Scene } from "babylonjs/scene";
  52857. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52858. import { Nullable } from "babylonjs/types";
  52859. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52860. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52861. /**
  52862. * @hidden
  52863. */
  52864. export interface IMaterialSheenDefines {
  52865. SHEEN: boolean;
  52866. SHEEN_TEXTURE: boolean;
  52867. SHEEN_TEXTUREDIRECTUV: number;
  52868. SHEEN_LINKWITHALBEDO: boolean;
  52869. SHEEN_ROUGHNESS: boolean;
  52870. SHEEN_ALBEDOSCALING: boolean;
  52871. /** @hidden */
  52872. _areTexturesDirty: boolean;
  52873. }
  52874. /**
  52875. * Define the code related to the Sheen parameters of the pbr material.
  52876. */
  52877. export class PBRSheenConfiguration {
  52878. private _isEnabled;
  52879. /**
  52880. * Defines if the material uses sheen.
  52881. */
  52882. isEnabled: boolean;
  52883. private _linkSheenWithAlbedo;
  52884. /**
  52885. * Defines if the sheen is linked to the sheen color.
  52886. */
  52887. linkSheenWithAlbedo: boolean;
  52888. /**
  52889. * Defines the sheen intensity.
  52890. */
  52891. intensity: number;
  52892. /**
  52893. * Defines the sheen color.
  52894. */
  52895. color: Color3;
  52896. private _texture;
  52897. /**
  52898. * Stores the sheen tint values in a texture.
  52899. * rgb is tint
  52900. * a is a intensity
  52901. */
  52902. texture: Nullable<BaseTexture>;
  52903. private _roughness;
  52904. /**
  52905. * Defines the sheen roughness.
  52906. * It is not taken into account if linkSheenWithAlbedo is true.
  52907. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52908. */
  52909. roughness: Nullable<number>;
  52910. private _albedoScaling;
  52911. /**
  52912. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52913. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52914. * making it easier to setup and tweak the effect
  52915. */
  52916. albedoScaling: boolean;
  52917. /** @hidden */
  52918. private _internalMarkAllSubMeshesAsTexturesDirty;
  52919. /** @hidden */
  52920. _markAllSubMeshesAsTexturesDirty(): void;
  52921. /**
  52922. * Instantiate a new istance of clear coat configuration.
  52923. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52924. */
  52925. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52926. /**
  52927. * Specifies that the submesh is ready to be used.
  52928. * @param defines the list of "defines" to update.
  52929. * @param scene defines the scene the material belongs to.
  52930. * @returns - boolean indicating that the submesh is ready or not.
  52931. */
  52932. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52933. /**
  52934. * Checks to see if a texture is used in the material.
  52935. * @param defines the list of "defines" to update.
  52936. * @param scene defines the scene the material belongs to.
  52937. */
  52938. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52939. /**
  52940. * Binds the material data.
  52941. * @param uniformBuffer defines the Uniform buffer to fill in.
  52942. * @param scene defines the scene the material belongs to.
  52943. * @param isFrozen defines wether the material is frozen or not.
  52944. */
  52945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52946. /**
  52947. * Checks to see if a texture is used in the material.
  52948. * @param texture - Base texture to use.
  52949. * @returns - Boolean specifying if a texture is used in the material.
  52950. */
  52951. hasTexture(texture: BaseTexture): boolean;
  52952. /**
  52953. * Returns an array of the actively used textures.
  52954. * @param activeTextures Array of BaseTextures
  52955. */
  52956. getActiveTextures(activeTextures: BaseTexture[]): void;
  52957. /**
  52958. * Returns the animatable textures.
  52959. * @param animatables Array of animatable textures.
  52960. */
  52961. getAnimatables(animatables: IAnimatable[]): void;
  52962. /**
  52963. * Disposes the resources of the material.
  52964. * @param forceDisposeTextures - Forces the disposal of all textures.
  52965. */
  52966. dispose(forceDisposeTextures?: boolean): void;
  52967. /**
  52968. * Get the current class name of the texture useful for serialization or dynamic coding.
  52969. * @returns "PBRSheenConfiguration"
  52970. */
  52971. getClassName(): string;
  52972. /**
  52973. * Add fallbacks to the effect fallbacks list.
  52974. * @param defines defines the Base texture to use.
  52975. * @param fallbacks defines the current fallback list.
  52976. * @param currentRank defines the current fallback rank.
  52977. * @returns the new fallback rank.
  52978. */
  52979. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52980. /**
  52981. * Add the required uniforms to the current list.
  52982. * @param uniforms defines the current uniform list.
  52983. */
  52984. static AddUniforms(uniforms: string[]): void;
  52985. /**
  52986. * Add the required uniforms to the current buffer.
  52987. * @param uniformBuffer defines the current uniform buffer.
  52988. */
  52989. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52990. /**
  52991. * Add the required samplers to the current list.
  52992. * @param samplers defines the current sampler list.
  52993. */
  52994. static AddSamplers(samplers: string[]): void;
  52995. /**
  52996. * Makes a duplicate of the current configuration into another one.
  52997. * @param sheenConfiguration define the config where to copy the info
  52998. */
  52999. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53000. /**
  53001. * Serializes this BRDF configuration.
  53002. * @returns - An object with the serialized config.
  53003. */
  53004. serialize(): any;
  53005. /**
  53006. * Parses a anisotropy Configuration from a serialized object.
  53007. * @param source - Serialized object.
  53008. * @param scene Defines the scene we are parsing for
  53009. * @param rootUrl Defines the rootUrl to load from
  53010. */
  53011. parse(source: any, scene: Scene, rootUrl: string): void;
  53012. }
  53013. }
  53014. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53015. import { Nullable } from "babylonjs/types";
  53016. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53017. import { Color3 } from "babylonjs/Maths/math.color";
  53018. import { SmartArray } from "babylonjs/Misc/smartArray";
  53019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53021. import { Effect } from "babylonjs/Materials/effect";
  53022. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53023. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53024. import { Engine } from "babylonjs/Engines/engine";
  53025. import { Scene } from "babylonjs/scene";
  53026. /**
  53027. * @hidden
  53028. */
  53029. export interface IMaterialSubSurfaceDefines {
  53030. SUBSURFACE: boolean;
  53031. SS_REFRACTION: boolean;
  53032. SS_TRANSLUCENCY: boolean;
  53033. SS_SCATERRING: boolean;
  53034. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53035. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53036. SS_REFRACTIONMAP_3D: boolean;
  53037. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53038. SS_LODINREFRACTIONALPHA: boolean;
  53039. SS_GAMMAREFRACTION: boolean;
  53040. SS_RGBDREFRACTION: boolean;
  53041. SS_LINEARSPECULARREFRACTION: boolean;
  53042. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53043. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53044. /** @hidden */
  53045. _areTexturesDirty: boolean;
  53046. }
  53047. /**
  53048. * Define the code related to the sub surface parameters of the pbr material.
  53049. */
  53050. export class PBRSubSurfaceConfiguration {
  53051. private _isRefractionEnabled;
  53052. /**
  53053. * Defines if the refraction is enabled in the material.
  53054. */
  53055. isRefractionEnabled: boolean;
  53056. private _isTranslucencyEnabled;
  53057. /**
  53058. * Defines if the translucency is enabled in the material.
  53059. */
  53060. isTranslucencyEnabled: boolean;
  53061. private _isScatteringEnabled;
  53062. /**
  53063. * Defines the refraction intensity of the material.
  53064. * The refraction when enabled replaces the Diffuse part of the material.
  53065. * The intensity helps transitionning between diffuse and refraction.
  53066. */
  53067. refractionIntensity: number;
  53068. /**
  53069. * Defines the translucency intensity of the material.
  53070. * When translucency has been enabled, this defines how much of the "translucency"
  53071. * is addded to the diffuse part of the material.
  53072. */
  53073. translucencyIntensity: number;
  53074. /**
  53075. * Defines the scattering intensity of the material.
  53076. * When scattering has been enabled, this defines how much of the "scattered light"
  53077. * is addded to the diffuse part of the material.
  53078. */
  53079. scatteringIntensity: number;
  53080. private _thicknessTexture;
  53081. /**
  53082. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53083. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53084. * 0 would mean minimumThickness
  53085. * 1 would mean maximumThickness
  53086. * The other channels might be use as a mask to vary the different effects intensity.
  53087. */
  53088. thicknessTexture: Nullable<BaseTexture>;
  53089. private _refractionTexture;
  53090. /**
  53091. * Defines the texture to use for refraction.
  53092. */
  53093. refractionTexture: Nullable<BaseTexture>;
  53094. private _indexOfRefraction;
  53095. /**
  53096. * Defines the index of refraction used in the material.
  53097. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53098. */
  53099. indexOfRefraction: number;
  53100. private _invertRefractionY;
  53101. /**
  53102. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53103. */
  53104. invertRefractionY: boolean;
  53105. private _linkRefractionWithTransparency;
  53106. /**
  53107. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53108. * Materials half opaque for instance using refraction could benefit from this control.
  53109. */
  53110. linkRefractionWithTransparency: boolean;
  53111. /**
  53112. * Defines the minimum thickness stored in the thickness map.
  53113. * If no thickness map is defined, this value will be used to simulate thickness.
  53114. */
  53115. minimumThickness: number;
  53116. /**
  53117. * Defines the maximum thickness stored in the thickness map.
  53118. */
  53119. maximumThickness: number;
  53120. /**
  53121. * Defines the volume tint of the material.
  53122. * This is used for both translucency and scattering.
  53123. */
  53124. tintColor: Color3;
  53125. /**
  53126. * Defines the distance at which the tint color should be found in the media.
  53127. * This is used for refraction only.
  53128. */
  53129. tintColorAtDistance: number;
  53130. /**
  53131. * Defines how far each channel transmit through the media.
  53132. * It is defined as a color to simplify it selection.
  53133. */
  53134. diffusionDistance: Color3;
  53135. private _useMaskFromThicknessTexture;
  53136. /**
  53137. * Stores the intensity of the different subsurface effects in the thickness texture.
  53138. * * the green channel is the translucency intensity.
  53139. * * the blue channel is the scattering intensity.
  53140. * * the alpha channel is the refraction intensity.
  53141. */
  53142. useMaskFromThicknessTexture: boolean;
  53143. /** @hidden */
  53144. private _internalMarkAllSubMeshesAsTexturesDirty;
  53145. /** @hidden */
  53146. _markAllSubMeshesAsTexturesDirty(): void;
  53147. /**
  53148. * Instantiate a new istance of sub surface configuration.
  53149. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53150. */
  53151. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53152. /**
  53153. * Gets wehter the submesh is ready to be used or not.
  53154. * @param defines the list of "defines" to update.
  53155. * @param scene defines the scene the material belongs to.
  53156. * @returns - boolean indicating that the submesh is ready or not.
  53157. */
  53158. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53159. /**
  53160. * Checks to see if a texture is used in the material.
  53161. * @param defines the list of "defines" to update.
  53162. * @param scene defines the scene to the material belongs to.
  53163. */
  53164. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53165. /**
  53166. * Binds the material data.
  53167. * @param uniformBuffer defines the Uniform buffer to fill in.
  53168. * @param scene defines the scene the material belongs to.
  53169. * @param engine defines the engine the material belongs to.
  53170. * @param isFrozen defines wether the material is frozen or not.
  53171. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53172. */
  53173. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53174. /**
  53175. * Unbinds the material from the mesh.
  53176. * @param activeEffect defines the effect that should be unbound from.
  53177. * @returns true if unbound, otherwise false
  53178. */
  53179. unbind(activeEffect: Effect): boolean;
  53180. /**
  53181. * Returns the texture used for refraction or null if none is used.
  53182. * @param scene defines the scene the material belongs to.
  53183. * @returns - Refraction texture if present. If no refraction texture and refraction
  53184. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53185. */
  53186. private _getRefractionTexture;
  53187. /**
  53188. * Returns true if alpha blending should be disabled.
  53189. */
  53190. get disableAlphaBlending(): boolean;
  53191. /**
  53192. * Fills the list of render target textures.
  53193. * @param renderTargets the list of render targets to update
  53194. */
  53195. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53196. /**
  53197. * Checks to see if a texture is used in the material.
  53198. * @param texture - Base texture to use.
  53199. * @returns - Boolean specifying if a texture is used in the material.
  53200. */
  53201. hasTexture(texture: BaseTexture): boolean;
  53202. /**
  53203. * Gets a boolean indicating that current material needs to register RTT
  53204. * @returns true if this uses a render target otherwise false.
  53205. */
  53206. hasRenderTargetTextures(): boolean;
  53207. /**
  53208. * Returns an array of the actively used textures.
  53209. * @param activeTextures Array of BaseTextures
  53210. */
  53211. getActiveTextures(activeTextures: BaseTexture[]): void;
  53212. /**
  53213. * Returns the animatable textures.
  53214. * @param animatables Array of animatable textures.
  53215. */
  53216. getAnimatables(animatables: IAnimatable[]): void;
  53217. /**
  53218. * Disposes the resources of the material.
  53219. * @param forceDisposeTextures - Forces the disposal of all textures.
  53220. */
  53221. dispose(forceDisposeTextures?: boolean): void;
  53222. /**
  53223. * Get the current class name of the texture useful for serialization or dynamic coding.
  53224. * @returns "PBRSubSurfaceConfiguration"
  53225. */
  53226. getClassName(): string;
  53227. /**
  53228. * Add fallbacks to the effect fallbacks list.
  53229. * @param defines defines the Base texture to use.
  53230. * @param fallbacks defines the current fallback list.
  53231. * @param currentRank defines the current fallback rank.
  53232. * @returns the new fallback rank.
  53233. */
  53234. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53235. /**
  53236. * Add the required uniforms to the current list.
  53237. * @param uniforms defines the current uniform list.
  53238. */
  53239. static AddUniforms(uniforms: string[]): void;
  53240. /**
  53241. * Add the required samplers to the current list.
  53242. * @param samplers defines the current sampler list.
  53243. */
  53244. static AddSamplers(samplers: string[]): void;
  53245. /**
  53246. * Add the required uniforms to the current buffer.
  53247. * @param uniformBuffer defines the current uniform buffer.
  53248. */
  53249. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53250. /**
  53251. * Makes a duplicate of the current configuration into another one.
  53252. * @param configuration define the config where to copy the info
  53253. */
  53254. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53255. /**
  53256. * Serializes this Sub Surface configuration.
  53257. * @returns - An object with the serialized config.
  53258. */
  53259. serialize(): any;
  53260. /**
  53261. * Parses a anisotropy Configuration from a serialized object.
  53262. * @param source - Serialized object.
  53263. * @param scene Defines the scene we are parsing for
  53264. * @param rootUrl Defines the rootUrl to load from
  53265. */
  53266. parse(source: any, scene: Scene, rootUrl: string): void;
  53267. }
  53268. }
  53269. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53270. /** @hidden */
  53271. export var pbrFragmentDeclaration: {
  53272. name: string;
  53273. shader: string;
  53274. };
  53275. }
  53276. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53277. /** @hidden */
  53278. export var pbrUboDeclaration: {
  53279. name: string;
  53280. shader: string;
  53281. };
  53282. }
  53283. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53284. /** @hidden */
  53285. export var pbrFragmentExtraDeclaration: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53291. /** @hidden */
  53292. export var pbrFragmentSamplersDeclaration: {
  53293. name: string;
  53294. shader: string;
  53295. };
  53296. }
  53297. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53298. /** @hidden */
  53299. export var pbrHelperFunctions: {
  53300. name: string;
  53301. shader: string;
  53302. };
  53303. }
  53304. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53305. /** @hidden */
  53306. export var harmonicsFunctions: {
  53307. name: string;
  53308. shader: string;
  53309. };
  53310. }
  53311. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53312. /** @hidden */
  53313. export var pbrDirectLightingSetupFunctions: {
  53314. name: string;
  53315. shader: string;
  53316. };
  53317. }
  53318. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53319. /** @hidden */
  53320. export var pbrDirectLightingFalloffFunctions: {
  53321. name: string;
  53322. shader: string;
  53323. };
  53324. }
  53325. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53326. /** @hidden */
  53327. export var pbrBRDFFunctions: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53333. /** @hidden */
  53334. export var pbrDirectLightingFunctions: {
  53335. name: string;
  53336. shader: string;
  53337. };
  53338. }
  53339. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53340. /** @hidden */
  53341. export var pbrIBLFunctions: {
  53342. name: string;
  53343. shader: string;
  53344. };
  53345. }
  53346. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53347. /** @hidden */
  53348. export var pbrBlockAlbedoOpacity: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53354. /** @hidden */
  53355. export var pbrBlockReflectivity: {
  53356. name: string;
  53357. shader: string;
  53358. };
  53359. }
  53360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53361. /** @hidden */
  53362. export var pbrBlockAmbientOcclusion: {
  53363. name: string;
  53364. shader: string;
  53365. };
  53366. }
  53367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53368. /** @hidden */
  53369. export var pbrBlockAlphaFresnel: {
  53370. name: string;
  53371. shader: string;
  53372. };
  53373. }
  53374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53375. /** @hidden */
  53376. export var pbrBlockAnisotropic: {
  53377. name: string;
  53378. shader: string;
  53379. };
  53380. }
  53381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53382. /** @hidden */
  53383. export var pbrBlockReflection: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53389. /** @hidden */
  53390. export var pbrBlockSheen: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53396. /** @hidden */
  53397. export var pbrBlockClearcoat: {
  53398. name: string;
  53399. shader: string;
  53400. };
  53401. }
  53402. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53403. /** @hidden */
  53404. export var pbrBlockSubSurface: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53410. /** @hidden */
  53411. export var pbrBlockNormalGeometric: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53417. /** @hidden */
  53418. export var pbrBlockNormalFinal: {
  53419. name: string;
  53420. shader: string;
  53421. };
  53422. }
  53423. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53424. /** @hidden */
  53425. export var pbrBlockGeometryInfo: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53431. /** @hidden */
  53432. export var pbrBlockReflectance0: {
  53433. name: string;
  53434. shader: string;
  53435. };
  53436. }
  53437. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53438. /** @hidden */
  53439. export var pbrBlockReflectance: {
  53440. name: string;
  53441. shader: string;
  53442. };
  53443. }
  53444. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53445. /** @hidden */
  53446. export var pbrBlockDirectLighting: {
  53447. name: string;
  53448. shader: string;
  53449. };
  53450. }
  53451. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53452. /** @hidden */
  53453. export var pbrBlockFinalLitComponents: {
  53454. name: string;
  53455. shader: string;
  53456. };
  53457. }
  53458. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53459. /** @hidden */
  53460. export var pbrBlockFinalUnlitComponents: {
  53461. name: string;
  53462. shader: string;
  53463. };
  53464. }
  53465. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53466. /** @hidden */
  53467. export var pbrBlockFinalColorComposition: {
  53468. name: string;
  53469. shader: string;
  53470. };
  53471. }
  53472. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53473. /** @hidden */
  53474. export var pbrBlockImageProcessing: {
  53475. name: string;
  53476. shader: string;
  53477. };
  53478. }
  53479. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53480. /** @hidden */
  53481. export var pbrDebug: {
  53482. name: string;
  53483. shader: string;
  53484. };
  53485. }
  53486. declare module "babylonjs/Shaders/pbr.fragment" {
  53487. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53488. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53489. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53492. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53493. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53495. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53496. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53498. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53499. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53500. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53501. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53502. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53503. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53504. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53505. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53506. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53507. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53508. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53509. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53510. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53511. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53512. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53513. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53514. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53515. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53516. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53517. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53518. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53519. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53520. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53521. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53522. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53523. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53524. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53525. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53526. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53527. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53528. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53529. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53530. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53531. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53532. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53533. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53534. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53535. /** @hidden */
  53536. export var pbrPixelShader: {
  53537. name: string;
  53538. shader: string;
  53539. };
  53540. }
  53541. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53542. /** @hidden */
  53543. export var pbrVertexDeclaration: {
  53544. name: string;
  53545. shader: string;
  53546. };
  53547. }
  53548. declare module "babylonjs/Shaders/pbr.vertex" {
  53549. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53550. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53552. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53553. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53554. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53555. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53556. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53557. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53558. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53559. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53561. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53562. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53564. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53565. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53566. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53568. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53569. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53570. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53571. /** @hidden */
  53572. export var pbrVertexShader: {
  53573. name: string;
  53574. shader: string;
  53575. };
  53576. }
  53577. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53578. import { Nullable } from "babylonjs/types";
  53579. import { Scene } from "babylonjs/scene";
  53580. import { Matrix } from "babylonjs/Maths/math.vector";
  53581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53583. import { Mesh } from "babylonjs/Meshes/mesh";
  53584. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53585. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53586. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53587. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53588. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53589. import { Color3 } from "babylonjs/Maths/math.color";
  53590. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53591. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53592. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53593. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53595. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53596. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53597. import "babylonjs/Shaders/pbr.fragment";
  53598. import "babylonjs/Shaders/pbr.vertex";
  53599. /**
  53600. * Manages the defines for the PBR Material.
  53601. * @hidden
  53602. */
  53603. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53604. PBR: boolean;
  53605. MAINUV1: boolean;
  53606. MAINUV2: boolean;
  53607. UV1: boolean;
  53608. UV2: boolean;
  53609. ALBEDO: boolean;
  53610. GAMMAALBEDO: boolean;
  53611. ALBEDODIRECTUV: number;
  53612. VERTEXCOLOR: boolean;
  53613. AMBIENT: boolean;
  53614. AMBIENTDIRECTUV: number;
  53615. AMBIENTINGRAYSCALE: boolean;
  53616. OPACITY: boolean;
  53617. VERTEXALPHA: boolean;
  53618. OPACITYDIRECTUV: number;
  53619. OPACITYRGB: boolean;
  53620. ALPHATEST: boolean;
  53621. DEPTHPREPASS: boolean;
  53622. ALPHABLEND: boolean;
  53623. ALPHAFROMALBEDO: boolean;
  53624. ALPHATESTVALUE: string;
  53625. SPECULAROVERALPHA: boolean;
  53626. RADIANCEOVERALPHA: boolean;
  53627. ALPHAFRESNEL: boolean;
  53628. LINEARALPHAFRESNEL: boolean;
  53629. PREMULTIPLYALPHA: boolean;
  53630. EMISSIVE: boolean;
  53631. EMISSIVEDIRECTUV: number;
  53632. REFLECTIVITY: boolean;
  53633. REFLECTIVITYDIRECTUV: number;
  53634. SPECULARTERM: boolean;
  53635. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53636. MICROSURFACEAUTOMATIC: boolean;
  53637. LODBASEDMICROSFURACE: boolean;
  53638. MICROSURFACEMAP: boolean;
  53639. MICROSURFACEMAPDIRECTUV: number;
  53640. METALLICWORKFLOW: boolean;
  53641. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53642. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53643. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53644. AOSTOREINMETALMAPRED: boolean;
  53645. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53646. ENVIRONMENTBRDF: boolean;
  53647. ENVIRONMENTBRDF_RGBD: boolean;
  53648. NORMAL: boolean;
  53649. TANGENT: boolean;
  53650. BUMP: boolean;
  53651. BUMPDIRECTUV: number;
  53652. OBJECTSPACE_NORMALMAP: boolean;
  53653. PARALLAX: boolean;
  53654. PARALLAXOCCLUSION: boolean;
  53655. NORMALXYSCALE: boolean;
  53656. LIGHTMAP: boolean;
  53657. LIGHTMAPDIRECTUV: number;
  53658. USELIGHTMAPASSHADOWMAP: boolean;
  53659. GAMMALIGHTMAP: boolean;
  53660. RGBDLIGHTMAP: boolean;
  53661. REFLECTION: boolean;
  53662. REFLECTIONMAP_3D: boolean;
  53663. REFLECTIONMAP_SPHERICAL: boolean;
  53664. REFLECTIONMAP_PLANAR: boolean;
  53665. REFLECTIONMAP_CUBIC: boolean;
  53666. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53667. REFLECTIONMAP_PROJECTION: boolean;
  53668. REFLECTIONMAP_SKYBOX: boolean;
  53669. REFLECTIONMAP_EXPLICIT: boolean;
  53670. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53671. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53672. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53673. INVERTCUBICMAP: boolean;
  53674. USESPHERICALFROMREFLECTIONMAP: boolean;
  53675. USEIRRADIANCEMAP: boolean;
  53676. SPHERICAL_HARMONICS: boolean;
  53677. USESPHERICALINVERTEX: boolean;
  53678. REFLECTIONMAP_OPPOSITEZ: boolean;
  53679. LODINREFLECTIONALPHA: boolean;
  53680. GAMMAREFLECTION: boolean;
  53681. RGBDREFLECTION: boolean;
  53682. LINEARSPECULARREFLECTION: boolean;
  53683. RADIANCEOCCLUSION: boolean;
  53684. HORIZONOCCLUSION: boolean;
  53685. INSTANCES: boolean;
  53686. NUM_BONE_INFLUENCERS: number;
  53687. BonesPerMesh: number;
  53688. BONETEXTURE: boolean;
  53689. NONUNIFORMSCALING: boolean;
  53690. MORPHTARGETS: boolean;
  53691. MORPHTARGETS_NORMAL: boolean;
  53692. MORPHTARGETS_TANGENT: boolean;
  53693. MORPHTARGETS_UV: boolean;
  53694. NUM_MORPH_INFLUENCERS: number;
  53695. IMAGEPROCESSING: boolean;
  53696. VIGNETTE: boolean;
  53697. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53698. VIGNETTEBLENDMODEOPAQUE: boolean;
  53699. TONEMAPPING: boolean;
  53700. TONEMAPPING_ACES: boolean;
  53701. CONTRAST: boolean;
  53702. COLORCURVES: boolean;
  53703. COLORGRADING: boolean;
  53704. COLORGRADING3D: boolean;
  53705. SAMPLER3DGREENDEPTH: boolean;
  53706. SAMPLER3DBGRMAP: boolean;
  53707. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53708. EXPOSURE: boolean;
  53709. MULTIVIEW: boolean;
  53710. USEPHYSICALLIGHTFALLOFF: boolean;
  53711. USEGLTFLIGHTFALLOFF: boolean;
  53712. TWOSIDEDLIGHTING: boolean;
  53713. SHADOWFLOAT: boolean;
  53714. CLIPPLANE: boolean;
  53715. CLIPPLANE2: boolean;
  53716. CLIPPLANE3: boolean;
  53717. CLIPPLANE4: boolean;
  53718. CLIPPLANE5: boolean;
  53719. CLIPPLANE6: boolean;
  53720. POINTSIZE: boolean;
  53721. FOG: boolean;
  53722. LOGARITHMICDEPTH: boolean;
  53723. FORCENORMALFORWARD: boolean;
  53724. SPECULARAA: boolean;
  53725. CLEARCOAT: boolean;
  53726. CLEARCOAT_DEFAULTIOR: boolean;
  53727. CLEARCOAT_TEXTURE: boolean;
  53728. CLEARCOAT_TEXTUREDIRECTUV: number;
  53729. CLEARCOAT_BUMP: boolean;
  53730. CLEARCOAT_BUMPDIRECTUV: number;
  53731. CLEARCOAT_TINT: boolean;
  53732. CLEARCOAT_TINT_TEXTURE: boolean;
  53733. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53734. ANISOTROPIC: boolean;
  53735. ANISOTROPIC_TEXTURE: boolean;
  53736. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53737. BRDF_V_HEIGHT_CORRELATED: boolean;
  53738. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53739. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53740. SHEEN: boolean;
  53741. SHEEN_TEXTURE: boolean;
  53742. SHEEN_TEXTUREDIRECTUV: number;
  53743. SHEEN_LINKWITHALBEDO: boolean;
  53744. SHEEN_ROUGHNESS: boolean;
  53745. SHEEN_ALBEDOSCALING: boolean;
  53746. SUBSURFACE: boolean;
  53747. SS_REFRACTION: boolean;
  53748. SS_TRANSLUCENCY: boolean;
  53749. SS_SCATERRING: boolean;
  53750. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53751. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53752. SS_REFRACTIONMAP_3D: boolean;
  53753. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53754. SS_LODINREFRACTIONALPHA: boolean;
  53755. SS_GAMMAREFRACTION: boolean;
  53756. SS_RGBDREFRACTION: boolean;
  53757. SS_LINEARSPECULARREFRACTION: boolean;
  53758. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53759. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53760. UNLIT: boolean;
  53761. DEBUGMODE: number;
  53762. /**
  53763. * Initializes the PBR Material defines.
  53764. */
  53765. constructor();
  53766. /**
  53767. * Resets the PBR Material defines.
  53768. */
  53769. reset(): void;
  53770. }
  53771. /**
  53772. * The Physically based material base class of BJS.
  53773. *
  53774. * This offers the main features of a standard PBR material.
  53775. * For more information, please refer to the documentation :
  53776. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53777. */
  53778. export abstract class PBRBaseMaterial extends PushMaterial {
  53779. /**
  53780. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53781. */
  53782. static readonly PBRMATERIAL_OPAQUE: number;
  53783. /**
  53784. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53785. */
  53786. static readonly PBRMATERIAL_ALPHATEST: number;
  53787. /**
  53788. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53789. */
  53790. static readonly PBRMATERIAL_ALPHABLEND: number;
  53791. /**
  53792. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53793. * They are also discarded below the alpha cutoff threshold to improve performances.
  53794. */
  53795. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53796. /**
  53797. * Defines the default value of how much AO map is occluding the analytical lights
  53798. * (point spot...).
  53799. */
  53800. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53801. /**
  53802. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53803. */
  53804. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53805. /**
  53806. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53807. * to enhance interoperability with other engines.
  53808. */
  53809. static readonly LIGHTFALLOFF_GLTF: number;
  53810. /**
  53811. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53812. * to enhance interoperability with other materials.
  53813. */
  53814. static readonly LIGHTFALLOFF_STANDARD: number;
  53815. /**
  53816. * Intensity of the direct lights e.g. the four lights available in your scene.
  53817. * This impacts both the direct diffuse and specular highlights.
  53818. */
  53819. protected _directIntensity: number;
  53820. /**
  53821. * Intensity of the emissive part of the material.
  53822. * This helps controlling the emissive effect without modifying the emissive color.
  53823. */
  53824. protected _emissiveIntensity: number;
  53825. /**
  53826. * Intensity of the environment e.g. how much the environment will light the object
  53827. * either through harmonics for rough material or through the refelction for shiny ones.
  53828. */
  53829. protected _environmentIntensity: number;
  53830. /**
  53831. * This is a special control allowing the reduction of the specular highlights coming from the
  53832. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53833. */
  53834. protected _specularIntensity: number;
  53835. /**
  53836. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53837. */
  53838. private _lightingInfos;
  53839. /**
  53840. * Debug Control allowing disabling the bump map on this material.
  53841. */
  53842. protected _disableBumpMap: boolean;
  53843. /**
  53844. * AKA Diffuse Texture in standard nomenclature.
  53845. */
  53846. protected _albedoTexture: Nullable<BaseTexture>;
  53847. /**
  53848. * AKA Occlusion Texture in other nomenclature.
  53849. */
  53850. protected _ambientTexture: Nullable<BaseTexture>;
  53851. /**
  53852. * AKA Occlusion Texture Intensity in other nomenclature.
  53853. */
  53854. protected _ambientTextureStrength: number;
  53855. /**
  53856. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53857. * 1 means it completely occludes it
  53858. * 0 mean it has no impact
  53859. */
  53860. protected _ambientTextureImpactOnAnalyticalLights: number;
  53861. /**
  53862. * Stores the alpha values in a texture.
  53863. */
  53864. protected _opacityTexture: Nullable<BaseTexture>;
  53865. /**
  53866. * Stores the reflection values in a texture.
  53867. */
  53868. protected _reflectionTexture: Nullable<BaseTexture>;
  53869. /**
  53870. * Stores the emissive values in a texture.
  53871. */
  53872. protected _emissiveTexture: Nullable<BaseTexture>;
  53873. /**
  53874. * AKA Specular texture in other nomenclature.
  53875. */
  53876. protected _reflectivityTexture: Nullable<BaseTexture>;
  53877. /**
  53878. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53879. */
  53880. protected _metallicTexture: Nullable<BaseTexture>;
  53881. /**
  53882. * Specifies the metallic scalar of the metallic/roughness workflow.
  53883. * Can also be used to scale the metalness values of the metallic texture.
  53884. */
  53885. protected _metallic: Nullable<number>;
  53886. /**
  53887. * Specifies the roughness scalar of the metallic/roughness workflow.
  53888. * Can also be used to scale the roughness values of the metallic texture.
  53889. */
  53890. protected _roughness: Nullable<number>;
  53891. /**
  53892. * Specifies the an F0 factor to help configuring the material F0.
  53893. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53894. * to 0.5 the previously hard coded value stays the same.
  53895. * Can also be used to scale the F0 values of the metallic texture.
  53896. */
  53897. protected _metallicF0Factor: number;
  53898. /**
  53899. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53900. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53901. * your expectation as it multiplies with the texture data.
  53902. */
  53903. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53904. /**
  53905. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53906. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53907. */
  53908. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53909. /**
  53910. * Stores surface normal data used to displace a mesh in a texture.
  53911. */
  53912. protected _bumpTexture: Nullable<BaseTexture>;
  53913. /**
  53914. * Stores the pre-calculated light information of a mesh in a texture.
  53915. */
  53916. protected _lightmapTexture: Nullable<BaseTexture>;
  53917. /**
  53918. * The color of a material in ambient lighting.
  53919. */
  53920. protected _ambientColor: Color3;
  53921. /**
  53922. * AKA Diffuse Color in other nomenclature.
  53923. */
  53924. protected _albedoColor: Color3;
  53925. /**
  53926. * AKA Specular Color in other nomenclature.
  53927. */
  53928. protected _reflectivityColor: Color3;
  53929. /**
  53930. * The color applied when light is reflected from a material.
  53931. */
  53932. protected _reflectionColor: Color3;
  53933. /**
  53934. * The color applied when light is emitted from a material.
  53935. */
  53936. protected _emissiveColor: Color3;
  53937. /**
  53938. * AKA Glossiness in other nomenclature.
  53939. */
  53940. protected _microSurface: number;
  53941. /**
  53942. * Specifies that the material will use the light map as a show map.
  53943. */
  53944. protected _useLightmapAsShadowmap: boolean;
  53945. /**
  53946. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53947. * makes the reflect vector face the model (under horizon).
  53948. */
  53949. protected _useHorizonOcclusion: boolean;
  53950. /**
  53951. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53952. * too much the area relying on ambient texture to define their ambient occlusion.
  53953. */
  53954. protected _useRadianceOcclusion: boolean;
  53955. /**
  53956. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53957. */
  53958. protected _useAlphaFromAlbedoTexture: boolean;
  53959. /**
  53960. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53961. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53962. */
  53963. protected _useSpecularOverAlpha: boolean;
  53964. /**
  53965. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53966. */
  53967. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53968. /**
  53969. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53970. */
  53971. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53972. /**
  53973. * Specifies if the metallic texture contains the roughness information in its green channel.
  53974. */
  53975. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53976. /**
  53977. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53978. */
  53979. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53980. /**
  53981. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53982. */
  53983. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53984. /**
  53985. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53986. */
  53987. protected _useAmbientInGrayScale: boolean;
  53988. /**
  53989. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53990. * The material will try to infer what glossiness each pixel should be.
  53991. */
  53992. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53993. /**
  53994. * Defines the falloff type used in this material.
  53995. * It by default is Physical.
  53996. */
  53997. protected _lightFalloff: number;
  53998. /**
  53999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54001. */
  54002. protected _useRadianceOverAlpha: boolean;
  54003. /**
  54004. * Allows using an object space normal map (instead of tangent space).
  54005. */
  54006. protected _useObjectSpaceNormalMap: boolean;
  54007. /**
  54008. * Allows using the bump map in parallax mode.
  54009. */
  54010. protected _useParallax: boolean;
  54011. /**
  54012. * Allows using the bump map in parallax occlusion mode.
  54013. */
  54014. protected _useParallaxOcclusion: boolean;
  54015. /**
  54016. * Controls the scale bias of the parallax mode.
  54017. */
  54018. protected _parallaxScaleBias: number;
  54019. /**
  54020. * If sets to true, disables all the lights affecting the material.
  54021. */
  54022. protected _disableLighting: boolean;
  54023. /**
  54024. * Number of Simultaneous lights allowed on the material.
  54025. */
  54026. protected _maxSimultaneousLights: number;
  54027. /**
  54028. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54029. */
  54030. protected _invertNormalMapX: boolean;
  54031. /**
  54032. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54033. */
  54034. protected _invertNormalMapY: boolean;
  54035. /**
  54036. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54037. */
  54038. protected _twoSidedLighting: boolean;
  54039. /**
  54040. * Defines the alpha limits in alpha test mode.
  54041. */
  54042. protected _alphaCutOff: number;
  54043. /**
  54044. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54045. */
  54046. protected _forceAlphaTest: boolean;
  54047. /**
  54048. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54049. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54050. */
  54051. protected _useAlphaFresnel: boolean;
  54052. /**
  54053. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54054. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54055. */
  54056. protected _useLinearAlphaFresnel: boolean;
  54057. /**
  54058. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54059. * from cos thetav and roughness:
  54060. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54061. */
  54062. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54063. /**
  54064. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54065. */
  54066. protected _forceIrradianceInFragment: boolean;
  54067. /**
  54068. * Force normal to face away from face.
  54069. */
  54070. protected _forceNormalForward: boolean;
  54071. /**
  54072. * Enables specular anti aliasing in the PBR shader.
  54073. * It will both interacts on the Geometry for analytical and IBL lighting.
  54074. * It also prefilter the roughness map based on the bump values.
  54075. */
  54076. protected _enableSpecularAntiAliasing: boolean;
  54077. /**
  54078. * Default configuration related to image processing available in the PBR Material.
  54079. */
  54080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54081. /**
  54082. * Keep track of the image processing observer to allow dispose and replace.
  54083. */
  54084. private _imageProcessingObserver;
  54085. /**
  54086. * Attaches a new image processing configuration to the PBR Material.
  54087. * @param configuration
  54088. */
  54089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54090. /**
  54091. * Stores the available render targets.
  54092. */
  54093. private _renderTargets;
  54094. /**
  54095. * Sets the global ambient color for the material used in lighting calculations.
  54096. */
  54097. private _globalAmbientColor;
  54098. /**
  54099. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54100. */
  54101. private _useLogarithmicDepth;
  54102. /**
  54103. * If set to true, no lighting calculations will be applied.
  54104. */
  54105. private _unlit;
  54106. private _debugMode;
  54107. /**
  54108. * @hidden
  54109. * This is reserved for the inspector.
  54110. * Defines the material debug mode.
  54111. * It helps seeing only some components of the material while troubleshooting.
  54112. */
  54113. debugMode: number;
  54114. /**
  54115. * @hidden
  54116. * This is reserved for the inspector.
  54117. * Specify from where on screen the debug mode should start.
  54118. * The value goes from -1 (full screen) to 1 (not visible)
  54119. * It helps with side by side comparison against the final render
  54120. * This defaults to -1
  54121. */
  54122. private debugLimit;
  54123. /**
  54124. * @hidden
  54125. * This is reserved for the inspector.
  54126. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54127. * You can use the factor to better multiply the final value.
  54128. */
  54129. private debugFactor;
  54130. /**
  54131. * Defines the clear coat layer parameters for the material.
  54132. */
  54133. readonly clearCoat: PBRClearCoatConfiguration;
  54134. /**
  54135. * Defines the anisotropic parameters for the material.
  54136. */
  54137. readonly anisotropy: PBRAnisotropicConfiguration;
  54138. /**
  54139. * Defines the BRDF parameters for the material.
  54140. */
  54141. readonly brdf: PBRBRDFConfiguration;
  54142. /**
  54143. * Defines the Sheen parameters for the material.
  54144. */
  54145. readonly sheen: PBRSheenConfiguration;
  54146. /**
  54147. * Defines the SubSurface parameters for the material.
  54148. */
  54149. readonly subSurface: PBRSubSurfaceConfiguration;
  54150. /**
  54151. * Custom callback helping to override the default shader used in the material.
  54152. */
  54153. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  54154. protected _rebuildInParallel: boolean;
  54155. /**
  54156. * Instantiates a new PBRMaterial instance.
  54157. *
  54158. * @param name The material name
  54159. * @param scene The scene the material will be use in.
  54160. */
  54161. constructor(name: string, scene: Scene);
  54162. /**
  54163. * Gets a boolean indicating that current material needs to register RTT
  54164. */
  54165. get hasRenderTargetTextures(): boolean;
  54166. /**
  54167. * Gets the name of the material class.
  54168. */
  54169. getClassName(): string;
  54170. /**
  54171. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54172. */
  54173. get useLogarithmicDepth(): boolean;
  54174. /**
  54175. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54176. */
  54177. set useLogarithmicDepth(value: boolean);
  54178. /**
  54179. * Returns true if alpha blending should be disabled.
  54180. */
  54181. protected get _disableAlphaBlending(): boolean;
  54182. /**
  54183. * Specifies whether or not this material should be rendered in alpha blend mode.
  54184. */
  54185. needAlphaBlending(): boolean;
  54186. /**
  54187. * Specifies whether or not this material should be rendered in alpha test mode.
  54188. */
  54189. needAlphaTesting(): boolean;
  54190. /**
  54191. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54192. */
  54193. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54194. /**
  54195. * Gets the texture used for the alpha test.
  54196. */
  54197. getAlphaTestTexture(): Nullable<BaseTexture>;
  54198. /**
  54199. * Specifies that the submesh is ready to be used.
  54200. * @param mesh - BJS mesh.
  54201. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54202. * @param useInstances - Specifies that instances should be used.
  54203. * @returns - boolean indicating that the submesh is ready or not.
  54204. */
  54205. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54206. /**
  54207. * Specifies if the material uses metallic roughness workflow.
  54208. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54209. */
  54210. isMetallicWorkflow(): boolean;
  54211. private _prepareEffect;
  54212. private _prepareDefines;
  54213. /**
  54214. * Force shader compilation
  54215. */
  54216. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54217. /**
  54218. * Initializes the uniform buffer layout for the shader.
  54219. */
  54220. buildUniformLayout(): void;
  54221. /**
  54222. * Unbinds the material from the mesh
  54223. */
  54224. unbind(): void;
  54225. /**
  54226. * Binds the submesh data.
  54227. * @param world - The world matrix.
  54228. * @param mesh - The BJS mesh.
  54229. * @param subMesh - A submesh of the BJS mesh.
  54230. */
  54231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54232. /**
  54233. * Returns the animatable textures.
  54234. * @returns - Array of animatable textures.
  54235. */
  54236. getAnimatables(): IAnimatable[];
  54237. /**
  54238. * Returns the texture used for reflections.
  54239. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54240. */
  54241. private _getReflectionTexture;
  54242. /**
  54243. * Returns an array of the actively used textures.
  54244. * @returns - Array of BaseTextures
  54245. */
  54246. getActiveTextures(): BaseTexture[];
  54247. /**
  54248. * Checks to see if a texture is used in the material.
  54249. * @param texture - Base texture to use.
  54250. * @returns - Boolean specifying if a texture is used in the material.
  54251. */
  54252. hasTexture(texture: BaseTexture): boolean;
  54253. /**
  54254. * Disposes the resources of the material.
  54255. * @param forceDisposeEffect - Forces the disposal of effects.
  54256. * @param forceDisposeTextures - Forces the disposal of all textures.
  54257. */
  54258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54262. import { Nullable } from "babylonjs/types";
  54263. import { Scene } from "babylonjs/scene";
  54264. import { Color3 } from "babylonjs/Maths/math.color";
  54265. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54266. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54268. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54269. /**
  54270. * The Physically based material of BJS.
  54271. *
  54272. * This offers the main features of a standard PBR material.
  54273. * For more information, please refer to the documentation :
  54274. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54275. */
  54276. export class PBRMaterial extends PBRBaseMaterial {
  54277. /**
  54278. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54279. */
  54280. static readonly PBRMATERIAL_OPAQUE: number;
  54281. /**
  54282. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54283. */
  54284. static readonly PBRMATERIAL_ALPHATEST: number;
  54285. /**
  54286. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54287. */
  54288. static readonly PBRMATERIAL_ALPHABLEND: number;
  54289. /**
  54290. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54291. * They are also discarded below the alpha cutoff threshold to improve performances.
  54292. */
  54293. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54294. /**
  54295. * Defines the default value of how much AO map is occluding the analytical lights
  54296. * (point spot...).
  54297. */
  54298. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54299. /**
  54300. * Intensity of the direct lights e.g. the four lights available in your scene.
  54301. * This impacts both the direct diffuse and specular highlights.
  54302. */
  54303. directIntensity: number;
  54304. /**
  54305. * Intensity of the emissive part of the material.
  54306. * This helps controlling the emissive effect without modifying the emissive color.
  54307. */
  54308. emissiveIntensity: number;
  54309. /**
  54310. * Intensity of the environment e.g. how much the environment will light the object
  54311. * either through harmonics for rough material or through the refelction for shiny ones.
  54312. */
  54313. environmentIntensity: number;
  54314. /**
  54315. * This is a special control allowing the reduction of the specular highlights coming from the
  54316. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54317. */
  54318. specularIntensity: number;
  54319. /**
  54320. * Debug Control allowing disabling the bump map on this material.
  54321. */
  54322. disableBumpMap: boolean;
  54323. /**
  54324. * AKA Diffuse Texture in standard nomenclature.
  54325. */
  54326. albedoTexture: BaseTexture;
  54327. /**
  54328. * AKA Occlusion Texture in other nomenclature.
  54329. */
  54330. ambientTexture: BaseTexture;
  54331. /**
  54332. * AKA Occlusion Texture Intensity in other nomenclature.
  54333. */
  54334. ambientTextureStrength: number;
  54335. /**
  54336. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54337. * 1 means it completely occludes it
  54338. * 0 mean it has no impact
  54339. */
  54340. ambientTextureImpactOnAnalyticalLights: number;
  54341. /**
  54342. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54343. */
  54344. opacityTexture: BaseTexture;
  54345. /**
  54346. * Stores the reflection values in a texture.
  54347. */
  54348. reflectionTexture: Nullable<BaseTexture>;
  54349. /**
  54350. * Stores the emissive values in a texture.
  54351. */
  54352. emissiveTexture: BaseTexture;
  54353. /**
  54354. * AKA Specular texture in other nomenclature.
  54355. */
  54356. reflectivityTexture: BaseTexture;
  54357. /**
  54358. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54359. */
  54360. metallicTexture: BaseTexture;
  54361. /**
  54362. * Specifies the metallic scalar of the metallic/roughness workflow.
  54363. * Can also be used to scale the metalness values of the metallic texture.
  54364. */
  54365. metallic: Nullable<number>;
  54366. /**
  54367. * Specifies the roughness scalar of the metallic/roughness workflow.
  54368. * Can also be used to scale the roughness values of the metallic texture.
  54369. */
  54370. roughness: Nullable<number>;
  54371. /**
  54372. * Specifies the an F0 factor to help configuring the material F0.
  54373. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54374. * to 0.5 the previously hard coded value stays the same.
  54375. * Can also be used to scale the F0 values of the metallic texture.
  54376. */
  54377. metallicF0Factor: number;
  54378. /**
  54379. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54380. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54381. * your expectation as it multiplies with the texture data.
  54382. */
  54383. useMetallicF0FactorFromMetallicTexture: boolean;
  54384. /**
  54385. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54386. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54387. */
  54388. microSurfaceTexture: BaseTexture;
  54389. /**
  54390. * Stores surface normal data used to displace a mesh in a texture.
  54391. */
  54392. bumpTexture: BaseTexture;
  54393. /**
  54394. * Stores the pre-calculated light information of a mesh in a texture.
  54395. */
  54396. lightmapTexture: BaseTexture;
  54397. /**
  54398. * Stores the refracted light information in a texture.
  54399. */
  54400. get refractionTexture(): Nullable<BaseTexture>;
  54401. set refractionTexture(value: Nullable<BaseTexture>);
  54402. /**
  54403. * The color of a material in ambient lighting.
  54404. */
  54405. ambientColor: Color3;
  54406. /**
  54407. * AKA Diffuse Color in other nomenclature.
  54408. */
  54409. albedoColor: Color3;
  54410. /**
  54411. * AKA Specular Color in other nomenclature.
  54412. */
  54413. reflectivityColor: Color3;
  54414. /**
  54415. * The color reflected from the material.
  54416. */
  54417. reflectionColor: Color3;
  54418. /**
  54419. * The color emitted from the material.
  54420. */
  54421. emissiveColor: Color3;
  54422. /**
  54423. * AKA Glossiness in other nomenclature.
  54424. */
  54425. microSurface: number;
  54426. /**
  54427. * source material index of refraction (IOR)' / 'destination material IOR.
  54428. */
  54429. get indexOfRefraction(): number;
  54430. set indexOfRefraction(value: number);
  54431. /**
  54432. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54433. */
  54434. get invertRefractionY(): boolean;
  54435. set invertRefractionY(value: boolean);
  54436. /**
  54437. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54438. * Materials half opaque for instance using refraction could benefit from this control.
  54439. */
  54440. get linkRefractionWithTransparency(): boolean;
  54441. set linkRefractionWithTransparency(value: boolean);
  54442. /**
  54443. * If true, the light map contains occlusion information instead of lighting info.
  54444. */
  54445. useLightmapAsShadowmap: boolean;
  54446. /**
  54447. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54448. */
  54449. useAlphaFromAlbedoTexture: boolean;
  54450. /**
  54451. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54452. */
  54453. forceAlphaTest: boolean;
  54454. /**
  54455. * Defines the alpha limits in alpha test mode.
  54456. */
  54457. alphaCutOff: number;
  54458. /**
  54459. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54460. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54461. */
  54462. useSpecularOverAlpha: boolean;
  54463. /**
  54464. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54465. */
  54466. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54467. /**
  54468. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54469. */
  54470. useRoughnessFromMetallicTextureAlpha: boolean;
  54471. /**
  54472. * Specifies if the metallic texture contains the roughness information in its green channel.
  54473. */
  54474. useRoughnessFromMetallicTextureGreen: boolean;
  54475. /**
  54476. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54477. */
  54478. useMetallnessFromMetallicTextureBlue: boolean;
  54479. /**
  54480. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54481. */
  54482. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54483. /**
  54484. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54485. */
  54486. useAmbientInGrayScale: boolean;
  54487. /**
  54488. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54489. * The material will try to infer what glossiness each pixel should be.
  54490. */
  54491. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54492. /**
  54493. * BJS is using an harcoded light falloff based on a manually sets up range.
  54494. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54495. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54496. */
  54497. get usePhysicalLightFalloff(): boolean;
  54498. /**
  54499. * BJS is using an harcoded light falloff based on a manually sets up range.
  54500. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54501. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54502. */
  54503. set usePhysicalLightFalloff(value: boolean);
  54504. /**
  54505. * In order to support the falloff compatibility with gltf, a special mode has been added
  54506. * to reproduce the gltf light falloff.
  54507. */
  54508. get useGLTFLightFalloff(): boolean;
  54509. /**
  54510. * In order to support the falloff compatibility with gltf, a special mode has been added
  54511. * to reproduce the gltf light falloff.
  54512. */
  54513. set useGLTFLightFalloff(value: boolean);
  54514. /**
  54515. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54516. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54517. */
  54518. useRadianceOverAlpha: boolean;
  54519. /**
  54520. * Allows using an object space normal map (instead of tangent space).
  54521. */
  54522. useObjectSpaceNormalMap: boolean;
  54523. /**
  54524. * Allows using the bump map in parallax mode.
  54525. */
  54526. useParallax: boolean;
  54527. /**
  54528. * Allows using the bump map in parallax occlusion mode.
  54529. */
  54530. useParallaxOcclusion: boolean;
  54531. /**
  54532. * Controls the scale bias of the parallax mode.
  54533. */
  54534. parallaxScaleBias: number;
  54535. /**
  54536. * If sets to true, disables all the lights affecting the material.
  54537. */
  54538. disableLighting: boolean;
  54539. /**
  54540. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54541. */
  54542. forceIrradianceInFragment: boolean;
  54543. /**
  54544. * Number of Simultaneous lights allowed on the material.
  54545. */
  54546. maxSimultaneousLights: number;
  54547. /**
  54548. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54549. */
  54550. invertNormalMapX: boolean;
  54551. /**
  54552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54553. */
  54554. invertNormalMapY: boolean;
  54555. /**
  54556. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54557. */
  54558. twoSidedLighting: boolean;
  54559. /**
  54560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54561. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54562. */
  54563. useAlphaFresnel: boolean;
  54564. /**
  54565. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54566. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54567. */
  54568. useLinearAlphaFresnel: boolean;
  54569. /**
  54570. * Let user defines the brdf lookup texture used for IBL.
  54571. * A default 8bit version is embedded but you could point at :
  54572. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54573. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54574. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54575. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54576. */
  54577. environmentBRDFTexture: Nullable<BaseTexture>;
  54578. /**
  54579. * Force normal to face away from face.
  54580. */
  54581. forceNormalForward: boolean;
  54582. /**
  54583. * Enables specular anti aliasing in the PBR shader.
  54584. * It will both interacts on the Geometry for analytical and IBL lighting.
  54585. * It also prefilter the roughness map based on the bump values.
  54586. */
  54587. enableSpecularAntiAliasing: boolean;
  54588. /**
  54589. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54590. * makes the reflect vector face the model (under horizon).
  54591. */
  54592. useHorizonOcclusion: boolean;
  54593. /**
  54594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54595. * too much the area relying on ambient texture to define their ambient occlusion.
  54596. */
  54597. useRadianceOcclusion: boolean;
  54598. /**
  54599. * If set to true, no lighting calculations will be applied.
  54600. */
  54601. unlit: boolean;
  54602. /**
  54603. * Gets the image processing configuration used either in this material.
  54604. */
  54605. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54606. /**
  54607. * Sets the Default image processing configuration used either in the this material.
  54608. *
  54609. * If sets to null, the scene one is in use.
  54610. */
  54611. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54612. /**
  54613. * Gets wether the color curves effect is enabled.
  54614. */
  54615. get cameraColorCurvesEnabled(): boolean;
  54616. /**
  54617. * Sets wether the color curves effect is enabled.
  54618. */
  54619. set cameraColorCurvesEnabled(value: boolean);
  54620. /**
  54621. * Gets wether the color grading effect is enabled.
  54622. */
  54623. get cameraColorGradingEnabled(): boolean;
  54624. /**
  54625. * Gets wether the color grading effect is enabled.
  54626. */
  54627. set cameraColorGradingEnabled(value: boolean);
  54628. /**
  54629. * Gets wether tonemapping is enabled or not.
  54630. */
  54631. get cameraToneMappingEnabled(): boolean;
  54632. /**
  54633. * Sets wether tonemapping is enabled or not
  54634. */
  54635. set cameraToneMappingEnabled(value: boolean);
  54636. /**
  54637. * The camera exposure used on this material.
  54638. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54639. * This corresponds to a photographic exposure.
  54640. */
  54641. get cameraExposure(): number;
  54642. /**
  54643. * The camera exposure used on this material.
  54644. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54645. * This corresponds to a photographic exposure.
  54646. */
  54647. set cameraExposure(value: number);
  54648. /**
  54649. * Gets The camera contrast used on this material.
  54650. */
  54651. get cameraContrast(): number;
  54652. /**
  54653. * Sets The camera contrast used on this material.
  54654. */
  54655. set cameraContrast(value: number);
  54656. /**
  54657. * Gets the Color Grading 2D Lookup Texture.
  54658. */
  54659. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54660. /**
  54661. * Sets the Color Grading 2D Lookup Texture.
  54662. */
  54663. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54664. /**
  54665. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54666. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54667. * 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;
  54668. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54669. */
  54670. get cameraColorCurves(): Nullable<ColorCurves>;
  54671. /**
  54672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54674. * 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;
  54675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54676. */
  54677. set cameraColorCurves(value: Nullable<ColorCurves>);
  54678. /**
  54679. * Instantiates a new PBRMaterial instance.
  54680. *
  54681. * @param name The material name
  54682. * @param scene The scene the material will be use in.
  54683. */
  54684. constructor(name: string, scene: Scene);
  54685. /**
  54686. * Returns the name of this material class.
  54687. */
  54688. getClassName(): string;
  54689. /**
  54690. * Makes a duplicate of the current material.
  54691. * @param name - name to use for the new material.
  54692. */
  54693. clone(name: string): PBRMaterial;
  54694. /**
  54695. * Serializes this PBR Material.
  54696. * @returns - An object with the serialized material.
  54697. */
  54698. serialize(): any;
  54699. /**
  54700. * Parses a PBR Material from a serialized object.
  54701. * @param source - Serialized object.
  54702. * @param scene - BJS scene instance.
  54703. * @param rootUrl - url for the scene object
  54704. * @returns - PBRMaterial
  54705. */
  54706. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54707. }
  54708. }
  54709. declare module "babylonjs/Misc/dds" {
  54710. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54712. import { Nullable } from "babylonjs/types";
  54713. import { Scene } from "babylonjs/scene";
  54714. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54715. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54716. /**
  54717. * Direct draw surface info
  54718. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54719. */
  54720. export interface DDSInfo {
  54721. /**
  54722. * Width of the texture
  54723. */
  54724. width: number;
  54725. /**
  54726. * Width of the texture
  54727. */
  54728. height: number;
  54729. /**
  54730. * Number of Mipmaps for the texture
  54731. * @see https://en.wikipedia.org/wiki/Mipmap
  54732. */
  54733. mipmapCount: number;
  54734. /**
  54735. * If the textures format is a known fourCC format
  54736. * @see https://www.fourcc.org/
  54737. */
  54738. isFourCC: boolean;
  54739. /**
  54740. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54741. */
  54742. isRGB: boolean;
  54743. /**
  54744. * If the texture is a lumincance format
  54745. */
  54746. isLuminance: boolean;
  54747. /**
  54748. * If this is a cube texture
  54749. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54750. */
  54751. isCube: boolean;
  54752. /**
  54753. * If the texture is a compressed format eg. FOURCC_DXT1
  54754. */
  54755. isCompressed: boolean;
  54756. /**
  54757. * The dxgiFormat of the texture
  54758. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54759. */
  54760. dxgiFormat: number;
  54761. /**
  54762. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54763. */
  54764. textureType: number;
  54765. /**
  54766. * Sphericle polynomial created for the dds texture
  54767. */
  54768. sphericalPolynomial?: SphericalPolynomial;
  54769. }
  54770. /**
  54771. * Class used to provide DDS decompression tools
  54772. */
  54773. export class DDSTools {
  54774. /**
  54775. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54776. */
  54777. static StoreLODInAlphaChannel: boolean;
  54778. /**
  54779. * Gets DDS information from an array buffer
  54780. * @param data defines the array buffer view to read data from
  54781. * @returns the DDS information
  54782. */
  54783. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54784. private static _FloatView;
  54785. private static _Int32View;
  54786. private static _ToHalfFloat;
  54787. private static _FromHalfFloat;
  54788. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54789. private static _GetHalfFloatRGBAArrayBuffer;
  54790. private static _GetFloatRGBAArrayBuffer;
  54791. private static _GetFloatAsUIntRGBAArrayBuffer;
  54792. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54793. private static _GetRGBAArrayBuffer;
  54794. private static _ExtractLongWordOrder;
  54795. private static _GetRGBArrayBuffer;
  54796. private static _GetLuminanceArrayBuffer;
  54797. /**
  54798. * Uploads DDS Levels to a Babylon Texture
  54799. * @hidden
  54800. */
  54801. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54802. }
  54803. module "babylonjs/Engines/thinEngine" {
  54804. interface ThinEngine {
  54805. /**
  54806. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54807. * @param rootUrl defines the url where the file to load is located
  54808. * @param scene defines the current scene
  54809. * @param lodScale defines scale to apply to the mip map selection
  54810. * @param lodOffset defines offset to apply to the mip map selection
  54811. * @param onLoad defines an optional callback raised when the texture is loaded
  54812. * @param onError defines an optional callback raised if there is an issue to load the texture
  54813. * @param format defines the format of the data
  54814. * @param forcedExtension defines the extension to use to pick the right loader
  54815. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54816. * @returns the cube texture as an InternalTexture
  54817. */
  54818. 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;
  54819. }
  54820. }
  54821. }
  54822. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54823. import { Nullable } from "babylonjs/types";
  54824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54825. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54826. /**
  54827. * Implementation of the DDS Texture Loader.
  54828. * @hidden
  54829. */
  54830. export class _DDSTextureLoader implements IInternalTextureLoader {
  54831. /**
  54832. * Defines wether the loader supports cascade loading the different faces.
  54833. */
  54834. readonly supportCascades: boolean;
  54835. /**
  54836. * This returns if the loader support the current file information.
  54837. * @param extension defines the file extension of the file being loaded
  54838. * @returns true if the loader can load the specified file
  54839. */
  54840. canLoad(extension: string): boolean;
  54841. /**
  54842. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54843. * @param data contains the texture data
  54844. * @param texture defines the BabylonJS internal texture
  54845. * @param createPolynomials will be true if polynomials have been requested
  54846. * @param onLoad defines the callback to trigger once the texture is ready
  54847. * @param onError defines the callback to trigger in case of error
  54848. */
  54849. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54850. /**
  54851. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54852. * @param data contains the texture data
  54853. * @param texture defines the BabylonJS internal texture
  54854. * @param callback defines the method to call once ready to upload
  54855. */
  54856. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54857. }
  54858. }
  54859. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54860. import { Nullable } from "babylonjs/types";
  54861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54862. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54863. /**
  54864. * Implementation of the ENV Texture Loader.
  54865. * @hidden
  54866. */
  54867. export class _ENVTextureLoader implements IInternalTextureLoader {
  54868. /**
  54869. * Defines wether the loader supports cascade loading the different faces.
  54870. */
  54871. readonly supportCascades: boolean;
  54872. /**
  54873. * This returns if the loader support the current file information.
  54874. * @param extension defines the file extension of the file being loaded
  54875. * @returns true if the loader can load the specified file
  54876. */
  54877. canLoad(extension: string): boolean;
  54878. /**
  54879. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54880. * @param data contains the texture data
  54881. * @param texture defines the BabylonJS internal texture
  54882. * @param createPolynomials will be true if polynomials have been requested
  54883. * @param onLoad defines the callback to trigger once the texture is ready
  54884. * @param onError defines the callback to trigger in case of error
  54885. */
  54886. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54887. /**
  54888. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54889. * @param data contains the texture data
  54890. * @param texture defines the BabylonJS internal texture
  54891. * @param callback defines the method to call once ready to upload
  54892. */
  54893. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54894. }
  54895. }
  54896. declare module "babylonjs/Misc/khronosTextureContainer" {
  54897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54898. /**
  54899. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54900. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54901. */
  54902. export class KhronosTextureContainer {
  54903. /** contents of the KTX container file */
  54904. data: ArrayBufferView;
  54905. private static HEADER_LEN;
  54906. private static COMPRESSED_2D;
  54907. private static COMPRESSED_3D;
  54908. private static TEX_2D;
  54909. private static TEX_3D;
  54910. /**
  54911. * Gets the openGL type
  54912. */
  54913. glType: number;
  54914. /**
  54915. * Gets the openGL type size
  54916. */
  54917. glTypeSize: number;
  54918. /**
  54919. * Gets the openGL format
  54920. */
  54921. glFormat: number;
  54922. /**
  54923. * Gets the openGL internal format
  54924. */
  54925. glInternalFormat: number;
  54926. /**
  54927. * Gets the base internal format
  54928. */
  54929. glBaseInternalFormat: number;
  54930. /**
  54931. * Gets image width in pixel
  54932. */
  54933. pixelWidth: number;
  54934. /**
  54935. * Gets image height in pixel
  54936. */
  54937. pixelHeight: number;
  54938. /**
  54939. * Gets image depth in pixels
  54940. */
  54941. pixelDepth: number;
  54942. /**
  54943. * Gets the number of array elements
  54944. */
  54945. numberOfArrayElements: number;
  54946. /**
  54947. * Gets the number of faces
  54948. */
  54949. numberOfFaces: number;
  54950. /**
  54951. * Gets the number of mipmap levels
  54952. */
  54953. numberOfMipmapLevels: number;
  54954. /**
  54955. * Gets the bytes of key value data
  54956. */
  54957. bytesOfKeyValueData: number;
  54958. /**
  54959. * Gets the load type
  54960. */
  54961. loadType: number;
  54962. /**
  54963. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54964. */
  54965. isInvalid: boolean;
  54966. /**
  54967. * Creates a new KhronosTextureContainer
  54968. * @param data contents of the KTX container file
  54969. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54970. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54971. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54972. */
  54973. constructor(
  54974. /** contents of the KTX container file */
  54975. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54976. /**
  54977. * Uploads KTX content to a Babylon Texture.
  54978. * It is assumed that the texture has already been created & is currently bound
  54979. * @hidden
  54980. */
  54981. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54982. private _upload2DCompressedLevels;
  54983. /**
  54984. * Checks if the given data starts with a KTX file identifier.
  54985. * @param data the data to check
  54986. * @returns true if the data is a KTX file or false otherwise
  54987. */
  54988. static IsValid(data: ArrayBufferView): boolean;
  54989. }
  54990. }
  54991. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54992. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54993. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54994. /**
  54995. * Class for loading KTX2 files
  54996. * !!! Experimental Extension Subject to Changes !!!
  54997. * @hidden
  54998. */
  54999. export class KhronosTextureContainer2 {
  55000. private static _ModulePromise;
  55001. private static _TranscodeFormat;
  55002. constructor(engine: ThinEngine);
  55003. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55004. private _determineTranscodeFormat;
  55005. /**
  55006. * Checks if the given data starts with a KTX2 file identifier.
  55007. * @param data the data to check
  55008. * @returns true if the data is a KTX2 file or false otherwise
  55009. */
  55010. static IsValid(data: ArrayBufferView): boolean;
  55011. }
  55012. }
  55013. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55014. import { Nullable } from "babylonjs/types";
  55015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55016. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55017. /**
  55018. * Implementation of the KTX Texture Loader.
  55019. * @hidden
  55020. */
  55021. export class _KTXTextureLoader implements IInternalTextureLoader {
  55022. /**
  55023. * Defines wether the loader supports cascade loading the different faces.
  55024. */
  55025. readonly supportCascades: boolean;
  55026. /**
  55027. * This returns if the loader support the current file information.
  55028. * @param extension defines the file extension of the file being loaded
  55029. * @returns true if the loader can load the specified file
  55030. */
  55031. canLoad(extension: string): boolean;
  55032. /**
  55033. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55034. * @param data contains the texture data
  55035. * @param texture defines the BabylonJS internal texture
  55036. * @param createPolynomials will be true if polynomials have been requested
  55037. * @param onLoad defines the callback to trigger once the texture is ready
  55038. * @param onError defines the callback to trigger in case of error
  55039. */
  55040. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55041. /**
  55042. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55043. * @param data contains the texture data
  55044. * @param texture defines the BabylonJS internal texture
  55045. * @param callback defines the method to call once ready to upload
  55046. */
  55047. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55048. }
  55049. }
  55050. declare module "babylonjs/Helpers/sceneHelpers" {
  55051. import { Nullable } from "babylonjs/types";
  55052. import { Mesh } from "babylonjs/Meshes/mesh";
  55053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55054. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55055. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55056. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55057. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55058. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55059. import "babylonjs/Meshes/Builders/boxBuilder";
  55060. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55061. /** @hidden */
  55062. export var _forceSceneHelpersToBundle: boolean;
  55063. module "babylonjs/scene" {
  55064. interface Scene {
  55065. /**
  55066. * Creates a default light for the scene.
  55067. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55068. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55069. */
  55070. createDefaultLight(replace?: boolean): void;
  55071. /**
  55072. * Creates a default camera for the scene.
  55073. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55074. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55075. * @param replace has default false, when true replaces the active camera in the scene
  55076. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55077. */
  55078. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55079. /**
  55080. * Creates a default camera and a default light.
  55081. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55082. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55083. * @param replace has the default false, when true replaces the active camera/light in the scene
  55084. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55085. */
  55086. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55087. /**
  55088. * Creates a new sky box
  55089. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55090. * @param environmentTexture defines the texture to use as environment texture
  55091. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55092. * @param scale defines the overall scale of the skybox
  55093. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55094. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55095. * @returns a new mesh holding the sky box
  55096. */
  55097. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55098. /**
  55099. * Creates a new environment
  55100. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55101. * @param options defines the options you can use to configure the environment
  55102. * @returns the new EnvironmentHelper
  55103. */
  55104. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55105. /**
  55106. * Creates a new VREXperienceHelper
  55107. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55108. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55109. * @returns a new VREXperienceHelper
  55110. */
  55111. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55112. /**
  55113. * Creates a new WebXRDefaultExperience
  55114. * @see http://doc.babylonjs.com/how_to/webxr
  55115. * @param options experience options
  55116. * @returns a promise for a new WebXRDefaultExperience
  55117. */
  55118. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55119. }
  55120. }
  55121. }
  55122. declare module "babylonjs/Helpers/videoDome" {
  55123. import { Scene } from "babylonjs/scene";
  55124. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55125. import { Mesh } from "babylonjs/Meshes/mesh";
  55126. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55127. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55128. import "babylonjs/Meshes/Builders/sphereBuilder";
  55129. /**
  55130. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55131. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55132. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55133. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55134. */
  55135. export class VideoDome extends TransformNode {
  55136. /**
  55137. * Define the video source as a Monoscopic panoramic 360 video.
  55138. */
  55139. static readonly MODE_MONOSCOPIC: number;
  55140. /**
  55141. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55142. */
  55143. static readonly MODE_TOPBOTTOM: number;
  55144. /**
  55145. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55146. */
  55147. static readonly MODE_SIDEBYSIDE: number;
  55148. private _halfDome;
  55149. private _useDirectMapping;
  55150. /**
  55151. * The video texture being displayed on the sphere
  55152. */
  55153. protected _videoTexture: VideoTexture;
  55154. /**
  55155. * Gets the video texture being displayed on the sphere
  55156. */
  55157. get videoTexture(): VideoTexture;
  55158. /**
  55159. * The skybox material
  55160. */
  55161. protected _material: BackgroundMaterial;
  55162. /**
  55163. * The surface used for the skybox
  55164. */
  55165. protected _mesh: Mesh;
  55166. /**
  55167. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55168. */
  55169. private _halfDomeMask;
  55170. /**
  55171. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55172. * Also see the options.resolution property.
  55173. */
  55174. get fovMultiplier(): number;
  55175. set fovMultiplier(value: number);
  55176. private _videoMode;
  55177. /**
  55178. * Gets or set the current video mode for the video. It can be:
  55179. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55180. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55181. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55182. */
  55183. get videoMode(): number;
  55184. set videoMode(value: number);
  55185. /**
  55186. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55187. *
  55188. */
  55189. get halfDome(): boolean;
  55190. /**
  55191. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55192. */
  55193. set halfDome(enabled: boolean);
  55194. /**
  55195. * Oberserver used in Stereoscopic VR Mode.
  55196. */
  55197. private _onBeforeCameraRenderObserver;
  55198. /**
  55199. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55200. * @param name Element's name, child elements will append suffixes for their own names.
  55201. * @param urlsOrVideo defines the url(s) or the video element to use
  55202. * @param options An object containing optional or exposed sub element properties
  55203. */
  55204. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55205. resolution?: number;
  55206. clickToPlay?: boolean;
  55207. autoPlay?: boolean;
  55208. loop?: boolean;
  55209. size?: number;
  55210. poster?: string;
  55211. faceForward?: boolean;
  55212. useDirectMapping?: boolean;
  55213. halfDomeMode?: boolean;
  55214. }, scene: Scene);
  55215. private _changeVideoMode;
  55216. /**
  55217. * Releases resources associated with this node.
  55218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55220. */
  55221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55222. }
  55223. }
  55224. declare module "babylonjs/Helpers/index" {
  55225. export * from "babylonjs/Helpers/environmentHelper";
  55226. export * from "babylonjs/Helpers/photoDome";
  55227. export * from "babylonjs/Helpers/sceneHelpers";
  55228. export * from "babylonjs/Helpers/videoDome";
  55229. }
  55230. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55231. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55232. import { IDisposable } from "babylonjs/scene";
  55233. import { Engine } from "babylonjs/Engines/engine";
  55234. /**
  55235. * This class can be used to get instrumentation data from a Babylon engine
  55236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55237. */
  55238. export class EngineInstrumentation implements IDisposable {
  55239. /**
  55240. * Define the instrumented engine.
  55241. */
  55242. engine: Engine;
  55243. private _captureGPUFrameTime;
  55244. private _gpuFrameTimeToken;
  55245. private _gpuFrameTime;
  55246. private _captureShaderCompilationTime;
  55247. private _shaderCompilationTime;
  55248. private _onBeginFrameObserver;
  55249. private _onEndFrameObserver;
  55250. private _onBeforeShaderCompilationObserver;
  55251. private _onAfterShaderCompilationObserver;
  55252. /**
  55253. * Gets the perf counter used for GPU frame time
  55254. */
  55255. get gpuFrameTimeCounter(): PerfCounter;
  55256. /**
  55257. * Gets the GPU frame time capture status
  55258. */
  55259. get captureGPUFrameTime(): boolean;
  55260. /**
  55261. * Enable or disable the GPU frame time capture
  55262. */
  55263. set captureGPUFrameTime(value: boolean);
  55264. /**
  55265. * Gets the perf counter used for shader compilation time
  55266. */
  55267. get shaderCompilationTimeCounter(): PerfCounter;
  55268. /**
  55269. * Gets the shader compilation time capture status
  55270. */
  55271. get captureShaderCompilationTime(): boolean;
  55272. /**
  55273. * Enable or disable the shader compilation time capture
  55274. */
  55275. set captureShaderCompilationTime(value: boolean);
  55276. /**
  55277. * Instantiates a new engine instrumentation.
  55278. * This class can be used to get instrumentation data from a Babylon engine
  55279. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55280. * @param engine Defines the engine to instrument
  55281. */
  55282. constructor(
  55283. /**
  55284. * Define the instrumented engine.
  55285. */
  55286. engine: Engine);
  55287. /**
  55288. * Dispose and release associated resources.
  55289. */
  55290. dispose(): void;
  55291. }
  55292. }
  55293. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55294. import { Scene, IDisposable } from "babylonjs/scene";
  55295. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55296. /**
  55297. * This class can be used to get instrumentation data from a Babylon engine
  55298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55299. */
  55300. export class SceneInstrumentation implements IDisposable {
  55301. /**
  55302. * Defines the scene to instrument
  55303. */
  55304. scene: Scene;
  55305. private _captureActiveMeshesEvaluationTime;
  55306. private _activeMeshesEvaluationTime;
  55307. private _captureRenderTargetsRenderTime;
  55308. private _renderTargetsRenderTime;
  55309. private _captureFrameTime;
  55310. private _frameTime;
  55311. private _captureRenderTime;
  55312. private _renderTime;
  55313. private _captureInterFrameTime;
  55314. private _interFrameTime;
  55315. private _captureParticlesRenderTime;
  55316. private _particlesRenderTime;
  55317. private _captureSpritesRenderTime;
  55318. private _spritesRenderTime;
  55319. private _capturePhysicsTime;
  55320. private _physicsTime;
  55321. private _captureAnimationsTime;
  55322. private _animationsTime;
  55323. private _captureCameraRenderTime;
  55324. private _cameraRenderTime;
  55325. private _onBeforeActiveMeshesEvaluationObserver;
  55326. private _onAfterActiveMeshesEvaluationObserver;
  55327. private _onBeforeRenderTargetsRenderObserver;
  55328. private _onAfterRenderTargetsRenderObserver;
  55329. private _onAfterRenderObserver;
  55330. private _onBeforeDrawPhaseObserver;
  55331. private _onAfterDrawPhaseObserver;
  55332. private _onBeforeAnimationsObserver;
  55333. private _onBeforeParticlesRenderingObserver;
  55334. private _onAfterParticlesRenderingObserver;
  55335. private _onBeforeSpritesRenderingObserver;
  55336. private _onAfterSpritesRenderingObserver;
  55337. private _onBeforePhysicsObserver;
  55338. private _onAfterPhysicsObserver;
  55339. private _onAfterAnimationsObserver;
  55340. private _onBeforeCameraRenderObserver;
  55341. private _onAfterCameraRenderObserver;
  55342. /**
  55343. * Gets the perf counter used for active meshes evaluation time
  55344. */
  55345. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55346. /**
  55347. * Gets the active meshes evaluation time capture status
  55348. */
  55349. get captureActiveMeshesEvaluationTime(): boolean;
  55350. /**
  55351. * Enable or disable the active meshes evaluation time capture
  55352. */
  55353. set captureActiveMeshesEvaluationTime(value: boolean);
  55354. /**
  55355. * Gets the perf counter used for render targets render time
  55356. */
  55357. get renderTargetsRenderTimeCounter(): PerfCounter;
  55358. /**
  55359. * Gets the render targets render time capture status
  55360. */
  55361. get captureRenderTargetsRenderTime(): boolean;
  55362. /**
  55363. * Enable or disable the render targets render time capture
  55364. */
  55365. set captureRenderTargetsRenderTime(value: boolean);
  55366. /**
  55367. * Gets the perf counter used for particles render time
  55368. */
  55369. get particlesRenderTimeCounter(): PerfCounter;
  55370. /**
  55371. * Gets the particles render time capture status
  55372. */
  55373. get captureParticlesRenderTime(): boolean;
  55374. /**
  55375. * Enable or disable the particles render time capture
  55376. */
  55377. set captureParticlesRenderTime(value: boolean);
  55378. /**
  55379. * Gets the perf counter used for sprites render time
  55380. */
  55381. get spritesRenderTimeCounter(): PerfCounter;
  55382. /**
  55383. * Gets the sprites render time capture status
  55384. */
  55385. get captureSpritesRenderTime(): boolean;
  55386. /**
  55387. * Enable or disable the sprites render time capture
  55388. */
  55389. set captureSpritesRenderTime(value: boolean);
  55390. /**
  55391. * Gets the perf counter used for physics time
  55392. */
  55393. get physicsTimeCounter(): PerfCounter;
  55394. /**
  55395. * Gets the physics time capture status
  55396. */
  55397. get capturePhysicsTime(): boolean;
  55398. /**
  55399. * Enable or disable the physics time capture
  55400. */
  55401. set capturePhysicsTime(value: boolean);
  55402. /**
  55403. * Gets the perf counter used for animations time
  55404. */
  55405. get animationsTimeCounter(): PerfCounter;
  55406. /**
  55407. * Gets the animations time capture status
  55408. */
  55409. get captureAnimationsTime(): boolean;
  55410. /**
  55411. * Enable or disable the animations time capture
  55412. */
  55413. set captureAnimationsTime(value: boolean);
  55414. /**
  55415. * Gets the perf counter used for frame time capture
  55416. */
  55417. get frameTimeCounter(): PerfCounter;
  55418. /**
  55419. * Gets the frame time capture status
  55420. */
  55421. get captureFrameTime(): boolean;
  55422. /**
  55423. * Enable or disable the frame time capture
  55424. */
  55425. set captureFrameTime(value: boolean);
  55426. /**
  55427. * Gets the perf counter used for inter-frames time capture
  55428. */
  55429. get interFrameTimeCounter(): PerfCounter;
  55430. /**
  55431. * Gets the inter-frames time capture status
  55432. */
  55433. get captureInterFrameTime(): boolean;
  55434. /**
  55435. * Enable or disable the inter-frames time capture
  55436. */
  55437. set captureInterFrameTime(value: boolean);
  55438. /**
  55439. * Gets the perf counter used for render time capture
  55440. */
  55441. get renderTimeCounter(): PerfCounter;
  55442. /**
  55443. * Gets the render time capture status
  55444. */
  55445. get captureRenderTime(): boolean;
  55446. /**
  55447. * Enable or disable the render time capture
  55448. */
  55449. set captureRenderTime(value: boolean);
  55450. /**
  55451. * Gets the perf counter used for camera render time capture
  55452. */
  55453. get cameraRenderTimeCounter(): PerfCounter;
  55454. /**
  55455. * Gets the camera render time capture status
  55456. */
  55457. get captureCameraRenderTime(): boolean;
  55458. /**
  55459. * Enable or disable the camera render time capture
  55460. */
  55461. set captureCameraRenderTime(value: boolean);
  55462. /**
  55463. * Gets the perf counter used for draw calls
  55464. */
  55465. get drawCallsCounter(): PerfCounter;
  55466. /**
  55467. * Instantiates a new scene instrumentation.
  55468. * This class can be used to get instrumentation data from a Babylon engine
  55469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55470. * @param scene Defines the scene to instrument
  55471. */
  55472. constructor(
  55473. /**
  55474. * Defines the scene to instrument
  55475. */
  55476. scene: Scene);
  55477. /**
  55478. * Dispose and release associated resources.
  55479. */
  55480. dispose(): void;
  55481. }
  55482. }
  55483. declare module "babylonjs/Instrumentation/index" {
  55484. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55485. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55486. export * from "babylonjs/Instrumentation/timeToken";
  55487. }
  55488. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55489. /** @hidden */
  55490. export var glowMapGenerationPixelShader: {
  55491. name: string;
  55492. shader: string;
  55493. };
  55494. }
  55495. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55496. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55498. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55499. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55500. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55501. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55502. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55503. /** @hidden */
  55504. export var glowMapGenerationVertexShader: {
  55505. name: string;
  55506. shader: string;
  55507. };
  55508. }
  55509. declare module "babylonjs/Layers/effectLayer" {
  55510. import { Observable } from "babylonjs/Misc/observable";
  55511. import { Nullable } from "babylonjs/types";
  55512. import { Camera } from "babylonjs/Cameras/camera";
  55513. import { Scene } from "babylonjs/scene";
  55514. import { ISize } from "babylonjs/Maths/math.size";
  55515. import { Color4 } from "babylonjs/Maths/math.color";
  55516. import { Engine } from "babylonjs/Engines/engine";
  55517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55519. import { Mesh } from "babylonjs/Meshes/mesh";
  55520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55523. import { Effect } from "babylonjs/Materials/effect";
  55524. import { Material } from "babylonjs/Materials/material";
  55525. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55526. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55527. /**
  55528. * Effect layer options. This helps customizing the behaviour
  55529. * of the effect layer.
  55530. */
  55531. export interface IEffectLayerOptions {
  55532. /**
  55533. * Multiplication factor apply to the canvas size to compute the render target size
  55534. * used to generated the objects (the smaller the faster).
  55535. */
  55536. mainTextureRatio: number;
  55537. /**
  55538. * Enforces a fixed size texture to ensure effect stability across devices.
  55539. */
  55540. mainTextureFixedSize?: number;
  55541. /**
  55542. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55543. */
  55544. alphaBlendingMode: number;
  55545. /**
  55546. * The camera attached to the layer.
  55547. */
  55548. camera: Nullable<Camera>;
  55549. /**
  55550. * The rendering group to draw the layer in.
  55551. */
  55552. renderingGroupId: number;
  55553. }
  55554. /**
  55555. * The effect layer Helps adding post process effect blended with the main pass.
  55556. *
  55557. * This can be for instance use to generate glow or higlight effects on the scene.
  55558. *
  55559. * The effect layer class can not be used directly and is intented to inherited from to be
  55560. * customized per effects.
  55561. */
  55562. export abstract class EffectLayer {
  55563. private _vertexBuffers;
  55564. private _indexBuffer;
  55565. private _cachedDefines;
  55566. private _effectLayerMapGenerationEffect;
  55567. private _effectLayerOptions;
  55568. private _mergeEffect;
  55569. protected _scene: Scene;
  55570. protected _engine: Engine;
  55571. protected _maxSize: number;
  55572. protected _mainTextureDesiredSize: ISize;
  55573. protected _mainTexture: RenderTargetTexture;
  55574. protected _shouldRender: boolean;
  55575. protected _postProcesses: PostProcess[];
  55576. protected _textures: BaseTexture[];
  55577. protected _emissiveTextureAndColor: {
  55578. texture: Nullable<BaseTexture>;
  55579. color: Color4;
  55580. };
  55581. /**
  55582. * The name of the layer
  55583. */
  55584. name: string;
  55585. /**
  55586. * The clear color of the texture used to generate the glow map.
  55587. */
  55588. neutralColor: Color4;
  55589. /**
  55590. * Specifies whether the highlight layer is enabled or not.
  55591. */
  55592. isEnabled: boolean;
  55593. /**
  55594. * Gets the camera attached to the layer.
  55595. */
  55596. get camera(): Nullable<Camera>;
  55597. /**
  55598. * Gets the rendering group id the layer should render in.
  55599. */
  55600. get renderingGroupId(): number;
  55601. set renderingGroupId(renderingGroupId: number);
  55602. /**
  55603. * An event triggered when the effect layer has been disposed.
  55604. */
  55605. onDisposeObservable: Observable<EffectLayer>;
  55606. /**
  55607. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55608. */
  55609. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55610. /**
  55611. * An event triggered when the generated texture is being merged in the scene.
  55612. */
  55613. onBeforeComposeObservable: Observable<EffectLayer>;
  55614. /**
  55615. * An event triggered when the mesh is rendered into the effect render target.
  55616. */
  55617. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55618. /**
  55619. * An event triggered after the mesh has been rendered into the effect render target.
  55620. */
  55621. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55622. /**
  55623. * An event triggered when the generated texture has been merged in the scene.
  55624. */
  55625. onAfterComposeObservable: Observable<EffectLayer>;
  55626. /**
  55627. * An event triggered when the efffect layer changes its size.
  55628. */
  55629. onSizeChangedObservable: Observable<EffectLayer>;
  55630. /** @hidden */
  55631. static _SceneComponentInitialization: (scene: Scene) => void;
  55632. /**
  55633. * Instantiates a new effect Layer and references it in the scene.
  55634. * @param name The name of the layer
  55635. * @param scene The scene to use the layer in
  55636. */
  55637. constructor(
  55638. /** The Friendly of the effect in the scene */
  55639. name: string, scene: Scene);
  55640. /**
  55641. * Get the effect name of the layer.
  55642. * @return The effect name
  55643. */
  55644. abstract getEffectName(): string;
  55645. /**
  55646. * Checks for the readiness of the element composing the layer.
  55647. * @param subMesh the mesh to check for
  55648. * @param useInstances specify whether or not to use instances to render the mesh
  55649. * @return true if ready otherwise, false
  55650. */
  55651. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55652. /**
  55653. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55654. * @returns true if the effect requires stencil during the main canvas render pass.
  55655. */
  55656. abstract needStencil(): boolean;
  55657. /**
  55658. * Create the merge effect. This is the shader use to blit the information back
  55659. * to the main canvas at the end of the scene rendering.
  55660. * @returns The effect containing the shader used to merge the effect on the main canvas
  55661. */
  55662. protected abstract _createMergeEffect(): Effect;
  55663. /**
  55664. * Creates the render target textures and post processes used in the effect layer.
  55665. */
  55666. protected abstract _createTextureAndPostProcesses(): void;
  55667. /**
  55668. * Implementation specific of rendering the generating effect on the main canvas.
  55669. * @param effect The effect used to render through
  55670. */
  55671. protected abstract _internalRender(effect: Effect): void;
  55672. /**
  55673. * Sets the required values for both the emissive texture and and the main color.
  55674. */
  55675. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55676. /**
  55677. * Free any resources and references associated to a mesh.
  55678. * Internal use
  55679. * @param mesh The mesh to free.
  55680. */
  55681. abstract _disposeMesh(mesh: Mesh): void;
  55682. /**
  55683. * Serializes this layer (Glow or Highlight for example)
  55684. * @returns a serialized layer object
  55685. */
  55686. abstract serialize?(): any;
  55687. /**
  55688. * Initializes the effect layer with the required options.
  55689. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55690. */
  55691. protected _init(options: Partial<IEffectLayerOptions>): void;
  55692. /**
  55693. * Generates the index buffer of the full screen quad blending to the main canvas.
  55694. */
  55695. private _generateIndexBuffer;
  55696. /**
  55697. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55698. */
  55699. private _generateVertexBuffer;
  55700. /**
  55701. * Sets the main texture desired size which is the closest power of two
  55702. * of the engine canvas size.
  55703. */
  55704. private _setMainTextureSize;
  55705. /**
  55706. * Creates the main texture for the effect layer.
  55707. */
  55708. protected _createMainTexture(): void;
  55709. /**
  55710. * Adds specific effects defines.
  55711. * @param defines The defines to add specifics to.
  55712. */
  55713. protected _addCustomEffectDefines(defines: string[]): void;
  55714. /**
  55715. * Checks for the readiness of the element composing the layer.
  55716. * @param subMesh the mesh to check for
  55717. * @param useInstances specify whether or not to use instances to render the mesh
  55718. * @param emissiveTexture the associated emissive texture used to generate the glow
  55719. * @return true if ready otherwise, false
  55720. */
  55721. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55722. /**
  55723. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55724. */
  55725. render(): void;
  55726. /**
  55727. * Determine if a given mesh will be used in the current effect.
  55728. * @param mesh mesh to test
  55729. * @returns true if the mesh will be used
  55730. */
  55731. hasMesh(mesh: AbstractMesh): boolean;
  55732. /**
  55733. * Returns true if the layer contains information to display, otherwise false.
  55734. * @returns true if the glow layer should be rendered
  55735. */
  55736. shouldRender(): boolean;
  55737. /**
  55738. * Returns true if the mesh should render, otherwise false.
  55739. * @param mesh The mesh to render
  55740. * @returns true if it should render otherwise false
  55741. */
  55742. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55743. /**
  55744. * Returns true if the mesh can be rendered, otherwise false.
  55745. * @param mesh The mesh to render
  55746. * @param material The material used on the mesh
  55747. * @returns true if it can be rendered otherwise false
  55748. */
  55749. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55750. /**
  55751. * Returns true if the mesh should render, otherwise false.
  55752. * @param mesh The mesh to render
  55753. * @returns true if it should render otherwise false
  55754. */
  55755. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55756. /**
  55757. * Renders the submesh passed in parameter to the generation map.
  55758. */
  55759. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55760. /**
  55761. * Defines whether the current material of the mesh should be use to render the effect.
  55762. * @param mesh defines the current mesh to render
  55763. */
  55764. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55765. /**
  55766. * Rebuild the required buffers.
  55767. * @hidden Internal use only.
  55768. */
  55769. _rebuild(): void;
  55770. /**
  55771. * Dispose only the render target textures and post process.
  55772. */
  55773. private _disposeTextureAndPostProcesses;
  55774. /**
  55775. * Dispose the highlight layer and free resources.
  55776. */
  55777. dispose(): void;
  55778. /**
  55779. * Gets the class name of the effect layer
  55780. * @returns the string with the class name of the effect layer
  55781. */
  55782. getClassName(): string;
  55783. /**
  55784. * Creates an effect layer from parsed effect layer data
  55785. * @param parsedEffectLayer defines effect layer data
  55786. * @param scene defines the current scene
  55787. * @param rootUrl defines the root URL containing the effect layer information
  55788. * @returns a parsed effect Layer
  55789. */
  55790. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55791. }
  55792. }
  55793. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55794. import { Scene } from "babylonjs/scene";
  55795. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55796. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55797. import { AbstractScene } from "babylonjs/abstractScene";
  55798. module "babylonjs/abstractScene" {
  55799. interface AbstractScene {
  55800. /**
  55801. * The list of effect layers (highlights/glow) added to the scene
  55802. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55803. * @see http://doc.babylonjs.com/how_to/glow_layer
  55804. */
  55805. effectLayers: Array<EffectLayer>;
  55806. /**
  55807. * Removes the given effect layer from this scene.
  55808. * @param toRemove defines the effect layer to remove
  55809. * @returns the index of the removed effect layer
  55810. */
  55811. removeEffectLayer(toRemove: EffectLayer): number;
  55812. /**
  55813. * Adds the given effect layer to this scene
  55814. * @param newEffectLayer defines the effect layer to add
  55815. */
  55816. addEffectLayer(newEffectLayer: EffectLayer): void;
  55817. }
  55818. }
  55819. /**
  55820. * Defines the layer scene component responsible to manage any effect layers
  55821. * in a given scene.
  55822. */
  55823. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55824. /**
  55825. * The component name helpfull to identify the component in the list of scene components.
  55826. */
  55827. readonly name: string;
  55828. /**
  55829. * The scene the component belongs to.
  55830. */
  55831. scene: Scene;
  55832. private _engine;
  55833. private _renderEffects;
  55834. private _needStencil;
  55835. private _previousStencilState;
  55836. /**
  55837. * Creates a new instance of the component for the given scene
  55838. * @param scene Defines the scene to register the component in
  55839. */
  55840. constructor(scene: Scene);
  55841. /**
  55842. * Registers the component in a given scene
  55843. */
  55844. register(): void;
  55845. /**
  55846. * Rebuilds the elements related to this component in case of
  55847. * context lost for instance.
  55848. */
  55849. rebuild(): void;
  55850. /**
  55851. * Serializes the component data to the specified json object
  55852. * @param serializationObject The object to serialize to
  55853. */
  55854. serialize(serializationObject: any): void;
  55855. /**
  55856. * Adds all the elements from the container to the scene
  55857. * @param container the container holding the elements
  55858. */
  55859. addFromContainer(container: AbstractScene): void;
  55860. /**
  55861. * Removes all the elements in the container from the scene
  55862. * @param container contains the elements to remove
  55863. * @param dispose if the removed element should be disposed (default: false)
  55864. */
  55865. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55866. /**
  55867. * Disposes the component and the associated ressources.
  55868. */
  55869. dispose(): void;
  55870. private _isReadyForMesh;
  55871. private _renderMainTexture;
  55872. private _setStencil;
  55873. private _setStencilBack;
  55874. private _draw;
  55875. private _drawCamera;
  55876. private _drawRenderingGroup;
  55877. }
  55878. }
  55879. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55880. /** @hidden */
  55881. export var glowMapMergePixelShader: {
  55882. name: string;
  55883. shader: string;
  55884. };
  55885. }
  55886. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55887. /** @hidden */
  55888. export var glowMapMergeVertexShader: {
  55889. name: string;
  55890. shader: string;
  55891. };
  55892. }
  55893. declare module "babylonjs/Layers/glowLayer" {
  55894. import { Nullable } from "babylonjs/types";
  55895. import { Camera } from "babylonjs/Cameras/camera";
  55896. import { Scene } from "babylonjs/scene";
  55897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55899. import { Mesh } from "babylonjs/Meshes/mesh";
  55900. import { Texture } from "babylonjs/Materials/Textures/texture";
  55901. import { Effect } from "babylonjs/Materials/effect";
  55902. import { Material } from "babylonjs/Materials/material";
  55903. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55904. import { Color4 } from "babylonjs/Maths/math.color";
  55905. import "babylonjs/Shaders/glowMapMerge.fragment";
  55906. import "babylonjs/Shaders/glowMapMerge.vertex";
  55907. import "babylonjs/Layers/effectLayerSceneComponent";
  55908. module "babylonjs/abstractScene" {
  55909. interface AbstractScene {
  55910. /**
  55911. * Return a the first highlight layer of the scene with a given name.
  55912. * @param name The name of the highlight layer to look for.
  55913. * @return The highlight layer if found otherwise null.
  55914. */
  55915. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55916. }
  55917. }
  55918. /**
  55919. * Glow layer options. This helps customizing the behaviour
  55920. * of the glow layer.
  55921. */
  55922. export interface IGlowLayerOptions {
  55923. /**
  55924. * Multiplication factor apply to the canvas size to compute the render target size
  55925. * used to generated the glowing objects (the smaller the faster).
  55926. */
  55927. mainTextureRatio: number;
  55928. /**
  55929. * Enforces a fixed size texture to ensure resize independant blur.
  55930. */
  55931. mainTextureFixedSize?: number;
  55932. /**
  55933. * How big is the kernel of the blur texture.
  55934. */
  55935. blurKernelSize: number;
  55936. /**
  55937. * The camera attached to the layer.
  55938. */
  55939. camera: Nullable<Camera>;
  55940. /**
  55941. * Enable MSAA by chosing the number of samples.
  55942. */
  55943. mainTextureSamples?: number;
  55944. /**
  55945. * The rendering group to draw the layer in.
  55946. */
  55947. renderingGroupId: number;
  55948. }
  55949. /**
  55950. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55951. *
  55952. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55953. *
  55954. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55955. */
  55956. export class GlowLayer extends EffectLayer {
  55957. /**
  55958. * Effect Name of the layer.
  55959. */
  55960. static readonly EffectName: string;
  55961. /**
  55962. * The default blur kernel size used for the glow.
  55963. */
  55964. static DefaultBlurKernelSize: number;
  55965. /**
  55966. * The default texture size ratio used for the glow.
  55967. */
  55968. static DefaultTextureRatio: number;
  55969. /**
  55970. * Sets the kernel size of the blur.
  55971. */
  55972. set blurKernelSize(value: number);
  55973. /**
  55974. * Gets the kernel size of the blur.
  55975. */
  55976. get blurKernelSize(): number;
  55977. /**
  55978. * Sets the glow intensity.
  55979. */
  55980. set intensity(value: number);
  55981. /**
  55982. * Gets the glow intensity.
  55983. */
  55984. get intensity(): number;
  55985. private _options;
  55986. private _intensity;
  55987. private _horizontalBlurPostprocess1;
  55988. private _verticalBlurPostprocess1;
  55989. private _horizontalBlurPostprocess2;
  55990. private _verticalBlurPostprocess2;
  55991. private _blurTexture1;
  55992. private _blurTexture2;
  55993. private _postProcesses1;
  55994. private _postProcesses2;
  55995. private _includedOnlyMeshes;
  55996. private _excludedMeshes;
  55997. private _meshesUsingTheirOwnMaterials;
  55998. /**
  55999. * Callback used to let the user override the color selection on a per mesh basis
  56000. */
  56001. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56002. /**
  56003. * Callback used to let the user override the texture selection on a per mesh basis
  56004. */
  56005. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56006. /**
  56007. * Instantiates a new glow Layer and references it to the scene.
  56008. * @param name The name of the layer
  56009. * @param scene The scene to use the layer in
  56010. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56011. */
  56012. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56013. /**
  56014. * Get the effect name of the layer.
  56015. * @return The effect name
  56016. */
  56017. getEffectName(): string;
  56018. /**
  56019. * Create the merge effect. This is the shader use to blit the information back
  56020. * to the main canvas at the end of the scene rendering.
  56021. */
  56022. protected _createMergeEffect(): Effect;
  56023. /**
  56024. * Creates the render target textures and post processes used in the glow layer.
  56025. */
  56026. protected _createTextureAndPostProcesses(): void;
  56027. /**
  56028. * Checks for the readiness of the element composing the layer.
  56029. * @param subMesh the mesh to check for
  56030. * @param useInstances specify wether or not to use instances to render the mesh
  56031. * @param emissiveTexture the associated emissive texture used to generate the glow
  56032. * @return true if ready otherwise, false
  56033. */
  56034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56035. /**
  56036. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56037. */
  56038. needStencil(): boolean;
  56039. /**
  56040. * Returns true if the mesh can be rendered, otherwise false.
  56041. * @param mesh The mesh to render
  56042. * @param material The material used on the mesh
  56043. * @returns true if it can be rendered otherwise false
  56044. */
  56045. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56046. /**
  56047. * Implementation specific of rendering the generating effect on the main canvas.
  56048. * @param effect The effect used to render through
  56049. */
  56050. protected _internalRender(effect: Effect): void;
  56051. /**
  56052. * Sets the required values for both the emissive texture and and the main color.
  56053. */
  56054. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56055. /**
  56056. * Returns true if the mesh should render, otherwise false.
  56057. * @param mesh The mesh to render
  56058. * @returns true if it should render otherwise false
  56059. */
  56060. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56061. /**
  56062. * Adds specific effects defines.
  56063. * @param defines The defines to add specifics to.
  56064. */
  56065. protected _addCustomEffectDefines(defines: string[]): void;
  56066. /**
  56067. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56068. * @param mesh The mesh to exclude from the glow layer
  56069. */
  56070. addExcludedMesh(mesh: Mesh): void;
  56071. /**
  56072. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56073. * @param mesh The mesh to remove
  56074. */
  56075. removeExcludedMesh(mesh: Mesh): void;
  56076. /**
  56077. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56078. * @param mesh The mesh to include in the glow layer
  56079. */
  56080. addIncludedOnlyMesh(mesh: Mesh): void;
  56081. /**
  56082. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56083. * @param mesh The mesh to remove
  56084. */
  56085. removeIncludedOnlyMesh(mesh: Mesh): void;
  56086. /**
  56087. * Determine if a given mesh will be used in the glow layer
  56088. * @param mesh The mesh to test
  56089. * @returns true if the mesh will be highlighted by the current glow layer
  56090. */
  56091. hasMesh(mesh: AbstractMesh): boolean;
  56092. /**
  56093. * Defines whether the current material of the mesh should be use to render the effect.
  56094. * @param mesh defines the current mesh to render
  56095. */
  56096. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56097. /**
  56098. * Add a mesh to be rendered through its own material and not with emissive only.
  56099. * @param mesh The mesh for which we need to use its material
  56100. */
  56101. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56102. /**
  56103. * Remove a mesh from being rendered through its own material and not with emissive only.
  56104. * @param mesh The mesh for which we need to not use its material
  56105. */
  56106. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56107. /**
  56108. * Free any resources and references associated to a mesh.
  56109. * Internal use
  56110. * @param mesh The mesh to free.
  56111. * @hidden
  56112. */
  56113. _disposeMesh(mesh: Mesh): void;
  56114. /**
  56115. * Gets the class name of the effect layer
  56116. * @returns the string with the class name of the effect layer
  56117. */
  56118. getClassName(): string;
  56119. /**
  56120. * Serializes this glow layer
  56121. * @returns a serialized glow layer object
  56122. */
  56123. serialize(): any;
  56124. /**
  56125. * Creates a Glow Layer from parsed glow layer data
  56126. * @param parsedGlowLayer defines glow layer data
  56127. * @param scene defines the current scene
  56128. * @param rootUrl defines the root URL containing the glow layer information
  56129. * @returns a parsed Glow Layer
  56130. */
  56131. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56132. }
  56133. }
  56134. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56135. /** @hidden */
  56136. export var glowBlurPostProcessPixelShader: {
  56137. name: string;
  56138. shader: string;
  56139. };
  56140. }
  56141. declare module "babylonjs/Layers/highlightLayer" {
  56142. import { Observable } from "babylonjs/Misc/observable";
  56143. import { Nullable } from "babylonjs/types";
  56144. import { Camera } from "babylonjs/Cameras/camera";
  56145. import { Scene } from "babylonjs/scene";
  56146. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56148. import { Mesh } from "babylonjs/Meshes/mesh";
  56149. import { Effect } from "babylonjs/Materials/effect";
  56150. import { Material } from "babylonjs/Materials/material";
  56151. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56152. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56153. import "babylonjs/Shaders/glowMapMerge.fragment";
  56154. import "babylonjs/Shaders/glowMapMerge.vertex";
  56155. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56156. module "babylonjs/abstractScene" {
  56157. interface AbstractScene {
  56158. /**
  56159. * Return a the first highlight layer of the scene with a given name.
  56160. * @param name The name of the highlight layer to look for.
  56161. * @return The highlight layer if found otherwise null.
  56162. */
  56163. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56164. }
  56165. }
  56166. /**
  56167. * Highlight layer options. This helps customizing the behaviour
  56168. * of the highlight layer.
  56169. */
  56170. export interface IHighlightLayerOptions {
  56171. /**
  56172. * Multiplication factor apply to the canvas size to compute the render target size
  56173. * used to generated the glowing objects (the smaller the faster).
  56174. */
  56175. mainTextureRatio: number;
  56176. /**
  56177. * Enforces a fixed size texture to ensure resize independant blur.
  56178. */
  56179. mainTextureFixedSize?: number;
  56180. /**
  56181. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56182. * of the picture to blur (the smaller the faster).
  56183. */
  56184. blurTextureSizeRatio: number;
  56185. /**
  56186. * How big in texel of the blur texture is the vertical blur.
  56187. */
  56188. blurVerticalSize: number;
  56189. /**
  56190. * How big in texel of the blur texture is the horizontal blur.
  56191. */
  56192. blurHorizontalSize: number;
  56193. /**
  56194. * Alpha blending mode used to apply the blur. Default is combine.
  56195. */
  56196. alphaBlendingMode: number;
  56197. /**
  56198. * The camera attached to the layer.
  56199. */
  56200. camera: Nullable<Camera>;
  56201. /**
  56202. * Should we display highlight as a solid stroke?
  56203. */
  56204. isStroke?: boolean;
  56205. /**
  56206. * The rendering group to draw the layer in.
  56207. */
  56208. renderingGroupId: number;
  56209. }
  56210. /**
  56211. * The highlight layer Helps adding a glow effect around a mesh.
  56212. *
  56213. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56214. * glowy meshes to your scene.
  56215. *
  56216. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56217. */
  56218. export class HighlightLayer extends EffectLayer {
  56219. name: string;
  56220. /**
  56221. * Effect Name of the highlight layer.
  56222. */
  56223. static readonly EffectName: string;
  56224. /**
  56225. * The neutral color used during the preparation of the glow effect.
  56226. * This is black by default as the blend operation is a blend operation.
  56227. */
  56228. static NeutralColor: Color4;
  56229. /**
  56230. * Stencil value used for glowing meshes.
  56231. */
  56232. static GlowingMeshStencilReference: number;
  56233. /**
  56234. * Stencil value used for the other meshes in the scene.
  56235. */
  56236. static NormalMeshStencilReference: number;
  56237. /**
  56238. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56239. */
  56240. innerGlow: boolean;
  56241. /**
  56242. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56243. */
  56244. outerGlow: boolean;
  56245. /**
  56246. * Specifies the horizontal size of the blur.
  56247. */
  56248. set blurHorizontalSize(value: number);
  56249. /**
  56250. * Specifies the vertical size of the blur.
  56251. */
  56252. set blurVerticalSize(value: number);
  56253. /**
  56254. * Gets the horizontal size of the blur.
  56255. */
  56256. get blurHorizontalSize(): number;
  56257. /**
  56258. * Gets the vertical size of the blur.
  56259. */
  56260. get blurVerticalSize(): number;
  56261. /**
  56262. * An event triggered when the highlight layer is being blurred.
  56263. */
  56264. onBeforeBlurObservable: Observable<HighlightLayer>;
  56265. /**
  56266. * An event triggered when the highlight layer has been blurred.
  56267. */
  56268. onAfterBlurObservable: Observable<HighlightLayer>;
  56269. private _instanceGlowingMeshStencilReference;
  56270. private _options;
  56271. private _downSamplePostprocess;
  56272. private _horizontalBlurPostprocess;
  56273. private _verticalBlurPostprocess;
  56274. private _blurTexture;
  56275. private _meshes;
  56276. private _excludedMeshes;
  56277. /**
  56278. * Instantiates a new highlight Layer and references it to the scene..
  56279. * @param name The name of the layer
  56280. * @param scene The scene to use the layer in
  56281. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56282. */
  56283. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56284. /**
  56285. * Get the effect name of the layer.
  56286. * @return The effect name
  56287. */
  56288. getEffectName(): string;
  56289. /**
  56290. * Create the merge effect. This is the shader use to blit the information back
  56291. * to the main canvas at the end of the scene rendering.
  56292. */
  56293. protected _createMergeEffect(): Effect;
  56294. /**
  56295. * Creates the render target textures and post processes used in the highlight layer.
  56296. */
  56297. protected _createTextureAndPostProcesses(): void;
  56298. /**
  56299. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56300. */
  56301. needStencil(): boolean;
  56302. /**
  56303. * Checks for the readiness of the element composing the layer.
  56304. * @param subMesh the mesh to check for
  56305. * @param useInstances specify wether or not to use instances to render the mesh
  56306. * @param emissiveTexture the associated emissive texture used to generate the glow
  56307. * @return true if ready otherwise, false
  56308. */
  56309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56310. /**
  56311. * Implementation specific of rendering the generating effect on the main canvas.
  56312. * @param effect The effect used to render through
  56313. */
  56314. protected _internalRender(effect: Effect): void;
  56315. /**
  56316. * Returns true if the layer contains information to display, otherwise false.
  56317. */
  56318. shouldRender(): boolean;
  56319. /**
  56320. * Returns true if the mesh should render, otherwise false.
  56321. * @param mesh The mesh to render
  56322. * @returns true if it should render otherwise false
  56323. */
  56324. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56325. /**
  56326. * Sets the required values for both the emissive texture and and the main color.
  56327. */
  56328. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56329. /**
  56330. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56331. * @param mesh The mesh to exclude from the highlight layer
  56332. */
  56333. addExcludedMesh(mesh: Mesh): void;
  56334. /**
  56335. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56336. * @param mesh The mesh to highlight
  56337. */
  56338. removeExcludedMesh(mesh: Mesh): void;
  56339. /**
  56340. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56341. * @param mesh mesh to test
  56342. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56343. */
  56344. hasMesh(mesh: AbstractMesh): boolean;
  56345. /**
  56346. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56347. * @param mesh The mesh to highlight
  56348. * @param color The color of the highlight
  56349. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56350. */
  56351. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56352. /**
  56353. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56354. * @param mesh The mesh to highlight
  56355. */
  56356. removeMesh(mesh: Mesh): void;
  56357. /**
  56358. * Remove all the meshes currently referenced in the highlight layer
  56359. */
  56360. removeAllMeshes(): void;
  56361. /**
  56362. * Force the stencil to the normal expected value for none glowing parts
  56363. */
  56364. private _defaultStencilReference;
  56365. /**
  56366. * Free any resources and references associated to a mesh.
  56367. * Internal use
  56368. * @param mesh The mesh to free.
  56369. * @hidden
  56370. */
  56371. _disposeMesh(mesh: Mesh): void;
  56372. /**
  56373. * Dispose the highlight layer and free resources.
  56374. */
  56375. dispose(): void;
  56376. /**
  56377. * Gets the class name of the effect layer
  56378. * @returns the string with the class name of the effect layer
  56379. */
  56380. getClassName(): string;
  56381. /**
  56382. * Serializes this Highlight layer
  56383. * @returns a serialized Highlight layer object
  56384. */
  56385. serialize(): any;
  56386. /**
  56387. * Creates a Highlight layer from parsed Highlight layer data
  56388. * @param parsedHightlightLayer defines the Highlight layer data
  56389. * @param scene defines the current scene
  56390. * @param rootUrl defines the root URL containing the Highlight layer information
  56391. * @returns a parsed Highlight layer
  56392. */
  56393. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56394. }
  56395. }
  56396. declare module "babylonjs/Layers/layerSceneComponent" {
  56397. import { Scene } from "babylonjs/scene";
  56398. import { ISceneComponent } from "babylonjs/sceneComponent";
  56399. import { Layer } from "babylonjs/Layers/layer";
  56400. import { AbstractScene } from "babylonjs/abstractScene";
  56401. module "babylonjs/abstractScene" {
  56402. interface AbstractScene {
  56403. /**
  56404. * The list of layers (background and foreground) of the scene
  56405. */
  56406. layers: Array<Layer>;
  56407. }
  56408. }
  56409. /**
  56410. * Defines the layer scene component responsible to manage any layers
  56411. * in a given scene.
  56412. */
  56413. export class LayerSceneComponent implements ISceneComponent {
  56414. /**
  56415. * The component name helpfull to identify the component in the list of scene components.
  56416. */
  56417. readonly name: string;
  56418. /**
  56419. * The scene the component belongs to.
  56420. */
  56421. scene: Scene;
  56422. private _engine;
  56423. /**
  56424. * Creates a new instance of the component for the given scene
  56425. * @param scene Defines the scene to register the component in
  56426. */
  56427. constructor(scene: Scene);
  56428. /**
  56429. * Registers the component in a given scene
  56430. */
  56431. register(): void;
  56432. /**
  56433. * Rebuilds the elements related to this component in case of
  56434. * context lost for instance.
  56435. */
  56436. rebuild(): void;
  56437. /**
  56438. * Disposes the component and the associated ressources.
  56439. */
  56440. dispose(): void;
  56441. private _draw;
  56442. private _drawCameraPredicate;
  56443. private _drawCameraBackground;
  56444. private _drawCameraForeground;
  56445. private _drawRenderTargetPredicate;
  56446. private _drawRenderTargetBackground;
  56447. private _drawRenderTargetForeground;
  56448. /**
  56449. * Adds all the elements from the container to the scene
  56450. * @param container the container holding the elements
  56451. */
  56452. addFromContainer(container: AbstractScene): void;
  56453. /**
  56454. * Removes all the elements in the container from the scene
  56455. * @param container contains the elements to remove
  56456. * @param dispose if the removed element should be disposed (default: false)
  56457. */
  56458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56459. }
  56460. }
  56461. declare module "babylonjs/Shaders/layer.fragment" {
  56462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56463. /** @hidden */
  56464. export var layerPixelShader: {
  56465. name: string;
  56466. shader: string;
  56467. };
  56468. }
  56469. declare module "babylonjs/Shaders/layer.vertex" {
  56470. /** @hidden */
  56471. export var layerVertexShader: {
  56472. name: string;
  56473. shader: string;
  56474. };
  56475. }
  56476. declare module "babylonjs/Layers/layer" {
  56477. import { Observable } from "babylonjs/Misc/observable";
  56478. import { Nullable } from "babylonjs/types";
  56479. import { Scene } from "babylonjs/scene";
  56480. import { Vector2 } from "babylonjs/Maths/math.vector";
  56481. import { Color4 } from "babylonjs/Maths/math.color";
  56482. import { Texture } from "babylonjs/Materials/Textures/texture";
  56483. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56484. import "babylonjs/Shaders/layer.fragment";
  56485. import "babylonjs/Shaders/layer.vertex";
  56486. /**
  56487. * This represents a full screen 2d layer.
  56488. * This can be useful to display a picture in the background of your scene for instance.
  56489. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56490. */
  56491. export class Layer {
  56492. /**
  56493. * Define the name of the layer.
  56494. */
  56495. name: string;
  56496. /**
  56497. * Define the texture the layer should display.
  56498. */
  56499. texture: Nullable<Texture>;
  56500. /**
  56501. * Is the layer in background or foreground.
  56502. */
  56503. isBackground: boolean;
  56504. /**
  56505. * Define the color of the layer (instead of texture).
  56506. */
  56507. color: Color4;
  56508. /**
  56509. * Define the scale of the layer in order to zoom in out of the texture.
  56510. */
  56511. scale: Vector2;
  56512. /**
  56513. * Define an offset for the layer in order to shift the texture.
  56514. */
  56515. offset: Vector2;
  56516. /**
  56517. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56518. */
  56519. alphaBlendingMode: number;
  56520. /**
  56521. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56522. * Alpha test will not mix with the background color in case of transparency.
  56523. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56524. */
  56525. alphaTest: boolean;
  56526. /**
  56527. * Define a mask to restrict the layer to only some of the scene cameras.
  56528. */
  56529. layerMask: number;
  56530. /**
  56531. * Define the list of render target the layer is visible into.
  56532. */
  56533. renderTargetTextures: RenderTargetTexture[];
  56534. /**
  56535. * Define if the layer is only used in renderTarget or if it also
  56536. * renders in the main frame buffer of the canvas.
  56537. */
  56538. renderOnlyInRenderTargetTextures: boolean;
  56539. private _scene;
  56540. private _vertexBuffers;
  56541. private _indexBuffer;
  56542. private _effect;
  56543. private _previousDefines;
  56544. /**
  56545. * An event triggered when the layer is disposed.
  56546. */
  56547. onDisposeObservable: Observable<Layer>;
  56548. private _onDisposeObserver;
  56549. /**
  56550. * Back compatibility with callback before the onDisposeObservable existed.
  56551. * The set callback will be triggered when the layer has been disposed.
  56552. */
  56553. set onDispose(callback: () => void);
  56554. /**
  56555. * An event triggered before rendering the scene
  56556. */
  56557. onBeforeRenderObservable: Observable<Layer>;
  56558. private _onBeforeRenderObserver;
  56559. /**
  56560. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56561. * The set callback will be triggered just before rendering the layer.
  56562. */
  56563. set onBeforeRender(callback: () => void);
  56564. /**
  56565. * An event triggered after rendering the scene
  56566. */
  56567. onAfterRenderObservable: Observable<Layer>;
  56568. private _onAfterRenderObserver;
  56569. /**
  56570. * Back compatibility with callback before the onAfterRenderObservable existed.
  56571. * The set callback will be triggered just after rendering the layer.
  56572. */
  56573. set onAfterRender(callback: () => void);
  56574. /**
  56575. * Instantiates a new layer.
  56576. * This represents a full screen 2d layer.
  56577. * This can be useful to display a picture in the background of your scene for instance.
  56578. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56579. * @param name Define the name of the layer in the scene
  56580. * @param imgUrl Define the url of the texture to display in the layer
  56581. * @param scene Define the scene the layer belongs to
  56582. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56583. * @param color Defines a color for the layer
  56584. */
  56585. constructor(
  56586. /**
  56587. * Define the name of the layer.
  56588. */
  56589. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56590. private _createIndexBuffer;
  56591. /** @hidden */
  56592. _rebuild(): void;
  56593. /**
  56594. * Renders the layer in the scene.
  56595. */
  56596. render(): void;
  56597. /**
  56598. * Disposes and releases the associated ressources.
  56599. */
  56600. dispose(): void;
  56601. }
  56602. }
  56603. declare module "babylonjs/Layers/index" {
  56604. export * from "babylonjs/Layers/effectLayer";
  56605. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56606. export * from "babylonjs/Layers/glowLayer";
  56607. export * from "babylonjs/Layers/highlightLayer";
  56608. export * from "babylonjs/Layers/layer";
  56609. export * from "babylonjs/Layers/layerSceneComponent";
  56610. }
  56611. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56612. /** @hidden */
  56613. export var lensFlarePixelShader: {
  56614. name: string;
  56615. shader: string;
  56616. };
  56617. }
  56618. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56619. /** @hidden */
  56620. export var lensFlareVertexShader: {
  56621. name: string;
  56622. shader: string;
  56623. };
  56624. }
  56625. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56626. import { Scene } from "babylonjs/scene";
  56627. import { Vector3 } from "babylonjs/Maths/math.vector";
  56628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56629. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56630. import "babylonjs/Shaders/lensFlare.fragment";
  56631. import "babylonjs/Shaders/lensFlare.vertex";
  56632. import { Viewport } from "babylonjs/Maths/math.viewport";
  56633. /**
  56634. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56635. * It is usually composed of several `lensFlare`.
  56636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56637. */
  56638. export class LensFlareSystem {
  56639. /**
  56640. * Define the name of the lens flare system
  56641. */
  56642. name: string;
  56643. /**
  56644. * List of lens flares used in this system.
  56645. */
  56646. lensFlares: LensFlare[];
  56647. /**
  56648. * Define a limit from the border the lens flare can be visible.
  56649. */
  56650. borderLimit: number;
  56651. /**
  56652. * Define a viewport border we do not want to see the lens flare in.
  56653. */
  56654. viewportBorder: number;
  56655. /**
  56656. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56657. */
  56658. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56659. /**
  56660. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56661. */
  56662. layerMask: number;
  56663. /**
  56664. * Define the id of the lens flare system in the scene.
  56665. * (equal to name by default)
  56666. */
  56667. id: string;
  56668. private _scene;
  56669. private _emitter;
  56670. private _vertexBuffers;
  56671. private _indexBuffer;
  56672. private _effect;
  56673. private _positionX;
  56674. private _positionY;
  56675. private _isEnabled;
  56676. /** @hidden */
  56677. static _SceneComponentInitialization: (scene: Scene) => void;
  56678. /**
  56679. * Instantiates a lens flare system.
  56680. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56681. * It is usually composed of several `lensFlare`.
  56682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56683. * @param name Define the name of the lens flare system in the scene
  56684. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56685. * @param scene Define the scene the lens flare system belongs to
  56686. */
  56687. constructor(
  56688. /**
  56689. * Define the name of the lens flare system
  56690. */
  56691. name: string, emitter: any, scene: Scene);
  56692. /**
  56693. * Define if the lens flare system is enabled.
  56694. */
  56695. get isEnabled(): boolean;
  56696. set isEnabled(value: boolean);
  56697. /**
  56698. * Get the scene the effects belongs to.
  56699. * @returns the scene holding the lens flare system
  56700. */
  56701. getScene(): Scene;
  56702. /**
  56703. * Get the emitter of the lens flare system.
  56704. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56705. * @returns the emitter of the lens flare system
  56706. */
  56707. getEmitter(): any;
  56708. /**
  56709. * Set the emitter of the lens flare system.
  56710. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56711. * @param newEmitter Define the new emitter of the system
  56712. */
  56713. setEmitter(newEmitter: any): void;
  56714. /**
  56715. * Get the lens flare system emitter position.
  56716. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56717. * @returns the position
  56718. */
  56719. getEmitterPosition(): Vector3;
  56720. /**
  56721. * @hidden
  56722. */
  56723. computeEffectivePosition(globalViewport: Viewport): boolean;
  56724. /** @hidden */
  56725. _isVisible(): boolean;
  56726. /**
  56727. * @hidden
  56728. */
  56729. render(): boolean;
  56730. /**
  56731. * Dispose and release the lens flare with its associated resources.
  56732. */
  56733. dispose(): void;
  56734. /**
  56735. * Parse a lens flare system from a JSON repressentation
  56736. * @param parsedLensFlareSystem Define the JSON to parse
  56737. * @param scene Define the scene the parsed system should be instantiated in
  56738. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56739. * @returns the parsed system
  56740. */
  56741. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56742. /**
  56743. * Serialize the current Lens Flare System into a JSON representation.
  56744. * @returns the serialized JSON
  56745. */
  56746. serialize(): any;
  56747. }
  56748. }
  56749. declare module "babylonjs/LensFlares/lensFlare" {
  56750. import { Nullable } from "babylonjs/types";
  56751. import { Color3 } from "babylonjs/Maths/math.color";
  56752. import { Texture } from "babylonjs/Materials/Textures/texture";
  56753. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56754. /**
  56755. * This represents one of the lens effect in a `lensFlareSystem`.
  56756. * It controls one of the indiviual texture used in the effect.
  56757. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56758. */
  56759. export class LensFlare {
  56760. /**
  56761. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56762. */
  56763. size: number;
  56764. /**
  56765. * 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.
  56766. */
  56767. position: number;
  56768. /**
  56769. * Define the lens color.
  56770. */
  56771. color: Color3;
  56772. /**
  56773. * Define the lens texture.
  56774. */
  56775. texture: Nullable<Texture>;
  56776. /**
  56777. * Define the alpha mode to render this particular lens.
  56778. */
  56779. alphaMode: number;
  56780. private _system;
  56781. /**
  56782. * Creates a new Lens Flare.
  56783. * This represents one of the lens effect in a `lensFlareSystem`.
  56784. * It controls one of the indiviual texture used in the effect.
  56785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56786. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56787. * @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.
  56788. * @param color Define the lens color
  56789. * @param imgUrl Define the lens texture url
  56790. * @param system Define the `lensFlareSystem` this flare is part of
  56791. * @returns The newly created Lens Flare
  56792. */
  56793. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56794. /**
  56795. * Instantiates a new Lens Flare.
  56796. * This represents one of the lens effect in a `lensFlareSystem`.
  56797. * It controls one of the indiviual texture used in the effect.
  56798. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56799. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56800. * @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.
  56801. * @param color Define the lens color
  56802. * @param imgUrl Define the lens texture url
  56803. * @param system Define the `lensFlareSystem` this flare is part of
  56804. */
  56805. constructor(
  56806. /**
  56807. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56808. */
  56809. size: number,
  56810. /**
  56811. * 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.
  56812. */
  56813. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56814. /**
  56815. * Dispose and release the lens flare with its associated resources.
  56816. */
  56817. dispose(): void;
  56818. }
  56819. }
  56820. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56821. import { Nullable } from "babylonjs/types";
  56822. import { Scene } from "babylonjs/scene";
  56823. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56824. import { AbstractScene } from "babylonjs/abstractScene";
  56825. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56826. module "babylonjs/abstractScene" {
  56827. interface AbstractScene {
  56828. /**
  56829. * The list of lens flare system added to the scene
  56830. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56831. */
  56832. lensFlareSystems: Array<LensFlareSystem>;
  56833. /**
  56834. * Removes the given lens flare system from this scene.
  56835. * @param toRemove The lens flare system to remove
  56836. * @returns The index of the removed lens flare system
  56837. */
  56838. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56839. /**
  56840. * Adds the given lens flare system to this scene
  56841. * @param newLensFlareSystem The lens flare system to add
  56842. */
  56843. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56844. /**
  56845. * Gets a lens flare system using its name
  56846. * @param name defines the name to look for
  56847. * @returns the lens flare system or null if not found
  56848. */
  56849. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56850. /**
  56851. * Gets a lens flare system using its id
  56852. * @param id defines the id to look for
  56853. * @returns the lens flare system or null if not found
  56854. */
  56855. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56856. }
  56857. }
  56858. /**
  56859. * Defines the lens flare scene component responsible to manage any lens flares
  56860. * in a given scene.
  56861. */
  56862. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56863. /**
  56864. * The component name helpfull to identify the component in the list of scene components.
  56865. */
  56866. readonly name: string;
  56867. /**
  56868. * The scene the component belongs to.
  56869. */
  56870. scene: Scene;
  56871. /**
  56872. * Creates a new instance of the component for the given scene
  56873. * @param scene Defines the scene to register the component in
  56874. */
  56875. constructor(scene: Scene);
  56876. /**
  56877. * Registers the component in a given scene
  56878. */
  56879. register(): void;
  56880. /**
  56881. * Rebuilds the elements related to this component in case of
  56882. * context lost for instance.
  56883. */
  56884. rebuild(): void;
  56885. /**
  56886. * Adds all the elements from the container to the scene
  56887. * @param container the container holding the elements
  56888. */
  56889. addFromContainer(container: AbstractScene): void;
  56890. /**
  56891. * Removes all the elements in the container from the scene
  56892. * @param container contains the elements to remove
  56893. * @param dispose if the removed element should be disposed (default: false)
  56894. */
  56895. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56896. /**
  56897. * Serializes the component data to the specified json object
  56898. * @param serializationObject The object to serialize to
  56899. */
  56900. serialize(serializationObject: any): void;
  56901. /**
  56902. * Disposes the component and the associated ressources.
  56903. */
  56904. dispose(): void;
  56905. private _draw;
  56906. }
  56907. }
  56908. declare module "babylonjs/LensFlares/index" {
  56909. export * from "babylonjs/LensFlares/lensFlare";
  56910. export * from "babylonjs/LensFlares/lensFlareSystem";
  56911. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56912. }
  56913. declare module "babylonjs/Shaders/depth.fragment" {
  56914. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56915. /** @hidden */
  56916. export var depthPixelShader: {
  56917. name: string;
  56918. shader: string;
  56919. };
  56920. }
  56921. declare module "babylonjs/Shaders/depth.vertex" {
  56922. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56925. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56927. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56928. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56929. /** @hidden */
  56930. export var depthVertexShader: {
  56931. name: string;
  56932. shader: string;
  56933. };
  56934. }
  56935. declare module "babylonjs/Rendering/depthRenderer" {
  56936. import { Nullable } from "babylonjs/types";
  56937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56938. import { Scene } from "babylonjs/scene";
  56939. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56940. import { Camera } from "babylonjs/Cameras/camera";
  56941. import "babylonjs/Shaders/depth.fragment";
  56942. import "babylonjs/Shaders/depth.vertex";
  56943. /**
  56944. * This represents a depth renderer in Babylon.
  56945. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56946. */
  56947. export class DepthRenderer {
  56948. private _scene;
  56949. private _depthMap;
  56950. private _effect;
  56951. private readonly _storeNonLinearDepth;
  56952. private readonly _clearColor;
  56953. /** Get if the depth renderer is using packed depth or not */
  56954. readonly isPacked: boolean;
  56955. private _cachedDefines;
  56956. private _camera;
  56957. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56958. enabled: boolean;
  56959. /**
  56960. * Specifiess that the depth renderer will only be used within
  56961. * the camera it is created for.
  56962. * This can help forcing its rendering during the camera processing.
  56963. */
  56964. useOnlyInActiveCamera: boolean;
  56965. /** @hidden */
  56966. static _SceneComponentInitialization: (scene: Scene) => void;
  56967. /**
  56968. * Instantiates a depth renderer
  56969. * @param scene The scene the renderer belongs to
  56970. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56971. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56972. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56973. */
  56974. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56975. /**
  56976. * Creates the depth rendering effect and checks if the effect is ready.
  56977. * @param subMesh The submesh to be used to render the depth map of
  56978. * @param useInstances If multiple world instances should be used
  56979. * @returns if the depth renderer is ready to render the depth map
  56980. */
  56981. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56982. /**
  56983. * Gets the texture which the depth map will be written to.
  56984. * @returns The depth map texture
  56985. */
  56986. getDepthMap(): RenderTargetTexture;
  56987. /**
  56988. * Disposes of the depth renderer.
  56989. */
  56990. dispose(): void;
  56991. }
  56992. }
  56993. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56994. /** @hidden */
  56995. export var minmaxReduxPixelShader: {
  56996. name: string;
  56997. shader: string;
  56998. };
  56999. }
  57000. declare module "babylonjs/Misc/minMaxReducer" {
  57001. import { Nullable } from "babylonjs/types";
  57002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57003. import { Camera } from "babylonjs/Cameras/camera";
  57004. import { Observer } from "babylonjs/Misc/observable";
  57005. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57006. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57007. import { Observable } from "babylonjs/Misc/observable";
  57008. import "babylonjs/Shaders/minmaxRedux.fragment";
  57009. /**
  57010. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57011. * and maximum values from all values of the texture.
  57012. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57013. * The source values are read from the red channel of the texture.
  57014. */
  57015. export class MinMaxReducer {
  57016. /**
  57017. * Observable triggered when the computation has been performed
  57018. */
  57019. onAfterReductionPerformed: Observable<{
  57020. min: number;
  57021. max: number;
  57022. }>;
  57023. protected _camera: Camera;
  57024. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57025. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57026. protected _postProcessManager: PostProcessManager;
  57027. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57028. protected _forceFullscreenViewport: boolean;
  57029. /**
  57030. * Creates a min/max reducer
  57031. * @param camera The camera to use for the post processes
  57032. */
  57033. constructor(camera: Camera);
  57034. /**
  57035. * Gets the texture used to read the values from.
  57036. */
  57037. get sourceTexture(): Nullable<RenderTargetTexture>;
  57038. /**
  57039. * Sets the source texture to read the values from.
  57040. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57041. * because in such textures '1' value must not be taken into account to compute the maximum
  57042. * as this value is used to clear the texture.
  57043. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57044. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57045. * @param depthRedux Indicates if the texture is a depth texture or not
  57046. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57047. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57048. */
  57049. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57050. /**
  57051. * Defines the refresh rate of the computation.
  57052. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57053. */
  57054. get refreshRate(): number;
  57055. set refreshRate(value: number);
  57056. protected _activated: boolean;
  57057. /**
  57058. * Gets the activation status of the reducer
  57059. */
  57060. get activated(): boolean;
  57061. /**
  57062. * Activates the reduction computation.
  57063. * When activated, the observers registered in onAfterReductionPerformed are
  57064. * called after the compuation is performed
  57065. */
  57066. activate(): void;
  57067. /**
  57068. * Deactivates the reduction computation.
  57069. */
  57070. deactivate(): void;
  57071. /**
  57072. * Disposes the min/max reducer
  57073. * @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.
  57074. */
  57075. dispose(disposeAll?: boolean): void;
  57076. }
  57077. }
  57078. declare module "babylonjs/Misc/depthReducer" {
  57079. import { Nullable } from "babylonjs/types";
  57080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57081. import { Camera } from "babylonjs/Cameras/camera";
  57082. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57083. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57084. /**
  57085. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57086. */
  57087. export class DepthReducer extends MinMaxReducer {
  57088. private _depthRenderer;
  57089. private _depthRendererId;
  57090. /**
  57091. * Gets the depth renderer used for the computation.
  57092. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57093. */
  57094. get depthRenderer(): Nullable<DepthRenderer>;
  57095. /**
  57096. * Creates a depth reducer
  57097. * @param camera The camera used to render the depth texture
  57098. */
  57099. constructor(camera: Camera);
  57100. /**
  57101. * Sets the depth renderer to use to generate the depth map
  57102. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57103. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57104. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57105. */
  57106. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57107. /** @hidden */
  57108. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57109. /**
  57110. * Activates the reduction computation.
  57111. * When activated, the observers registered in onAfterReductionPerformed are
  57112. * called after the compuation is performed
  57113. */
  57114. activate(): void;
  57115. /**
  57116. * Deactivates the reduction computation.
  57117. */
  57118. deactivate(): void;
  57119. /**
  57120. * Disposes the depth reducer
  57121. * @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.
  57122. */
  57123. dispose(disposeAll?: boolean): void;
  57124. }
  57125. }
  57126. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57127. import { Nullable } from "babylonjs/types";
  57128. import { Scene } from "babylonjs/scene";
  57129. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57131. import { Effect } from "babylonjs/Materials/effect";
  57132. import "babylonjs/Shaders/shadowMap.fragment";
  57133. import "babylonjs/Shaders/shadowMap.vertex";
  57134. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57135. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57136. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57137. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57138. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57139. /**
  57140. * A CSM implementation allowing casting shadows on large scenes.
  57141. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57142. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57143. */
  57144. export class CascadedShadowGenerator extends ShadowGenerator {
  57145. private static readonly frustumCornersNDCSpace;
  57146. /**
  57147. * Name of the CSM class
  57148. */
  57149. static CLASSNAME: string;
  57150. /**
  57151. * Defines the default number of cascades used by the CSM.
  57152. */
  57153. static readonly DEFAULT_CASCADES_COUNT: number;
  57154. /**
  57155. * Defines the minimum number of cascades used by the CSM.
  57156. */
  57157. static readonly MIN_CASCADES_COUNT: number;
  57158. /**
  57159. * Defines the maximum number of cascades used by the CSM.
  57160. */
  57161. static readonly MAX_CASCADES_COUNT: number;
  57162. protected _validateFilter(filter: number): number;
  57163. /**
  57164. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57165. */
  57166. penumbraDarkness: number;
  57167. private _numCascades;
  57168. /**
  57169. * Gets or set the number of cascades used by the CSM.
  57170. */
  57171. get numCascades(): number;
  57172. set numCascades(value: number);
  57173. /**
  57174. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57175. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57176. */
  57177. stabilizeCascades: boolean;
  57178. private _freezeShadowCastersBoundingInfo;
  57179. private _freezeShadowCastersBoundingInfoObservable;
  57180. /**
  57181. * Enables or disables the shadow casters bounding info computation.
  57182. * If your shadow casters don't move, you can disable this feature.
  57183. * If it is enabled, the bounding box computation is done every frame.
  57184. */
  57185. get freezeShadowCastersBoundingInfo(): boolean;
  57186. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57187. private _scbiMin;
  57188. private _scbiMax;
  57189. protected _computeShadowCastersBoundingInfo(): void;
  57190. protected _shadowCastersBoundingInfo: BoundingInfo;
  57191. /**
  57192. * Gets or sets the shadow casters bounding info.
  57193. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57194. * so that the system won't overwrite the bounds you provide
  57195. */
  57196. get shadowCastersBoundingInfo(): BoundingInfo;
  57197. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57198. protected _breaksAreDirty: boolean;
  57199. protected _minDistance: number;
  57200. protected _maxDistance: number;
  57201. /**
  57202. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57203. *
  57204. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57205. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57206. * @param min minimal distance for the breaks (default to 0.)
  57207. * @param max maximal distance for the breaks (default to 1.)
  57208. */
  57209. setMinMaxDistance(min: number, max: number): void;
  57210. /** Gets the minimal distance used in the cascade break computation */
  57211. get minDistance(): number;
  57212. /** Gets the maximal distance used in the cascade break computation */
  57213. get maxDistance(): number;
  57214. /**
  57215. * Gets the class name of that object
  57216. * @returns "CascadedShadowGenerator"
  57217. */
  57218. getClassName(): string;
  57219. private _cascadeMinExtents;
  57220. private _cascadeMaxExtents;
  57221. /**
  57222. * Gets a cascade minimum extents
  57223. * @param cascadeIndex index of the cascade
  57224. * @returns the minimum cascade extents
  57225. */
  57226. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57227. /**
  57228. * Gets a cascade maximum extents
  57229. * @param cascadeIndex index of the cascade
  57230. * @returns the maximum cascade extents
  57231. */
  57232. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57233. private _cascades;
  57234. private _currentLayer;
  57235. private _viewSpaceFrustumsZ;
  57236. private _viewMatrices;
  57237. private _projectionMatrices;
  57238. private _transformMatrices;
  57239. private _transformMatricesAsArray;
  57240. private _frustumLengths;
  57241. private _lightSizeUVCorrection;
  57242. private _depthCorrection;
  57243. private _frustumCornersWorldSpace;
  57244. private _frustumCenter;
  57245. private _shadowCameraPos;
  57246. private _shadowMaxZ;
  57247. /**
  57248. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57249. * It defaults to camera.maxZ
  57250. */
  57251. get shadowMaxZ(): number;
  57252. /**
  57253. * Sets the shadow max z distance.
  57254. */
  57255. set shadowMaxZ(value: number);
  57256. protected _debug: boolean;
  57257. /**
  57258. * Gets or sets the debug flag.
  57259. * When enabled, the cascades are materialized by different colors on the screen.
  57260. */
  57261. get debug(): boolean;
  57262. set debug(dbg: boolean);
  57263. private _depthClamp;
  57264. /**
  57265. * Gets or sets the depth clamping value.
  57266. *
  57267. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57268. * to account for the shadow casters far away.
  57269. *
  57270. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57271. */
  57272. get depthClamp(): boolean;
  57273. set depthClamp(value: boolean);
  57274. private _cascadeBlendPercentage;
  57275. /**
  57276. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57277. * It defaults to 0.1 (10% blending).
  57278. */
  57279. get cascadeBlendPercentage(): number;
  57280. set cascadeBlendPercentage(value: number);
  57281. private _lambda;
  57282. /**
  57283. * Gets or set the lambda parameter.
  57284. * This parameter is used to split the camera frustum and create the cascades.
  57285. * 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.
  57286. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57287. */
  57288. get lambda(): number;
  57289. set lambda(value: number);
  57290. /**
  57291. * Gets the view matrix corresponding to a given cascade
  57292. * @param cascadeNum cascade to retrieve the view matrix from
  57293. * @returns the cascade view matrix
  57294. */
  57295. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57296. /**
  57297. * Gets the projection matrix corresponding to a given cascade
  57298. * @param cascadeNum cascade to retrieve the projection matrix from
  57299. * @returns the cascade projection matrix
  57300. */
  57301. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57302. /**
  57303. * Gets the transformation matrix corresponding to a given cascade
  57304. * @param cascadeNum cascade to retrieve the transformation matrix from
  57305. * @returns the cascade transformation matrix
  57306. */
  57307. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57308. private _depthRenderer;
  57309. /**
  57310. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57311. *
  57312. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57313. *
  57314. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57315. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57316. * @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
  57317. */
  57318. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57319. private _depthReducer;
  57320. private _autoCalcDepthBounds;
  57321. /**
  57322. * Gets or sets the autoCalcDepthBounds property.
  57323. *
  57324. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57325. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57326. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57327. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57328. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57329. */
  57330. get autoCalcDepthBounds(): boolean;
  57331. set autoCalcDepthBounds(value: boolean);
  57332. /**
  57333. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57334. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57335. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57336. * for setting the refresh rate on the renderer yourself!
  57337. */
  57338. get autoCalcDepthBoundsRefreshRate(): number;
  57339. set autoCalcDepthBoundsRefreshRate(value: number);
  57340. /**
  57341. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57342. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57343. * you change the camera near/far planes!
  57344. */
  57345. splitFrustum(): void;
  57346. private _splitFrustum;
  57347. private _computeMatrices;
  57348. private _computeFrustumInWorldSpace;
  57349. private _computeCascadeFrustum;
  57350. /**
  57351. * Support test.
  57352. */
  57353. static get IsSupported(): boolean;
  57354. /** @hidden */
  57355. static _SceneComponentInitialization: (scene: Scene) => void;
  57356. /**
  57357. * Creates a Cascaded Shadow Generator object.
  57358. * A ShadowGenerator is the required tool to use the shadows.
  57359. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57360. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57361. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57362. * @param light The directional light object generating the shadows.
  57363. * @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.
  57364. */
  57365. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57366. protected _initializeGenerator(): void;
  57367. protected _createTargetRenderTexture(): void;
  57368. protected _initializeShadowMap(): void;
  57369. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57370. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57371. /**
  57372. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57373. * @param defines Defines of the material we want to update
  57374. * @param lightIndex Index of the light in the enabled light list of the material
  57375. */
  57376. prepareDefines(defines: any, lightIndex: number): void;
  57377. /**
  57378. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57379. * defined in the generator but impacting the effect).
  57380. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57381. * @param effect The effect we are binfing the information for
  57382. */
  57383. bindShadowLight(lightIndex: string, effect: Effect): void;
  57384. /**
  57385. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57386. * (eq to view projection * shadow projection matrices)
  57387. * @returns The transform matrix used to create the shadow map
  57388. */
  57389. getTransformMatrix(): Matrix;
  57390. /**
  57391. * Disposes the ShadowGenerator.
  57392. * Returns nothing.
  57393. */
  57394. dispose(): void;
  57395. /**
  57396. * Serializes the shadow generator setup to a json object.
  57397. * @returns The serialized JSON object
  57398. */
  57399. serialize(): any;
  57400. /**
  57401. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57402. * @param parsedShadowGenerator The JSON object to parse
  57403. * @param scene The scene to create the shadow map for
  57404. * @returns The parsed shadow generator
  57405. */
  57406. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57407. }
  57408. }
  57409. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57410. import { Scene } from "babylonjs/scene";
  57411. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57412. import { AbstractScene } from "babylonjs/abstractScene";
  57413. /**
  57414. * Defines the shadow generator component responsible to manage any shadow generators
  57415. * in a given scene.
  57416. */
  57417. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57418. /**
  57419. * The component name helpfull to identify the component in the list of scene components.
  57420. */
  57421. readonly name: string;
  57422. /**
  57423. * The scene the component belongs to.
  57424. */
  57425. scene: Scene;
  57426. /**
  57427. * Creates a new instance of the component for the given scene
  57428. * @param scene Defines the scene to register the component in
  57429. */
  57430. constructor(scene: Scene);
  57431. /**
  57432. * Registers the component in a given scene
  57433. */
  57434. register(): void;
  57435. /**
  57436. * Rebuilds the elements related to this component in case of
  57437. * context lost for instance.
  57438. */
  57439. rebuild(): void;
  57440. /**
  57441. * Serializes the component data to the specified json object
  57442. * @param serializationObject The object to serialize to
  57443. */
  57444. serialize(serializationObject: any): void;
  57445. /**
  57446. * Adds all the elements from the container to the scene
  57447. * @param container the container holding the elements
  57448. */
  57449. addFromContainer(container: AbstractScene): void;
  57450. /**
  57451. * Removes all the elements in the container from the scene
  57452. * @param container contains the elements to remove
  57453. * @param dispose if the removed element should be disposed (default: false)
  57454. */
  57455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57456. /**
  57457. * Rebuilds the elements related to this component in case of
  57458. * context lost for instance.
  57459. */
  57460. dispose(): void;
  57461. private _gatherRenderTargets;
  57462. }
  57463. }
  57464. declare module "babylonjs/Lights/Shadows/index" {
  57465. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57466. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57467. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57468. }
  57469. declare module "babylonjs/Lights/pointLight" {
  57470. import { Scene } from "babylonjs/scene";
  57471. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57473. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57474. import { Effect } from "babylonjs/Materials/effect";
  57475. /**
  57476. * A point light is a light defined by an unique point in world space.
  57477. * The light is emitted in every direction from this point.
  57478. * A good example of a point light is a standard light bulb.
  57479. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57480. */
  57481. export class PointLight extends ShadowLight {
  57482. private _shadowAngle;
  57483. /**
  57484. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57485. * This specifies what angle the shadow will use to be created.
  57486. *
  57487. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57488. */
  57489. get shadowAngle(): number;
  57490. /**
  57491. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57492. * This specifies what angle the shadow will use to be created.
  57493. *
  57494. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57495. */
  57496. set shadowAngle(value: number);
  57497. /**
  57498. * Gets the direction if it has been set.
  57499. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57500. */
  57501. get direction(): Vector3;
  57502. /**
  57503. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57504. */
  57505. set direction(value: Vector3);
  57506. /**
  57507. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57508. * A PointLight emits the light in every direction.
  57509. * It can cast shadows.
  57510. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57511. * ```javascript
  57512. * var pointLight = new PointLight("pl", camera.position, scene);
  57513. * ```
  57514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57515. * @param name The light friendly name
  57516. * @param position The position of the point light in the scene
  57517. * @param scene The scene the lights belongs to
  57518. */
  57519. constructor(name: string, position: Vector3, scene: Scene);
  57520. /**
  57521. * Returns the string "PointLight"
  57522. * @returns the class name
  57523. */
  57524. getClassName(): string;
  57525. /**
  57526. * Returns the integer 0.
  57527. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57528. */
  57529. getTypeID(): number;
  57530. /**
  57531. * Specifies wether or not the shadowmap should be a cube texture.
  57532. * @returns true if the shadowmap needs to be a cube texture.
  57533. */
  57534. needCube(): boolean;
  57535. /**
  57536. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57537. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57538. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57539. */
  57540. getShadowDirection(faceIndex?: number): Vector3;
  57541. /**
  57542. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57543. * - fov = PI / 2
  57544. * - aspect ratio : 1.0
  57545. * - z-near and far equal to the active camera minZ and maxZ.
  57546. * Returns the PointLight.
  57547. */
  57548. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57549. protected _buildUniformLayout(): void;
  57550. /**
  57551. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57552. * @param effect The effect to update
  57553. * @param lightIndex The index of the light in the effect to update
  57554. * @returns The point light
  57555. */
  57556. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57557. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57558. /**
  57559. * Prepares the list of defines specific to the light type.
  57560. * @param defines the list of defines
  57561. * @param lightIndex defines the index of the light for the effect
  57562. */
  57563. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57564. }
  57565. }
  57566. declare module "babylonjs/Lights/index" {
  57567. export * from "babylonjs/Lights/light";
  57568. export * from "babylonjs/Lights/shadowLight";
  57569. export * from "babylonjs/Lights/Shadows/index";
  57570. export * from "babylonjs/Lights/directionalLight";
  57571. export * from "babylonjs/Lights/hemisphericLight";
  57572. export * from "babylonjs/Lights/pointLight";
  57573. export * from "babylonjs/Lights/spotLight";
  57574. }
  57575. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57576. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57577. /**
  57578. * Header information of HDR texture files.
  57579. */
  57580. export interface HDRInfo {
  57581. /**
  57582. * The height of the texture in pixels.
  57583. */
  57584. height: number;
  57585. /**
  57586. * The width of the texture in pixels.
  57587. */
  57588. width: number;
  57589. /**
  57590. * The index of the beginning of the data in the binary file.
  57591. */
  57592. dataPosition: number;
  57593. }
  57594. /**
  57595. * This groups tools to convert HDR texture to native colors array.
  57596. */
  57597. export class HDRTools {
  57598. private static Ldexp;
  57599. private static Rgbe2float;
  57600. private static readStringLine;
  57601. /**
  57602. * Reads header information from an RGBE texture stored in a native array.
  57603. * More information on this format are available here:
  57604. * https://en.wikipedia.org/wiki/RGBE_image_format
  57605. *
  57606. * @param uint8array The binary file stored in native array.
  57607. * @return The header information.
  57608. */
  57609. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57610. /**
  57611. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57612. * This RGBE texture needs to store the information as a panorama.
  57613. *
  57614. * More information on this format are available here:
  57615. * https://en.wikipedia.org/wiki/RGBE_image_format
  57616. *
  57617. * @param buffer The binary file stored in an array buffer.
  57618. * @param size The expected size of the extracted cubemap.
  57619. * @return The Cube Map information.
  57620. */
  57621. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57622. /**
  57623. * Returns the pixels data extracted from an RGBE texture.
  57624. * This pixels will be stored left to right up to down in the R G B order in one array.
  57625. *
  57626. * More information on this format are available here:
  57627. * https://en.wikipedia.org/wiki/RGBE_image_format
  57628. *
  57629. * @param uint8array The binary file stored in an array buffer.
  57630. * @param hdrInfo The header information of the file.
  57631. * @return The pixels data in RGB right to left up to down order.
  57632. */
  57633. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57634. private static RGBE_ReadPixels_RLE;
  57635. }
  57636. }
  57637. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57638. import { Nullable } from "babylonjs/types";
  57639. import { Scene } from "babylonjs/scene";
  57640. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57641. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57642. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57643. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57644. /**
  57645. * This represents a texture coming from an HDR input.
  57646. *
  57647. * The only supported format is currently panorama picture stored in RGBE format.
  57648. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57649. */
  57650. export class HDRCubeTexture extends BaseTexture {
  57651. private static _facesMapping;
  57652. private _generateHarmonics;
  57653. private _noMipmap;
  57654. private _textureMatrix;
  57655. private _size;
  57656. private _onLoad;
  57657. private _onError;
  57658. /**
  57659. * The texture URL.
  57660. */
  57661. url: string;
  57662. /**
  57663. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57664. */
  57665. coordinatesMode: number;
  57666. protected _isBlocking: boolean;
  57667. /**
  57668. * Sets wether or not the texture is blocking during loading.
  57669. */
  57670. set isBlocking(value: boolean);
  57671. /**
  57672. * Gets wether or not the texture is blocking during loading.
  57673. */
  57674. get isBlocking(): boolean;
  57675. protected _rotationY: number;
  57676. /**
  57677. * Sets texture matrix rotation angle around Y axis in radians.
  57678. */
  57679. set rotationY(value: number);
  57680. /**
  57681. * Gets texture matrix rotation angle around Y axis radians.
  57682. */
  57683. get rotationY(): number;
  57684. /**
  57685. * Gets or sets the center of the bounding box associated with the cube texture
  57686. * It must define where the camera used to render the texture was set
  57687. */
  57688. boundingBoxPosition: Vector3;
  57689. private _boundingBoxSize;
  57690. /**
  57691. * Gets or sets the size of the bounding box associated with the cube texture
  57692. * When defined, the cubemap will switch to local mode
  57693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57694. * @example https://www.babylonjs-playground.com/#RNASML
  57695. */
  57696. set boundingBoxSize(value: Vector3);
  57697. get boundingBoxSize(): Vector3;
  57698. /**
  57699. * Instantiates an HDRTexture from the following parameters.
  57700. *
  57701. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57702. * @param scene The scene the texture will be used in
  57703. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57704. * @param noMipmap Forces to not generate the mipmap if true
  57705. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57706. * @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)
  57707. * @param reserved Reserved flag for internal use.
  57708. */
  57709. 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>);
  57710. /**
  57711. * Get the current class name of the texture useful for serialization or dynamic coding.
  57712. * @returns "HDRCubeTexture"
  57713. */
  57714. getClassName(): string;
  57715. /**
  57716. * Occurs when the file is raw .hdr file.
  57717. */
  57718. private loadTexture;
  57719. clone(): HDRCubeTexture;
  57720. delayLoad(): void;
  57721. /**
  57722. * Get the texture reflection matrix used to rotate/transform the reflection.
  57723. * @returns the reflection matrix
  57724. */
  57725. getReflectionTextureMatrix(): Matrix;
  57726. /**
  57727. * Set the texture reflection matrix used to rotate/transform the reflection.
  57728. * @param value Define the reflection matrix to set
  57729. */
  57730. setReflectionTextureMatrix(value: Matrix): void;
  57731. /**
  57732. * Parses a JSON representation of an HDR Texture in order to create the texture
  57733. * @param parsedTexture Define the JSON representation
  57734. * @param scene Define the scene the texture should be created in
  57735. * @param rootUrl Define the root url in case we need to load relative dependencies
  57736. * @returns the newly created texture after parsing
  57737. */
  57738. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57739. serialize(): any;
  57740. }
  57741. }
  57742. declare module "babylonjs/Physics/physicsEngine" {
  57743. import { Nullable } from "babylonjs/types";
  57744. import { Vector3 } from "babylonjs/Maths/math.vector";
  57745. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57746. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57747. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57748. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57749. /**
  57750. * Class used to control physics engine
  57751. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57752. */
  57753. export class PhysicsEngine implements IPhysicsEngine {
  57754. private _physicsPlugin;
  57755. /**
  57756. * Global value used to control the smallest number supported by the simulation
  57757. */
  57758. static Epsilon: number;
  57759. private _impostors;
  57760. private _joints;
  57761. private _subTimeStep;
  57762. /**
  57763. * Gets the gravity vector used by the simulation
  57764. */
  57765. gravity: Vector3;
  57766. /**
  57767. * Factory used to create the default physics plugin.
  57768. * @returns The default physics plugin
  57769. */
  57770. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57771. /**
  57772. * Creates a new Physics Engine
  57773. * @param gravity defines the gravity vector used by the simulation
  57774. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57775. */
  57776. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57777. /**
  57778. * Sets the gravity vector used by the simulation
  57779. * @param gravity defines the gravity vector to use
  57780. */
  57781. setGravity(gravity: Vector3): void;
  57782. /**
  57783. * Set the time step of the physics engine.
  57784. * Default is 1/60.
  57785. * To slow it down, enter 1/600 for example.
  57786. * To speed it up, 1/30
  57787. * @param newTimeStep defines the new timestep to apply to this world.
  57788. */
  57789. setTimeStep(newTimeStep?: number): void;
  57790. /**
  57791. * Get the time step of the physics engine.
  57792. * @returns the current time step
  57793. */
  57794. getTimeStep(): number;
  57795. /**
  57796. * Set the sub time step of the physics engine.
  57797. * Default is 0 meaning there is no sub steps
  57798. * To increase physics resolution precision, set a small value (like 1 ms)
  57799. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57800. */
  57801. setSubTimeStep(subTimeStep?: number): void;
  57802. /**
  57803. * Get the sub time step of the physics engine.
  57804. * @returns the current sub time step
  57805. */
  57806. getSubTimeStep(): number;
  57807. /**
  57808. * Release all resources
  57809. */
  57810. dispose(): void;
  57811. /**
  57812. * Gets the name of the current physics plugin
  57813. * @returns the name of the plugin
  57814. */
  57815. getPhysicsPluginName(): string;
  57816. /**
  57817. * Adding a new impostor for the impostor tracking.
  57818. * This will be done by the impostor itself.
  57819. * @param impostor the impostor to add
  57820. */
  57821. addImpostor(impostor: PhysicsImpostor): void;
  57822. /**
  57823. * Remove an impostor from the engine.
  57824. * This impostor and its mesh will not longer be updated by the physics engine.
  57825. * @param impostor the impostor to remove
  57826. */
  57827. removeImpostor(impostor: PhysicsImpostor): void;
  57828. /**
  57829. * Add a joint to the physics engine
  57830. * @param mainImpostor defines the main impostor to which the joint is added.
  57831. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57832. * @param joint defines the joint that will connect both impostors.
  57833. */
  57834. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57835. /**
  57836. * Removes a joint from the simulation
  57837. * @param mainImpostor defines the impostor used with the joint
  57838. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57839. * @param joint defines the joint to remove
  57840. */
  57841. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57842. /**
  57843. * Called by the scene. No need to call it.
  57844. * @param delta defines the timespam between frames
  57845. */
  57846. _step(delta: number): void;
  57847. /**
  57848. * Gets the current plugin used to run the simulation
  57849. * @returns current plugin
  57850. */
  57851. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57852. /**
  57853. * Gets the list of physic impostors
  57854. * @returns an array of PhysicsImpostor
  57855. */
  57856. getImpostors(): Array<PhysicsImpostor>;
  57857. /**
  57858. * Gets the impostor for a physics enabled object
  57859. * @param object defines the object impersonated by the impostor
  57860. * @returns the PhysicsImpostor or null if not found
  57861. */
  57862. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57863. /**
  57864. * Gets the impostor for a physics body object
  57865. * @param body defines physics body used by the impostor
  57866. * @returns the PhysicsImpostor or null if not found
  57867. */
  57868. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57869. /**
  57870. * Does a raycast in the physics world
  57871. * @param from when should the ray start?
  57872. * @param to when should the ray end?
  57873. * @returns PhysicsRaycastResult
  57874. */
  57875. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57876. }
  57877. }
  57878. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57879. import { Nullable } from "babylonjs/types";
  57880. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57882. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57883. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57884. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57885. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57886. /** @hidden */
  57887. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57888. private _useDeltaForWorldStep;
  57889. world: any;
  57890. name: string;
  57891. private _physicsMaterials;
  57892. private _fixedTimeStep;
  57893. private _cannonRaycastResult;
  57894. private _raycastResult;
  57895. private _physicsBodysToRemoveAfterStep;
  57896. BJSCANNON: any;
  57897. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57898. setGravity(gravity: Vector3): void;
  57899. setTimeStep(timeStep: number): void;
  57900. getTimeStep(): number;
  57901. executeStep(delta: number): void;
  57902. private _removeMarkedPhysicsBodiesFromWorld;
  57903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57906. private _processChildMeshes;
  57907. removePhysicsBody(impostor: PhysicsImpostor): void;
  57908. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57909. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57910. private _addMaterial;
  57911. private _checkWithEpsilon;
  57912. private _createShape;
  57913. private _createHeightmap;
  57914. private _minus90X;
  57915. private _plus90X;
  57916. private _tmpPosition;
  57917. private _tmpDeltaPosition;
  57918. private _tmpUnityRotation;
  57919. private _updatePhysicsBodyTransformation;
  57920. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57921. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57922. isSupported(): boolean;
  57923. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57924. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57925. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57926. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57928. getBodyMass(impostor: PhysicsImpostor): number;
  57929. getBodyFriction(impostor: PhysicsImpostor): number;
  57930. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57931. getBodyRestitution(impostor: PhysicsImpostor): number;
  57932. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57933. sleepBody(impostor: PhysicsImpostor): void;
  57934. wakeUpBody(impostor: PhysicsImpostor): void;
  57935. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57936. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57937. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57938. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57939. getRadius(impostor: PhysicsImpostor): number;
  57940. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57941. dispose(): void;
  57942. private _extendNamespace;
  57943. /**
  57944. * Does a raycast in the physics world
  57945. * @param from when should the ray start?
  57946. * @param to when should the ray end?
  57947. * @returns PhysicsRaycastResult
  57948. */
  57949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57950. }
  57951. }
  57952. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57953. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57954. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57955. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57957. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57958. import { Nullable } from "babylonjs/types";
  57959. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57960. /** @hidden */
  57961. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57962. world: any;
  57963. name: string;
  57964. BJSOIMO: any;
  57965. private _raycastResult;
  57966. constructor(iterations?: number, oimoInjection?: any);
  57967. setGravity(gravity: Vector3): void;
  57968. setTimeStep(timeStep: number): void;
  57969. getTimeStep(): number;
  57970. private _tmpImpostorsArray;
  57971. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57972. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57973. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57974. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57975. private _tmpPositionVector;
  57976. removePhysicsBody(impostor: PhysicsImpostor): void;
  57977. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57978. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57979. isSupported(): boolean;
  57980. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57981. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57982. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57983. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57984. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57986. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57987. getBodyMass(impostor: PhysicsImpostor): number;
  57988. getBodyFriction(impostor: PhysicsImpostor): number;
  57989. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57990. getBodyRestitution(impostor: PhysicsImpostor): number;
  57991. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57992. sleepBody(impostor: PhysicsImpostor): void;
  57993. wakeUpBody(impostor: PhysicsImpostor): void;
  57994. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57995. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57996. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57997. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57998. getRadius(impostor: PhysicsImpostor): number;
  57999. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58000. dispose(): void;
  58001. /**
  58002. * Does a raycast in the physics world
  58003. * @param from when should the ray start?
  58004. * @param to when should the ray end?
  58005. * @returns PhysicsRaycastResult
  58006. */
  58007. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58008. }
  58009. }
  58010. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58011. import { Nullable } from "babylonjs/types";
  58012. import { Scene } from "babylonjs/scene";
  58013. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58014. import { Color4 } from "babylonjs/Maths/math.color";
  58015. import { Mesh } from "babylonjs/Meshes/mesh";
  58016. /**
  58017. * Class containing static functions to help procedurally build meshes
  58018. */
  58019. export class RibbonBuilder {
  58020. /**
  58021. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58022. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58023. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58024. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58025. * * 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
  58026. * * 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
  58027. * * 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
  58028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58031. * * 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
  58032. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58033. * * 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
  58034. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58036. * @param name defines the name of the mesh
  58037. * @param options defines the options used to create the mesh
  58038. * @param scene defines the hosting scene
  58039. * @returns the ribbon mesh
  58040. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58042. */
  58043. static CreateRibbon(name: string, options: {
  58044. pathArray: Vector3[][];
  58045. closeArray?: boolean;
  58046. closePath?: boolean;
  58047. offset?: number;
  58048. updatable?: boolean;
  58049. sideOrientation?: number;
  58050. frontUVs?: Vector4;
  58051. backUVs?: Vector4;
  58052. instance?: Mesh;
  58053. invertUV?: boolean;
  58054. uvs?: Vector2[];
  58055. colors?: Color4[];
  58056. }, scene?: Nullable<Scene>): Mesh;
  58057. }
  58058. }
  58059. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58060. import { Nullable } from "babylonjs/types";
  58061. import { Scene } from "babylonjs/scene";
  58062. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58063. import { Mesh } from "babylonjs/Meshes/mesh";
  58064. /**
  58065. * Class containing static functions to help procedurally build meshes
  58066. */
  58067. export class ShapeBuilder {
  58068. /**
  58069. * 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.
  58070. * * 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.
  58071. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58072. * * 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.
  58073. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58074. * * 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
  58075. * * 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
  58076. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58081. * @param name defines the name of the mesh
  58082. * @param options defines the options used to create the mesh
  58083. * @param scene defines the hosting scene
  58084. * @returns the extruded shape mesh
  58085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58087. */
  58088. static ExtrudeShape(name: string, options: {
  58089. shape: Vector3[];
  58090. path: Vector3[];
  58091. scale?: number;
  58092. rotation?: number;
  58093. cap?: number;
  58094. updatable?: boolean;
  58095. sideOrientation?: number;
  58096. frontUVs?: Vector4;
  58097. backUVs?: Vector4;
  58098. instance?: Mesh;
  58099. invertUV?: boolean;
  58100. }, scene?: Nullable<Scene>): Mesh;
  58101. /**
  58102. * Creates an custom extruded shape mesh.
  58103. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58104. * * 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.
  58105. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58106. * * 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
  58107. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58108. * * 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
  58109. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58110. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58111. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58112. * * 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
  58113. * * 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
  58114. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58119. * @param name defines the name of the mesh
  58120. * @param options defines the options used to create the mesh
  58121. * @param scene defines the hosting scene
  58122. * @returns the custom extruded shape mesh
  58123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58126. */
  58127. static ExtrudeShapeCustom(name: string, options: {
  58128. shape: Vector3[];
  58129. path: Vector3[];
  58130. scaleFunction?: any;
  58131. rotationFunction?: any;
  58132. ribbonCloseArray?: boolean;
  58133. ribbonClosePath?: boolean;
  58134. cap?: number;
  58135. updatable?: boolean;
  58136. sideOrientation?: number;
  58137. frontUVs?: Vector4;
  58138. backUVs?: Vector4;
  58139. instance?: Mesh;
  58140. invertUV?: boolean;
  58141. }, scene?: Nullable<Scene>): Mesh;
  58142. private static _ExtrudeShapeGeneric;
  58143. }
  58144. }
  58145. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58146. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58147. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58148. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58149. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58150. import { Nullable } from "babylonjs/types";
  58151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58152. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58153. /**
  58154. * AmmoJS Physics plugin
  58155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58156. * @see https://github.com/kripken/ammo.js/
  58157. */
  58158. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58159. private _useDeltaForWorldStep;
  58160. /**
  58161. * Reference to the Ammo library
  58162. */
  58163. bjsAMMO: any;
  58164. /**
  58165. * Created ammoJS world which physics bodies are added to
  58166. */
  58167. world: any;
  58168. /**
  58169. * Name of the plugin
  58170. */
  58171. name: string;
  58172. private _timeStep;
  58173. private _fixedTimeStep;
  58174. private _maxSteps;
  58175. private _tmpQuaternion;
  58176. private _tmpAmmoTransform;
  58177. private _tmpAmmoQuaternion;
  58178. private _tmpAmmoConcreteContactResultCallback;
  58179. private _collisionConfiguration;
  58180. private _dispatcher;
  58181. private _overlappingPairCache;
  58182. private _solver;
  58183. private _softBodySolver;
  58184. private _tmpAmmoVectorA;
  58185. private _tmpAmmoVectorB;
  58186. private _tmpAmmoVectorC;
  58187. private _tmpAmmoVectorD;
  58188. private _tmpContactCallbackResult;
  58189. private _tmpAmmoVectorRCA;
  58190. private _tmpAmmoVectorRCB;
  58191. private _raycastResult;
  58192. private static readonly DISABLE_COLLISION_FLAG;
  58193. private static readonly KINEMATIC_FLAG;
  58194. private static readonly DISABLE_DEACTIVATION_FLAG;
  58195. /**
  58196. * Initializes the ammoJS plugin
  58197. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58198. * @param ammoInjection can be used to inject your own ammo reference
  58199. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58200. */
  58201. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58202. /**
  58203. * Sets the gravity of the physics world (m/(s^2))
  58204. * @param gravity Gravity to set
  58205. */
  58206. setGravity(gravity: Vector3): void;
  58207. /**
  58208. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58209. * @param timeStep timestep to use in seconds
  58210. */
  58211. setTimeStep(timeStep: number): void;
  58212. /**
  58213. * 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)
  58214. * @param fixedTimeStep fixedTimeStep to use in seconds
  58215. */
  58216. setFixedTimeStep(fixedTimeStep: number): void;
  58217. /**
  58218. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58219. * @param maxSteps the maximum number of steps by the physics engine per frame
  58220. */
  58221. setMaxSteps(maxSteps: number): void;
  58222. /**
  58223. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58224. * @returns the current timestep in seconds
  58225. */
  58226. getTimeStep(): number;
  58227. /**
  58228. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58229. */
  58230. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58231. private _isImpostorInContact;
  58232. private _isImpostorPairInContact;
  58233. private _stepSimulation;
  58234. /**
  58235. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58236. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58237. * After the step the babylon meshes are set to the position of the physics imposters
  58238. * @param delta amount of time to step forward
  58239. * @param impostors array of imposters to update before/after the step
  58240. */
  58241. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58242. /**
  58243. * Update babylon mesh to match physics world object
  58244. * @param impostor imposter to match
  58245. */
  58246. private _afterSoftStep;
  58247. /**
  58248. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58249. * @param impostor imposter to match
  58250. */
  58251. private _ropeStep;
  58252. /**
  58253. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58254. * @param impostor imposter to match
  58255. */
  58256. private _softbodyOrClothStep;
  58257. private _tmpVector;
  58258. private _tmpMatrix;
  58259. /**
  58260. * Applies an impulse on the imposter
  58261. * @param impostor imposter to apply impulse to
  58262. * @param force amount of force to be applied to the imposter
  58263. * @param contactPoint the location to apply the impulse on the imposter
  58264. */
  58265. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58266. /**
  58267. * Applies a force on the imposter
  58268. * @param impostor imposter to apply force
  58269. * @param force amount of force to be applied to the imposter
  58270. * @param contactPoint the location to apply the force on the imposter
  58271. */
  58272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58273. /**
  58274. * Creates a physics body using the plugin
  58275. * @param impostor the imposter to create the physics body on
  58276. */
  58277. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58278. /**
  58279. * Removes the physics body from the imposter and disposes of the body's memory
  58280. * @param impostor imposter to remove the physics body from
  58281. */
  58282. removePhysicsBody(impostor: PhysicsImpostor): void;
  58283. /**
  58284. * Generates a joint
  58285. * @param impostorJoint the imposter joint to create the joint with
  58286. */
  58287. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58288. /**
  58289. * Removes a joint
  58290. * @param impostorJoint the imposter joint to remove the joint from
  58291. */
  58292. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58293. private _addMeshVerts;
  58294. /**
  58295. * Initialise the soft body vertices to match its object's (mesh) vertices
  58296. * Softbody vertices (nodes) are in world space and to match this
  58297. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58298. * @param impostor to create the softbody for
  58299. */
  58300. private _softVertexData;
  58301. /**
  58302. * Create an impostor's soft body
  58303. * @param impostor to create the softbody for
  58304. */
  58305. private _createSoftbody;
  58306. /**
  58307. * Create cloth for an impostor
  58308. * @param impostor to create the softbody for
  58309. */
  58310. private _createCloth;
  58311. /**
  58312. * Create rope for an impostor
  58313. * @param impostor to create the softbody for
  58314. */
  58315. private _createRope;
  58316. /**
  58317. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58318. * @param impostor to create the custom physics shape for
  58319. */
  58320. private _createCustom;
  58321. private _addHullVerts;
  58322. private _createShape;
  58323. /**
  58324. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58325. * @param impostor imposter containing the physics body and babylon object
  58326. */
  58327. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58328. /**
  58329. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58330. * @param impostor imposter containing the physics body and babylon object
  58331. * @param newPosition new position
  58332. * @param newRotation new rotation
  58333. */
  58334. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58335. /**
  58336. * If this plugin is supported
  58337. * @returns true if its supported
  58338. */
  58339. isSupported(): boolean;
  58340. /**
  58341. * Sets the linear velocity of the physics body
  58342. * @param impostor imposter to set the velocity on
  58343. * @param velocity velocity to set
  58344. */
  58345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58346. /**
  58347. * Sets the angular velocity of the physics body
  58348. * @param impostor imposter to set the velocity on
  58349. * @param velocity velocity to set
  58350. */
  58351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58352. /**
  58353. * gets the linear velocity
  58354. * @param impostor imposter to get linear velocity from
  58355. * @returns linear velocity
  58356. */
  58357. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58358. /**
  58359. * gets the angular velocity
  58360. * @param impostor imposter to get angular velocity from
  58361. * @returns angular velocity
  58362. */
  58363. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58364. /**
  58365. * Sets the mass of physics body
  58366. * @param impostor imposter to set the mass on
  58367. * @param mass mass to set
  58368. */
  58369. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58370. /**
  58371. * Gets the mass of the physics body
  58372. * @param impostor imposter to get the mass from
  58373. * @returns mass
  58374. */
  58375. getBodyMass(impostor: PhysicsImpostor): number;
  58376. /**
  58377. * Gets friction of the impostor
  58378. * @param impostor impostor to get friction from
  58379. * @returns friction value
  58380. */
  58381. getBodyFriction(impostor: PhysicsImpostor): number;
  58382. /**
  58383. * Sets friction of the impostor
  58384. * @param impostor impostor to set friction on
  58385. * @param friction friction value
  58386. */
  58387. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58388. /**
  58389. * Gets restitution of the impostor
  58390. * @param impostor impostor to get restitution from
  58391. * @returns restitution value
  58392. */
  58393. getBodyRestitution(impostor: PhysicsImpostor): number;
  58394. /**
  58395. * Sets resitution of the impostor
  58396. * @param impostor impostor to set resitution on
  58397. * @param restitution resitution value
  58398. */
  58399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58400. /**
  58401. * Gets pressure inside the impostor
  58402. * @param impostor impostor to get pressure from
  58403. * @returns pressure value
  58404. */
  58405. getBodyPressure(impostor: PhysicsImpostor): number;
  58406. /**
  58407. * Sets pressure inside a soft body impostor
  58408. * Cloth and rope must remain 0 pressure
  58409. * @param impostor impostor to set pressure on
  58410. * @param pressure pressure value
  58411. */
  58412. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58413. /**
  58414. * Gets stiffness of the impostor
  58415. * @param impostor impostor to get stiffness from
  58416. * @returns pressure value
  58417. */
  58418. getBodyStiffness(impostor: PhysicsImpostor): number;
  58419. /**
  58420. * Sets stiffness of the impostor
  58421. * @param impostor impostor to set stiffness on
  58422. * @param stiffness stiffness value from 0 to 1
  58423. */
  58424. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58425. /**
  58426. * Gets velocityIterations of the impostor
  58427. * @param impostor impostor to get velocity iterations from
  58428. * @returns velocityIterations value
  58429. */
  58430. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58431. /**
  58432. * Sets velocityIterations of the impostor
  58433. * @param impostor impostor to set velocity iterations on
  58434. * @param velocityIterations velocityIterations value
  58435. */
  58436. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58437. /**
  58438. * Gets positionIterations of the impostor
  58439. * @param impostor impostor to get position iterations from
  58440. * @returns positionIterations value
  58441. */
  58442. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58443. /**
  58444. * Sets positionIterations of the impostor
  58445. * @param impostor impostor to set position on
  58446. * @param positionIterations positionIterations value
  58447. */
  58448. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58449. /**
  58450. * Append an anchor to a cloth object
  58451. * @param impostor is the cloth impostor to add anchor to
  58452. * @param otherImpostor is the rigid impostor to anchor to
  58453. * @param width ratio across width from 0 to 1
  58454. * @param height ratio up height from 0 to 1
  58455. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58456. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58457. */
  58458. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58459. /**
  58460. * Append an hook to a rope object
  58461. * @param impostor is the rope impostor to add hook to
  58462. * @param otherImpostor is the rigid impostor to hook to
  58463. * @param length ratio along the rope from 0 to 1
  58464. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58465. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58466. */
  58467. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58468. /**
  58469. * Sleeps the physics body and stops it from being active
  58470. * @param impostor impostor to sleep
  58471. */
  58472. sleepBody(impostor: PhysicsImpostor): void;
  58473. /**
  58474. * Activates the physics body
  58475. * @param impostor impostor to activate
  58476. */
  58477. wakeUpBody(impostor: PhysicsImpostor): void;
  58478. /**
  58479. * Updates the distance parameters of the joint
  58480. * @param joint joint to update
  58481. * @param maxDistance maximum distance of the joint
  58482. * @param minDistance minimum distance of the joint
  58483. */
  58484. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58485. /**
  58486. * Sets a motor on the joint
  58487. * @param joint joint to set motor on
  58488. * @param speed speed of the motor
  58489. * @param maxForce maximum force of the motor
  58490. * @param motorIndex index of the motor
  58491. */
  58492. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58493. /**
  58494. * Sets the motors limit
  58495. * @param joint joint to set limit on
  58496. * @param upperLimit upper limit
  58497. * @param lowerLimit lower limit
  58498. */
  58499. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58500. /**
  58501. * Syncs the position and rotation of a mesh with the impostor
  58502. * @param mesh mesh to sync
  58503. * @param impostor impostor to update the mesh with
  58504. */
  58505. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58506. /**
  58507. * Gets the radius of the impostor
  58508. * @param impostor impostor to get radius from
  58509. * @returns the radius
  58510. */
  58511. getRadius(impostor: PhysicsImpostor): number;
  58512. /**
  58513. * Gets the box size of the impostor
  58514. * @param impostor impostor to get box size from
  58515. * @param result the resulting box size
  58516. */
  58517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58518. /**
  58519. * Disposes of the impostor
  58520. */
  58521. dispose(): void;
  58522. /**
  58523. * Does a raycast in the physics world
  58524. * @param from when should the ray start?
  58525. * @param to when should the ray end?
  58526. * @returns PhysicsRaycastResult
  58527. */
  58528. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58529. }
  58530. }
  58531. declare module "babylonjs/Probes/reflectionProbe" {
  58532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58533. import { Vector3 } from "babylonjs/Maths/math.vector";
  58534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58535. import { Nullable } from "babylonjs/types";
  58536. import { Scene } from "babylonjs/scene";
  58537. module "babylonjs/abstractScene" {
  58538. interface AbstractScene {
  58539. /**
  58540. * The list of reflection probes added to the scene
  58541. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58542. */
  58543. reflectionProbes: Array<ReflectionProbe>;
  58544. /**
  58545. * Removes the given reflection probe from this scene.
  58546. * @param toRemove The reflection probe to remove
  58547. * @returns The index of the removed reflection probe
  58548. */
  58549. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58550. /**
  58551. * Adds the given reflection probe to this scene.
  58552. * @param newReflectionProbe The reflection probe to add
  58553. */
  58554. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58555. }
  58556. }
  58557. /**
  58558. * Class used to generate realtime reflection / refraction cube textures
  58559. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58560. */
  58561. export class ReflectionProbe {
  58562. /** defines the name of the probe */
  58563. name: string;
  58564. private _scene;
  58565. private _renderTargetTexture;
  58566. private _projectionMatrix;
  58567. private _viewMatrix;
  58568. private _target;
  58569. private _add;
  58570. private _attachedMesh;
  58571. private _invertYAxis;
  58572. /** Gets or sets probe position (center of the cube map) */
  58573. position: Vector3;
  58574. /**
  58575. * Creates a new reflection probe
  58576. * @param name defines the name of the probe
  58577. * @param size defines the texture resolution (for each face)
  58578. * @param scene defines the hosting scene
  58579. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58580. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58581. */
  58582. constructor(
  58583. /** defines the name of the probe */
  58584. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58585. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58586. get samples(): number;
  58587. set samples(value: number);
  58588. /** Gets or sets the refresh rate to use (on every frame by default) */
  58589. get refreshRate(): number;
  58590. set refreshRate(value: number);
  58591. /**
  58592. * Gets the hosting scene
  58593. * @returns a Scene
  58594. */
  58595. getScene(): Scene;
  58596. /** Gets the internal CubeTexture used to render to */
  58597. get cubeTexture(): RenderTargetTexture;
  58598. /** Gets the list of meshes to render */
  58599. get renderList(): Nullable<AbstractMesh[]>;
  58600. /**
  58601. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58602. * @param mesh defines the mesh to attach to
  58603. */
  58604. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58605. /**
  58606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58607. * @param renderingGroupId The rendering group id corresponding to its index
  58608. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58609. */
  58610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58611. /**
  58612. * Clean all associated resources
  58613. */
  58614. dispose(): void;
  58615. /**
  58616. * Converts the reflection probe information to a readable string for debug purpose.
  58617. * @param fullDetails Supports for multiple levels of logging within scene loading
  58618. * @returns the human readable reflection probe info
  58619. */
  58620. toString(fullDetails?: boolean): string;
  58621. /**
  58622. * Get the class name of the relfection probe.
  58623. * @returns "ReflectionProbe"
  58624. */
  58625. getClassName(): string;
  58626. /**
  58627. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58628. * @returns The JSON representation of the texture
  58629. */
  58630. serialize(): any;
  58631. /**
  58632. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58633. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58634. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58635. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58636. * @returns The parsed reflection probe if successful
  58637. */
  58638. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58639. }
  58640. }
  58641. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58642. /** @hidden */
  58643. export var _BabylonLoaderRegistered: boolean;
  58644. /**
  58645. * Helps setting up some configuration for the babylon file loader.
  58646. */
  58647. export class BabylonFileLoaderConfiguration {
  58648. /**
  58649. * The loader does not allow injecting custom physix engine into the plugins.
  58650. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58651. * So you could set this variable to your engine import to make it work.
  58652. */
  58653. static LoaderInjectedPhysicsEngine: any;
  58654. }
  58655. }
  58656. declare module "babylonjs/Loading/Plugins/index" {
  58657. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58658. }
  58659. declare module "babylonjs/Loading/index" {
  58660. export * from "babylonjs/Loading/loadingScreen";
  58661. export * from "babylonjs/Loading/Plugins/index";
  58662. export * from "babylonjs/Loading/sceneLoader";
  58663. export * from "babylonjs/Loading/sceneLoaderFlags";
  58664. }
  58665. declare module "babylonjs/Materials/Background/index" {
  58666. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58667. }
  58668. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58669. import { Scene } from "babylonjs/scene";
  58670. import { Color3 } from "babylonjs/Maths/math.color";
  58671. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58673. /**
  58674. * The Physically based simple base material of BJS.
  58675. *
  58676. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58677. * It is used as the base class for both the specGloss and metalRough conventions.
  58678. */
  58679. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58680. /**
  58681. * Number of Simultaneous lights allowed on the material.
  58682. */
  58683. maxSimultaneousLights: number;
  58684. /**
  58685. * If sets to true, disables all the lights affecting the material.
  58686. */
  58687. disableLighting: boolean;
  58688. /**
  58689. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58690. */
  58691. environmentTexture: BaseTexture;
  58692. /**
  58693. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58694. */
  58695. invertNormalMapX: boolean;
  58696. /**
  58697. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58698. */
  58699. invertNormalMapY: boolean;
  58700. /**
  58701. * Normal map used in the model.
  58702. */
  58703. normalTexture: BaseTexture;
  58704. /**
  58705. * Emissivie color used to self-illuminate the model.
  58706. */
  58707. emissiveColor: Color3;
  58708. /**
  58709. * Emissivie texture used to self-illuminate the model.
  58710. */
  58711. emissiveTexture: BaseTexture;
  58712. /**
  58713. * Occlusion Channel Strenght.
  58714. */
  58715. occlusionStrength: number;
  58716. /**
  58717. * Occlusion Texture of the material (adding extra occlusion effects).
  58718. */
  58719. occlusionTexture: BaseTexture;
  58720. /**
  58721. * Defines the alpha limits in alpha test mode.
  58722. */
  58723. alphaCutOff: number;
  58724. /**
  58725. * Gets the current double sided mode.
  58726. */
  58727. get doubleSided(): boolean;
  58728. /**
  58729. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58730. */
  58731. set doubleSided(value: boolean);
  58732. /**
  58733. * Stores the pre-calculated light information of a mesh in a texture.
  58734. */
  58735. lightmapTexture: BaseTexture;
  58736. /**
  58737. * If true, the light map contains occlusion information instead of lighting info.
  58738. */
  58739. useLightmapAsShadowmap: boolean;
  58740. /**
  58741. * Instantiates a new PBRMaterial instance.
  58742. *
  58743. * @param name The material name
  58744. * @param scene The scene the material will be use in.
  58745. */
  58746. constructor(name: string, scene: Scene);
  58747. getClassName(): string;
  58748. }
  58749. }
  58750. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58751. import { Scene } from "babylonjs/scene";
  58752. import { Color3 } from "babylonjs/Maths/math.color";
  58753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58754. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58755. /**
  58756. * The PBR material of BJS following the metal roughness convention.
  58757. *
  58758. * This fits to the PBR convention in the GLTF definition:
  58759. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58760. */
  58761. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58762. /**
  58763. * The base color has two different interpretations depending on the value of metalness.
  58764. * When the material is a metal, the base color is the specific measured reflectance value
  58765. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58766. * of the material.
  58767. */
  58768. baseColor: Color3;
  58769. /**
  58770. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58771. * well as opacity information in the alpha channel.
  58772. */
  58773. baseTexture: BaseTexture;
  58774. /**
  58775. * Specifies the metallic scalar value of the material.
  58776. * Can also be used to scale the metalness values of the metallic texture.
  58777. */
  58778. metallic: number;
  58779. /**
  58780. * Specifies the roughness scalar value of the material.
  58781. * Can also be used to scale the roughness values of the metallic texture.
  58782. */
  58783. roughness: number;
  58784. /**
  58785. * Texture containing both the metallic value in the B channel and the
  58786. * roughness value in the G channel to keep better precision.
  58787. */
  58788. metallicRoughnessTexture: BaseTexture;
  58789. /**
  58790. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58791. *
  58792. * @param name The material name
  58793. * @param scene The scene the material will be use in.
  58794. */
  58795. constructor(name: string, scene: Scene);
  58796. /**
  58797. * Return the currrent class name of the material.
  58798. */
  58799. getClassName(): string;
  58800. /**
  58801. * Makes a duplicate of the current material.
  58802. * @param name - name to use for the new material.
  58803. */
  58804. clone(name: string): PBRMetallicRoughnessMaterial;
  58805. /**
  58806. * Serialize the material to a parsable JSON object.
  58807. */
  58808. serialize(): any;
  58809. /**
  58810. * Parses a JSON object correponding to the serialize function.
  58811. */
  58812. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58813. }
  58814. }
  58815. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58816. import { Scene } from "babylonjs/scene";
  58817. import { Color3 } from "babylonjs/Maths/math.color";
  58818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58819. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58820. /**
  58821. * The PBR material of BJS following the specular glossiness convention.
  58822. *
  58823. * This fits to the PBR convention in the GLTF definition:
  58824. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58825. */
  58826. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58827. /**
  58828. * Specifies the diffuse color of the material.
  58829. */
  58830. diffuseColor: Color3;
  58831. /**
  58832. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58833. * channel.
  58834. */
  58835. diffuseTexture: BaseTexture;
  58836. /**
  58837. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58838. */
  58839. specularColor: Color3;
  58840. /**
  58841. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58842. */
  58843. glossiness: number;
  58844. /**
  58845. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58846. */
  58847. specularGlossinessTexture: BaseTexture;
  58848. /**
  58849. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58850. *
  58851. * @param name The material name
  58852. * @param scene The scene the material will be use in.
  58853. */
  58854. constructor(name: string, scene: Scene);
  58855. /**
  58856. * Return the currrent class name of the material.
  58857. */
  58858. getClassName(): string;
  58859. /**
  58860. * Makes a duplicate of the current material.
  58861. * @param name - name to use for the new material.
  58862. */
  58863. clone(name: string): PBRSpecularGlossinessMaterial;
  58864. /**
  58865. * Serialize the material to a parsable JSON object.
  58866. */
  58867. serialize(): any;
  58868. /**
  58869. * Parses a JSON object correponding to the serialize function.
  58870. */
  58871. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58872. }
  58873. }
  58874. declare module "babylonjs/Materials/PBR/index" {
  58875. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58876. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58877. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58878. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58879. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58880. }
  58881. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58882. import { Nullable } from "babylonjs/types";
  58883. import { Scene } from "babylonjs/scene";
  58884. import { Matrix } from "babylonjs/Maths/math.vector";
  58885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58886. /**
  58887. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58888. * It can help converting any input color in a desired output one. This can then be used to create effects
  58889. * from sepia, black and white to sixties or futuristic rendering...
  58890. *
  58891. * The only supported format is currently 3dl.
  58892. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58893. */
  58894. export class ColorGradingTexture extends BaseTexture {
  58895. /**
  58896. * The current texture matrix. (will always be identity in color grading texture)
  58897. */
  58898. private _textureMatrix;
  58899. /**
  58900. * The texture URL.
  58901. */
  58902. url: string;
  58903. /**
  58904. * Empty line regex stored for GC.
  58905. */
  58906. private static _noneEmptyLineRegex;
  58907. private _engine;
  58908. /**
  58909. * Instantiates a ColorGradingTexture from the following parameters.
  58910. *
  58911. * @param url The location of the color gradind data (currently only supporting 3dl)
  58912. * @param scene The scene the texture will be used in
  58913. */
  58914. constructor(url: string, scene: Scene);
  58915. /**
  58916. * Returns the texture matrix used in most of the material.
  58917. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58918. */
  58919. getTextureMatrix(): Matrix;
  58920. /**
  58921. * Occurs when the file being loaded is a .3dl LUT file.
  58922. */
  58923. private load3dlTexture;
  58924. /**
  58925. * Starts the loading process of the texture.
  58926. */
  58927. private loadTexture;
  58928. /**
  58929. * Clones the color gradind texture.
  58930. */
  58931. clone(): ColorGradingTexture;
  58932. /**
  58933. * Called during delayed load for textures.
  58934. */
  58935. delayLoad(): void;
  58936. /**
  58937. * Parses a color grading texture serialized by Babylon.
  58938. * @param parsedTexture The texture information being parsedTexture
  58939. * @param scene The scene to load the texture in
  58940. * @param rootUrl The root url of the data assets to load
  58941. * @return A color gradind texture
  58942. */
  58943. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58944. /**
  58945. * Serializes the LUT texture to json format.
  58946. */
  58947. serialize(): any;
  58948. }
  58949. }
  58950. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58952. import { Scene } from "babylonjs/scene";
  58953. import { Nullable } from "babylonjs/types";
  58954. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58955. /**
  58956. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58957. */
  58958. export class EquiRectangularCubeTexture extends BaseTexture {
  58959. /** The six faces of the cube. */
  58960. private static _FacesMapping;
  58961. private _noMipmap;
  58962. private _onLoad;
  58963. private _onError;
  58964. /** The size of the cubemap. */
  58965. private _size;
  58966. /** The buffer of the image. */
  58967. private _buffer;
  58968. /** The width of the input image. */
  58969. private _width;
  58970. /** The height of the input image. */
  58971. private _height;
  58972. /** The URL to the image. */
  58973. url: string;
  58974. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58975. coordinatesMode: number;
  58976. /**
  58977. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58978. * @param url The location of the image
  58979. * @param scene The scene the texture will be used in
  58980. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58981. * @param noMipmap Forces to not generate the mipmap if true
  58982. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58983. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58984. * @param onLoad — defines a callback called when texture is loaded
  58985. * @param onError — defines a callback called if there is an error
  58986. */
  58987. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58988. /**
  58989. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58990. */
  58991. private loadImage;
  58992. /**
  58993. * Convert the image buffer into a cubemap and create a CubeTexture.
  58994. */
  58995. private loadTexture;
  58996. /**
  58997. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58998. * @param buffer The ArrayBuffer that should be converted.
  58999. * @returns The buffer as Float32Array.
  59000. */
  59001. private getFloat32ArrayFromArrayBuffer;
  59002. /**
  59003. * Get the current class name of the texture useful for serialization or dynamic coding.
  59004. * @returns "EquiRectangularCubeTexture"
  59005. */
  59006. getClassName(): string;
  59007. /**
  59008. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59009. * @returns A clone of the current EquiRectangularCubeTexture.
  59010. */
  59011. clone(): EquiRectangularCubeTexture;
  59012. }
  59013. }
  59014. declare module "babylonjs/Misc/tga" {
  59015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59016. /**
  59017. * Based on jsTGALoader - Javascript loader for TGA file
  59018. * By Vincent Thibault
  59019. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59020. */
  59021. export class TGATools {
  59022. private static _TYPE_INDEXED;
  59023. private static _TYPE_RGB;
  59024. private static _TYPE_GREY;
  59025. private static _TYPE_RLE_INDEXED;
  59026. private static _TYPE_RLE_RGB;
  59027. private static _TYPE_RLE_GREY;
  59028. private static _ORIGIN_MASK;
  59029. private static _ORIGIN_SHIFT;
  59030. private static _ORIGIN_BL;
  59031. private static _ORIGIN_BR;
  59032. private static _ORIGIN_UL;
  59033. private static _ORIGIN_UR;
  59034. /**
  59035. * Gets the header of a TGA file
  59036. * @param data defines the TGA data
  59037. * @returns the header
  59038. */
  59039. static GetTGAHeader(data: Uint8Array): any;
  59040. /**
  59041. * Uploads TGA content to a Babylon Texture
  59042. * @hidden
  59043. */
  59044. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59045. /** @hidden */
  59046. 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;
  59047. /** @hidden */
  59048. 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;
  59049. /** @hidden */
  59050. 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;
  59051. /** @hidden */
  59052. 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;
  59053. /** @hidden */
  59054. 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;
  59055. /** @hidden */
  59056. 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;
  59057. }
  59058. }
  59059. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59060. import { Nullable } from "babylonjs/types";
  59061. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59062. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59063. /**
  59064. * Implementation of the TGA Texture Loader.
  59065. * @hidden
  59066. */
  59067. export class _TGATextureLoader implements IInternalTextureLoader {
  59068. /**
  59069. * Defines wether the loader supports cascade loading the different faces.
  59070. */
  59071. readonly supportCascades: boolean;
  59072. /**
  59073. * This returns if the loader support the current file information.
  59074. * @param extension defines the file extension of the file being loaded
  59075. * @returns true if the loader can load the specified file
  59076. */
  59077. canLoad(extension: string): boolean;
  59078. /**
  59079. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59080. * @param data contains the texture data
  59081. * @param texture defines the BabylonJS internal texture
  59082. * @param createPolynomials will be true if polynomials have been requested
  59083. * @param onLoad defines the callback to trigger once the texture is ready
  59084. * @param onError defines the callback to trigger in case of error
  59085. */
  59086. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59087. /**
  59088. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59089. * @param data contains the texture data
  59090. * @param texture defines the BabylonJS internal texture
  59091. * @param callback defines the method to call once ready to upload
  59092. */
  59093. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59094. }
  59095. }
  59096. declare module "babylonjs/Misc/basis" {
  59097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59098. /**
  59099. * Info about the .basis files
  59100. */
  59101. class BasisFileInfo {
  59102. /**
  59103. * If the file has alpha
  59104. */
  59105. hasAlpha: boolean;
  59106. /**
  59107. * Info about each image of the basis file
  59108. */
  59109. images: Array<{
  59110. levels: Array<{
  59111. width: number;
  59112. height: number;
  59113. transcodedPixels: ArrayBufferView;
  59114. }>;
  59115. }>;
  59116. }
  59117. /**
  59118. * Result of transcoding a basis file
  59119. */
  59120. class TranscodeResult {
  59121. /**
  59122. * Info about the .basis file
  59123. */
  59124. fileInfo: BasisFileInfo;
  59125. /**
  59126. * Format to use when loading the file
  59127. */
  59128. format: number;
  59129. }
  59130. /**
  59131. * Configuration options for the Basis transcoder
  59132. */
  59133. export class BasisTranscodeConfiguration {
  59134. /**
  59135. * Supported compression formats used to determine the supported output format of the transcoder
  59136. */
  59137. supportedCompressionFormats?: {
  59138. /**
  59139. * etc1 compression format
  59140. */
  59141. etc1?: boolean;
  59142. /**
  59143. * s3tc compression format
  59144. */
  59145. s3tc?: boolean;
  59146. /**
  59147. * pvrtc compression format
  59148. */
  59149. pvrtc?: boolean;
  59150. /**
  59151. * etc2 compression format
  59152. */
  59153. etc2?: boolean;
  59154. };
  59155. /**
  59156. * If mipmap levels should be loaded for transcoded images (Default: true)
  59157. */
  59158. loadMipmapLevels?: boolean;
  59159. /**
  59160. * Index of a single image to load (Default: all images)
  59161. */
  59162. loadSingleImage?: number;
  59163. }
  59164. /**
  59165. * Used to load .Basis files
  59166. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59167. */
  59168. export class BasisTools {
  59169. private static _IgnoreSupportedFormats;
  59170. /**
  59171. * URL to use when loading the basis transcoder
  59172. */
  59173. static JSModuleURL: string;
  59174. /**
  59175. * URL to use when loading the wasm module for the transcoder
  59176. */
  59177. static WasmModuleURL: string;
  59178. /**
  59179. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59180. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59181. * @returns internal format corresponding to the Basis format
  59182. */
  59183. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59184. private static _WorkerPromise;
  59185. private static _Worker;
  59186. private static _actionId;
  59187. private static _CreateWorkerAsync;
  59188. /**
  59189. * Transcodes a loaded image file to compressed pixel data
  59190. * @param data image data to transcode
  59191. * @param config configuration options for the transcoding
  59192. * @returns a promise resulting in the transcoded image
  59193. */
  59194. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59195. /**
  59196. * Loads a texture from the transcode result
  59197. * @param texture texture load to
  59198. * @param transcodeResult the result of transcoding the basis file to load from
  59199. */
  59200. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59201. }
  59202. }
  59203. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59204. import { Nullable } from "babylonjs/types";
  59205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59206. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59207. /**
  59208. * Loader for .basis file format
  59209. */
  59210. export class _BasisTextureLoader implements IInternalTextureLoader {
  59211. /**
  59212. * Defines whether the loader supports cascade loading the different faces.
  59213. */
  59214. readonly supportCascades: boolean;
  59215. /**
  59216. * This returns if the loader support the current file information.
  59217. * @param extension defines the file extension of the file being loaded
  59218. * @returns true if the loader can load the specified file
  59219. */
  59220. canLoad(extension: string): boolean;
  59221. /**
  59222. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59223. * @param data contains the texture data
  59224. * @param texture defines the BabylonJS internal texture
  59225. * @param createPolynomials will be true if polynomials have been requested
  59226. * @param onLoad defines the callback to trigger once the texture is ready
  59227. * @param onError defines the callback to trigger in case of error
  59228. */
  59229. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59230. /**
  59231. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59232. * @param data contains the texture data
  59233. * @param texture defines the BabylonJS internal texture
  59234. * @param callback defines the method to call once ready to upload
  59235. */
  59236. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59237. }
  59238. }
  59239. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59240. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59241. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59242. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59243. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59244. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59245. }
  59246. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59247. import { Scene } from "babylonjs/scene";
  59248. import { Texture } from "babylonjs/Materials/Textures/texture";
  59249. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59250. /**
  59251. * 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.
  59252. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59253. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59254. */
  59255. export class CustomProceduralTexture extends ProceduralTexture {
  59256. private _animate;
  59257. private _time;
  59258. private _config;
  59259. private _texturePath;
  59260. /**
  59261. * Instantiates a new Custom Procedural Texture.
  59262. * 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.
  59263. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59265. * @param name Define the name of the texture
  59266. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59267. * @param size Define the size of the texture to create
  59268. * @param scene Define the scene the texture belongs to
  59269. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59270. * @param generateMipMaps Define if the texture should creates mip maps or not
  59271. */
  59272. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59273. private _loadJson;
  59274. /**
  59275. * Is the texture ready to be used ? (rendered at least once)
  59276. * @returns true if ready, otherwise, false.
  59277. */
  59278. isReady(): boolean;
  59279. /**
  59280. * Render the texture to its associated render target.
  59281. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59282. */
  59283. render(useCameraPostProcess?: boolean): void;
  59284. /**
  59285. * Update the list of dependant textures samplers in the shader.
  59286. */
  59287. updateTextures(): void;
  59288. /**
  59289. * Update the uniform values of the procedural texture in the shader.
  59290. */
  59291. updateShaderUniforms(): void;
  59292. /**
  59293. * Define if the texture animates or not.
  59294. */
  59295. get animate(): boolean;
  59296. set animate(value: boolean);
  59297. }
  59298. }
  59299. declare module "babylonjs/Shaders/noise.fragment" {
  59300. /** @hidden */
  59301. export var noisePixelShader: {
  59302. name: string;
  59303. shader: string;
  59304. };
  59305. }
  59306. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59307. import { Nullable } from "babylonjs/types";
  59308. import { Scene } from "babylonjs/scene";
  59309. import { Texture } from "babylonjs/Materials/Textures/texture";
  59310. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59311. import "babylonjs/Shaders/noise.fragment";
  59312. /**
  59313. * Class used to generate noise procedural textures
  59314. */
  59315. export class NoiseProceduralTexture extends ProceduralTexture {
  59316. private _time;
  59317. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59318. brightness: number;
  59319. /** Defines the number of octaves to process */
  59320. octaves: number;
  59321. /** Defines the level of persistence (0.8 by default) */
  59322. persistence: number;
  59323. /** Gets or sets animation speed factor (default is 1) */
  59324. animationSpeedFactor: number;
  59325. /**
  59326. * Creates a new NoiseProceduralTexture
  59327. * @param name defines the name fo the texture
  59328. * @param size defines the size of the texture (default is 256)
  59329. * @param scene defines the hosting scene
  59330. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59331. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59332. */
  59333. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59334. private _updateShaderUniforms;
  59335. protected _getDefines(): string;
  59336. /** Generate the current state of the procedural texture */
  59337. render(useCameraPostProcess?: boolean): void;
  59338. /**
  59339. * Serializes this noise procedural texture
  59340. * @returns a serialized noise procedural texture object
  59341. */
  59342. serialize(): any;
  59343. /**
  59344. * Clone the texture.
  59345. * @returns the cloned texture
  59346. */
  59347. clone(): NoiseProceduralTexture;
  59348. /**
  59349. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59350. * @param parsedTexture defines parsed texture data
  59351. * @param scene defines the current scene
  59352. * @param rootUrl defines the root URL containing noise procedural texture information
  59353. * @returns a parsed NoiseProceduralTexture
  59354. */
  59355. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59356. }
  59357. }
  59358. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59359. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59360. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59361. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59362. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59363. }
  59364. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59365. import { Nullable } from "babylonjs/types";
  59366. import { Scene } from "babylonjs/scene";
  59367. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59369. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59370. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59371. /**
  59372. * Raw cube texture where the raw buffers are passed in
  59373. */
  59374. export class RawCubeTexture extends CubeTexture {
  59375. /**
  59376. * Creates a cube texture where the raw buffers are passed in.
  59377. * @param scene defines the scene the texture is attached to
  59378. * @param data defines the array of data to use to create each face
  59379. * @param size defines the size of the textures
  59380. * @param format defines the format of the data
  59381. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59382. * @param generateMipMaps defines if the engine should generate the mip levels
  59383. * @param invertY defines if data must be stored with Y axis inverted
  59384. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59385. * @param compression defines the compression used (null by default)
  59386. */
  59387. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59388. /**
  59389. * Updates the raw cube texture.
  59390. * @param data defines the data to store
  59391. * @param format defines the data format
  59392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59393. * @param invertY defines if data must be stored with Y axis inverted
  59394. * @param compression defines the compression used (null by default)
  59395. * @param level defines which level of the texture to update
  59396. */
  59397. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59398. /**
  59399. * Updates a raw cube texture with RGBD encoded data.
  59400. * @param data defines the array of data [mipmap][face] to use to create each face
  59401. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59402. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59403. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59404. * @returns a promsie that resolves when the operation is complete
  59405. */
  59406. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59407. /**
  59408. * Clones the raw cube texture.
  59409. * @return a new cube texture
  59410. */
  59411. clone(): CubeTexture;
  59412. /** @hidden */
  59413. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59414. }
  59415. }
  59416. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59417. import { Scene } from "babylonjs/scene";
  59418. import { Texture } from "babylonjs/Materials/Textures/texture";
  59419. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59420. /**
  59421. * Class used to store 3D textures containing user data
  59422. */
  59423. export class RawTexture3D extends Texture {
  59424. /** Gets or sets the texture format to use */
  59425. format: number;
  59426. private _engine;
  59427. /**
  59428. * Create a new RawTexture3D
  59429. * @param data defines the data of the texture
  59430. * @param width defines the width of the texture
  59431. * @param height defines the height of the texture
  59432. * @param depth defines the depth of the texture
  59433. * @param format defines the texture format to use
  59434. * @param scene defines the hosting scene
  59435. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59436. * @param invertY defines if texture must be stored with Y axis inverted
  59437. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59438. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59439. */
  59440. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59441. /** Gets or sets the texture format to use */
  59442. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59443. /**
  59444. * Update the texture with new data
  59445. * @param data defines the data to store in the texture
  59446. */
  59447. update(data: ArrayBufferView): void;
  59448. }
  59449. }
  59450. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59451. import { Scene } from "babylonjs/scene";
  59452. import { Texture } from "babylonjs/Materials/Textures/texture";
  59453. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59454. /**
  59455. * Class used to store 2D array textures containing user data
  59456. */
  59457. export class RawTexture2DArray extends Texture {
  59458. /** Gets or sets the texture format to use */
  59459. format: number;
  59460. private _engine;
  59461. /**
  59462. * Create a new RawTexture2DArray
  59463. * @param data defines the data of the texture
  59464. * @param width defines the width of the texture
  59465. * @param height defines the height of the texture
  59466. * @param depth defines the number of layers of the texture
  59467. * @param format defines the texture format to use
  59468. * @param scene defines the hosting scene
  59469. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59470. * @param invertY defines if texture must be stored with Y axis inverted
  59471. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59473. */
  59474. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59475. /** Gets or sets the texture format to use */
  59476. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59477. /**
  59478. * Update the texture with new data
  59479. * @param data defines the data to store in the texture
  59480. */
  59481. update(data: ArrayBufferView): void;
  59482. }
  59483. }
  59484. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59485. import { Scene } from "babylonjs/scene";
  59486. import { Plane } from "babylonjs/Maths/math.plane";
  59487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59488. /**
  59489. * Creates a refraction texture used by refraction channel of the standard material.
  59490. * It is like a mirror but to see through a material.
  59491. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59492. */
  59493. export class RefractionTexture extends RenderTargetTexture {
  59494. /**
  59495. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59496. * 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.
  59497. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59498. */
  59499. refractionPlane: Plane;
  59500. /**
  59501. * Define how deep under the surface we should see.
  59502. */
  59503. depth: number;
  59504. /**
  59505. * Creates a refraction texture used by refraction channel of the standard material.
  59506. * It is like a mirror but to see through a material.
  59507. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59508. * @param name Define the texture name
  59509. * @param size Define the size of the underlying texture
  59510. * @param scene Define the scene the refraction belongs to
  59511. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59512. */
  59513. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59514. /**
  59515. * Clone the refraction texture.
  59516. * @returns the cloned texture
  59517. */
  59518. clone(): RefractionTexture;
  59519. /**
  59520. * Serialize the texture to a JSON representation you could use in Parse later on
  59521. * @returns the serialized JSON representation
  59522. */
  59523. serialize(): any;
  59524. }
  59525. }
  59526. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59527. import { Nullable } from "babylonjs/types";
  59528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59529. import { Matrix } from "babylonjs/Maths/math.vector";
  59530. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59531. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59532. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59533. import { Scene } from "babylonjs/scene";
  59534. /**
  59535. * Defines the options related to the creation of an HtmlElementTexture
  59536. */
  59537. export interface IHtmlElementTextureOptions {
  59538. /**
  59539. * Defines wether mip maps should be created or not.
  59540. */
  59541. generateMipMaps?: boolean;
  59542. /**
  59543. * Defines the sampling mode of the texture.
  59544. */
  59545. samplingMode?: number;
  59546. /**
  59547. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59548. */
  59549. engine: Nullable<ThinEngine>;
  59550. /**
  59551. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59552. */
  59553. scene: Nullable<Scene>;
  59554. }
  59555. /**
  59556. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59557. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59558. * is automatically managed.
  59559. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59560. * in your application.
  59561. *
  59562. * As the update is not automatic, you need to call them manually.
  59563. */
  59564. export class HtmlElementTexture extends BaseTexture {
  59565. /**
  59566. * The texture URL.
  59567. */
  59568. element: HTMLVideoElement | HTMLCanvasElement;
  59569. private static readonly DefaultOptions;
  59570. private _textureMatrix;
  59571. private _engine;
  59572. private _isVideo;
  59573. private _generateMipMaps;
  59574. private _samplingMode;
  59575. /**
  59576. * Instantiates a HtmlElementTexture from the following parameters.
  59577. *
  59578. * @param name Defines the name of the texture
  59579. * @param element Defines the video or canvas the texture is filled with
  59580. * @param options Defines the other none mandatory texture creation options
  59581. */
  59582. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59583. private _createInternalTexture;
  59584. /**
  59585. * Returns the texture matrix used in most of the material.
  59586. */
  59587. getTextureMatrix(): Matrix;
  59588. /**
  59589. * Updates the content of the texture.
  59590. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59591. */
  59592. update(invertY?: Nullable<boolean>): void;
  59593. }
  59594. }
  59595. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59596. import { Vector2 } from "babylonjs/Maths/math.vector";
  59597. /**
  59598. * Defines the basic options interface of a TexturePacker Frame
  59599. */
  59600. export interface ITexturePackerFrame {
  59601. /**
  59602. * The frame ID
  59603. */
  59604. id: number;
  59605. /**
  59606. * The frames Scale
  59607. */
  59608. scale: Vector2;
  59609. /**
  59610. * The Frames offset
  59611. */
  59612. offset: Vector2;
  59613. }
  59614. /**
  59615. * This is a support class for frame Data on texture packer sets.
  59616. */
  59617. export class TexturePackerFrame implements ITexturePackerFrame {
  59618. /**
  59619. * The frame ID
  59620. */
  59621. id: number;
  59622. /**
  59623. * The frames Scale
  59624. */
  59625. scale: Vector2;
  59626. /**
  59627. * The Frames offset
  59628. */
  59629. offset: Vector2;
  59630. /**
  59631. * Initializes a texture package frame.
  59632. * @param id The numerical frame identifier
  59633. * @param scale Scalar Vector2 for UV frame
  59634. * @param offset Vector2 for the frame position in UV units.
  59635. * @returns TexturePackerFrame
  59636. */
  59637. constructor(id: number, scale: Vector2, offset: Vector2);
  59638. }
  59639. }
  59640. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59642. import { Scene } from "babylonjs/scene";
  59643. import { Nullable } from "babylonjs/types";
  59644. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59645. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59646. /**
  59647. * Defines the basic options interface of a TexturePacker
  59648. */
  59649. export interface ITexturePackerOptions {
  59650. /**
  59651. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59652. */
  59653. map?: string[];
  59654. /**
  59655. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59656. */
  59657. uvsIn?: string;
  59658. /**
  59659. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59660. */
  59661. uvsOut?: string;
  59662. /**
  59663. * number representing the layout style. Defaults to LAYOUT_STRIP
  59664. */
  59665. layout?: number;
  59666. /**
  59667. * number of columns if using custom column count layout(2). This defaults to 4.
  59668. */
  59669. colnum?: number;
  59670. /**
  59671. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59672. */
  59673. updateInputMeshes?: boolean;
  59674. /**
  59675. * boolean flag to dispose all the source textures. Defaults to true.
  59676. */
  59677. disposeSources?: boolean;
  59678. /**
  59679. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59680. */
  59681. fillBlanks?: boolean;
  59682. /**
  59683. * string value representing the context fill style color. Defaults to 'black'.
  59684. */
  59685. customFillColor?: string;
  59686. /**
  59687. * Width and Height Value of each Frame in the TexturePacker Sets
  59688. */
  59689. frameSize?: number;
  59690. /**
  59691. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59692. */
  59693. paddingRatio?: number;
  59694. /**
  59695. * Number that declares the fill method for the padding gutter.
  59696. */
  59697. paddingMode?: number;
  59698. /**
  59699. * If in SUBUV_COLOR padding mode what color to use.
  59700. */
  59701. paddingColor?: Color3 | Color4;
  59702. }
  59703. /**
  59704. * Defines the basic interface of a TexturePacker JSON File
  59705. */
  59706. export interface ITexturePackerJSON {
  59707. /**
  59708. * The frame ID
  59709. */
  59710. name: string;
  59711. /**
  59712. * The base64 channel data
  59713. */
  59714. sets: any;
  59715. /**
  59716. * The options of the Packer
  59717. */
  59718. options: ITexturePackerOptions;
  59719. /**
  59720. * The frame data of the Packer
  59721. */
  59722. frames: Array<number>;
  59723. }
  59724. /**
  59725. * This is a support class that generates a series of packed texture sets.
  59726. * @see https://doc.babylonjs.com/babylon101/materials
  59727. */
  59728. export class TexturePacker {
  59729. /** Packer Layout Constant 0 */
  59730. static readonly LAYOUT_STRIP: number;
  59731. /** Packer Layout Constant 1 */
  59732. static readonly LAYOUT_POWER2: number;
  59733. /** Packer Layout Constant 2 */
  59734. static readonly LAYOUT_COLNUM: number;
  59735. /** Packer Layout Constant 0 */
  59736. static readonly SUBUV_WRAP: number;
  59737. /** Packer Layout Constant 1 */
  59738. static readonly SUBUV_EXTEND: number;
  59739. /** Packer Layout Constant 2 */
  59740. static readonly SUBUV_COLOR: number;
  59741. /** The Name of the Texture Package */
  59742. name: string;
  59743. /** The scene scope of the TexturePacker */
  59744. scene: Scene;
  59745. /** The Meshes to target */
  59746. meshes: AbstractMesh[];
  59747. /** Arguments passed with the Constructor */
  59748. options: ITexturePackerOptions;
  59749. /** The promise that is started upon initialization */
  59750. promise: Nullable<Promise<TexturePacker | string>>;
  59751. /** The Container object for the channel sets that are generated */
  59752. sets: object;
  59753. /** The Container array for the frames that are generated */
  59754. frames: TexturePackerFrame[];
  59755. /** The expected number of textures the system is parsing. */
  59756. private _expecting;
  59757. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59758. private _paddingValue;
  59759. /**
  59760. * Initializes a texture package series from an array of meshes or a single mesh.
  59761. * @param name The name of the package
  59762. * @param meshes The target meshes to compose the package from
  59763. * @param options The arguments that texture packer should follow while building.
  59764. * @param scene The scene which the textures are scoped to.
  59765. * @returns TexturePacker
  59766. */
  59767. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59768. /**
  59769. * Starts the package process
  59770. * @param resolve The promises resolution function
  59771. * @returns TexturePacker
  59772. */
  59773. private _createFrames;
  59774. /**
  59775. * Calculates the Size of the Channel Sets
  59776. * @returns Vector2
  59777. */
  59778. private _calculateSize;
  59779. /**
  59780. * Calculates the UV data for the frames.
  59781. * @param baseSize the base frameSize
  59782. * @param padding the base frame padding
  59783. * @param dtSize size of the Dynamic Texture for that channel
  59784. * @param dtUnits is 1/dtSize
  59785. * @param update flag to update the input meshes
  59786. */
  59787. private _calculateMeshUVFrames;
  59788. /**
  59789. * Calculates the frames Offset.
  59790. * @param index of the frame
  59791. * @returns Vector2
  59792. */
  59793. private _getFrameOffset;
  59794. /**
  59795. * Updates a Mesh to the frame data
  59796. * @param mesh that is the target
  59797. * @param frameID or the frame index
  59798. */
  59799. private _updateMeshUV;
  59800. /**
  59801. * Updates a Meshes materials to use the texture packer channels
  59802. * @param m is the mesh to target
  59803. * @param force all channels on the packer to be set.
  59804. */
  59805. private _updateTextureReferences;
  59806. /**
  59807. * Public method to set a Mesh to a frame
  59808. * @param m that is the target
  59809. * @param frameID or the frame index
  59810. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59811. */
  59812. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59813. /**
  59814. * Starts the async promise to compile the texture packer.
  59815. * @returns Promise<void>
  59816. */
  59817. processAsync(): Promise<void>;
  59818. /**
  59819. * Disposes all textures associated with this packer
  59820. */
  59821. dispose(): void;
  59822. /**
  59823. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59824. * @param imageType is the image type to use.
  59825. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59826. */
  59827. download(imageType?: string, quality?: number): void;
  59828. /**
  59829. * Public method to load a texturePacker JSON file.
  59830. * @param data of the JSON file in string format.
  59831. */
  59832. updateFromJSON(data: string): void;
  59833. }
  59834. }
  59835. declare module "babylonjs/Materials/Textures/Packer/index" {
  59836. export * from "babylonjs/Materials/Textures/Packer/packer";
  59837. export * from "babylonjs/Materials/Textures/Packer/frame";
  59838. }
  59839. declare module "babylonjs/Materials/Textures/index" {
  59840. export * from "babylonjs/Materials/Textures/baseTexture";
  59841. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59842. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59843. export * from "babylonjs/Materials/Textures/cubeTexture";
  59844. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59845. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59846. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59847. export * from "babylonjs/Materials/Textures/internalTexture";
  59848. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59849. export * from "babylonjs/Materials/Textures/Loaders/index";
  59850. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59851. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59852. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59853. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59854. export * from "babylonjs/Materials/Textures/rawTexture";
  59855. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59856. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59857. export * from "babylonjs/Materials/Textures/refractionTexture";
  59858. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59859. export * from "babylonjs/Materials/Textures/texture";
  59860. export * from "babylonjs/Materials/Textures/videoTexture";
  59861. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59862. export * from "babylonjs/Materials/Textures/Packer/index";
  59863. }
  59864. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59865. /**
  59866. * Enum used to define the target of a block
  59867. */
  59868. export enum NodeMaterialBlockTargets {
  59869. /** Vertex shader */
  59870. Vertex = 1,
  59871. /** Fragment shader */
  59872. Fragment = 2,
  59873. /** Neutral */
  59874. Neutral = 4,
  59875. /** Vertex and Fragment */
  59876. VertexAndFragment = 3
  59877. }
  59878. }
  59879. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59880. /**
  59881. * Defines the kind of connection point for node based material
  59882. */
  59883. export enum NodeMaterialBlockConnectionPointTypes {
  59884. /** Float */
  59885. Float = 1,
  59886. /** Int */
  59887. Int = 2,
  59888. /** Vector2 */
  59889. Vector2 = 4,
  59890. /** Vector3 */
  59891. Vector3 = 8,
  59892. /** Vector4 */
  59893. Vector4 = 16,
  59894. /** Color3 */
  59895. Color3 = 32,
  59896. /** Color4 */
  59897. Color4 = 64,
  59898. /** Matrix */
  59899. Matrix = 128,
  59900. /** Detect type based on connection */
  59901. AutoDetect = 1024,
  59902. /** Output type that will be defined by input type */
  59903. BasedOnInput = 2048
  59904. }
  59905. }
  59906. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59907. /**
  59908. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59909. */
  59910. export enum NodeMaterialBlockConnectionPointMode {
  59911. /** Value is an uniform */
  59912. Uniform = 0,
  59913. /** Value is a mesh attribute */
  59914. Attribute = 1,
  59915. /** Value is a varying between vertex and fragment shaders */
  59916. Varying = 2,
  59917. /** Mode is undefined */
  59918. Undefined = 3
  59919. }
  59920. }
  59921. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59922. /**
  59923. * Enum used to define system values e.g. values automatically provided by the system
  59924. */
  59925. export enum NodeMaterialSystemValues {
  59926. /** World */
  59927. World = 1,
  59928. /** View */
  59929. View = 2,
  59930. /** Projection */
  59931. Projection = 3,
  59932. /** ViewProjection */
  59933. ViewProjection = 4,
  59934. /** WorldView */
  59935. WorldView = 5,
  59936. /** WorldViewProjection */
  59937. WorldViewProjection = 6,
  59938. /** CameraPosition */
  59939. CameraPosition = 7,
  59940. /** Fog Color */
  59941. FogColor = 8,
  59942. /** Delta time */
  59943. DeltaTime = 9
  59944. }
  59945. }
  59946. declare module "babylonjs/Materials/Node/Enums/index" {
  59947. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59948. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59949. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59950. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59951. }
  59952. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59954. /**
  59955. * Root class for all node material optimizers
  59956. */
  59957. export class NodeMaterialOptimizer {
  59958. /**
  59959. * Function used to optimize a NodeMaterial graph
  59960. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59961. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59962. */
  59963. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59964. }
  59965. }
  59966. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59970. import { Scene } from "babylonjs/scene";
  59971. /**
  59972. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59973. */
  59974. export class TransformBlock extends NodeMaterialBlock {
  59975. /**
  59976. * Defines the value to use to complement W value to transform it to a Vector4
  59977. */
  59978. complementW: number;
  59979. /**
  59980. * Defines the value to use to complement z value to transform it to a Vector4
  59981. */
  59982. complementZ: number;
  59983. /**
  59984. * Creates a new TransformBlock
  59985. * @param name defines the block name
  59986. */
  59987. constructor(name: string);
  59988. /**
  59989. * Gets the current class name
  59990. * @returns the class name
  59991. */
  59992. getClassName(): string;
  59993. /**
  59994. * Gets the vector input
  59995. */
  59996. get vector(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the output component
  59999. */
  60000. get output(): NodeMaterialConnectionPoint;
  60001. /**
  60002. * Gets the xyz output component
  60003. */
  60004. get xyz(): NodeMaterialConnectionPoint;
  60005. /**
  60006. * Gets the matrix transform input
  60007. */
  60008. get transform(): NodeMaterialConnectionPoint;
  60009. protected _buildBlock(state: NodeMaterialBuildState): this;
  60010. serialize(): any;
  60011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60012. protected _dumpPropertiesCode(): string;
  60013. }
  60014. }
  60015. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60019. /**
  60020. * Block used to output the vertex position
  60021. */
  60022. export class VertexOutputBlock extends NodeMaterialBlock {
  60023. /**
  60024. * Creates a new VertexOutputBlock
  60025. * @param name defines the block name
  60026. */
  60027. constructor(name: string);
  60028. /**
  60029. * Gets the current class name
  60030. * @returns the class name
  60031. */
  60032. getClassName(): string;
  60033. /**
  60034. * Gets the vector input component
  60035. */
  60036. get vector(): NodeMaterialConnectionPoint;
  60037. protected _buildBlock(state: NodeMaterialBuildState): this;
  60038. }
  60039. }
  60040. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60044. /**
  60045. * Block used to output the final color
  60046. */
  60047. export class FragmentOutputBlock extends NodeMaterialBlock {
  60048. /**
  60049. * Create a new FragmentOutputBlock
  60050. * @param name defines the block name
  60051. */
  60052. constructor(name: string);
  60053. /**
  60054. * Gets the current class name
  60055. * @returns the class name
  60056. */
  60057. getClassName(): string;
  60058. /**
  60059. * Gets the rgba input component
  60060. */
  60061. get rgba(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the rgb input component
  60064. */
  60065. get rgb(): NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the a input component
  60068. */
  60069. get a(): NodeMaterialConnectionPoint;
  60070. protected _buildBlock(state: NodeMaterialBuildState): this;
  60071. }
  60072. }
  60073. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60079. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60080. import { Effect } from "babylonjs/Materials/effect";
  60081. import { Mesh } from "babylonjs/Meshes/mesh";
  60082. import { Nullable } from "babylonjs/types";
  60083. import { Scene } from "babylonjs/scene";
  60084. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60085. /**
  60086. * Block used to read a reflection texture from a sampler
  60087. */
  60088. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60089. private _define3DName;
  60090. private _defineCubicName;
  60091. private _defineExplicitName;
  60092. private _defineProjectionName;
  60093. private _defineLocalCubicName;
  60094. private _defineSphericalName;
  60095. private _definePlanarName;
  60096. private _defineEquirectangularName;
  60097. private _defineMirroredEquirectangularFixedName;
  60098. private _defineEquirectangularFixedName;
  60099. private _defineSkyboxName;
  60100. private _cubeSamplerName;
  60101. private _2DSamplerName;
  60102. private _positionUVWName;
  60103. private _directionWName;
  60104. private _reflectionCoordsName;
  60105. private _reflection2DCoordsName;
  60106. private _reflectionColorName;
  60107. private _reflectionMatrixName;
  60108. /**
  60109. * Gets or sets the texture associated with the node
  60110. */
  60111. texture: Nullable<BaseTexture>;
  60112. /**
  60113. * Create a new TextureBlock
  60114. * @param name defines the block name
  60115. */
  60116. constructor(name: string);
  60117. /**
  60118. * Gets the current class name
  60119. * @returns the class name
  60120. */
  60121. getClassName(): string;
  60122. /**
  60123. * Gets the world position input component
  60124. */
  60125. get position(): NodeMaterialConnectionPoint;
  60126. /**
  60127. * Gets the world position input component
  60128. */
  60129. get worldPosition(): NodeMaterialConnectionPoint;
  60130. /**
  60131. * Gets the world normal input component
  60132. */
  60133. get worldNormal(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the world input component
  60136. */
  60137. get world(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the camera (or eye) position component
  60140. */
  60141. get cameraPosition(): NodeMaterialConnectionPoint;
  60142. /**
  60143. * Gets the view input component
  60144. */
  60145. get view(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the rgb output component
  60148. */
  60149. get rgb(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the r output component
  60152. */
  60153. get r(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the g output component
  60156. */
  60157. get g(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the b output component
  60160. */
  60161. get b(): NodeMaterialConnectionPoint;
  60162. autoConfigure(material: NodeMaterial): void;
  60163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60164. isReady(): boolean;
  60165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60166. private _injectVertexCode;
  60167. private _writeOutput;
  60168. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60169. protected _dumpPropertiesCode(): string;
  60170. serialize(): any;
  60171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60172. }
  60173. }
  60174. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60176. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60177. import { Scene } from "babylonjs/scene";
  60178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60179. import { Matrix } from "babylonjs/Maths/math.vector";
  60180. import { Mesh } from "babylonjs/Meshes/mesh";
  60181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60182. import { Observable } from "babylonjs/Misc/observable";
  60183. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60185. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60186. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60187. import { Nullable } from "babylonjs/types";
  60188. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60189. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60190. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60191. /**
  60192. * Interface used to configure the node material editor
  60193. */
  60194. export interface INodeMaterialEditorOptions {
  60195. /** Define the URl to load node editor script */
  60196. editorURL?: string;
  60197. }
  60198. /** @hidden */
  60199. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60200. NORMAL: boolean;
  60201. TANGENT: boolean;
  60202. UV1: boolean;
  60203. /** BONES */
  60204. NUM_BONE_INFLUENCERS: number;
  60205. BonesPerMesh: number;
  60206. BONETEXTURE: boolean;
  60207. /** MORPH TARGETS */
  60208. MORPHTARGETS: boolean;
  60209. MORPHTARGETS_NORMAL: boolean;
  60210. MORPHTARGETS_TANGENT: boolean;
  60211. MORPHTARGETS_UV: boolean;
  60212. NUM_MORPH_INFLUENCERS: number;
  60213. /** IMAGE PROCESSING */
  60214. IMAGEPROCESSING: boolean;
  60215. VIGNETTE: boolean;
  60216. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60217. VIGNETTEBLENDMODEOPAQUE: boolean;
  60218. TONEMAPPING: boolean;
  60219. TONEMAPPING_ACES: boolean;
  60220. CONTRAST: boolean;
  60221. EXPOSURE: boolean;
  60222. COLORCURVES: boolean;
  60223. COLORGRADING: boolean;
  60224. COLORGRADING3D: boolean;
  60225. SAMPLER3DGREENDEPTH: boolean;
  60226. SAMPLER3DBGRMAP: boolean;
  60227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60228. /** MISC. */
  60229. BUMPDIRECTUV: number;
  60230. constructor();
  60231. setValue(name: string, value: boolean): void;
  60232. }
  60233. /**
  60234. * Class used to configure NodeMaterial
  60235. */
  60236. export interface INodeMaterialOptions {
  60237. /**
  60238. * Defines if blocks should emit comments
  60239. */
  60240. emitComments: boolean;
  60241. }
  60242. /**
  60243. * Class used to create a node based material built by assembling shader blocks
  60244. */
  60245. export class NodeMaterial extends PushMaterial {
  60246. private static _BuildIdGenerator;
  60247. private _options;
  60248. private _vertexCompilationState;
  60249. private _fragmentCompilationState;
  60250. private _sharedData;
  60251. private _buildId;
  60252. private _buildWasSuccessful;
  60253. private _cachedWorldViewMatrix;
  60254. private _cachedWorldViewProjectionMatrix;
  60255. private _optimizers;
  60256. private _animationFrame;
  60257. /** Define the Url to load node editor script */
  60258. static EditorURL: string;
  60259. /** Define the Url to load snippets */
  60260. static SnippetUrl: string;
  60261. private BJSNODEMATERIALEDITOR;
  60262. /** Get the inspector from bundle or global */
  60263. private _getGlobalNodeMaterialEditor;
  60264. /**
  60265. * Snippet ID if the material was created from the snippet server
  60266. */
  60267. snippetId: string;
  60268. /**
  60269. * Gets or sets data used by visual editor
  60270. * @see https://nme.babylonjs.com
  60271. */
  60272. editorData: any;
  60273. /**
  60274. * 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)
  60275. */
  60276. ignoreAlpha: boolean;
  60277. /**
  60278. * Defines the maximum number of lights that can be used in the material
  60279. */
  60280. maxSimultaneousLights: number;
  60281. /**
  60282. * Observable raised when the material is built
  60283. */
  60284. onBuildObservable: Observable<NodeMaterial>;
  60285. /**
  60286. * Gets or sets the root nodes of the material vertex shader
  60287. */
  60288. _vertexOutputNodes: NodeMaterialBlock[];
  60289. /**
  60290. * Gets or sets the root nodes of the material fragment (pixel) shader
  60291. */
  60292. _fragmentOutputNodes: NodeMaterialBlock[];
  60293. /** Gets or sets options to control the node material overall behavior */
  60294. get options(): INodeMaterialOptions;
  60295. set options(options: INodeMaterialOptions);
  60296. /**
  60297. * Default configuration related to image processing available in the standard Material.
  60298. */
  60299. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60300. /**
  60301. * Gets the image processing configuration used either in this material.
  60302. */
  60303. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60304. /**
  60305. * Sets the Default image processing configuration used either in the this material.
  60306. *
  60307. * If sets to null, the scene one is in use.
  60308. */
  60309. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60310. /**
  60311. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60312. */
  60313. attachedBlocks: NodeMaterialBlock[];
  60314. /**
  60315. * Create a new node based material
  60316. * @param name defines the material name
  60317. * @param scene defines the hosting scene
  60318. * @param options defines creation option
  60319. */
  60320. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60321. /**
  60322. * Gets the current class name of the material e.g. "NodeMaterial"
  60323. * @returns the class name
  60324. */
  60325. getClassName(): string;
  60326. /**
  60327. * Keep track of the image processing observer to allow dispose and replace.
  60328. */
  60329. private _imageProcessingObserver;
  60330. /**
  60331. * Attaches a new image processing configuration to the Standard Material.
  60332. * @param configuration
  60333. */
  60334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60335. /**
  60336. * Get a block by its name
  60337. * @param name defines the name of the block to retrieve
  60338. * @returns the required block or null if not found
  60339. */
  60340. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60341. /**
  60342. * Get a block by its name
  60343. * @param predicate defines the predicate used to find the good candidate
  60344. * @returns the required block or null if not found
  60345. */
  60346. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60347. /**
  60348. * Get an input block by its name
  60349. * @param predicate defines the predicate used to find the good candidate
  60350. * @returns the required input block or null if not found
  60351. */
  60352. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60353. /**
  60354. * Gets the list of input blocks attached to this material
  60355. * @returns an array of InputBlocks
  60356. */
  60357. getInputBlocks(): InputBlock[];
  60358. /**
  60359. * Adds a new optimizer to the list of optimizers
  60360. * @param optimizer defines the optimizers to add
  60361. * @returns the current material
  60362. */
  60363. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60364. /**
  60365. * Remove an optimizer from the list of optimizers
  60366. * @param optimizer defines the optimizers to remove
  60367. * @returns the current material
  60368. */
  60369. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60370. /**
  60371. * Add a new block to the list of output nodes
  60372. * @param node defines the node to add
  60373. * @returns the current material
  60374. */
  60375. addOutputNode(node: NodeMaterialBlock): this;
  60376. /**
  60377. * Remove a block from the list of root nodes
  60378. * @param node defines the node to remove
  60379. * @returns the current material
  60380. */
  60381. removeOutputNode(node: NodeMaterialBlock): this;
  60382. private _addVertexOutputNode;
  60383. private _removeVertexOutputNode;
  60384. private _addFragmentOutputNode;
  60385. private _removeFragmentOutputNode;
  60386. /**
  60387. * Specifies if the material will require alpha blending
  60388. * @returns a boolean specifying if alpha blending is needed
  60389. */
  60390. needAlphaBlending(): boolean;
  60391. /**
  60392. * Specifies if this material should be rendered in alpha test mode
  60393. * @returns a boolean specifying if an alpha test is needed.
  60394. */
  60395. needAlphaTesting(): boolean;
  60396. private _initializeBlock;
  60397. private _resetDualBlocks;
  60398. /**
  60399. * Remove a block from the current node material
  60400. * @param block defines the block to remove
  60401. */
  60402. removeBlock(block: NodeMaterialBlock): void;
  60403. /**
  60404. * Build the material and generates the inner effect
  60405. * @param verbose defines if the build should log activity
  60406. */
  60407. build(verbose?: boolean): void;
  60408. /**
  60409. * Runs an otpimization phase to try to improve the shader code
  60410. */
  60411. optimize(): void;
  60412. private _prepareDefinesForAttributes;
  60413. /**
  60414. * Get if the submesh is ready to be used and all its information available.
  60415. * Child classes can use it to update shaders
  60416. * @param mesh defines the mesh to check
  60417. * @param subMesh defines which submesh to check
  60418. * @param useInstances specifies that instances should be used
  60419. * @returns a boolean indicating that the submesh is ready or not
  60420. */
  60421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60422. /**
  60423. * Get a string representing the shaders built by the current node graph
  60424. */
  60425. get compiledShaders(): string;
  60426. /**
  60427. * Binds the world matrix to the material
  60428. * @param world defines the world transformation matrix
  60429. */
  60430. bindOnlyWorldMatrix(world: Matrix): void;
  60431. /**
  60432. * Binds the submesh to this material by preparing the effect and shader to draw
  60433. * @param world defines the world transformation matrix
  60434. * @param mesh defines the mesh containing the submesh
  60435. * @param subMesh defines the submesh to bind the material to
  60436. */
  60437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60438. /**
  60439. * Gets the active textures from the material
  60440. * @returns an array of textures
  60441. */
  60442. getActiveTextures(): BaseTexture[];
  60443. /**
  60444. * Gets the list of texture blocks
  60445. * @returns an array of texture blocks
  60446. */
  60447. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60448. /**
  60449. * Specifies if the material uses a texture
  60450. * @param texture defines the texture to check against the material
  60451. * @returns a boolean specifying if the material uses the texture
  60452. */
  60453. hasTexture(texture: BaseTexture): boolean;
  60454. /**
  60455. * Disposes the material
  60456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60459. */
  60460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60461. /** Creates the node editor window. */
  60462. private _createNodeEditor;
  60463. /**
  60464. * Launch the node material editor
  60465. * @param config Define the configuration of the editor
  60466. * @return a promise fulfilled when the node editor is visible
  60467. */
  60468. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60469. /**
  60470. * Clear the current material
  60471. */
  60472. clear(): void;
  60473. /**
  60474. * Clear the current material and set it to a default state
  60475. */
  60476. setToDefault(): void;
  60477. /**
  60478. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60479. * @param url defines the url to load from
  60480. * @returns a promise that will fullfil when the material is fully loaded
  60481. */
  60482. loadAsync(url: string): Promise<void>;
  60483. private _gatherBlocks;
  60484. /**
  60485. * Generate a string containing the code declaration required to create an equivalent of this material
  60486. * @returns a string
  60487. */
  60488. generateCode(): string;
  60489. /**
  60490. * Serializes this material in a JSON representation
  60491. * @returns the serialized material object
  60492. */
  60493. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60494. private _restoreConnections;
  60495. /**
  60496. * Clear the current graph and load a new one from a serialization object
  60497. * @param source defines the JSON representation of the material
  60498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60499. */
  60500. loadFromSerialization(source: any, rootUrl?: string): void;
  60501. /**
  60502. * Makes a duplicate of the current material.
  60503. * @param name - name to use for the new material.
  60504. */
  60505. clone(name: string): NodeMaterial;
  60506. /**
  60507. * Creates a node material from parsed material data
  60508. * @param source defines the JSON representation of the material
  60509. * @param scene defines the hosting scene
  60510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60511. * @returns a new node material
  60512. */
  60513. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60514. /**
  60515. * Creates a node material from a snippet saved in a remote file
  60516. * @param name defines the name of the material to create
  60517. * @param url defines the url to load from
  60518. * @param scene defines the hosting scene
  60519. * @returns a promise that will resolve to the new node material
  60520. */
  60521. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60522. /**
  60523. * Creates a node material from a snippet saved by the node material editor
  60524. * @param snippetId defines the snippet to load
  60525. * @param scene defines the hosting scene
  60526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60527. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60528. * @returns a promise that will resolve to the new node material
  60529. */
  60530. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60531. /**
  60532. * Creates a new node material set to default basic configuration
  60533. * @param name defines the name of the material
  60534. * @param scene defines the hosting scene
  60535. * @returns a new NodeMaterial
  60536. */
  60537. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60538. }
  60539. }
  60540. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60543. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60546. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60547. import { Effect } from "babylonjs/Materials/effect";
  60548. import { Mesh } from "babylonjs/Meshes/mesh";
  60549. import { Nullable } from "babylonjs/types";
  60550. import { Texture } from "babylonjs/Materials/Textures/texture";
  60551. import { Scene } from "babylonjs/scene";
  60552. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60553. /**
  60554. * Block used to read a texture from a sampler
  60555. */
  60556. export class TextureBlock extends NodeMaterialBlock {
  60557. private _defineName;
  60558. private _linearDefineName;
  60559. private _tempTextureRead;
  60560. private _samplerName;
  60561. private _transformedUVName;
  60562. private _textureTransformName;
  60563. private _textureInfoName;
  60564. private _mainUVName;
  60565. private _mainUVDefineName;
  60566. /**
  60567. * Gets or sets the texture associated with the node
  60568. */
  60569. texture: Nullable<Texture>;
  60570. /**
  60571. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60572. */
  60573. convertToGammaSpace: boolean;
  60574. /**
  60575. * Create a new TextureBlock
  60576. * @param name defines the block name
  60577. */
  60578. constructor(name: string);
  60579. /**
  60580. * Gets the current class name
  60581. * @returns the class name
  60582. */
  60583. getClassName(): string;
  60584. /**
  60585. * Gets the uv input component
  60586. */
  60587. get uv(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the rgba output component
  60590. */
  60591. get rgba(): NodeMaterialConnectionPoint;
  60592. /**
  60593. * Gets the rgb output component
  60594. */
  60595. get rgb(): NodeMaterialConnectionPoint;
  60596. /**
  60597. * Gets the r output component
  60598. */
  60599. get r(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the g output component
  60602. */
  60603. get g(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the b output component
  60606. */
  60607. get b(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the a output component
  60610. */
  60611. get a(): NodeMaterialConnectionPoint;
  60612. get target(): NodeMaterialBlockTargets;
  60613. autoConfigure(material: NodeMaterial): void;
  60614. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60616. isReady(): boolean;
  60617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60618. private get _isMixed();
  60619. private _injectVertexCode;
  60620. private _writeTextureRead;
  60621. private _writeOutput;
  60622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60623. protected _dumpPropertiesCode(): string;
  60624. serialize(): any;
  60625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60626. }
  60627. }
  60628. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60631. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60632. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60633. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60634. import { Scene } from "babylonjs/scene";
  60635. /**
  60636. * Class used to store shared data between 2 NodeMaterialBuildState
  60637. */
  60638. export class NodeMaterialBuildStateSharedData {
  60639. /**
  60640. * Gets the list of emitted varyings
  60641. */
  60642. temps: string[];
  60643. /**
  60644. * Gets the list of emitted varyings
  60645. */
  60646. varyings: string[];
  60647. /**
  60648. * Gets the varying declaration string
  60649. */
  60650. varyingDeclaration: string;
  60651. /**
  60652. * Input blocks
  60653. */
  60654. inputBlocks: InputBlock[];
  60655. /**
  60656. * Input blocks
  60657. */
  60658. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60659. /**
  60660. * Bindable blocks (Blocks that need to set data to the effect)
  60661. */
  60662. bindableBlocks: NodeMaterialBlock[];
  60663. /**
  60664. * List of blocks that can provide a compilation fallback
  60665. */
  60666. blocksWithFallbacks: NodeMaterialBlock[];
  60667. /**
  60668. * List of blocks that can provide a define update
  60669. */
  60670. blocksWithDefines: NodeMaterialBlock[];
  60671. /**
  60672. * List of blocks that can provide a repeatable content
  60673. */
  60674. repeatableContentBlocks: NodeMaterialBlock[];
  60675. /**
  60676. * List of blocks that can provide a dynamic list of uniforms
  60677. */
  60678. dynamicUniformBlocks: NodeMaterialBlock[];
  60679. /**
  60680. * List of blocks that can block the isReady function for the material
  60681. */
  60682. blockingBlocks: NodeMaterialBlock[];
  60683. /**
  60684. * Gets the list of animated inputs
  60685. */
  60686. animatedInputs: InputBlock[];
  60687. /**
  60688. * Build Id used to avoid multiple recompilations
  60689. */
  60690. buildId: number;
  60691. /** List of emitted variables */
  60692. variableNames: {
  60693. [key: string]: number;
  60694. };
  60695. /** List of emitted defines */
  60696. defineNames: {
  60697. [key: string]: number;
  60698. };
  60699. /** Should emit comments? */
  60700. emitComments: boolean;
  60701. /** Emit build activity */
  60702. verbose: boolean;
  60703. /** Gets or sets the hosting scene */
  60704. scene: Scene;
  60705. /**
  60706. * Gets the compilation hints emitted at compilation time
  60707. */
  60708. hints: {
  60709. needWorldViewMatrix: boolean;
  60710. needWorldViewProjectionMatrix: boolean;
  60711. needAlphaBlending: boolean;
  60712. needAlphaTesting: boolean;
  60713. };
  60714. /**
  60715. * List of compilation checks
  60716. */
  60717. checks: {
  60718. emitVertex: boolean;
  60719. emitFragment: boolean;
  60720. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60721. };
  60722. /** Creates a new shared data */
  60723. constructor();
  60724. /**
  60725. * Emits console errors and exceptions if there is a failing check
  60726. */
  60727. emitErrors(): void;
  60728. }
  60729. }
  60730. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60731. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60732. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60733. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60734. /**
  60735. * Class used to store node based material build state
  60736. */
  60737. export class NodeMaterialBuildState {
  60738. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60739. supportUniformBuffers: boolean;
  60740. /**
  60741. * Gets the list of emitted attributes
  60742. */
  60743. attributes: string[];
  60744. /**
  60745. * Gets the list of emitted uniforms
  60746. */
  60747. uniforms: string[];
  60748. /**
  60749. * Gets the list of emitted constants
  60750. */
  60751. constants: string[];
  60752. /**
  60753. * Gets the list of emitted samplers
  60754. */
  60755. samplers: string[];
  60756. /**
  60757. * Gets the list of emitted functions
  60758. */
  60759. functions: {
  60760. [key: string]: string;
  60761. };
  60762. /**
  60763. * Gets the list of emitted extensions
  60764. */
  60765. extensions: {
  60766. [key: string]: string;
  60767. };
  60768. /**
  60769. * Gets the target of the compilation state
  60770. */
  60771. target: NodeMaterialBlockTargets;
  60772. /**
  60773. * Gets the list of emitted counters
  60774. */
  60775. counters: {
  60776. [key: string]: number;
  60777. };
  60778. /**
  60779. * Shared data between multiple NodeMaterialBuildState instances
  60780. */
  60781. sharedData: NodeMaterialBuildStateSharedData;
  60782. /** @hidden */
  60783. _vertexState: NodeMaterialBuildState;
  60784. /** @hidden */
  60785. _attributeDeclaration: string;
  60786. /** @hidden */
  60787. _uniformDeclaration: string;
  60788. /** @hidden */
  60789. _constantDeclaration: string;
  60790. /** @hidden */
  60791. _samplerDeclaration: string;
  60792. /** @hidden */
  60793. _varyingTransfer: string;
  60794. private _repeatableContentAnchorIndex;
  60795. /** @hidden */
  60796. _builtCompilationString: string;
  60797. /**
  60798. * Gets the emitted compilation strings
  60799. */
  60800. compilationString: string;
  60801. /**
  60802. * Finalize the compilation strings
  60803. * @param state defines the current compilation state
  60804. */
  60805. finalize(state: NodeMaterialBuildState): void;
  60806. /** @hidden */
  60807. get _repeatableContentAnchor(): string;
  60808. /** @hidden */
  60809. _getFreeVariableName(prefix: string): string;
  60810. /** @hidden */
  60811. _getFreeDefineName(prefix: string): string;
  60812. /** @hidden */
  60813. _excludeVariableName(name: string): void;
  60814. /** @hidden */
  60815. _emit2DSampler(name: string): void;
  60816. /** @hidden */
  60817. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60818. /** @hidden */
  60819. _emitExtension(name: string, extension: string): void;
  60820. /** @hidden */
  60821. _emitFunction(name: string, code: string, comments: string): void;
  60822. /** @hidden */
  60823. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60824. replaceStrings?: {
  60825. search: RegExp;
  60826. replace: string;
  60827. }[];
  60828. repeatKey?: string;
  60829. }): string;
  60830. /** @hidden */
  60831. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60832. repeatKey?: string;
  60833. removeAttributes?: boolean;
  60834. removeUniforms?: boolean;
  60835. removeVaryings?: boolean;
  60836. removeIfDef?: boolean;
  60837. replaceStrings?: {
  60838. search: RegExp;
  60839. replace: string;
  60840. }[];
  60841. }, storeKey?: string): void;
  60842. /** @hidden */
  60843. _registerTempVariable(name: string): boolean;
  60844. /** @hidden */
  60845. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60846. /** @hidden */
  60847. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60848. /** @hidden */
  60849. _emitFloat(value: number): string;
  60850. }
  60851. }
  60852. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60853. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60855. import { Nullable } from "babylonjs/types";
  60856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60857. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60858. import { Effect } from "babylonjs/Materials/effect";
  60859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60860. import { Mesh } from "babylonjs/Meshes/mesh";
  60861. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60862. import { Scene } from "babylonjs/scene";
  60863. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60864. /**
  60865. * Defines a block that can be used inside a node based material
  60866. */
  60867. export class NodeMaterialBlock {
  60868. private _buildId;
  60869. private _buildTarget;
  60870. private _target;
  60871. private _isFinalMerger;
  60872. private _isInput;
  60873. protected _isUnique: boolean;
  60874. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60875. inputsAreExclusive: boolean;
  60876. /** @hidden */
  60877. _codeVariableName: string;
  60878. /** @hidden */
  60879. _inputs: NodeMaterialConnectionPoint[];
  60880. /** @hidden */
  60881. _outputs: NodeMaterialConnectionPoint[];
  60882. /** @hidden */
  60883. _preparationId: number;
  60884. /**
  60885. * Gets or sets the name of the block
  60886. */
  60887. name: string;
  60888. /**
  60889. * Gets or sets the unique id of the node
  60890. */
  60891. uniqueId: number;
  60892. /**
  60893. * Gets or sets the comments associated with this block
  60894. */
  60895. comments: string;
  60896. /**
  60897. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60898. */
  60899. get isUnique(): boolean;
  60900. /**
  60901. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60902. */
  60903. get isFinalMerger(): boolean;
  60904. /**
  60905. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60906. */
  60907. get isInput(): boolean;
  60908. /**
  60909. * Gets or sets the build Id
  60910. */
  60911. get buildId(): number;
  60912. set buildId(value: number);
  60913. /**
  60914. * Gets or sets the target of the block
  60915. */
  60916. get target(): NodeMaterialBlockTargets;
  60917. set target(value: NodeMaterialBlockTargets);
  60918. /**
  60919. * Gets the list of input points
  60920. */
  60921. get inputs(): NodeMaterialConnectionPoint[];
  60922. /** Gets the list of output points */
  60923. get outputs(): NodeMaterialConnectionPoint[];
  60924. /**
  60925. * Find an input by its name
  60926. * @param name defines the name of the input to look for
  60927. * @returns the input or null if not found
  60928. */
  60929. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60930. /**
  60931. * Find an output by its name
  60932. * @param name defines the name of the outputto look for
  60933. * @returns the output or null if not found
  60934. */
  60935. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60936. /**
  60937. * Creates a new NodeMaterialBlock
  60938. * @param name defines the block name
  60939. * @param target defines the target of that block (Vertex by default)
  60940. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60941. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60942. */
  60943. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60944. /**
  60945. * Initialize the block and prepare the context for build
  60946. * @param state defines the state that will be used for the build
  60947. */
  60948. initialize(state: NodeMaterialBuildState): void;
  60949. /**
  60950. * Bind data to effect. Will only be called for blocks with isBindable === true
  60951. * @param effect defines the effect to bind data to
  60952. * @param nodeMaterial defines the hosting NodeMaterial
  60953. * @param mesh defines the mesh that will be rendered
  60954. */
  60955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60956. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60957. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60958. protected _writeFloat(value: number): string;
  60959. /**
  60960. * Gets the current class name e.g. "NodeMaterialBlock"
  60961. * @returns the class name
  60962. */
  60963. getClassName(): string;
  60964. /**
  60965. * Register a new input. Must be called inside a block constructor
  60966. * @param name defines the connection point name
  60967. * @param type defines the connection point type
  60968. * @param isOptional defines a boolean indicating that this input can be omitted
  60969. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60970. * @returns the current block
  60971. */
  60972. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60973. /**
  60974. * Register a new output. Must be called inside a block constructor
  60975. * @param name defines the connection point name
  60976. * @param type defines the connection point type
  60977. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60978. * @returns the current block
  60979. */
  60980. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60981. /**
  60982. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60983. * @param forOutput defines an optional connection point to check compatibility with
  60984. * @returns the first available input or null
  60985. */
  60986. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60987. /**
  60988. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60989. * @param forBlock defines an optional block to check compatibility with
  60990. * @returns the first available input or null
  60991. */
  60992. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60993. /**
  60994. * Gets the sibling of the given output
  60995. * @param current defines the current output
  60996. * @returns the next output in the list or null
  60997. */
  60998. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60999. /**
  61000. * Connect current block with another block
  61001. * @param other defines the block to connect with
  61002. * @param options define the various options to help pick the right connections
  61003. * @returns the current block
  61004. */
  61005. connectTo(other: NodeMaterialBlock, options?: {
  61006. input?: string;
  61007. output?: string;
  61008. outputSwizzle?: string;
  61009. }): this | undefined;
  61010. protected _buildBlock(state: NodeMaterialBuildState): void;
  61011. /**
  61012. * Add uniforms, samplers and uniform buffers at compilation time
  61013. * @param state defines the state to update
  61014. * @param nodeMaterial defines the node material requesting the update
  61015. * @param defines defines the material defines to update
  61016. * @param uniformBuffers defines the list of uniform buffer names
  61017. */
  61018. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61019. /**
  61020. * Add potential fallbacks if shader compilation fails
  61021. * @param mesh defines the mesh to be rendered
  61022. * @param fallbacks defines the current prioritized list of fallbacks
  61023. */
  61024. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61025. /**
  61026. * Initialize defines for shader compilation
  61027. * @param mesh defines the mesh to be rendered
  61028. * @param nodeMaterial defines the node material requesting the update
  61029. * @param defines defines the material defines to update
  61030. * @param useInstances specifies that instances should be used
  61031. */
  61032. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61033. /**
  61034. * Update defines for shader compilation
  61035. * @param mesh defines the mesh to be rendered
  61036. * @param nodeMaterial defines the node material requesting the update
  61037. * @param defines defines the material defines to update
  61038. * @param useInstances specifies that instances should be used
  61039. */
  61040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61041. /**
  61042. * Lets the block try to connect some inputs automatically
  61043. * @param material defines the hosting NodeMaterial
  61044. */
  61045. autoConfigure(material: NodeMaterial): void;
  61046. /**
  61047. * Function called when a block is declared as repeatable content generator
  61048. * @param vertexShaderState defines the current compilation state for the vertex shader
  61049. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61050. * @param mesh defines the mesh to be rendered
  61051. * @param defines defines the material defines to update
  61052. */
  61053. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61054. /**
  61055. * Checks if the block is ready
  61056. * @param mesh defines the mesh to be rendered
  61057. * @param nodeMaterial defines the node material requesting the update
  61058. * @param defines defines the material defines to update
  61059. * @param useInstances specifies that instances should be used
  61060. * @returns true if the block is ready
  61061. */
  61062. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61063. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61064. private _processBuild;
  61065. /**
  61066. * Compile the current node and generate the shader code
  61067. * @param state defines the current compilation state (uniforms, samplers, current string)
  61068. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61069. * @returns true if already built
  61070. */
  61071. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61072. protected _inputRename(name: string): string;
  61073. protected _outputRename(name: string): string;
  61074. protected _dumpPropertiesCode(): string;
  61075. /** @hidden */
  61076. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61077. /** @hidden */
  61078. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61079. /**
  61080. * Clone the current block to a new identical block
  61081. * @param scene defines the hosting scene
  61082. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61083. * @returns a copy of the current block
  61084. */
  61085. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61086. /**
  61087. * Serializes this block in a JSON representation
  61088. * @returns the serialized block object
  61089. */
  61090. serialize(): any;
  61091. /** @hidden */
  61092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61093. /**
  61094. * Release resources
  61095. */
  61096. dispose(): void;
  61097. }
  61098. }
  61099. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61100. /**
  61101. * Enum defining the type of animations supported by InputBlock
  61102. */
  61103. export enum AnimatedInputBlockTypes {
  61104. /** No animation */
  61105. None = 0,
  61106. /** Time based animation. Will only work for floats */
  61107. Time = 1
  61108. }
  61109. }
  61110. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61112. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61113. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61114. import { Nullable } from "babylonjs/types";
  61115. import { Effect } from "babylonjs/Materials/effect";
  61116. import { Matrix } from "babylonjs/Maths/math.vector";
  61117. import { Scene } from "babylonjs/scene";
  61118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61120. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61121. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61122. import { Observable } from "babylonjs/Misc/observable";
  61123. /**
  61124. * Block used to expose an input value
  61125. */
  61126. export class InputBlock extends NodeMaterialBlock {
  61127. private _mode;
  61128. private _associatedVariableName;
  61129. private _storedValue;
  61130. private _valueCallback;
  61131. private _type;
  61132. private _animationType;
  61133. /** Gets or set a value used to limit the range of float values */
  61134. min: number;
  61135. /** Gets or set a value used to limit the range of float values */
  61136. max: number;
  61137. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61138. isBoolean: boolean;
  61139. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61140. matrixMode: number;
  61141. /** @hidden */
  61142. _systemValue: Nullable<NodeMaterialSystemValues>;
  61143. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61144. visibleInInspector: boolean;
  61145. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61146. isConstant: boolean;
  61147. /** Gets or sets the group to use to display this block in the Inspector */
  61148. groupInInspector: string;
  61149. /** Gets an observable raised when the value is changed */
  61150. onValueChangedObservable: Observable<InputBlock>;
  61151. /**
  61152. * Gets or sets the connection point type (default is float)
  61153. */
  61154. get type(): NodeMaterialBlockConnectionPointTypes;
  61155. /**
  61156. * Creates a new InputBlock
  61157. * @param name defines the block name
  61158. * @param target defines the target of that block (Vertex by default)
  61159. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61160. */
  61161. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61162. /**
  61163. * Gets the output component
  61164. */
  61165. get output(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Set the source of this connection point to a vertex attribute
  61168. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61169. * @returns the current connection point
  61170. */
  61171. setAsAttribute(attributeName?: string): InputBlock;
  61172. /**
  61173. * Set the source of this connection point to a system value
  61174. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61175. * @returns the current connection point
  61176. */
  61177. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61178. /**
  61179. * Gets or sets the value of that point.
  61180. * Please note that this value will be ignored if valueCallback is defined
  61181. */
  61182. get value(): any;
  61183. set value(value: any);
  61184. /**
  61185. * Gets or sets a callback used to get the value of that point.
  61186. * Please note that setting this value will force the connection point to ignore the value property
  61187. */
  61188. get valueCallback(): () => any;
  61189. set valueCallback(value: () => any);
  61190. /**
  61191. * Gets or sets the associated variable name in the shader
  61192. */
  61193. get associatedVariableName(): string;
  61194. set associatedVariableName(value: string);
  61195. /** Gets or sets the type of animation applied to the input */
  61196. get animationType(): AnimatedInputBlockTypes;
  61197. set animationType(value: AnimatedInputBlockTypes);
  61198. /**
  61199. * Gets a boolean indicating that this connection point not defined yet
  61200. */
  61201. get isUndefined(): boolean;
  61202. /**
  61203. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61204. * In this case the connection point name must be the name of the uniform to use.
  61205. * Can only be set on inputs
  61206. */
  61207. get isUniform(): boolean;
  61208. set isUniform(value: boolean);
  61209. /**
  61210. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61211. * In this case the connection point name must be the name of the attribute to use
  61212. * Can only be set on inputs
  61213. */
  61214. get isAttribute(): boolean;
  61215. set isAttribute(value: boolean);
  61216. /**
  61217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61218. * Can only be set on exit points
  61219. */
  61220. get isVarying(): boolean;
  61221. set isVarying(value: boolean);
  61222. /**
  61223. * Gets a boolean indicating that the current connection point is a system value
  61224. */
  61225. get isSystemValue(): boolean;
  61226. /**
  61227. * Gets or sets the current well known value or null if not defined as a system value
  61228. */
  61229. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61230. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61231. /**
  61232. * Gets the current class name
  61233. * @returns the class name
  61234. */
  61235. getClassName(): string;
  61236. /**
  61237. * Animate the input if animationType !== None
  61238. * @param scene defines the rendering scene
  61239. */
  61240. animate(scene: Scene): void;
  61241. private _emitDefine;
  61242. initialize(state: NodeMaterialBuildState): void;
  61243. /**
  61244. * Set the input block to its default value (based on its type)
  61245. */
  61246. setDefaultValue(): void;
  61247. private _emitConstant;
  61248. private _emit;
  61249. /** @hidden */
  61250. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61251. /** @hidden */
  61252. _transmit(effect: Effect, scene: Scene): void;
  61253. protected _buildBlock(state: NodeMaterialBuildState): void;
  61254. protected _dumpPropertiesCode(): string;
  61255. dispose(): void;
  61256. serialize(): any;
  61257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61258. }
  61259. }
  61260. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61261. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61262. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61263. import { Nullable } from "babylonjs/types";
  61264. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61265. import { Observable } from "babylonjs/Misc/observable";
  61266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61267. /**
  61268. * Enum used to define the compatibility state between two connection points
  61269. */
  61270. export enum NodeMaterialConnectionPointCompatibilityStates {
  61271. /** Points are compatibles */
  61272. Compatible = 0,
  61273. /** Points are incompatible because of their types */
  61274. TypeIncompatible = 1,
  61275. /** Points are incompatible because of their targets (vertex vs fragment) */
  61276. TargetIncompatible = 2
  61277. }
  61278. /**
  61279. * Defines the direction of a connection point
  61280. */
  61281. export enum NodeMaterialConnectionPointDirection {
  61282. /** Input */
  61283. Input = 0,
  61284. /** Output */
  61285. Output = 1
  61286. }
  61287. /**
  61288. * Defines a connection point for a block
  61289. */
  61290. export class NodeMaterialConnectionPoint {
  61291. /** @hidden */
  61292. _ownerBlock: NodeMaterialBlock;
  61293. /** @hidden */
  61294. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61295. private _endpoints;
  61296. private _associatedVariableName;
  61297. private _direction;
  61298. /** @hidden */
  61299. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61300. /** @hidden */
  61301. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61302. private _type;
  61303. /** @hidden */
  61304. _enforceAssociatedVariableName: boolean;
  61305. /** Gets the direction of the point */
  61306. get direction(): NodeMaterialConnectionPointDirection;
  61307. /**
  61308. * Gets or sets the additional types supported by this connection point
  61309. */
  61310. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61311. /**
  61312. * Gets or sets the additional types excluded by this connection point
  61313. */
  61314. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61315. /**
  61316. * Observable triggered when this point is connected
  61317. */
  61318. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61319. /**
  61320. * Gets or sets the associated variable name in the shader
  61321. */
  61322. get associatedVariableName(): string;
  61323. set associatedVariableName(value: string);
  61324. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61325. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61326. /**
  61327. * Gets or sets the connection point type (default is float)
  61328. */
  61329. get type(): NodeMaterialBlockConnectionPointTypes;
  61330. set type(value: NodeMaterialBlockConnectionPointTypes);
  61331. /**
  61332. * Gets or sets the connection point name
  61333. */
  61334. name: string;
  61335. /**
  61336. * Gets or sets a boolean indicating that this connection point can be omitted
  61337. */
  61338. isOptional: boolean;
  61339. /**
  61340. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61341. */
  61342. define: string;
  61343. /** @hidden */
  61344. _prioritizeVertex: boolean;
  61345. private _target;
  61346. /** Gets or sets the target of that connection point */
  61347. get target(): NodeMaterialBlockTargets;
  61348. set target(value: NodeMaterialBlockTargets);
  61349. /**
  61350. * Gets a boolean indicating that the current point is connected
  61351. */
  61352. get isConnected(): boolean;
  61353. /**
  61354. * Gets a boolean indicating that the current point is connected to an input block
  61355. */
  61356. get isConnectedToInputBlock(): boolean;
  61357. /**
  61358. * Gets a the connected input block (if any)
  61359. */
  61360. get connectInputBlock(): Nullable<InputBlock>;
  61361. /** Get the other side of the connection (if any) */
  61362. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61363. /** Get the block that owns this connection point */
  61364. get ownerBlock(): NodeMaterialBlock;
  61365. /** Get the block connected on the other side of this connection (if any) */
  61366. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61367. /** Get the block connected on the endpoints of this connection (if any) */
  61368. get connectedBlocks(): Array<NodeMaterialBlock>;
  61369. /** Gets the list of connected endpoints */
  61370. get endpoints(): NodeMaterialConnectionPoint[];
  61371. /** Gets a boolean indicating if that output point is connected to at least one input */
  61372. get hasEndpoints(): boolean;
  61373. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61374. get isConnectedInVertexShader(): boolean;
  61375. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61376. get isConnectedInFragmentShader(): boolean;
  61377. /**
  61378. * Creates a new connection point
  61379. * @param name defines the connection point name
  61380. * @param ownerBlock defines the block hosting this connection point
  61381. * @param direction defines the direction of the connection point
  61382. */
  61383. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61384. /**
  61385. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61386. * @returns the class name
  61387. */
  61388. getClassName(): string;
  61389. /**
  61390. * Gets a boolean indicating if the current point can be connected to another point
  61391. * @param connectionPoint defines the other connection point
  61392. * @returns a boolean
  61393. */
  61394. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61395. /**
  61396. * Gets a number indicating if the current point can be connected to another point
  61397. * @param connectionPoint defines the other connection point
  61398. * @returns a number defining the compatibility state
  61399. */
  61400. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61401. /**
  61402. * Connect this point to another connection point
  61403. * @param connectionPoint defines the other connection point
  61404. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61405. * @returns the current connection point
  61406. */
  61407. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61408. /**
  61409. * Disconnect this point from one of his endpoint
  61410. * @param endpoint defines the other connection point
  61411. * @returns the current connection point
  61412. */
  61413. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Serializes this point in a JSON representation
  61416. * @returns the serialized point object
  61417. */
  61418. serialize(): any;
  61419. /**
  61420. * Release resources
  61421. */
  61422. dispose(): void;
  61423. }
  61424. }
  61425. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61429. import { Mesh } from "babylonjs/Meshes/mesh";
  61430. import { Effect } from "babylonjs/Materials/effect";
  61431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61432. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61433. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61434. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61435. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61436. /**
  61437. * Block used to add support for vertex skinning (bones)
  61438. */
  61439. export class BonesBlock extends NodeMaterialBlock {
  61440. /**
  61441. * Creates a new BonesBlock
  61442. * @param name defines the block name
  61443. */
  61444. constructor(name: string);
  61445. /**
  61446. * Initialize the block and prepare the context for build
  61447. * @param state defines the state that will be used for the build
  61448. */
  61449. initialize(state: NodeMaterialBuildState): void;
  61450. /**
  61451. * Gets the current class name
  61452. * @returns the class name
  61453. */
  61454. getClassName(): string;
  61455. /**
  61456. * Gets the matrix indices input component
  61457. */
  61458. get matricesIndices(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the matrix weights input component
  61461. */
  61462. get matricesWeights(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the extra matrix indices input component
  61465. */
  61466. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the extra matrix weights input component
  61469. */
  61470. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the world input component
  61473. */
  61474. get world(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the output component
  61477. */
  61478. get output(): NodeMaterialConnectionPoint;
  61479. autoConfigure(material: NodeMaterial): void;
  61480. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61483. protected _buildBlock(state: NodeMaterialBuildState): this;
  61484. }
  61485. }
  61486. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61491. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61492. /**
  61493. * Block used to add support for instances
  61494. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61495. */
  61496. export class InstancesBlock extends NodeMaterialBlock {
  61497. /**
  61498. * Creates a new InstancesBlock
  61499. * @param name defines the block name
  61500. */
  61501. constructor(name: string);
  61502. /**
  61503. * Gets the current class name
  61504. * @returns the class name
  61505. */
  61506. getClassName(): string;
  61507. /**
  61508. * Gets the first world row input component
  61509. */
  61510. get world0(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the second world row input component
  61513. */
  61514. get world1(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the third world row input component
  61517. */
  61518. get world2(): NodeMaterialConnectionPoint;
  61519. /**
  61520. * Gets the forth world row input component
  61521. */
  61522. get world3(): NodeMaterialConnectionPoint;
  61523. /**
  61524. * Gets the world input component
  61525. */
  61526. get world(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the output component
  61529. */
  61530. get output(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the isntanceID component
  61533. */
  61534. get instanceID(): NodeMaterialConnectionPoint;
  61535. autoConfigure(material: NodeMaterial): void;
  61536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61537. protected _buildBlock(state: NodeMaterialBuildState): this;
  61538. }
  61539. }
  61540. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61545. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61546. import { Effect } from "babylonjs/Materials/effect";
  61547. import { Mesh } from "babylonjs/Meshes/mesh";
  61548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61550. /**
  61551. * Block used to add morph targets support to vertex shader
  61552. */
  61553. export class MorphTargetsBlock extends NodeMaterialBlock {
  61554. private _repeatableContentAnchor;
  61555. /**
  61556. * Create a new MorphTargetsBlock
  61557. * @param name defines the block name
  61558. */
  61559. constructor(name: string);
  61560. /**
  61561. * Gets the current class name
  61562. * @returns the class name
  61563. */
  61564. getClassName(): string;
  61565. /**
  61566. * Gets the position input component
  61567. */
  61568. get position(): NodeMaterialConnectionPoint;
  61569. /**
  61570. * Gets the normal input component
  61571. */
  61572. get normal(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the tangent input component
  61575. */
  61576. get tangent(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the tangent input component
  61579. */
  61580. get uv(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the position output component
  61583. */
  61584. get positionOutput(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the normal output component
  61587. */
  61588. get normalOutput(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the tangent output component
  61591. */
  61592. get tangentOutput(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the tangent output component
  61595. */
  61596. get uvOutput(): NodeMaterialConnectionPoint;
  61597. initialize(state: NodeMaterialBuildState): void;
  61598. autoConfigure(material: NodeMaterial): void;
  61599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61601. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61602. protected _buildBlock(state: NodeMaterialBuildState): this;
  61603. }
  61604. }
  61605. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61609. import { Nullable } from "babylonjs/types";
  61610. import { Scene } from "babylonjs/scene";
  61611. import { Effect } from "babylonjs/Materials/effect";
  61612. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61613. import { Mesh } from "babylonjs/Meshes/mesh";
  61614. import { Light } from "babylonjs/Lights/light";
  61615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61616. /**
  61617. * Block used to get data information from a light
  61618. */
  61619. export class LightInformationBlock extends NodeMaterialBlock {
  61620. private _lightDataUniformName;
  61621. private _lightColorUniformName;
  61622. private _lightTypeDefineName;
  61623. /**
  61624. * Gets or sets the light associated with this block
  61625. */
  61626. light: Nullable<Light>;
  61627. /**
  61628. * Creates a new LightInformationBlock
  61629. * @param name defines the block name
  61630. */
  61631. constructor(name: string);
  61632. /**
  61633. * Gets the current class name
  61634. * @returns the class name
  61635. */
  61636. getClassName(): string;
  61637. /**
  61638. * Gets the world position input component
  61639. */
  61640. get worldPosition(): NodeMaterialConnectionPoint;
  61641. /**
  61642. * Gets the direction output component
  61643. */
  61644. get direction(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the direction output component
  61647. */
  61648. get color(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the direction output component
  61651. */
  61652. get intensity(): NodeMaterialConnectionPoint;
  61653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61655. protected _buildBlock(state: NodeMaterialBuildState): this;
  61656. serialize(): any;
  61657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61658. }
  61659. }
  61660. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61661. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61662. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61663. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61664. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61665. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61666. }
  61667. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61672. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61673. import { Effect } from "babylonjs/Materials/effect";
  61674. import { Mesh } from "babylonjs/Meshes/mesh";
  61675. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61676. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61677. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61678. /**
  61679. * Block used to add image processing support to fragment shader
  61680. */
  61681. export class ImageProcessingBlock extends NodeMaterialBlock {
  61682. /**
  61683. * Create a new ImageProcessingBlock
  61684. * @param name defines the block name
  61685. */
  61686. constructor(name: string);
  61687. /**
  61688. * Gets the current class name
  61689. * @returns the class name
  61690. */
  61691. getClassName(): string;
  61692. /**
  61693. * Gets the color input component
  61694. */
  61695. get color(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the output component
  61698. */
  61699. get output(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Initialize the block and prepare the context for build
  61702. * @param state defines the state that will be used for the build
  61703. */
  61704. initialize(state: NodeMaterialBuildState): void;
  61705. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61708. protected _buildBlock(state: NodeMaterialBuildState): this;
  61709. }
  61710. }
  61711. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61715. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61717. import { Effect } from "babylonjs/Materials/effect";
  61718. import { Mesh } from "babylonjs/Meshes/mesh";
  61719. import { Scene } from "babylonjs/scene";
  61720. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61721. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61722. /**
  61723. * Block used to pertub normals based on a normal map
  61724. */
  61725. export class PerturbNormalBlock extends NodeMaterialBlock {
  61726. private _tangentSpaceParameterName;
  61727. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61728. invertX: boolean;
  61729. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61730. invertY: boolean;
  61731. /**
  61732. * Create a new PerturbNormalBlock
  61733. * @param name defines the block name
  61734. */
  61735. constructor(name: string);
  61736. /**
  61737. * Gets the current class name
  61738. * @returns the class name
  61739. */
  61740. getClassName(): string;
  61741. /**
  61742. * Gets the world position input component
  61743. */
  61744. get worldPosition(): NodeMaterialConnectionPoint;
  61745. /**
  61746. * Gets the world normal input component
  61747. */
  61748. get worldNormal(): NodeMaterialConnectionPoint;
  61749. /**
  61750. * Gets the world tangent input component
  61751. */
  61752. get worldTangent(): NodeMaterialConnectionPoint;
  61753. /**
  61754. * Gets the uv input component
  61755. */
  61756. get uv(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the normal map color input component
  61759. */
  61760. get normalMapColor(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the strength input component
  61763. */
  61764. get strength(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the output component
  61767. */
  61768. get output(): NodeMaterialConnectionPoint;
  61769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61771. autoConfigure(material: NodeMaterial): void;
  61772. protected _buildBlock(state: NodeMaterialBuildState): this;
  61773. protected _dumpPropertiesCode(): string;
  61774. serialize(): any;
  61775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61776. }
  61777. }
  61778. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61782. /**
  61783. * Block used to discard a pixel if a value is smaller than a cutoff
  61784. */
  61785. export class DiscardBlock extends NodeMaterialBlock {
  61786. /**
  61787. * Create a new DiscardBlock
  61788. * @param name defines the block name
  61789. */
  61790. constructor(name: string);
  61791. /**
  61792. * Gets the current class name
  61793. * @returns the class name
  61794. */
  61795. getClassName(): string;
  61796. /**
  61797. * Gets the color input component
  61798. */
  61799. get value(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the cutoff input component
  61802. */
  61803. get cutoff(): NodeMaterialConnectionPoint;
  61804. protected _buildBlock(state: NodeMaterialBuildState): this;
  61805. }
  61806. }
  61807. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61811. /**
  61812. * Block used to test if the fragment shader is front facing
  61813. */
  61814. export class FrontFacingBlock extends NodeMaterialBlock {
  61815. /**
  61816. * Creates a new FrontFacingBlock
  61817. * @param name defines the block name
  61818. */
  61819. constructor(name: string);
  61820. /**
  61821. * Gets the current class name
  61822. * @returns the class name
  61823. */
  61824. getClassName(): string;
  61825. /**
  61826. * Gets the output component
  61827. */
  61828. get output(): NodeMaterialConnectionPoint;
  61829. protected _buildBlock(state: NodeMaterialBuildState): this;
  61830. }
  61831. }
  61832. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61836. /**
  61837. * Block used to get the derivative value on x and y of a given input
  61838. */
  61839. export class DerivativeBlock extends NodeMaterialBlock {
  61840. /**
  61841. * Create a new DerivativeBlock
  61842. * @param name defines the block name
  61843. */
  61844. constructor(name: string);
  61845. /**
  61846. * Gets the current class name
  61847. * @returns the class name
  61848. */
  61849. getClassName(): string;
  61850. /**
  61851. * Gets the input component
  61852. */
  61853. get input(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the derivative output on x
  61856. */
  61857. get dx(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the derivative output on y
  61860. */
  61861. get dy(): NodeMaterialConnectionPoint;
  61862. protected _buildBlock(state: NodeMaterialBuildState): this;
  61863. }
  61864. }
  61865. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61866. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61867. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61868. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61869. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61870. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61871. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61872. }
  61873. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61876. import { Mesh } from "babylonjs/Meshes/mesh";
  61877. import { Effect } from "babylonjs/Materials/effect";
  61878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61880. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61881. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61882. /**
  61883. * Block used to add support for scene fog
  61884. */
  61885. export class FogBlock extends NodeMaterialBlock {
  61886. private _fogDistanceName;
  61887. private _fogParameters;
  61888. /**
  61889. * Create a new FogBlock
  61890. * @param name defines the block name
  61891. */
  61892. constructor(name: string);
  61893. /**
  61894. * Gets the current class name
  61895. * @returns the class name
  61896. */
  61897. getClassName(): string;
  61898. /**
  61899. * Gets the world position input component
  61900. */
  61901. get worldPosition(): NodeMaterialConnectionPoint;
  61902. /**
  61903. * Gets the view input component
  61904. */
  61905. get view(): NodeMaterialConnectionPoint;
  61906. /**
  61907. * Gets the color input component
  61908. */
  61909. get input(): NodeMaterialConnectionPoint;
  61910. /**
  61911. * Gets the fog color input component
  61912. */
  61913. get fogColor(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the output component
  61916. */
  61917. get output(): NodeMaterialConnectionPoint;
  61918. autoConfigure(material: NodeMaterial): void;
  61919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61921. protected _buildBlock(state: NodeMaterialBuildState): this;
  61922. }
  61923. }
  61924. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61929. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61930. import { Effect } from "babylonjs/Materials/effect";
  61931. import { Mesh } from "babylonjs/Meshes/mesh";
  61932. import { Light } from "babylonjs/Lights/light";
  61933. import { Nullable } from "babylonjs/types";
  61934. import { Scene } from "babylonjs/scene";
  61935. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61936. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61937. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61938. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61939. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61940. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61941. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61942. /**
  61943. * Block used to add light in the fragment shader
  61944. */
  61945. export class LightBlock extends NodeMaterialBlock {
  61946. private _lightId;
  61947. /**
  61948. * Gets or sets the light associated with this block
  61949. */
  61950. light: Nullable<Light>;
  61951. /**
  61952. * Create a new LightBlock
  61953. * @param name defines the block name
  61954. */
  61955. constructor(name: string);
  61956. /**
  61957. * Gets the current class name
  61958. * @returns the class name
  61959. */
  61960. getClassName(): string;
  61961. /**
  61962. * Gets the world position input component
  61963. */
  61964. get worldPosition(): NodeMaterialConnectionPoint;
  61965. /**
  61966. * Gets the world normal input component
  61967. */
  61968. get worldNormal(): NodeMaterialConnectionPoint;
  61969. /**
  61970. * Gets the camera (or eye) position component
  61971. */
  61972. get cameraPosition(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the glossiness component
  61975. */
  61976. get glossiness(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the glossinness power component
  61979. */
  61980. get glossPower(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the diffuse color component
  61983. */
  61984. get diffuseColor(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the specular color component
  61987. */
  61988. get specularColor(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the diffuse output component
  61991. */
  61992. get diffuseOutput(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the specular output component
  61995. */
  61996. get specularOutput(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the shadow output component
  61999. */
  62000. get shadow(): NodeMaterialConnectionPoint;
  62001. autoConfigure(material: NodeMaterial): void;
  62002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62003. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62005. private _injectVertexCode;
  62006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62007. serialize(): any;
  62008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62009. }
  62010. }
  62011. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62012. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62013. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62014. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62015. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62016. }
  62017. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62018. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62019. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62020. }
  62021. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62025. /**
  62026. * Block used to multiply 2 values
  62027. */
  62028. export class MultiplyBlock extends NodeMaterialBlock {
  62029. /**
  62030. * Creates a new MultiplyBlock
  62031. * @param name defines the block name
  62032. */
  62033. constructor(name: string);
  62034. /**
  62035. * Gets the current class name
  62036. * @returns the class name
  62037. */
  62038. getClassName(): string;
  62039. /**
  62040. * Gets the left operand input component
  62041. */
  62042. get left(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the right operand input component
  62045. */
  62046. get right(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the output component
  62049. */
  62050. get output(): NodeMaterialConnectionPoint;
  62051. protected _buildBlock(state: NodeMaterialBuildState): this;
  62052. }
  62053. }
  62054. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62058. /**
  62059. * Block used to add 2 vectors
  62060. */
  62061. export class AddBlock extends NodeMaterialBlock {
  62062. /**
  62063. * Creates a new AddBlock
  62064. * @param name defines the block name
  62065. */
  62066. constructor(name: string);
  62067. /**
  62068. * Gets the current class name
  62069. * @returns the class name
  62070. */
  62071. getClassName(): string;
  62072. /**
  62073. * Gets the left operand input component
  62074. */
  62075. get left(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the right operand input component
  62078. */
  62079. get right(): NodeMaterialConnectionPoint;
  62080. /**
  62081. * Gets the output component
  62082. */
  62083. get output(): NodeMaterialConnectionPoint;
  62084. protected _buildBlock(state: NodeMaterialBuildState): this;
  62085. }
  62086. }
  62087. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62091. /**
  62092. * Block used to scale a vector by a float
  62093. */
  62094. export class ScaleBlock extends NodeMaterialBlock {
  62095. /**
  62096. * Creates a new ScaleBlock
  62097. * @param name defines the block name
  62098. */
  62099. constructor(name: string);
  62100. /**
  62101. * Gets the current class name
  62102. * @returns the class name
  62103. */
  62104. getClassName(): string;
  62105. /**
  62106. * Gets the input component
  62107. */
  62108. get input(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the factor input component
  62111. */
  62112. get factor(): NodeMaterialConnectionPoint;
  62113. /**
  62114. * Gets the output component
  62115. */
  62116. get output(): NodeMaterialConnectionPoint;
  62117. protected _buildBlock(state: NodeMaterialBuildState): this;
  62118. }
  62119. }
  62120. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62124. import { Scene } from "babylonjs/scene";
  62125. /**
  62126. * Block used to clamp a float
  62127. */
  62128. export class ClampBlock extends NodeMaterialBlock {
  62129. /** Gets or sets the minimum range */
  62130. minimum: number;
  62131. /** Gets or sets the maximum range */
  62132. maximum: number;
  62133. /**
  62134. * Creates a new ClampBlock
  62135. * @param name defines the block name
  62136. */
  62137. constructor(name: string);
  62138. /**
  62139. * Gets the current class name
  62140. * @returns the class name
  62141. */
  62142. getClassName(): string;
  62143. /**
  62144. * Gets the value input component
  62145. */
  62146. get value(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the output component
  62149. */
  62150. get output(): NodeMaterialConnectionPoint;
  62151. protected _buildBlock(state: NodeMaterialBuildState): this;
  62152. protected _dumpPropertiesCode(): string;
  62153. serialize(): any;
  62154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62155. }
  62156. }
  62157. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62161. /**
  62162. * Block used to apply a cross product between 2 vectors
  62163. */
  62164. export class CrossBlock extends NodeMaterialBlock {
  62165. /**
  62166. * Creates a new CrossBlock
  62167. * @param name defines the block name
  62168. */
  62169. constructor(name: string);
  62170. /**
  62171. * Gets the current class name
  62172. * @returns the class name
  62173. */
  62174. getClassName(): string;
  62175. /**
  62176. * Gets the left operand input component
  62177. */
  62178. get left(): NodeMaterialConnectionPoint;
  62179. /**
  62180. * Gets the right operand input component
  62181. */
  62182. get right(): NodeMaterialConnectionPoint;
  62183. /**
  62184. * Gets the output component
  62185. */
  62186. get output(): NodeMaterialConnectionPoint;
  62187. protected _buildBlock(state: NodeMaterialBuildState): this;
  62188. }
  62189. }
  62190. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62194. /**
  62195. * Block used to apply a dot product between 2 vectors
  62196. */
  62197. export class DotBlock extends NodeMaterialBlock {
  62198. /**
  62199. * Creates a new DotBlock
  62200. * @param name defines the block name
  62201. */
  62202. constructor(name: string);
  62203. /**
  62204. * Gets the current class name
  62205. * @returns the class name
  62206. */
  62207. getClassName(): string;
  62208. /**
  62209. * Gets the left operand input component
  62210. */
  62211. get left(): NodeMaterialConnectionPoint;
  62212. /**
  62213. * Gets the right operand input component
  62214. */
  62215. get right(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the output component
  62218. */
  62219. get output(): NodeMaterialConnectionPoint;
  62220. protected _buildBlock(state: NodeMaterialBuildState): this;
  62221. }
  62222. }
  62223. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62227. import { Vector2 } from "babylonjs/Maths/math.vector";
  62228. import { Scene } from "babylonjs/scene";
  62229. /**
  62230. * Block used to remap a float from a range to a new one
  62231. */
  62232. export class RemapBlock extends NodeMaterialBlock {
  62233. /**
  62234. * Gets or sets the source range
  62235. */
  62236. sourceRange: Vector2;
  62237. /**
  62238. * Gets or sets the target range
  62239. */
  62240. targetRange: Vector2;
  62241. /**
  62242. * Creates a new RemapBlock
  62243. * @param name defines the block name
  62244. */
  62245. constructor(name: string);
  62246. /**
  62247. * Gets the current class name
  62248. * @returns the class name
  62249. */
  62250. getClassName(): string;
  62251. /**
  62252. * Gets the input component
  62253. */
  62254. get input(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the source min input component
  62257. */
  62258. get sourceMin(): NodeMaterialConnectionPoint;
  62259. /**
  62260. * Gets the source max input component
  62261. */
  62262. get sourceMax(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the target min input component
  62265. */
  62266. get targetMin(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the target max input component
  62269. */
  62270. get targetMax(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the output component
  62273. */
  62274. get output(): NodeMaterialConnectionPoint;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. protected _dumpPropertiesCode(): string;
  62277. serialize(): any;
  62278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62279. }
  62280. }
  62281. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62285. /**
  62286. * Block used to normalize a vector
  62287. */
  62288. export class NormalizeBlock extends NodeMaterialBlock {
  62289. /**
  62290. * Creates a new NormalizeBlock
  62291. * @param name defines the block name
  62292. */
  62293. constructor(name: string);
  62294. /**
  62295. * Gets the current class name
  62296. * @returns the class name
  62297. */
  62298. getClassName(): string;
  62299. /**
  62300. * Gets the input component
  62301. */
  62302. get input(): NodeMaterialConnectionPoint;
  62303. /**
  62304. * Gets the output component
  62305. */
  62306. get output(): NodeMaterialConnectionPoint;
  62307. protected _buildBlock(state: NodeMaterialBuildState): this;
  62308. }
  62309. }
  62310. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62314. import { Scene } from "babylonjs/scene";
  62315. /**
  62316. * Operations supported by the Trigonometry block
  62317. */
  62318. export enum TrigonometryBlockOperations {
  62319. /** Cos */
  62320. Cos = 0,
  62321. /** Sin */
  62322. Sin = 1,
  62323. /** Abs */
  62324. Abs = 2,
  62325. /** Exp */
  62326. Exp = 3,
  62327. /** Exp2 */
  62328. Exp2 = 4,
  62329. /** Round */
  62330. Round = 5,
  62331. /** Floor */
  62332. Floor = 6,
  62333. /** Ceiling */
  62334. Ceiling = 7,
  62335. /** Square root */
  62336. Sqrt = 8,
  62337. /** Log */
  62338. Log = 9,
  62339. /** Tangent */
  62340. Tan = 10,
  62341. /** Arc tangent */
  62342. ArcTan = 11,
  62343. /** Arc cosinus */
  62344. ArcCos = 12,
  62345. /** Arc sinus */
  62346. ArcSin = 13,
  62347. /** Fraction */
  62348. Fract = 14,
  62349. /** Sign */
  62350. Sign = 15,
  62351. /** To radians (from degrees) */
  62352. Radians = 16,
  62353. /** To degrees (from radians) */
  62354. Degrees = 17
  62355. }
  62356. /**
  62357. * Block used to apply trigonometry operation to floats
  62358. */
  62359. export class TrigonometryBlock extends NodeMaterialBlock {
  62360. /**
  62361. * Gets or sets the operation applied by the block
  62362. */
  62363. operation: TrigonometryBlockOperations;
  62364. /**
  62365. * Creates a new TrigonometryBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Gets the current class name
  62371. * @returns the class name
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * Gets the input component
  62376. */
  62377. get input(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. protected _buildBlock(state: NodeMaterialBuildState): this;
  62383. serialize(): any;
  62384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62385. protected _dumpPropertiesCode(): string;
  62386. }
  62387. }
  62388. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62392. /**
  62393. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62394. */
  62395. export class ColorMergerBlock extends NodeMaterialBlock {
  62396. /**
  62397. * Create a new ColorMergerBlock
  62398. * @param name defines the block name
  62399. */
  62400. constructor(name: string);
  62401. /**
  62402. * Gets the current class name
  62403. * @returns the class name
  62404. */
  62405. getClassName(): string;
  62406. /**
  62407. * Gets the rgb component (input)
  62408. */
  62409. get rgbIn(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the r component (input)
  62412. */
  62413. get r(): NodeMaterialConnectionPoint;
  62414. /**
  62415. * Gets the g component (input)
  62416. */
  62417. get g(): NodeMaterialConnectionPoint;
  62418. /**
  62419. * Gets the b component (input)
  62420. */
  62421. get b(): NodeMaterialConnectionPoint;
  62422. /**
  62423. * Gets the a component (input)
  62424. */
  62425. get a(): NodeMaterialConnectionPoint;
  62426. /**
  62427. * Gets the rgba component (output)
  62428. */
  62429. get rgba(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the rgb component (output)
  62432. */
  62433. get rgbOut(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the rgb component (output)
  62436. * @deprecated Please use rgbOut instead.
  62437. */
  62438. get rgb(): NodeMaterialConnectionPoint;
  62439. protected _buildBlock(state: NodeMaterialBuildState): this;
  62440. }
  62441. }
  62442. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62446. /**
  62447. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62448. */
  62449. export class VectorMergerBlock extends NodeMaterialBlock {
  62450. /**
  62451. * Create a new VectorMergerBlock
  62452. * @param name defines the block name
  62453. */
  62454. constructor(name: string);
  62455. /**
  62456. * Gets the current class name
  62457. * @returns the class name
  62458. */
  62459. getClassName(): string;
  62460. /**
  62461. * Gets the xyz component (input)
  62462. */
  62463. get xyzIn(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the xy component (input)
  62466. */
  62467. get xyIn(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the x component (input)
  62470. */
  62471. get x(): NodeMaterialConnectionPoint;
  62472. /**
  62473. * Gets the y component (input)
  62474. */
  62475. get y(): NodeMaterialConnectionPoint;
  62476. /**
  62477. * Gets the z component (input)
  62478. */
  62479. get z(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the w component (input)
  62482. */
  62483. get w(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the xyzw component (output)
  62486. */
  62487. get xyzw(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the xyz component (output)
  62490. */
  62491. get xyzOut(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the xy component (output)
  62494. */
  62495. get xyOut(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the xy component (output)
  62498. * @deprecated Please use xyOut instead.
  62499. */
  62500. get xy(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the xyz component (output)
  62503. * @deprecated Please use xyzOut instead.
  62504. */
  62505. get xyz(): NodeMaterialConnectionPoint;
  62506. protected _buildBlock(state: NodeMaterialBuildState): this;
  62507. }
  62508. }
  62509. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62513. /**
  62514. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62515. */
  62516. export class ColorSplitterBlock extends NodeMaterialBlock {
  62517. /**
  62518. * Create a new ColorSplitterBlock
  62519. * @param name defines the block name
  62520. */
  62521. constructor(name: string);
  62522. /**
  62523. * Gets the current class name
  62524. * @returns the class name
  62525. */
  62526. getClassName(): string;
  62527. /**
  62528. * Gets the rgba component (input)
  62529. */
  62530. get rgba(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the rgb component (input)
  62533. */
  62534. get rgbIn(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the rgb component (output)
  62537. */
  62538. get rgbOut(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the r component (output)
  62541. */
  62542. get r(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the g component (output)
  62545. */
  62546. get g(): NodeMaterialConnectionPoint;
  62547. /**
  62548. * Gets the b component (output)
  62549. */
  62550. get b(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the a component (output)
  62553. */
  62554. get a(): NodeMaterialConnectionPoint;
  62555. protected _inputRename(name: string): string;
  62556. protected _outputRename(name: string): string;
  62557. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62558. }
  62559. }
  62560. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62564. /**
  62565. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62566. */
  62567. export class VectorSplitterBlock extends NodeMaterialBlock {
  62568. /**
  62569. * Create a new VectorSplitterBlock
  62570. * @param name defines the block name
  62571. */
  62572. constructor(name: string);
  62573. /**
  62574. * Gets the current class name
  62575. * @returns the class name
  62576. */
  62577. getClassName(): string;
  62578. /**
  62579. * Gets the xyzw component (input)
  62580. */
  62581. get xyzw(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the xyz component (input)
  62584. */
  62585. get xyzIn(): NodeMaterialConnectionPoint;
  62586. /**
  62587. * Gets the xy component (input)
  62588. */
  62589. get xyIn(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the xyz component (output)
  62592. */
  62593. get xyzOut(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the xy component (output)
  62596. */
  62597. get xyOut(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the x component (output)
  62600. */
  62601. get x(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the y component (output)
  62604. */
  62605. get y(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the z component (output)
  62608. */
  62609. get z(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the w component (output)
  62612. */
  62613. get w(): NodeMaterialConnectionPoint;
  62614. protected _inputRename(name: string): string;
  62615. protected _outputRename(name: string): string;
  62616. protected _buildBlock(state: NodeMaterialBuildState): this;
  62617. }
  62618. }
  62619. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62623. /**
  62624. * Block used to lerp between 2 values
  62625. */
  62626. export class LerpBlock extends NodeMaterialBlock {
  62627. /**
  62628. * Creates a new LerpBlock
  62629. * @param name defines the block name
  62630. */
  62631. constructor(name: string);
  62632. /**
  62633. * Gets the current class name
  62634. * @returns the class name
  62635. */
  62636. getClassName(): string;
  62637. /**
  62638. * Gets the left operand input component
  62639. */
  62640. get left(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the right operand input component
  62643. */
  62644. get right(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the gradient operand input component
  62647. */
  62648. get gradient(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the output component
  62651. */
  62652. get output(): NodeMaterialConnectionPoint;
  62653. protected _buildBlock(state: NodeMaterialBuildState): this;
  62654. }
  62655. }
  62656. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62660. /**
  62661. * Block used to divide 2 vectors
  62662. */
  62663. export class DivideBlock extends NodeMaterialBlock {
  62664. /**
  62665. * Creates a new DivideBlock
  62666. * @param name defines the block name
  62667. */
  62668. constructor(name: string);
  62669. /**
  62670. * Gets the current class name
  62671. * @returns the class name
  62672. */
  62673. getClassName(): string;
  62674. /**
  62675. * Gets the left operand input component
  62676. */
  62677. get left(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the right operand input component
  62680. */
  62681. get right(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the output component
  62684. */
  62685. get output(): NodeMaterialConnectionPoint;
  62686. protected _buildBlock(state: NodeMaterialBuildState): this;
  62687. }
  62688. }
  62689. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62693. /**
  62694. * Block used to subtract 2 vectors
  62695. */
  62696. export class SubtractBlock extends NodeMaterialBlock {
  62697. /**
  62698. * Creates a new SubtractBlock
  62699. * @param name defines the block name
  62700. */
  62701. constructor(name: string);
  62702. /**
  62703. * Gets the current class name
  62704. * @returns the class name
  62705. */
  62706. getClassName(): string;
  62707. /**
  62708. * Gets the left operand input component
  62709. */
  62710. get left(): NodeMaterialConnectionPoint;
  62711. /**
  62712. * Gets the right operand input component
  62713. */
  62714. get right(): NodeMaterialConnectionPoint;
  62715. /**
  62716. * Gets the output component
  62717. */
  62718. get output(): NodeMaterialConnectionPoint;
  62719. protected _buildBlock(state: NodeMaterialBuildState): this;
  62720. }
  62721. }
  62722. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62726. /**
  62727. * Block used to step a value
  62728. */
  62729. export class StepBlock extends NodeMaterialBlock {
  62730. /**
  62731. * Creates a new StepBlock
  62732. * @param name defines the block name
  62733. */
  62734. constructor(name: string);
  62735. /**
  62736. * Gets the current class name
  62737. * @returns the class name
  62738. */
  62739. getClassName(): string;
  62740. /**
  62741. * Gets the value operand input component
  62742. */
  62743. get value(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the edge operand input component
  62746. */
  62747. get edge(): NodeMaterialConnectionPoint;
  62748. /**
  62749. * Gets the output component
  62750. */
  62751. get output(): NodeMaterialConnectionPoint;
  62752. protected _buildBlock(state: NodeMaterialBuildState): this;
  62753. }
  62754. }
  62755. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62759. /**
  62760. * Block used to get the opposite (1 - x) of a value
  62761. */
  62762. export class OneMinusBlock extends NodeMaterialBlock {
  62763. /**
  62764. * Creates a new OneMinusBlock
  62765. * @param name defines the block name
  62766. */
  62767. constructor(name: string);
  62768. /**
  62769. * Gets the current class name
  62770. * @returns the class name
  62771. */
  62772. getClassName(): string;
  62773. /**
  62774. * Gets the input component
  62775. */
  62776. get input(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the output component
  62779. */
  62780. get output(): NodeMaterialConnectionPoint;
  62781. protected _buildBlock(state: NodeMaterialBuildState): this;
  62782. }
  62783. }
  62784. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62788. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62789. /**
  62790. * Block used to get the view direction
  62791. */
  62792. export class ViewDirectionBlock extends NodeMaterialBlock {
  62793. /**
  62794. * Creates a new ViewDirectionBlock
  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 world position component
  62805. */
  62806. get worldPosition(): NodeMaterialConnectionPoint;
  62807. /**
  62808. * Gets the camera position component
  62809. */
  62810. get cameraPosition(): NodeMaterialConnectionPoint;
  62811. /**
  62812. * Gets the output component
  62813. */
  62814. get output(): NodeMaterialConnectionPoint;
  62815. autoConfigure(material: NodeMaterial): void;
  62816. protected _buildBlock(state: NodeMaterialBuildState): this;
  62817. }
  62818. }
  62819. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62823. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62824. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62825. /**
  62826. * Block used to compute fresnel value
  62827. */
  62828. export class FresnelBlock extends NodeMaterialBlock {
  62829. /**
  62830. * Create a new FresnelBlock
  62831. * @param name defines the block name
  62832. */
  62833. constructor(name: string);
  62834. /**
  62835. * Gets the current class name
  62836. * @returns the class name
  62837. */
  62838. getClassName(): string;
  62839. /**
  62840. * Gets the world normal input component
  62841. */
  62842. get worldNormal(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the view direction input component
  62845. */
  62846. get viewDirection(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the bias input component
  62849. */
  62850. get bias(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the camera (or eye) position component
  62853. */
  62854. get power(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the fresnel output component
  62857. */
  62858. get fresnel(): NodeMaterialConnectionPoint;
  62859. autoConfigure(material: NodeMaterial): void;
  62860. protected _buildBlock(state: NodeMaterialBuildState): this;
  62861. }
  62862. }
  62863. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62867. /**
  62868. * Block used to get the max of 2 values
  62869. */
  62870. export class MaxBlock extends NodeMaterialBlock {
  62871. /**
  62872. * Creates a new MaxBlock
  62873. * @param name defines the block name
  62874. */
  62875. constructor(name: string);
  62876. /**
  62877. * Gets the current class name
  62878. * @returns the class name
  62879. */
  62880. getClassName(): string;
  62881. /**
  62882. * Gets the left operand input component
  62883. */
  62884. get left(): NodeMaterialConnectionPoint;
  62885. /**
  62886. * Gets the right operand input component
  62887. */
  62888. get right(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the output component
  62891. */
  62892. get output(): NodeMaterialConnectionPoint;
  62893. protected _buildBlock(state: NodeMaterialBuildState): this;
  62894. }
  62895. }
  62896. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62900. /**
  62901. * Block used to get the min of 2 values
  62902. */
  62903. export class MinBlock extends NodeMaterialBlock {
  62904. /**
  62905. * Creates a new MinBlock
  62906. * @param name defines the block name
  62907. */
  62908. constructor(name: string);
  62909. /**
  62910. * Gets the current class name
  62911. * @returns the class name
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Gets the left operand input component
  62916. */
  62917. get left(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the right operand input component
  62920. */
  62921. get right(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the output component
  62924. */
  62925. get output(): NodeMaterialConnectionPoint;
  62926. protected _buildBlock(state: NodeMaterialBuildState): this;
  62927. }
  62928. }
  62929. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62933. /**
  62934. * Block used to get the distance between 2 values
  62935. */
  62936. export class DistanceBlock extends NodeMaterialBlock {
  62937. /**
  62938. * Creates a new DistanceBlock
  62939. * @param name defines the block name
  62940. */
  62941. constructor(name: string);
  62942. /**
  62943. * Gets the current class name
  62944. * @returns the class name
  62945. */
  62946. getClassName(): string;
  62947. /**
  62948. * Gets the left operand input component
  62949. */
  62950. get left(): NodeMaterialConnectionPoint;
  62951. /**
  62952. * Gets the right operand input component
  62953. */
  62954. get right(): NodeMaterialConnectionPoint;
  62955. /**
  62956. * Gets the output component
  62957. */
  62958. get output(): NodeMaterialConnectionPoint;
  62959. protected _buildBlock(state: NodeMaterialBuildState): this;
  62960. }
  62961. }
  62962. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62966. /**
  62967. * Block used to get the length of a vector
  62968. */
  62969. export class LengthBlock extends NodeMaterialBlock {
  62970. /**
  62971. * Creates a new LengthBlock
  62972. * @param name defines the block name
  62973. */
  62974. constructor(name: string);
  62975. /**
  62976. * Gets the current class name
  62977. * @returns the class name
  62978. */
  62979. getClassName(): string;
  62980. /**
  62981. * Gets the value input component
  62982. */
  62983. get value(): NodeMaterialConnectionPoint;
  62984. /**
  62985. * Gets the output component
  62986. */
  62987. get output(): NodeMaterialConnectionPoint;
  62988. protected _buildBlock(state: NodeMaterialBuildState): this;
  62989. }
  62990. }
  62991. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62995. /**
  62996. * Block used to get negative version of a value (i.e. x * -1)
  62997. */
  62998. export class NegateBlock extends NodeMaterialBlock {
  62999. /**
  63000. * Creates a new NegateBlock
  63001. * @param name defines the block name
  63002. */
  63003. constructor(name: string);
  63004. /**
  63005. * Gets the current class name
  63006. * @returns the class name
  63007. */
  63008. getClassName(): string;
  63009. /**
  63010. * Gets the value input component
  63011. */
  63012. get value(): NodeMaterialConnectionPoint;
  63013. /**
  63014. * Gets the output component
  63015. */
  63016. get output(): NodeMaterialConnectionPoint;
  63017. protected _buildBlock(state: NodeMaterialBuildState): this;
  63018. }
  63019. }
  63020. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63024. /**
  63025. * Block used to get the value of the first parameter raised to the power of the second
  63026. */
  63027. export class PowBlock extends NodeMaterialBlock {
  63028. /**
  63029. * Creates a new PowBlock
  63030. * @param name defines the block name
  63031. */
  63032. constructor(name: string);
  63033. /**
  63034. * Gets the current class name
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Gets the value operand input component
  63040. */
  63041. get value(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the power operand input component
  63044. */
  63045. get power(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the output component
  63048. */
  63049. get output(): NodeMaterialConnectionPoint;
  63050. protected _buildBlock(state: NodeMaterialBuildState): this;
  63051. }
  63052. }
  63053. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63057. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63058. /**
  63059. * Block used to get a random number
  63060. */
  63061. export class RandomNumberBlock extends NodeMaterialBlock {
  63062. /**
  63063. * Creates a new RandomNumberBlock
  63064. * @param name defines the block name
  63065. */
  63066. constructor(name: string);
  63067. /**
  63068. * Gets the current class name
  63069. * @returns the class name
  63070. */
  63071. getClassName(): string;
  63072. /**
  63073. * Gets the seed input component
  63074. */
  63075. get seed(): 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/arcTan2Block" {
  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. /**
  63088. * Block used to compute arc tangent of 2 values
  63089. */
  63090. export class ArcTan2Block extends NodeMaterialBlock {
  63091. /**
  63092. * Creates a new ArcTan2Block
  63093. * @param name defines the block name
  63094. */
  63095. constructor(name: string);
  63096. /**
  63097. * Gets the current class name
  63098. * @returns the class name
  63099. */
  63100. getClassName(): string;
  63101. /**
  63102. * Gets the x operand input component
  63103. */
  63104. get x(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the y operand input component
  63107. */
  63108. get y(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the output component
  63111. */
  63112. get output(): NodeMaterialConnectionPoint;
  63113. protected _buildBlock(state: NodeMaterialBuildState): this;
  63114. }
  63115. }
  63116. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63120. /**
  63121. * Block used to smooth step a value
  63122. */
  63123. export class SmoothStepBlock extends NodeMaterialBlock {
  63124. /**
  63125. * Creates a new SmoothStepBlock
  63126. * @param name defines the block name
  63127. */
  63128. constructor(name: string);
  63129. /**
  63130. * Gets the current class name
  63131. * @returns the class name
  63132. */
  63133. getClassName(): string;
  63134. /**
  63135. * Gets the value operand input component
  63136. */
  63137. get value(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the first edge operand input component
  63140. */
  63141. get edge0(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the second edge operand input component
  63144. */
  63145. get edge1(): NodeMaterialConnectionPoint;
  63146. /**
  63147. * Gets the output component
  63148. */
  63149. get output(): NodeMaterialConnectionPoint;
  63150. protected _buildBlock(state: NodeMaterialBuildState): this;
  63151. }
  63152. }
  63153. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63157. /**
  63158. * Block used to get the reciprocal (1 / x) of a value
  63159. */
  63160. export class ReciprocalBlock extends NodeMaterialBlock {
  63161. /**
  63162. * Creates a new ReciprocalBlock
  63163. * @param name defines the block name
  63164. */
  63165. constructor(name: string);
  63166. /**
  63167. * Gets the current class name
  63168. * @returns the class name
  63169. */
  63170. getClassName(): string;
  63171. /**
  63172. * Gets the input component
  63173. */
  63174. get input(): NodeMaterialConnectionPoint;
  63175. /**
  63176. * Gets the output component
  63177. */
  63178. get output(): NodeMaterialConnectionPoint;
  63179. protected _buildBlock(state: NodeMaterialBuildState): this;
  63180. }
  63181. }
  63182. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63186. /**
  63187. * Block used to replace a color by another one
  63188. */
  63189. export class ReplaceColorBlock extends NodeMaterialBlock {
  63190. /**
  63191. * Creates a new ReplaceColorBlock
  63192. * @param name defines the block name
  63193. */
  63194. constructor(name: string);
  63195. /**
  63196. * Gets the current class name
  63197. * @returns the class name
  63198. */
  63199. getClassName(): string;
  63200. /**
  63201. * Gets the value input component
  63202. */
  63203. get value(): NodeMaterialConnectionPoint;
  63204. /**
  63205. * Gets the reference input component
  63206. */
  63207. get reference(): NodeMaterialConnectionPoint;
  63208. /**
  63209. * Gets the distance input component
  63210. */
  63211. get distance(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the replacement input component
  63214. */
  63215. get replacement(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the output component
  63218. */
  63219. get output(): NodeMaterialConnectionPoint;
  63220. protected _buildBlock(state: NodeMaterialBuildState): this;
  63221. }
  63222. }
  63223. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63227. /**
  63228. * Block used to posterize a value
  63229. * @see https://en.wikipedia.org/wiki/Posterization
  63230. */
  63231. export class PosterizeBlock extends NodeMaterialBlock {
  63232. /**
  63233. * Creates a new PosterizeBlock
  63234. * @param name defines the block name
  63235. */
  63236. constructor(name: string);
  63237. /**
  63238. * Gets the current class name
  63239. * @returns the class name
  63240. */
  63241. getClassName(): string;
  63242. /**
  63243. * Gets the value input component
  63244. */
  63245. get value(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the steps input component
  63248. */
  63249. get steps(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the output component
  63252. */
  63253. get output(): NodeMaterialConnectionPoint;
  63254. protected _buildBlock(state: NodeMaterialBuildState): this;
  63255. }
  63256. }
  63257. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63261. import { Scene } from "babylonjs/scene";
  63262. /**
  63263. * Operations supported by the Wave block
  63264. */
  63265. export enum WaveBlockKind {
  63266. /** SawTooth */
  63267. SawTooth = 0,
  63268. /** Square */
  63269. Square = 1,
  63270. /** Triangle */
  63271. Triangle = 2
  63272. }
  63273. /**
  63274. * Block used to apply wave operation to floats
  63275. */
  63276. export class WaveBlock extends NodeMaterialBlock {
  63277. /**
  63278. * Gets or sets the kibnd of wave to be applied by the block
  63279. */
  63280. kind: WaveBlockKind;
  63281. /**
  63282. * Creates a new WaveBlock
  63283. * @param name defines the block name
  63284. */
  63285. constructor(name: string);
  63286. /**
  63287. * Gets the current class name
  63288. * @returns the class name
  63289. */
  63290. getClassName(): string;
  63291. /**
  63292. * Gets the input component
  63293. */
  63294. get input(): NodeMaterialConnectionPoint;
  63295. /**
  63296. * Gets the output component
  63297. */
  63298. get output(): NodeMaterialConnectionPoint;
  63299. protected _buildBlock(state: NodeMaterialBuildState): this;
  63300. serialize(): any;
  63301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63302. }
  63303. }
  63304. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63308. import { Color3 } from "babylonjs/Maths/math.color";
  63309. import { Scene } from "babylonjs/scene";
  63310. /**
  63311. * Class used to store a color step for the GradientBlock
  63312. */
  63313. export class GradientBlockColorStep {
  63314. /**
  63315. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63316. */
  63317. step: number;
  63318. /**
  63319. * Gets or sets the color associated with this step
  63320. */
  63321. color: Color3;
  63322. /**
  63323. * Creates a new GradientBlockColorStep
  63324. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63325. * @param color defines the color associated with this step
  63326. */
  63327. constructor(
  63328. /**
  63329. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63330. */
  63331. step: number,
  63332. /**
  63333. * Gets or sets the color associated with this step
  63334. */
  63335. color: Color3);
  63336. }
  63337. /**
  63338. * Block used to return a color from a gradient based on an input value between 0 and 1
  63339. */
  63340. export class GradientBlock extends NodeMaterialBlock {
  63341. /**
  63342. * Gets or sets the list of color steps
  63343. */
  63344. colorSteps: GradientBlockColorStep[];
  63345. /**
  63346. * Creates a new GradientBlock
  63347. * @param name defines the block name
  63348. */
  63349. constructor(name: string);
  63350. /**
  63351. * Gets the current class name
  63352. * @returns the class name
  63353. */
  63354. getClassName(): string;
  63355. /**
  63356. * Gets the gradient input component
  63357. */
  63358. get gradient(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the output component
  63361. */
  63362. get output(): NodeMaterialConnectionPoint;
  63363. private _writeColorConstant;
  63364. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63365. serialize(): any;
  63366. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63367. protected _dumpPropertiesCode(): string;
  63368. }
  63369. }
  63370. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63374. /**
  63375. * Block used to normalize lerp between 2 values
  63376. */
  63377. export class NLerpBlock extends NodeMaterialBlock {
  63378. /**
  63379. * Creates a new NLerpBlock
  63380. * @param name defines the block name
  63381. */
  63382. constructor(name: string);
  63383. /**
  63384. * Gets the current class name
  63385. * @returns the class name
  63386. */
  63387. getClassName(): string;
  63388. /**
  63389. * Gets the left operand input component
  63390. */
  63391. get left(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the right operand input component
  63394. */
  63395. get right(): NodeMaterialConnectionPoint;
  63396. /**
  63397. * Gets the gradient operand input component
  63398. */
  63399. get gradient(): NodeMaterialConnectionPoint;
  63400. /**
  63401. * Gets the output component
  63402. */
  63403. get output(): NodeMaterialConnectionPoint;
  63404. protected _buildBlock(state: NodeMaterialBuildState): this;
  63405. }
  63406. }
  63407. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63411. import { Scene } from "babylonjs/scene";
  63412. /**
  63413. * block used to Generate a Worley Noise 3D Noise Pattern
  63414. */
  63415. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63416. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63417. manhattanDistance: boolean;
  63418. /**
  63419. * Creates a new WorleyNoise3DBlock
  63420. * @param name defines the block name
  63421. */
  63422. constructor(name: string);
  63423. /**
  63424. * Gets the current class name
  63425. * @returns the class name
  63426. */
  63427. getClassName(): string;
  63428. /**
  63429. * Gets the seed input component
  63430. */
  63431. get seed(): NodeMaterialConnectionPoint;
  63432. /**
  63433. * Gets the jitter input component
  63434. */
  63435. get jitter(): NodeMaterialConnectionPoint;
  63436. /**
  63437. * Gets the output component
  63438. */
  63439. get output(): NodeMaterialConnectionPoint;
  63440. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63441. /**
  63442. * Exposes the properties to the UI?
  63443. */
  63444. protected _dumpPropertiesCode(): string;
  63445. /**
  63446. * Exposes the properties to the Seralize?
  63447. */
  63448. serialize(): any;
  63449. /**
  63450. * Exposes the properties to the deseralize?
  63451. */
  63452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63453. }
  63454. }
  63455. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63459. /**
  63460. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63461. */
  63462. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63463. /**
  63464. * Creates a new SimplexPerlin3DBlock
  63465. * @param name defines the block name
  63466. */
  63467. constructor(name: string);
  63468. /**
  63469. * Gets the current class name
  63470. * @returns the class name
  63471. */
  63472. getClassName(): string;
  63473. /**
  63474. * Gets the seed operand input component
  63475. */
  63476. get seed(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the output component
  63479. */
  63480. get output(): NodeMaterialConnectionPoint;
  63481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63482. }
  63483. }
  63484. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63488. /**
  63489. * Block used to blend normals
  63490. */
  63491. export class NormalBlendBlock extends NodeMaterialBlock {
  63492. /**
  63493. * Creates a new NormalBlendBlock
  63494. * @param name defines the block name
  63495. */
  63496. constructor(name: string);
  63497. /**
  63498. * Gets the current class name
  63499. * @returns the class name
  63500. */
  63501. getClassName(): string;
  63502. /**
  63503. * Gets the first input component
  63504. */
  63505. get normalMap0(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the second input component
  63508. */
  63509. get normalMap1(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the output component
  63512. */
  63513. get output(): NodeMaterialConnectionPoint;
  63514. protected _buildBlock(state: NodeMaterialBuildState): this;
  63515. }
  63516. }
  63517. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63521. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63522. /**
  63523. * Block used to rotate a 2d vector by a given angle
  63524. */
  63525. export class Rotate2dBlock extends NodeMaterialBlock {
  63526. /**
  63527. * Creates a new Rotate2dBlock
  63528. * @param name defines the block name
  63529. */
  63530. constructor(name: string);
  63531. /**
  63532. * Gets the current class name
  63533. * @returns the class name
  63534. */
  63535. getClassName(): string;
  63536. /**
  63537. * Gets the input vector
  63538. */
  63539. get input(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the input angle
  63542. */
  63543. get angle(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the output component
  63546. */
  63547. get output(): NodeMaterialConnectionPoint;
  63548. autoConfigure(material: NodeMaterial): void;
  63549. protected _buildBlock(state: NodeMaterialBuildState): this;
  63550. }
  63551. }
  63552. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63556. /**
  63557. * Block used to get the reflected vector from a direction and a normal
  63558. */
  63559. export class ReflectBlock extends NodeMaterialBlock {
  63560. /**
  63561. * Creates a new ReflectBlock
  63562. * @param name defines the block name
  63563. */
  63564. constructor(name: string);
  63565. /**
  63566. * Gets the current class name
  63567. * @returns the class name
  63568. */
  63569. getClassName(): string;
  63570. /**
  63571. * Gets the incident component
  63572. */
  63573. get incident(): NodeMaterialConnectionPoint;
  63574. /**
  63575. * Gets the normal component
  63576. */
  63577. get normal(): NodeMaterialConnectionPoint;
  63578. /**
  63579. * Gets the output component
  63580. */
  63581. get output(): NodeMaterialConnectionPoint;
  63582. protected _buildBlock(state: NodeMaterialBuildState): this;
  63583. }
  63584. }
  63585. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63589. /**
  63590. * Block used to get the refracted vector from a direction and a normal
  63591. */
  63592. export class RefractBlock extends NodeMaterialBlock {
  63593. /**
  63594. * Creates a new RefractBlock
  63595. * @param name defines the block name
  63596. */
  63597. constructor(name: string);
  63598. /**
  63599. * Gets the current class name
  63600. * @returns the class name
  63601. */
  63602. getClassName(): string;
  63603. /**
  63604. * Gets the incident component
  63605. */
  63606. get incident(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the normal component
  63609. */
  63610. get normal(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the index of refraction component
  63613. */
  63614. get ior(): NodeMaterialConnectionPoint;
  63615. /**
  63616. * Gets the output component
  63617. */
  63618. get output(): NodeMaterialConnectionPoint;
  63619. protected _buildBlock(state: NodeMaterialBuildState): this;
  63620. }
  63621. }
  63622. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63626. /**
  63627. * Block used to desaturate a color
  63628. */
  63629. export class DesaturateBlock extends NodeMaterialBlock {
  63630. /**
  63631. * Creates a new DesaturateBlock
  63632. * @param name defines the block name
  63633. */
  63634. constructor(name: string);
  63635. /**
  63636. * Gets the current class name
  63637. * @returns the class name
  63638. */
  63639. getClassName(): string;
  63640. /**
  63641. * Gets the color operand input component
  63642. */
  63643. get color(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the level operand input component
  63646. */
  63647. get level(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the output component
  63650. */
  63651. get output(): NodeMaterialConnectionPoint;
  63652. protected _buildBlock(state: NodeMaterialBuildState): this;
  63653. }
  63654. }
  63655. declare module "babylonjs/Materials/Node/Blocks/index" {
  63656. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63657. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63658. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63659. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63660. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63661. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63662. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63663. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63664. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63665. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63666. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63667. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63668. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63669. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63670. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63671. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63672. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63673. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63674. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63675. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63676. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63677. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63678. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63679. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63680. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63681. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63682. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63683. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63684. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63685. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63686. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63687. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63688. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63689. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63690. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63700. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63702. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63703. }
  63704. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63705. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63706. }
  63707. declare module "babylonjs/Materials/Node/index" {
  63708. export * from "babylonjs/Materials/Node/Enums/index";
  63709. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63710. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63711. export * from "babylonjs/Materials/Node/nodeMaterial";
  63712. export * from "babylonjs/Materials/Node/Blocks/index";
  63713. export * from "babylonjs/Materials/Node/Optimizers/index";
  63714. }
  63715. declare module "babylonjs/Materials/effectRenderer" {
  63716. import { Nullable } from "babylonjs/types";
  63717. import { Texture } from "babylonjs/Materials/Textures/texture";
  63718. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63719. import { Viewport } from "babylonjs/Maths/math.viewport";
  63720. import { Observable } from "babylonjs/Misc/observable";
  63721. import { Effect } from "babylonjs/Materials/effect";
  63722. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63723. import "babylonjs/Shaders/postprocess.vertex";
  63724. /**
  63725. * Effect Render Options
  63726. */
  63727. export interface IEffectRendererOptions {
  63728. /**
  63729. * Defines the vertices positions.
  63730. */
  63731. positions?: number[];
  63732. /**
  63733. * Defines the indices.
  63734. */
  63735. indices?: number[];
  63736. }
  63737. /**
  63738. * Helper class to render one or more effects
  63739. */
  63740. export class EffectRenderer {
  63741. private engine;
  63742. private static _DefaultOptions;
  63743. private _vertexBuffers;
  63744. private _indexBuffer;
  63745. private _ringBufferIndex;
  63746. private _ringScreenBuffer;
  63747. private _fullscreenViewport;
  63748. private _getNextFrameBuffer;
  63749. /**
  63750. * Creates an effect renderer
  63751. * @param engine the engine to use for rendering
  63752. * @param options defines the options of the effect renderer
  63753. */
  63754. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63755. /**
  63756. * Sets the current viewport in normalized coordinates 0-1
  63757. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63758. */
  63759. setViewport(viewport?: Viewport): void;
  63760. /**
  63761. * Binds the embedded attributes buffer to the effect.
  63762. * @param effect Defines the effect to bind the attributes for
  63763. */
  63764. bindBuffers(effect: Effect): void;
  63765. /**
  63766. * Sets the current effect wrapper to use during draw.
  63767. * The effect needs to be ready before calling this api.
  63768. * This also sets the default full screen position attribute.
  63769. * @param effectWrapper Defines the effect to draw with
  63770. */
  63771. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63772. /**
  63773. * Draws a full screen quad.
  63774. */
  63775. draw(): void;
  63776. /**
  63777. * renders one or more effects to a specified texture
  63778. * @param effectWrappers list of effects to renderer
  63779. * @param outputTexture texture to draw to, if null it will render to the screen
  63780. */
  63781. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63782. /**
  63783. * Disposes of the effect renderer
  63784. */
  63785. dispose(): void;
  63786. }
  63787. /**
  63788. * Options to create an EffectWrapper
  63789. */
  63790. interface EffectWrapperCreationOptions {
  63791. /**
  63792. * Engine to use to create the effect
  63793. */
  63794. engine: ThinEngine;
  63795. /**
  63796. * Fragment shader for the effect
  63797. */
  63798. fragmentShader: string;
  63799. /**
  63800. * Vertex shader for the effect
  63801. */
  63802. vertexShader?: string;
  63803. /**
  63804. * Attributes to use in the shader
  63805. */
  63806. attributeNames?: Array<string>;
  63807. /**
  63808. * Uniforms to use in the shader
  63809. */
  63810. uniformNames?: Array<string>;
  63811. /**
  63812. * Texture sampler names to use in the shader
  63813. */
  63814. samplerNames?: Array<string>;
  63815. /**
  63816. * The friendly name of the effect displayed in Spector.
  63817. */
  63818. name?: string;
  63819. }
  63820. /**
  63821. * Wraps an effect to be used for rendering
  63822. */
  63823. export class EffectWrapper {
  63824. /**
  63825. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63826. */
  63827. onApplyObservable: Observable<{}>;
  63828. /**
  63829. * The underlying effect
  63830. */
  63831. effect: Effect;
  63832. /**
  63833. * Creates an effect to be renderer
  63834. * @param creationOptions options to create the effect
  63835. */
  63836. constructor(creationOptions: EffectWrapperCreationOptions);
  63837. /**
  63838. * Disposes of the effect wrapper
  63839. */
  63840. dispose(): void;
  63841. }
  63842. }
  63843. declare module "babylonjs/Materials/index" {
  63844. export * from "babylonjs/Materials/Background/index";
  63845. export * from "babylonjs/Materials/colorCurves";
  63846. export * from "babylonjs/Materials/iEffectFallbacks";
  63847. export * from "babylonjs/Materials/effectFallbacks";
  63848. export * from "babylonjs/Materials/effect";
  63849. export * from "babylonjs/Materials/fresnelParameters";
  63850. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63851. export * from "babylonjs/Materials/material";
  63852. export * from "babylonjs/Materials/materialDefines";
  63853. export * from "babylonjs/Materials/materialHelper";
  63854. export * from "babylonjs/Materials/multiMaterial";
  63855. export * from "babylonjs/Materials/PBR/index";
  63856. export * from "babylonjs/Materials/pushMaterial";
  63857. export * from "babylonjs/Materials/shaderMaterial";
  63858. export * from "babylonjs/Materials/standardMaterial";
  63859. export * from "babylonjs/Materials/Textures/index";
  63860. export * from "babylonjs/Materials/uniformBuffer";
  63861. export * from "babylonjs/Materials/materialFlags";
  63862. export * from "babylonjs/Materials/Node/index";
  63863. export * from "babylonjs/Materials/effectRenderer";
  63864. }
  63865. declare module "babylonjs/Maths/index" {
  63866. export * from "babylonjs/Maths/math.scalar";
  63867. export * from "babylonjs/Maths/math";
  63868. export * from "babylonjs/Maths/sphericalPolynomial";
  63869. }
  63870. declare module "babylonjs/Misc/workerPool" {
  63871. import { IDisposable } from "babylonjs/scene";
  63872. /**
  63873. * Helper class to push actions to a pool of workers.
  63874. */
  63875. export class WorkerPool implements IDisposable {
  63876. private _workerInfos;
  63877. private _pendingActions;
  63878. /**
  63879. * Constructor
  63880. * @param workers Array of workers to use for actions
  63881. */
  63882. constructor(workers: Array<Worker>);
  63883. /**
  63884. * Terminates all workers and clears any pending actions.
  63885. */
  63886. dispose(): void;
  63887. /**
  63888. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63889. * pended until a worker has completed its action.
  63890. * @param action The action to perform. Call onComplete when the action is complete.
  63891. */
  63892. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63893. private _execute;
  63894. }
  63895. }
  63896. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63897. import { IDisposable } from "babylonjs/scene";
  63898. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63899. /**
  63900. * Configuration for Draco compression
  63901. */
  63902. export interface IDracoCompressionConfiguration {
  63903. /**
  63904. * Configuration for the decoder.
  63905. */
  63906. decoder: {
  63907. /**
  63908. * The url to the WebAssembly module.
  63909. */
  63910. wasmUrl?: string;
  63911. /**
  63912. * The url to the WebAssembly binary.
  63913. */
  63914. wasmBinaryUrl?: string;
  63915. /**
  63916. * The url to the fallback JavaScript module.
  63917. */
  63918. fallbackUrl?: string;
  63919. };
  63920. }
  63921. /**
  63922. * Draco compression (https://google.github.io/draco/)
  63923. *
  63924. * This class wraps the Draco module.
  63925. *
  63926. * **Encoder**
  63927. *
  63928. * The encoder is not currently implemented.
  63929. *
  63930. * **Decoder**
  63931. *
  63932. * 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.
  63933. *
  63934. * To update the configuration, use the following code:
  63935. * ```javascript
  63936. * DracoCompression.Configuration = {
  63937. * decoder: {
  63938. * wasmUrl: "<url to the WebAssembly library>",
  63939. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63940. * fallbackUrl: "<url to the fallback JavaScript library>",
  63941. * }
  63942. * };
  63943. * ```
  63944. *
  63945. * 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.
  63946. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63947. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63948. *
  63949. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63950. * ```javascript
  63951. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63952. * ```
  63953. *
  63954. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63955. */
  63956. export class DracoCompression implements IDisposable {
  63957. private _workerPoolPromise?;
  63958. private _decoderModulePromise?;
  63959. /**
  63960. * The configuration. Defaults to the following urls:
  63961. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63962. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63963. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63964. */
  63965. static Configuration: IDracoCompressionConfiguration;
  63966. /**
  63967. * Returns true if the decoder configuration is available.
  63968. */
  63969. static get DecoderAvailable(): boolean;
  63970. /**
  63971. * Default number of workers to create when creating the draco compression object.
  63972. */
  63973. static DefaultNumWorkers: number;
  63974. private static GetDefaultNumWorkers;
  63975. private static _Default;
  63976. /**
  63977. * Default instance for the draco compression object.
  63978. */
  63979. static get Default(): DracoCompression;
  63980. /**
  63981. * Constructor
  63982. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63983. */
  63984. constructor(numWorkers?: number);
  63985. /**
  63986. * Stop all async operations and release resources.
  63987. */
  63988. dispose(): void;
  63989. /**
  63990. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63991. * @returns a promise that resolves when ready
  63992. */
  63993. whenReadyAsync(): Promise<void>;
  63994. /**
  63995. * Decode Draco compressed mesh data to vertex data.
  63996. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63997. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63998. * @returns A promise that resolves with the decoded vertex data
  63999. */
  64000. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64001. [kind: string]: number;
  64002. }): Promise<VertexData>;
  64003. }
  64004. }
  64005. declare module "babylonjs/Meshes/Compression/index" {
  64006. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64007. }
  64008. declare module "babylonjs/Meshes/csg" {
  64009. import { Nullable } from "babylonjs/types";
  64010. import { Scene } from "babylonjs/scene";
  64011. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64012. import { Mesh } from "babylonjs/Meshes/mesh";
  64013. import { Material } from "babylonjs/Materials/material";
  64014. /**
  64015. * Class for building Constructive Solid Geometry
  64016. */
  64017. export class CSG {
  64018. private polygons;
  64019. /**
  64020. * The world matrix
  64021. */
  64022. matrix: Matrix;
  64023. /**
  64024. * Stores the position
  64025. */
  64026. position: Vector3;
  64027. /**
  64028. * Stores the rotation
  64029. */
  64030. rotation: Vector3;
  64031. /**
  64032. * Stores the rotation quaternion
  64033. */
  64034. rotationQuaternion: Nullable<Quaternion>;
  64035. /**
  64036. * Stores the scaling vector
  64037. */
  64038. scaling: Vector3;
  64039. /**
  64040. * Convert the Mesh to CSG
  64041. * @param mesh The Mesh to convert to CSG
  64042. * @returns A new CSG from the Mesh
  64043. */
  64044. static FromMesh(mesh: Mesh): CSG;
  64045. /**
  64046. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64047. * @param polygons Polygons used to construct a CSG solid
  64048. */
  64049. private static FromPolygons;
  64050. /**
  64051. * Clones, or makes a deep copy, of the CSG
  64052. * @returns A new CSG
  64053. */
  64054. clone(): CSG;
  64055. /**
  64056. * Unions this CSG with another CSG
  64057. * @param csg The CSG to union against this CSG
  64058. * @returns The unioned CSG
  64059. */
  64060. union(csg: CSG): CSG;
  64061. /**
  64062. * Unions this CSG with another CSG in place
  64063. * @param csg The CSG to union against this CSG
  64064. */
  64065. unionInPlace(csg: CSG): void;
  64066. /**
  64067. * Subtracts this CSG with another CSG
  64068. * @param csg The CSG to subtract against this CSG
  64069. * @returns A new CSG
  64070. */
  64071. subtract(csg: CSG): CSG;
  64072. /**
  64073. * Subtracts this CSG with another CSG in place
  64074. * @param csg The CSG to subtact against this CSG
  64075. */
  64076. subtractInPlace(csg: CSG): void;
  64077. /**
  64078. * Intersect this CSG with another CSG
  64079. * @param csg The CSG to intersect against this CSG
  64080. * @returns A new CSG
  64081. */
  64082. intersect(csg: CSG): CSG;
  64083. /**
  64084. * Intersects this CSG with another CSG in place
  64085. * @param csg The CSG to intersect against this CSG
  64086. */
  64087. intersectInPlace(csg: CSG): void;
  64088. /**
  64089. * Return a new CSG solid with solid and empty space switched. This solid is
  64090. * not modified.
  64091. * @returns A new CSG solid with solid and empty space switched
  64092. */
  64093. inverse(): CSG;
  64094. /**
  64095. * Inverses the CSG in place
  64096. */
  64097. inverseInPlace(): void;
  64098. /**
  64099. * This is used to keep meshes transformations so they can be restored
  64100. * when we build back a Babylon Mesh
  64101. * NB : All CSG operations are performed in world coordinates
  64102. * @param csg The CSG to copy the transform attributes from
  64103. * @returns This CSG
  64104. */
  64105. copyTransformAttributes(csg: CSG): CSG;
  64106. /**
  64107. * Build Raw mesh from CSG
  64108. * Coordinates here are in world space
  64109. * @param name The name of the mesh geometry
  64110. * @param scene The Scene
  64111. * @param keepSubMeshes Specifies if the submeshes should be kept
  64112. * @returns A new Mesh
  64113. */
  64114. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64115. /**
  64116. * Build Mesh from CSG taking material and transforms into account
  64117. * @param name The name of the Mesh
  64118. * @param material The material of the Mesh
  64119. * @param scene The Scene
  64120. * @param keepSubMeshes Specifies if submeshes should be kept
  64121. * @returns The new Mesh
  64122. */
  64123. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64124. }
  64125. }
  64126. declare module "babylonjs/Meshes/trailMesh" {
  64127. import { Mesh } from "babylonjs/Meshes/mesh";
  64128. import { Scene } from "babylonjs/scene";
  64129. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64130. /**
  64131. * Class used to create a trail following a mesh
  64132. */
  64133. export class TrailMesh extends Mesh {
  64134. private _generator;
  64135. private _autoStart;
  64136. private _running;
  64137. private _diameter;
  64138. private _length;
  64139. private _sectionPolygonPointsCount;
  64140. private _sectionVectors;
  64141. private _sectionNormalVectors;
  64142. private _beforeRenderObserver;
  64143. /**
  64144. * @constructor
  64145. * @param name The value used by scene.getMeshByName() to do a lookup.
  64146. * @param generator The mesh or transform node to generate a trail.
  64147. * @param scene The scene to add this mesh to.
  64148. * @param diameter Diameter of trailing mesh. Default is 1.
  64149. * @param length Length of trailing mesh. Default is 60.
  64150. * @param autoStart Automatically start trailing mesh. Default true.
  64151. */
  64152. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64153. /**
  64154. * "TrailMesh"
  64155. * @returns "TrailMesh"
  64156. */
  64157. getClassName(): string;
  64158. private _createMesh;
  64159. /**
  64160. * Start trailing mesh.
  64161. */
  64162. start(): void;
  64163. /**
  64164. * Stop trailing mesh.
  64165. */
  64166. stop(): void;
  64167. /**
  64168. * Update trailing mesh geometry.
  64169. */
  64170. update(): void;
  64171. /**
  64172. * Returns a new TrailMesh object.
  64173. * @param name is a string, the name given to the new mesh
  64174. * @param newGenerator use new generator object for cloned trail mesh
  64175. * @returns a new mesh
  64176. */
  64177. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64178. /**
  64179. * Serializes this trail mesh
  64180. * @param serializationObject object to write serialization to
  64181. */
  64182. serialize(serializationObject: any): void;
  64183. /**
  64184. * Parses a serialized trail mesh
  64185. * @param parsedMesh the serialized mesh
  64186. * @param scene the scene to create the trail mesh in
  64187. * @returns the created trail mesh
  64188. */
  64189. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64190. }
  64191. }
  64192. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64193. import { Nullable } from "babylonjs/types";
  64194. import { Scene } from "babylonjs/scene";
  64195. import { Vector4 } from "babylonjs/Maths/math.vector";
  64196. import { Color4 } from "babylonjs/Maths/math.color";
  64197. import { Mesh } from "babylonjs/Meshes/mesh";
  64198. /**
  64199. * Class containing static functions to help procedurally build meshes
  64200. */
  64201. export class TiledBoxBuilder {
  64202. /**
  64203. * Creates a box mesh
  64204. * 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)
  64205. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64209. * @param name defines the name of the mesh
  64210. * @param options defines the options used to create the mesh
  64211. * @param scene defines the hosting scene
  64212. * @returns the box mesh
  64213. */
  64214. static CreateTiledBox(name: string, options: {
  64215. pattern?: number;
  64216. width?: number;
  64217. height?: number;
  64218. depth?: number;
  64219. tileSize?: number;
  64220. tileWidth?: number;
  64221. tileHeight?: number;
  64222. alignHorizontal?: number;
  64223. alignVertical?: number;
  64224. faceUV?: Vector4[];
  64225. faceColors?: Color4[];
  64226. sideOrientation?: number;
  64227. updatable?: boolean;
  64228. }, scene?: Nullable<Scene>): Mesh;
  64229. }
  64230. }
  64231. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64232. import { Vector4 } from "babylonjs/Maths/math.vector";
  64233. import { Mesh } from "babylonjs/Meshes/mesh";
  64234. /**
  64235. * Class containing static functions to help procedurally build meshes
  64236. */
  64237. export class TorusKnotBuilder {
  64238. /**
  64239. * Creates a torus knot mesh
  64240. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64241. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64242. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64243. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64247. * @param name defines the name of the mesh
  64248. * @param options defines the options used to create the mesh
  64249. * @param scene defines the hosting scene
  64250. * @returns the torus knot mesh
  64251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64252. */
  64253. static CreateTorusKnot(name: string, options: {
  64254. radius?: number;
  64255. tube?: number;
  64256. radialSegments?: number;
  64257. tubularSegments?: number;
  64258. p?: number;
  64259. q?: number;
  64260. updatable?: boolean;
  64261. sideOrientation?: number;
  64262. frontUVs?: Vector4;
  64263. backUVs?: Vector4;
  64264. }, scene: any): Mesh;
  64265. }
  64266. }
  64267. declare module "babylonjs/Meshes/polygonMesh" {
  64268. import { Scene } from "babylonjs/scene";
  64269. import { Vector2 } from "babylonjs/Maths/math.vector";
  64270. import { Mesh } from "babylonjs/Meshes/mesh";
  64271. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64272. import { Path2 } from "babylonjs/Maths/math.path";
  64273. /**
  64274. * Polygon
  64275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64276. */
  64277. export class Polygon {
  64278. /**
  64279. * Creates a rectangle
  64280. * @param xmin bottom X coord
  64281. * @param ymin bottom Y coord
  64282. * @param xmax top X coord
  64283. * @param ymax top Y coord
  64284. * @returns points that make the resulting rectation
  64285. */
  64286. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64287. /**
  64288. * Creates a circle
  64289. * @param radius radius of circle
  64290. * @param cx scale in x
  64291. * @param cy scale in y
  64292. * @param numberOfSides number of sides that make up the circle
  64293. * @returns points that make the resulting circle
  64294. */
  64295. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64296. /**
  64297. * Creates a polygon from input string
  64298. * @param input Input polygon data
  64299. * @returns the parsed points
  64300. */
  64301. static Parse(input: string): Vector2[];
  64302. /**
  64303. * Starts building a polygon from x and y coordinates
  64304. * @param x x coordinate
  64305. * @param y y coordinate
  64306. * @returns the started path2
  64307. */
  64308. static StartingAt(x: number, y: number): Path2;
  64309. }
  64310. /**
  64311. * Builds a polygon
  64312. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64313. */
  64314. export class PolygonMeshBuilder {
  64315. private _points;
  64316. private _outlinepoints;
  64317. private _holes;
  64318. private _name;
  64319. private _scene;
  64320. private _epoints;
  64321. private _eholes;
  64322. private _addToepoint;
  64323. /**
  64324. * Babylon reference to the earcut plugin.
  64325. */
  64326. bjsEarcut: any;
  64327. /**
  64328. * Creates a PolygonMeshBuilder
  64329. * @param name name of the builder
  64330. * @param contours Path of the polygon
  64331. * @param scene scene to add to when creating the mesh
  64332. * @param earcutInjection can be used to inject your own earcut reference
  64333. */
  64334. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64335. /**
  64336. * Adds a whole within the polygon
  64337. * @param hole Array of points defining the hole
  64338. * @returns this
  64339. */
  64340. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64341. /**
  64342. * Creates the polygon
  64343. * @param updatable If the mesh should be updatable
  64344. * @param depth The depth of the mesh created
  64345. * @returns the created mesh
  64346. */
  64347. build(updatable?: boolean, depth?: number): Mesh;
  64348. /**
  64349. * Creates the polygon
  64350. * @param depth The depth of the mesh created
  64351. * @returns the created VertexData
  64352. */
  64353. buildVertexData(depth?: number): VertexData;
  64354. /**
  64355. * Adds a side to the polygon
  64356. * @param positions points that make the polygon
  64357. * @param normals normals of the polygon
  64358. * @param uvs uvs of the polygon
  64359. * @param indices indices of the polygon
  64360. * @param bounds bounds of the polygon
  64361. * @param points points of the polygon
  64362. * @param depth depth of the polygon
  64363. * @param flip flip of the polygon
  64364. */
  64365. private addSide;
  64366. }
  64367. }
  64368. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64369. import { Scene } from "babylonjs/scene";
  64370. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64371. import { Color4 } from "babylonjs/Maths/math.color";
  64372. import { Mesh } from "babylonjs/Meshes/mesh";
  64373. import { Nullable } from "babylonjs/types";
  64374. /**
  64375. * Class containing static functions to help procedurally build meshes
  64376. */
  64377. export class PolygonBuilder {
  64378. /**
  64379. * Creates a polygon mesh
  64380. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64381. * * 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
  64382. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64385. * * Remember you can only change the shape positions, not their number when updating a polygon
  64386. * @param name defines the name of the mesh
  64387. * @param options defines the options used to create the mesh
  64388. * @param scene defines the hosting scene
  64389. * @param earcutInjection can be used to inject your own earcut reference
  64390. * @returns the polygon mesh
  64391. */
  64392. static CreatePolygon(name: string, options: {
  64393. shape: Vector3[];
  64394. holes?: Vector3[][];
  64395. depth?: number;
  64396. faceUV?: Vector4[];
  64397. faceColors?: Color4[];
  64398. updatable?: boolean;
  64399. sideOrientation?: number;
  64400. frontUVs?: Vector4;
  64401. backUVs?: Vector4;
  64402. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64403. /**
  64404. * Creates an extruded polygon mesh, with depth in the Y direction.
  64405. * * 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)
  64406. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64407. * @param name defines the name of the mesh
  64408. * @param options defines the options used to create the mesh
  64409. * @param scene defines the hosting scene
  64410. * @param earcutInjection can be used to inject your own earcut reference
  64411. * @returns the polygon mesh
  64412. */
  64413. static ExtrudePolygon(name: string, options: {
  64414. shape: Vector3[];
  64415. holes?: Vector3[][];
  64416. depth?: number;
  64417. faceUV?: Vector4[];
  64418. faceColors?: Color4[];
  64419. updatable?: boolean;
  64420. sideOrientation?: number;
  64421. frontUVs?: Vector4;
  64422. backUVs?: Vector4;
  64423. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64424. }
  64425. }
  64426. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64427. import { Scene } from "babylonjs/scene";
  64428. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64429. import { Mesh } from "babylonjs/Meshes/mesh";
  64430. import { Nullable } from "babylonjs/types";
  64431. /**
  64432. * Class containing static functions to help procedurally build meshes
  64433. */
  64434. export class LatheBuilder {
  64435. /**
  64436. * Creates lathe mesh.
  64437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64438. * * 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
  64439. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64440. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64441. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64442. * * 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
  64443. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64444. * * 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
  64445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64449. * @param name defines the name of the mesh
  64450. * @param options defines the options used to create the mesh
  64451. * @param scene defines the hosting scene
  64452. * @returns the lathe mesh
  64453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64454. */
  64455. static CreateLathe(name: string, options: {
  64456. shape: Vector3[];
  64457. radius?: number;
  64458. tessellation?: number;
  64459. clip?: number;
  64460. arc?: number;
  64461. closed?: boolean;
  64462. updatable?: boolean;
  64463. sideOrientation?: number;
  64464. frontUVs?: Vector4;
  64465. backUVs?: Vector4;
  64466. cap?: number;
  64467. invertUV?: boolean;
  64468. }, scene?: Nullable<Scene>): Mesh;
  64469. }
  64470. }
  64471. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64472. import { Nullable } from "babylonjs/types";
  64473. import { Scene } from "babylonjs/scene";
  64474. import { Vector4 } from "babylonjs/Maths/math.vector";
  64475. import { Mesh } from "babylonjs/Meshes/mesh";
  64476. /**
  64477. * Class containing static functions to help procedurally build meshes
  64478. */
  64479. export class TiledPlaneBuilder {
  64480. /**
  64481. * Creates a tiled plane mesh
  64482. * * The parameter `pattern` will, depending on value, do nothing or
  64483. * * * flip (reflect about central vertical) alternate tiles across and up
  64484. * * * flip every tile on alternate rows
  64485. * * * rotate (180 degs) alternate tiles across and up
  64486. * * * rotate every tile on alternate rows
  64487. * * * flip and rotate alternate tiles across and up
  64488. * * * flip and rotate every tile on alternate rows
  64489. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64490. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64493. * * 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)
  64494. * * 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)
  64495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64496. * @param name defines the name of the mesh
  64497. * @param options defines the options used to create the mesh
  64498. * @param scene defines the hosting scene
  64499. * @returns the box mesh
  64500. */
  64501. static CreateTiledPlane(name: string, options: {
  64502. pattern?: number;
  64503. tileSize?: number;
  64504. tileWidth?: number;
  64505. tileHeight?: number;
  64506. size?: number;
  64507. width?: number;
  64508. height?: number;
  64509. alignHorizontal?: number;
  64510. alignVertical?: number;
  64511. sideOrientation?: number;
  64512. frontUVs?: Vector4;
  64513. backUVs?: Vector4;
  64514. updatable?: boolean;
  64515. }, scene?: Nullable<Scene>): Mesh;
  64516. }
  64517. }
  64518. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64519. import { Nullable } from "babylonjs/types";
  64520. import { Scene } from "babylonjs/scene";
  64521. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64522. import { Mesh } from "babylonjs/Meshes/mesh";
  64523. /**
  64524. * Class containing static functions to help procedurally build meshes
  64525. */
  64526. export class TubeBuilder {
  64527. /**
  64528. * Creates a tube mesh.
  64529. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64530. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64531. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64532. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64533. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64534. * * 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)
  64535. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64536. * * 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
  64537. * * 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
  64538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64542. * @param name defines the name of the mesh
  64543. * @param options defines the options used to create the mesh
  64544. * @param scene defines the hosting scene
  64545. * @returns the tube mesh
  64546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64547. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64548. */
  64549. static CreateTube(name: string, options: {
  64550. path: Vector3[];
  64551. radius?: number;
  64552. tessellation?: number;
  64553. radiusFunction?: {
  64554. (i: number, distance: number): number;
  64555. };
  64556. cap?: number;
  64557. arc?: number;
  64558. updatable?: boolean;
  64559. sideOrientation?: number;
  64560. frontUVs?: Vector4;
  64561. backUVs?: Vector4;
  64562. instance?: Mesh;
  64563. invertUV?: boolean;
  64564. }, scene?: Nullable<Scene>): Mesh;
  64565. }
  64566. }
  64567. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64568. import { Scene } from "babylonjs/scene";
  64569. import { Vector4 } from "babylonjs/Maths/math.vector";
  64570. import { Mesh } from "babylonjs/Meshes/mesh";
  64571. import { Nullable } from "babylonjs/types";
  64572. /**
  64573. * Class containing static functions to help procedurally build meshes
  64574. */
  64575. export class IcoSphereBuilder {
  64576. /**
  64577. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64578. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64579. * * 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`)
  64580. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64581. * * 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
  64582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64585. * @param name defines the name of the mesh
  64586. * @param options defines the options used to create the mesh
  64587. * @param scene defines the hosting scene
  64588. * @returns the icosahedron mesh
  64589. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64590. */
  64591. static CreateIcoSphere(name: string, options: {
  64592. radius?: number;
  64593. radiusX?: number;
  64594. radiusY?: number;
  64595. radiusZ?: number;
  64596. flat?: boolean;
  64597. subdivisions?: number;
  64598. sideOrientation?: number;
  64599. frontUVs?: Vector4;
  64600. backUVs?: Vector4;
  64601. updatable?: boolean;
  64602. }, scene?: Nullable<Scene>): Mesh;
  64603. }
  64604. }
  64605. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64606. import { Vector3 } from "babylonjs/Maths/math.vector";
  64607. import { Mesh } from "babylonjs/Meshes/mesh";
  64608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64609. /**
  64610. * Class containing static functions to help procedurally build meshes
  64611. */
  64612. export class DecalBuilder {
  64613. /**
  64614. * Creates a decal mesh.
  64615. * 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
  64616. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64617. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64618. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64619. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64620. * @param name defines the name of the mesh
  64621. * @param sourceMesh defines the mesh where the decal must be applied
  64622. * @param options defines the options used to create the mesh
  64623. * @param scene defines the hosting scene
  64624. * @returns the decal mesh
  64625. * @see https://doc.babylonjs.com/how_to/decals
  64626. */
  64627. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64628. position?: Vector3;
  64629. normal?: Vector3;
  64630. size?: Vector3;
  64631. angle?: number;
  64632. }): Mesh;
  64633. }
  64634. }
  64635. declare module "babylonjs/Meshes/meshBuilder" {
  64636. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64637. import { Nullable } from "babylonjs/types";
  64638. import { Scene } from "babylonjs/scene";
  64639. import { Mesh } from "babylonjs/Meshes/mesh";
  64640. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64641. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64643. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64644. import { Plane } from "babylonjs/Maths/math.plane";
  64645. /**
  64646. * Class containing static functions to help procedurally build meshes
  64647. */
  64648. export class MeshBuilder {
  64649. /**
  64650. * Creates a box mesh
  64651. * * The parameter `size` sets the size (float) of each box side (default 1)
  64652. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64653. * * 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)
  64654. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64658. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64659. * @param name defines the name of the mesh
  64660. * @param options defines the options used to create the mesh
  64661. * @param scene defines the hosting scene
  64662. * @returns the box mesh
  64663. */
  64664. static CreateBox(name: string, options: {
  64665. size?: number;
  64666. width?: number;
  64667. height?: number;
  64668. depth?: number;
  64669. faceUV?: Vector4[];
  64670. faceColors?: Color4[];
  64671. sideOrientation?: number;
  64672. frontUVs?: Vector4;
  64673. backUVs?: Vector4;
  64674. wrap?: boolean;
  64675. topBaseAt?: number;
  64676. bottomBaseAt?: number;
  64677. updatable?: boolean;
  64678. }, scene?: Nullable<Scene>): Mesh;
  64679. /**
  64680. * Creates a tiled box mesh
  64681. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64683. * @param name defines the name of the mesh
  64684. * @param options defines the options used to create the mesh
  64685. * @param scene defines the hosting scene
  64686. * @returns the tiled box mesh
  64687. */
  64688. static CreateTiledBox(name: string, options: {
  64689. pattern?: number;
  64690. size?: number;
  64691. width?: number;
  64692. height?: number;
  64693. depth: number;
  64694. tileSize?: number;
  64695. tileWidth?: number;
  64696. tileHeight?: number;
  64697. faceUV?: Vector4[];
  64698. faceColors?: Color4[];
  64699. alignHorizontal?: number;
  64700. alignVertical?: number;
  64701. sideOrientation?: number;
  64702. updatable?: boolean;
  64703. }, scene?: Nullable<Scene>): Mesh;
  64704. /**
  64705. * Creates a sphere mesh
  64706. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64707. * * 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`)
  64708. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64709. * * 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
  64710. * * 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)
  64711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64714. * @param name defines the name of the mesh
  64715. * @param options defines the options used to create the mesh
  64716. * @param scene defines the hosting scene
  64717. * @returns the sphere mesh
  64718. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64719. */
  64720. static CreateSphere(name: string, options: {
  64721. segments?: number;
  64722. diameter?: number;
  64723. diameterX?: number;
  64724. diameterY?: number;
  64725. diameterZ?: number;
  64726. arc?: number;
  64727. slice?: number;
  64728. sideOrientation?: number;
  64729. frontUVs?: Vector4;
  64730. backUVs?: Vector4;
  64731. updatable?: boolean;
  64732. }, scene?: Nullable<Scene>): Mesh;
  64733. /**
  64734. * Creates a plane polygonal mesh. By default, this is a disc
  64735. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64736. * * 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
  64737. * * 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
  64738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64741. * @param name defines the name of the mesh
  64742. * @param options defines the options used to create the mesh
  64743. * @param scene defines the hosting scene
  64744. * @returns the plane polygonal mesh
  64745. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64746. */
  64747. static CreateDisc(name: string, options: {
  64748. radius?: number;
  64749. tessellation?: number;
  64750. arc?: number;
  64751. updatable?: boolean;
  64752. sideOrientation?: number;
  64753. frontUVs?: Vector4;
  64754. backUVs?: Vector4;
  64755. }, scene?: Nullable<Scene>): Mesh;
  64756. /**
  64757. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64758. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64759. * * 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`)
  64760. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64761. * * 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
  64762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64765. * @param name defines the name of the mesh
  64766. * @param options defines the options used to create the mesh
  64767. * @param scene defines the hosting scene
  64768. * @returns the icosahedron mesh
  64769. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64770. */
  64771. static CreateIcoSphere(name: string, options: {
  64772. radius?: number;
  64773. radiusX?: number;
  64774. radiusY?: number;
  64775. radiusZ?: number;
  64776. flat?: boolean;
  64777. subdivisions?: number;
  64778. sideOrientation?: number;
  64779. frontUVs?: Vector4;
  64780. backUVs?: Vector4;
  64781. updatable?: boolean;
  64782. }, scene?: Nullable<Scene>): Mesh;
  64783. /**
  64784. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64785. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64786. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64787. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64788. * * 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
  64789. * * 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
  64790. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64794. * * 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
  64795. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64796. * * 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
  64797. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64799. * @param name defines the name of the mesh
  64800. * @param options defines the options used to create the mesh
  64801. * @param scene defines the hosting scene
  64802. * @returns the ribbon mesh
  64803. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64805. */
  64806. static CreateRibbon(name: string, options: {
  64807. pathArray: Vector3[][];
  64808. closeArray?: boolean;
  64809. closePath?: boolean;
  64810. offset?: number;
  64811. updatable?: boolean;
  64812. sideOrientation?: number;
  64813. frontUVs?: Vector4;
  64814. backUVs?: Vector4;
  64815. instance?: Mesh;
  64816. invertUV?: boolean;
  64817. uvs?: Vector2[];
  64818. colors?: Color4[];
  64819. }, scene?: Nullable<Scene>): Mesh;
  64820. /**
  64821. * Creates a cylinder or a cone mesh
  64822. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64823. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64824. * * 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.
  64825. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64826. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64827. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64828. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64829. * * 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).
  64830. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64831. * * 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).
  64832. * * 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
  64833. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64834. * * 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
  64835. * * 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.
  64836. * * If `enclose` is false, a ring surface is one element.
  64837. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64838. * * 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
  64839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64842. * @param name defines the name of the mesh
  64843. * @param options defines the options used to create the mesh
  64844. * @param scene defines the hosting scene
  64845. * @returns the cylinder mesh
  64846. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64847. */
  64848. static CreateCylinder(name: string, options: {
  64849. height?: number;
  64850. diameterTop?: number;
  64851. diameterBottom?: number;
  64852. diameter?: number;
  64853. tessellation?: number;
  64854. subdivisions?: number;
  64855. arc?: number;
  64856. faceColors?: Color4[];
  64857. faceUV?: Vector4[];
  64858. updatable?: boolean;
  64859. hasRings?: boolean;
  64860. enclose?: boolean;
  64861. cap?: number;
  64862. sideOrientation?: number;
  64863. frontUVs?: Vector4;
  64864. backUVs?: Vector4;
  64865. }, scene?: Nullable<Scene>): Mesh;
  64866. /**
  64867. * Creates a torus mesh
  64868. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64869. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64870. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64874. * @param name defines the name of the mesh
  64875. * @param options defines the options used to create the mesh
  64876. * @param scene defines the hosting scene
  64877. * @returns the torus mesh
  64878. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64879. */
  64880. static CreateTorus(name: string, options: {
  64881. diameter?: number;
  64882. thickness?: number;
  64883. tessellation?: number;
  64884. updatable?: boolean;
  64885. sideOrientation?: number;
  64886. frontUVs?: Vector4;
  64887. backUVs?: Vector4;
  64888. }, scene?: Nullable<Scene>): Mesh;
  64889. /**
  64890. * Creates a torus knot mesh
  64891. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64892. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64893. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64894. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64898. * @param name defines the name of the mesh
  64899. * @param options defines the options used to create the mesh
  64900. * @param scene defines the hosting scene
  64901. * @returns the torus knot mesh
  64902. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64903. */
  64904. static CreateTorusKnot(name: string, options: {
  64905. radius?: number;
  64906. tube?: number;
  64907. radialSegments?: number;
  64908. tubularSegments?: number;
  64909. p?: number;
  64910. q?: number;
  64911. updatable?: boolean;
  64912. sideOrientation?: number;
  64913. frontUVs?: Vector4;
  64914. backUVs?: Vector4;
  64915. }, scene?: Nullable<Scene>): Mesh;
  64916. /**
  64917. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64918. * * 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
  64919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64920. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64921. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64922. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64923. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64924. * * 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
  64925. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64928. * @param name defines the name of the new line system
  64929. * @param options defines the options used to create the line system
  64930. * @param scene defines the hosting scene
  64931. * @returns a new line system mesh
  64932. */
  64933. static CreateLineSystem(name: string, options: {
  64934. lines: Vector3[][];
  64935. updatable?: boolean;
  64936. instance?: Nullable<LinesMesh>;
  64937. colors?: Nullable<Color4[][]>;
  64938. useVertexAlpha?: boolean;
  64939. }, scene: Nullable<Scene>): LinesMesh;
  64940. /**
  64941. * Creates a line mesh
  64942. * 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
  64943. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64944. * * The parameter `points` is an array successive Vector3
  64945. * * 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
  64946. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64947. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64948. * * When updating an instance, remember that only point positions can change, not the number of points
  64949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64951. * @param name defines the name of the new line system
  64952. * @param options defines the options used to create the line system
  64953. * @param scene defines the hosting scene
  64954. * @returns a new line mesh
  64955. */
  64956. static CreateLines(name: string, options: {
  64957. points: Vector3[];
  64958. updatable?: boolean;
  64959. instance?: Nullable<LinesMesh>;
  64960. colors?: Color4[];
  64961. useVertexAlpha?: boolean;
  64962. }, scene?: Nullable<Scene>): LinesMesh;
  64963. /**
  64964. * Creates a dashed line mesh
  64965. * * 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
  64966. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64967. * * The parameter `points` is an array successive Vector3
  64968. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64969. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64970. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64971. * * 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
  64972. * * When updating an instance, remember that only point positions can change, not the number of points
  64973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64974. * @param name defines the name of the mesh
  64975. * @param options defines the options used to create the mesh
  64976. * @param scene defines the hosting scene
  64977. * @returns the dashed line mesh
  64978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64979. */
  64980. static CreateDashedLines(name: string, options: {
  64981. points: Vector3[];
  64982. dashSize?: number;
  64983. gapSize?: number;
  64984. dashNb?: number;
  64985. updatable?: boolean;
  64986. instance?: LinesMesh;
  64987. }, scene?: Nullable<Scene>): LinesMesh;
  64988. /**
  64989. * 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.
  64990. * * 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.
  64991. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64992. * * 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.
  64993. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64994. * * 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
  64995. * * 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
  64996. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64999. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65001. * @param name defines the name of the mesh
  65002. * @param options defines the options used to create the mesh
  65003. * @param scene defines the hosting scene
  65004. * @returns the extruded shape mesh
  65005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65007. */
  65008. static ExtrudeShape(name: string, options: {
  65009. shape: Vector3[];
  65010. path: Vector3[];
  65011. scale?: number;
  65012. rotation?: number;
  65013. cap?: number;
  65014. updatable?: boolean;
  65015. sideOrientation?: number;
  65016. frontUVs?: Vector4;
  65017. backUVs?: Vector4;
  65018. instance?: Mesh;
  65019. invertUV?: boolean;
  65020. }, scene?: Nullable<Scene>): Mesh;
  65021. /**
  65022. * Creates an custom extruded shape mesh.
  65023. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65024. * * 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.
  65025. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65026. * * 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
  65027. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65028. * * 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
  65029. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65030. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65031. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65032. * * 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
  65033. * * 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
  65034. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65039. * @param name defines the name of the mesh
  65040. * @param options defines the options used to create the mesh
  65041. * @param scene defines the hosting scene
  65042. * @returns the custom extruded shape mesh
  65043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65046. */
  65047. static ExtrudeShapeCustom(name: string, options: {
  65048. shape: Vector3[];
  65049. path: Vector3[];
  65050. scaleFunction?: any;
  65051. rotationFunction?: any;
  65052. ribbonCloseArray?: boolean;
  65053. ribbonClosePath?: boolean;
  65054. cap?: number;
  65055. updatable?: boolean;
  65056. sideOrientation?: number;
  65057. frontUVs?: Vector4;
  65058. backUVs?: Vector4;
  65059. instance?: Mesh;
  65060. invertUV?: boolean;
  65061. }, scene?: Nullable<Scene>): Mesh;
  65062. /**
  65063. * Creates lathe mesh.
  65064. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65065. * * 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
  65066. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65067. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65068. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65069. * * 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
  65070. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65071. * * 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
  65072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65076. * @param name defines the name of the mesh
  65077. * @param options defines the options used to create the mesh
  65078. * @param scene defines the hosting scene
  65079. * @returns the lathe mesh
  65080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65081. */
  65082. static CreateLathe(name: string, options: {
  65083. shape: Vector3[];
  65084. radius?: number;
  65085. tessellation?: number;
  65086. clip?: number;
  65087. arc?: number;
  65088. closed?: boolean;
  65089. updatable?: boolean;
  65090. sideOrientation?: number;
  65091. frontUVs?: Vector4;
  65092. backUVs?: Vector4;
  65093. cap?: number;
  65094. invertUV?: boolean;
  65095. }, scene?: Nullable<Scene>): Mesh;
  65096. /**
  65097. * Creates a tiled plane mesh
  65098. * * You can set a limited pattern arrangement with the tiles
  65099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65102. * @param name defines the name of the mesh
  65103. * @param options defines the options used to create the mesh
  65104. * @param scene defines the hosting scene
  65105. * @returns the plane mesh
  65106. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65107. */
  65108. static CreateTiledPlane(name: string, options: {
  65109. pattern?: number;
  65110. tileSize?: number;
  65111. tileWidth?: number;
  65112. tileHeight?: number;
  65113. size?: number;
  65114. width?: number;
  65115. height?: number;
  65116. alignHorizontal?: number;
  65117. alignVertical?: number;
  65118. sideOrientation?: number;
  65119. frontUVs?: Vector4;
  65120. backUVs?: Vector4;
  65121. updatable?: boolean;
  65122. }, scene?: Nullable<Scene>): Mesh;
  65123. /**
  65124. * Creates a plane mesh
  65125. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65126. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65127. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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 CreatePlane(name: string, options: {
  65138. size?: number;
  65139. width?: number;
  65140. height?: number;
  65141. sideOrientation?: number;
  65142. frontUVs?: Vector4;
  65143. backUVs?: Vector4;
  65144. updatable?: boolean;
  65145. sourcePlane?: Plane;
  65146. }, scene?: Nullable<Scene>): Mesh;
  65147. /**
  65148. * Creates a ground mesh
  65149. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65150. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65152. * @param name defines the name of the mesh
  65153. * @param options defines the options used to create the mesh
  65154. * @param scene defines the hosting scene
  65155. * @returns the ground mesh
  65156. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65157. */
  65158. static CreateGround(name: string, options: {
  65159. width?: number;
  65160. height?: number;
  65161. subdivisions?: number;
  65162. subdivisionsX?: number;
  65163. subdivisionsY?: number;
  65164. updatable?: boolean;
  65165. }, scene?: Nullable<Scene>): Mesh;
  65166. /**
  65167. * Creates a tiled ground mesh
  65168. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65169. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65170. * * 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
  65171. * * 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
  65172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65173. * @param name defines the name of the mesh
  65174. * @param options defines the options used to create the mesh
  65175. * @param scene defines the hosting scene
  65176. * @returns the tiled ground mesh
  65177. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65178. */
  65179. static CreateTiledGround(name: string, options: {
  65180. xmin: number;
  65181. zmin: number;
  65182. xmax: number;
  65183. zmax: number;
  65184. subdivisions?: {
  65185. w: number;
  65186. h: number;
  65187. };
  65188. precision?: {
  65189. w: number;
  65190. h: number;
  65191. };
  65192. updatable?: boolean;
  65193. }, scene?: Nullable<Scene>): Mesh;
  65194. /**
  65195. * Creates a ground mesh from a height map
  65196. * * The parameter `url` sets the URL of the height map image resource.
  65197. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65198. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65199. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65200. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65201. * * 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.
  65202. * * 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).
  65203. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65205. * @param name defines the name of the mesh
  65206. * @param url defines the url to the height map
  65207. * @param options defines the options used to create the mesh
  65208. * @param scene defines the hosting scene
  65209. * @returns the ground mesh
  65210. * @see https://doc.babylonjs.com/babylon101/height_map
  65211. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65212. */
  65213. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65214. width?: number;
  65215. height?: number;
  65216. subdivisions?: number;
  65217. minHeight?: number;
  65218. maxHeight?: number;
  65219. colorFilter?: Color3;
  65220. alphaFilter?: number;
  65221. updatable?: boolean;
  65222. onReady?: (mesh: GroundMesh) => void;
  65223. }, scene?: Nullable<Scene>): GroundMesh;
  65224. /**
  65225. * Creates a polygon mesh
  65226. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65227. * * 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
  65228. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65231. * * Remember you can only change the shape positions, not their number when updating a polygon
  65232. * @param name defines the name of the mesh
  65233. * @param options defines the options used to create the mesh
  65234. * @param scene defines the hosting scene
  65235. * @param earcutInjection can be used to inject your own earcut reference
  65236. * @returns the polygon mesh
  65237. */
  65238. static CreatePolygon(name: string, options: {
  65239. shape: Vector3[];
  65240. holes?: Vector3[][];
  65241. depth?: number;
  65242. faceUV?: Vector4[];
  65243. faceColors?: Color4[];
  65244. updatable?: boolean;
  65245. sideOrientation?: number;
  65246. frontUVs?: Vector4;
  65247. backUVs?: Vector4;
  65248. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65249. /**
  65250. * Creates an extruded polygon mesh, with depth in the Y direction.
  65251. * * 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)
  65252. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65253. * @param name defines the name of the mesh
  65254. * @param options defines the options used to create the mesh
  65255. * @param scene defines the hosting scene
  65256. * @param earcutInjection can be used to inject your own earcut reference
  65257. * @returns the polygon mesh
  65258. */
  65259. static ExtrudePolygon(name: string, options: {
  65260. shape: Vector3[];
  65261. holes?: Vector3[][];
  65262. depth?: number;
  65263. faceUV?: Vector4[];
  65264. faceColors?: Color4[];
  65265. updatable?: boolean;
  65266. sideOrientation?: number;
  65267. frontUVs?: Vector4;
  65268. backUVs?: Vector4;
  65269. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65270. /**
  65271. * Creates a tube mesh.
  65272. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65273. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65274. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65275. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65276. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65277. * * 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)
  65278. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65279. * * 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
  65280. * * 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
  65281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65285. * @param name defines the name of the mesh
  65286. * @param options defines the options used to create the mesh
  65287. * @param scene defines the hosting scene
  65288. * @returns the tube mesh
  65289. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65290. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65291. */
  65292. static CreateTube(name: string, options: {
  65293. path: Vector3[];
  65294. radius?: number;
  65295. tessellation?: number;
  65296. radiusFunction?: {
  65297. (i: number, distance: number): number;
  65298. };
  65299. cap?: number;
  65300. arc?: number;
  65301. updatable?: boolean;
  65302. sideOrientation?: number;
  65303. frontUVs?: Vector4;
  65304. backUVs?: Vector4;
  65305. instance?: Mesh;
  65306. invertUV?: boolean;
  65307. }, scene?: Nullable<Scene>): Mesh;
  65308. /**
  65309. * Creates a polyhedron mesh
  65310. * * 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
  65311. * * The parameter `size` (positive float, default 1) sets the polygon size
  65312. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65313. * * 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`
  65314. * * 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
  65315. * * 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)`)
  65316. * * 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
  65317. * * 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
  65318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65321. * @param name defines the name of the mesh
  65322. * @param options defines the options used to create the mesh
  65323. * @param scene defines the hosting scene
  65324. * @returns the polyhedron mesh
  65325. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65326. */
  65327. static CreatePolyhedron(name: string, options: {
  65328. type?: number;
  65329. size?: number;
  65330. sizeX?: number;
  65331. sizeY?: number;
  65332. sizeZ?: number;
  65333. custom?: any;
  65334. faceUV?: Vector4[];
  65335. faceColors?: Color4[];
  65336. flat?: boolean;
  65337. updatable?: boolean;
  65338. sideOrientation?: number;
  65339. frontUVs?: Vector4;
  65340. backUVs?: Vector4;
  65341. }, scene?: Nullable<Scene>): Mesh;
  65342. /**
  65343. * Creates a decal mesh.
  65344. * 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
  65345. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65346. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65347. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65348. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65349. * @param name defines the name of the mesh
  65350. * @param sourceMesh defines the mesh where the decal must be applied
  65351. * @param options defines the options used to create the mesh
  65352. * @param scene defines the hosting scene
  65353. * @returns the decal mesh
  65354. * @see https://doc.babylonjs.com/how_to/decals
  65355. */
  65356. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65357. position?: Vector3;
  65358. normal?: Vector3;
  65359. size?: Vector3;
  65360. angle?: number;
  65361. }): Mesh;
  65362. }
  65363. }
  65364. declare module "babylonjs/Meshes/meshSimplification" {
  65365. import { Mesh } from "babylonjs/Meshes/mesh";
  65366. /**
  65367. * A simplifier interface for future simplification implementations
  65368. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65369. */
  65370. export interface ISimplifier {
  65371. /**
  65372. * Simplification of a given mesh according to the given settings.
  65373. * Since this requires computation, it is assumed that the function runs async.
  65374. * @param settings The settings of the simplification, including quality and distance
  65375. * @param successCallback A callback that will be called after the mesh was simplified.
  65376. * @param errorCallback in case of an error, this callback will be called. optional.
  65377. */
  65378. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65379. }
  65380. /**
  65381. * Expected simplification settings.
  65382. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65383. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65384. */
  65385. export interface ISimplificationSettings {
  65386. /**
  65387. * Gets or sets the expected quality
  65388. */
  65389. quality: number;
  65390. /**
  65391. * Gets or sets the distance when this optimized version should be used
  65392. */
  65393. distance: number;
  65394. /**
  65395. * Gets an already optimized mesh
  65396. */
  65397. optimizeMesh?: boolean;
  65398. }
  65399. /**
  65400. * Class used to specify simplification options
  65401. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65402. */
  65403. export class SimplificationSettings implements ISimplificationSettings {
  65404. /** expected quality */
  65405. quality: number;
  65406. /** distance when this optimized version should be used */
  65407. distance: number;
  65408. /** already optimized mesh */
  65409. optimizeMesh?: boolean | undefined;
  65410. /**
  65411. * Creates a SimplificationSettings
  65412. * @param quality expected quality
  65413. * @param distance distance when this optimized version should be used
  65414. * @param optimizeMesh already optimized mesh
  65415. */
  65416. constructor(
  65417. /** expected quality */
  65418. quality: number,
  65419. /** distance when this optimized version should be used */
  65420. distance: number,
  65421. /** already optimized mesh */
  65422. optimizeMesh?: boolean | undefined);
  65423. }
  65424. /**
  65425. * Interface used to define a simplification task
  65426. */
  65427. export interface ISimplificationTask {
  65428. /**
  65429. * Array of settings
  65430. */
  65431. settings: Array<ISimplificationSettings>;
  65432. /**
  65433. * Simplification type
  65434. */
  65435. simplificationType: SimplificationType;
  65436. /**
  65437. * Mesh to simplify
  65438. */
  65439. mesh: Mesh;
  65440. /**
  65441. * Callback called on success
  65442. */
  65443. successCallback?: () => void;
  65444. /**
  65445. * Defines if parallel processing can be used
  65446. */
  65447. parallelProcessing: boolean;
  65448. }
  65449. /**
  65450. * Queue used to order the simplification tasks
  65451. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65452. */
  65453. export class SimplificationQueue {
  65454. private _simplificationArray;
  65455. /**
  65456. * Gets a boolean indicating that the process is still running
  65457. */
  65458. running: boolean;
  65459. /**
  65460. * Creates a new queue
  65461. */
  65462. constructor();
  65463. /**
  65464. * Adds a new simplification task
  65465. * @param task defines a task to add
  65466. */
  65467. addTask(task: ISimplificationTask): void;
  65468. /**
  65469. * Execute next task
  65470. */
  65471. executeNext(): void;
  65472. /**
  65473. * Execute a simplification task
  65474. * @param task defines the task to run
  65475. */
  65476. runSimplification(task: ISimplificationTask): void;
  65477. private getSimplifier;
  65478. }
  65479. /**
  65480. * The implemented types of simplification
  65481. * At the moment only Quadratic Error Decimation is implemented
  65482. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65483. */
  65484. export enum SimplificationType {
  65485. /** Quadratic error decimation */
  65486. QUADRATIC = 0
  65487. }
  65488. /**
  65489. * An implementation of the Quadratic Error simplification algorithm.
  65490. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65491. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65492. * @author RaananW
  65493. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65494. */
  65495. export class QuadraticErrorSimplification implements ISimplifier {
  65496. private _mesh;
  65497. private triangles;
  65498. private vertices;
  65499. private references;
  65500. private _reconstructedMesh;
  65501. /** Gets or sets the number pf sync interations */
  65502. syncIterations: number;
  65503. /** Gets or sets the aggressiveness of the simplifier */
  65504. aggressiveness: number;
  65505. /** Gets or sets the number of allowed iterations for decimation */
  65506. decimationIterations: number;
  65507. /** Gets or sets the espilon to use for bounding box computation */
  65508. boundingBoxEpsilon: number;
  65509. /**
  65510. * Creates a new QuadraticErrorSimplification
  65511. * @param _mesh defines the target mesh
  65512. */
  65513. constructor(_mesh: Mesh);
  65514. /**
  65515. * Simplification of a given mesh according to the given settings.
  65516. * Since this requires computation, it is assumed that the function runs async.
  65517. * @param settings The settings of the simplification, including quality and distance
  65518. * @param successCallback A callback that will be called after the mesh was simplified.
  65519. */
  65520. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65521. private runDecimation;
  65522. private initWithMesh;
  65523. private init;
  65524. private reconstructMesh;
  65525. private initDecimatedMesh;
  65526. private isFlipped;
  65527. private updateTriangles;
  65528. private identifyBorder;
  65529. private updateMesh;
  65530. private vertexError;
  65531. private calculateError;
  65532. }
  65533. }
  65534. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65535. import { Scene } from "babylonjs/scene";
  65536. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65537. import { ISceneComponent } from "babylonjs/sceneComponent";
  65538. module "babylonjs/scene" {
  65539. interface Scene {
  65540. /** @hidden (Backing field) */
  65541. _simplificationQueue: SimplificationQueue;
  65542. /**
  65543. * Gets or sets the simplification queue attached to the scene
  65544. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65545. */
  65546. simplificationQueue: SimplificationQueue;
  65547. }
  65548. }
  65549. module "babylonjs/Meshes/mesh" {
  65550. interface Mesh {
  65551. /**
  65552. * Simplify the mesh according to the given array of settings.
  65553. * Function will return immediately and will simplify async
  65554. * @param settings a collection of simplification settings
  65555. * @param parallelProcessing should all levels calculate parallel or one after the other
  65556. * @param simplificationType the type of simplification to run
  65557. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65558. * @returns the current mesh
  65559. */
  65560. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65561. }
  65562. }
  65563. /**
  65564. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65565. * created in a scene
  65566. */
  65567. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65568. /**
  65569. * The component name helpfull to identify the component in the list of scene components.
  65570. */
  65571. readonly name: string;
  65572. /**
  65573. * The scene the component belongs to.
  65574. */
  65575. scene: Scene;
  65576. /**
  65577. * Creates a new instance of the component for the given scene
  65578. * @param scene Defines the scene to register the component in
  65579. */
  65580. constructor(scene: Scene);
  65581. /**
  65582. * Registers the component in a given scene
  65583. */
  65584. register(): void;
  65585. /**
  65586. * Rebuilds the elements related to this component in case of
  65587. * context lost for instance.
  65588. */
  65589. rebuild(): void;
  65590. /**
  65591. * Disposes the component and the associated ressources
  65592. */
  65593. dispose(): void;
  65594. private _beforeCameraUpdate;
  65595. }
  65596. }
  65597. declare module "babylonjs/Meshes/Builders/index" {
  65598. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65599. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65600. export * from "babylonjs/Meshes/Builders/discBuilder";
  65601. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65602. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65603. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65604. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65605. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65606. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65607. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65608. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65609. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65610. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65611. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65612. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65613. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65614. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65615. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65616. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65617. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65618. }
  65619. declare module "babylonjs/Meshes/index" {
  65620. export * from "babylonjs/Meshes/abstractMesh";
  65621. export * from "babylonjs/Meshes/buffer";
  65622. export * from "babylonjs/Meshes/Compression/index";
  65623. export * from "babylonjs/Meshes/csg";
  65624. export * from "babylonjs/Meshes/geometry";
  65625. export * from "babylonjs/Meshes/groundMesh";
  65626. export * from "babylonjs/Meshes/trailMesh";
  65627. export * from "babylonjs/Meshes/instancedMesh";
  65628. export * from "babylonjs/Meshes/linesMesh";
  65629. export * from "babylonjs/Meshes/mesh";
  65630. export * from "babylonjs/Meshes/mesh.vertexData";
  65631. export * from "babylonjs/Meshes/meshBuilder";
  65632. export * from "babylonjs/Meshes/meshSimplification";
  65633. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65634. export * from "babylonjs/Meshes/polygonMesh";
  65635. export * from "babylonjs/Meshes/subMesh";
  65636. export * from "babylonjs/Meshes/meshLODLevel";
  65637. export * from "babylonjs/Meshes/transformNode";
  65638. export * from "babylonjs/Meshes/Builders/index";
  65639. export * from "babylonjs/Meshes/dataBuffer";
  65640. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65641. }
  65642. declare module "babylonjs/Morph/index" {
  65643. export * from "babylonjs/Morph/morphTarget";
  65644. export * from "babylonjs/Morph/morphTargetManager";
  65645. }
  65646. declare module "babylonjs/Navigation/INavigationEngine" {
  65647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65648. import { Vector3 } from "babylonjs/Maths/math";
  65649. import { Mesh } from "babylonjs/Meshes/mesh";
  65650. import { Scene } from "babylonjs/scene";
  65651. /**
  65652. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65653. */
  65654. export interface INavigationEnginePlugin {
  65655. /**
  65656. * plugin name
  65657. */
  65658. name: string;
  65659. /**
  65660. * Creates a navigation mesh
  65661. * @param meshes array of all the geometry used to compute the navigatio mesh
  65662. * @param parameters bunch of parameters used to filter geometry
  65663. */
  65664. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65665. /**
  65666. * Create a navigation mesh debug mesh
  65667. * @param scene is where the mesh will be added
  65668. * @returns debug display mesh
  65669. */
  65670. createDebugNavMesh(scene: Scene): Mesh;
  65671. /**
  65672. * Get a navigation mesh constrained position, closest to the parameter position
  65673. * @param position world position
  65674. * @returns the closest point to position constrained by the navigation mesh
  65675. */
  65676. getClosestPoint(position: Vector3): Vector3;
  65677. /**
  65678. * Get a navigation mesh constrained position, closest to the parameter position
  65679. * @param position world position
  65680. * @param result output the closest point to position constrained by the navigation mesh
  65681. */
  65682. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65683. /**
  65684. * Get a navigation mesh constrained position, within a particular radius
  65685. * @param position world position
  65686. * @param maxRadius the maximum distance to the constrained world position
  65687. * @returns the closest point to position constrained by the navigation mesh
  65688. */
  65689. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65690. /**
  65691. * Get a navigation mesh constrained position, within a particular radius
  65692. * @param position world position
  65693. * @param maxRadius the maximum distance to the constrained world position
  65694. * @param result output the closest point to position constrained by the navigation mesh
  65695. */
  65696. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65697. /**
  65698. * Compute the final position from a segment made of destination-position
  65699. * @param position world position
  65700. * @param destination world position
  65701. * @returns the resulting point along the navmesh
  65702. */
  65703. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65704. /**
  65705. * Compute the final position from a segment made of destination-position
  65706. * @param position world position
  65707. * @param destination world position
  65708. * @param result output the resulting point along the navmesh
  65709. */
  65710. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65711. /**
  65712. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65713. * @param start world position
  65714. * @param end world position
  65715. * @returns array containing world position composing the path
  65716. */
  65717. computePath(start: Vector3, end: Vector3): Vector3[];
  65718. /**
  65719. * If this plugin is supported
  65720. * @returns true if plugin is supported
  65721. */
  65722. isSupported(): boolean;
  65723. /**
  65724. * Create a new Crowd so you can add agents
  65725. * @param maxAgents the maximum agent count in the crowd
  65726. * @param maxAgentRadius the maximum radius an agent can have
  65727. * @param scene to attach the crowd to
  65728. * @returns the crowd you can add agents to
  65729. */
  65730. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65731. /**
  65732. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65733. * The queries will try to find a solution within those bounds
  65734. * default is (1,1,1)
  65735. * @param extent x,y,z value that define the extent around the queries point of reference
  65736. */
  65737. setDefaultQueryExtent(extent: Vector3): void;
  65738. /**
  65739. * Get the Bounding box extent specified by setDefaultQueryExtent
  65740. * @returns the box extent values
  65741. */
  65742. getDefaultQueryExtent(): Vector3;
  65743. /**
  65744. * build the navmesh from a previously saved state using getNavmeshData
  65745. * @param data the Uint8Array returned by getNavmeshData
  65746. */
  65747. buildFromNavmeshData(data: Uint8Array): void;
  65748. /**
  65749. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65750. * @returns data the Uint8Array that can be saved and reused
  65751. */
  65752. getNavmeshData(): Uint8Array;
  65753. /**
  65754. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65755. * @param result output the box extent values
  65756. */
  65757. getDefaultQueryExtentToRef(result: Vector3): void;
  65758. /**
  65759. * Release all resources
  65760. */
  65761. dispose(): void;
  65762. }
  65763. /**
  65764. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65765. */
  65766. export interface ICrowd {
  65767. /**
  65768. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65769. * You can attach anything to that node. The node position is updated in the scene update tick.
  65770. * @param pos world position that will be constrained by the navigation mesh
  65771. * @param parameters agent parameters
  65772. * @param transform hooked to the agent that will be update by the scene
  65773. * @returns agent index
  65774. */
  65775. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65776. /**
  65777. * Returns the agent position in world space
  65778. * @param index agent index returned by addAgent
  65779. * @returns world space position
  65780. */
  65781. getAgentPosition(index: number): Vector3;
  65782. /**
  65783. * Gets the agent position result in world space
  65784. * @param index agent index returned by addAgent
  65785. * @param result output world space position
  65786. */
  65787. getAgentPositionToRef(index: number, result: Vector3): void;
  65788. /**
  65789. * Gets the agent velocity in world space
  65790. * @param index agent index returned by addAgent
  65791. * @returns world space velocity
  65792. */
  65793. getAgentVelocity(index: number): Vector3;
  65794. /**
  65795. * Gets the agent velocity result in world space
  65796. * @param index agent index returned by addAgent
  65797. * @param result output world space velocity
  65798. */
  65799. getAgentVelocityToRef(index: number, result: Vector3): void;
  65800. /**
  65801. * remove a particular agent previously created
  65802. * @param index agent index returned by addAgent
  65803. */
  65804. removeAgent(index: number): void;
  65805. /**
  65806. * get the list of all agents attached to this crowd
  65807. * @returns list of agent indices
  65808. */
  65809. getAgents(): number[];
  65810. /**
  65811. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65812. * @param deltaTime in seconds
  65813. */
  65814. update(deltaTime: number): void;
  65815. /**
  65816. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65817. * @param index agent index returned by addAgent
  65818. * @param destination targeted world position
  65819. */
  65820. agentGoto(index: number, destination: Vector3): void;
  65821. /**
  65822. * Teleport the agent to a new position
  65823. * @param index agent index returned by addAgent
  65824. * @param destination targeted world position
  65825. */
  65826. agentTeleport(index: number, destination: Vector3): void;
  65827. /**
  65828. * Update agent parameters
  65829. * @param index agent index returned by addAgent
  65830. * @param parameters agent parameters
  65831. */
  65832. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65833. /**
  65834. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65835. * The queries will try to find a solution within those bounds
  65836. * default is (1,1,1)
  65837. * @param extent x,y,z value that define the extent around the queries point of reference
  65838. */
  65839. setDefaultQueryExtent(extent: Vector3): void;
  65840. /**
  65841. * Get the Bounding box extent specified by setDefaultQueryExtent
  65842. * @returns the box extent values
  65843. */
  65844. getDefaultQueryExtent(): Vector3;
  65845. /**
  65846. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65847. * @param result output the box extent values
  65848. */
  65849. getDefaultQueryExtentToRef(result: Vector3): void;
  65850. /**
  65851. * Release all resources
  65852. */
  65853. dispose(): void;
  65854. }
  65855. /**
  65856. * Configures an agent
  65857. */
  65858. export interface IAgentParameters {
  65859. /**
  65860. * Agent radius. [Limit: >= 0]
  65861. */
  65862. radius: number;
  65863. /**
  65864. * Agent height. [Limit: > 0]
  65865. */
  65866. height: number;
  65867. /**
  65868. * Maximum allowed acceleration. [Limit: >= 0]
  65869. */
  65870. maxAcceleration: number;
  65871. /**
  65872. * Maximum allowed speed. [Limit: >= 0]
  65873. */
  65874. maxSpeed: number;
  65875. /**
  65876. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65877. */
  65878. collisionQueryRange: number;
  65879. /**
  65880. * The path visibility optimization range. [Limit: > 0]
  65881. */
  65882. pathOptimizationRange: number;
  65883. /**
  65884. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65885. */
  65886. separationWeight: number;
  65887. }
  65888. /**
  65889. * Configures the navigation mesh creation
  65890. */
  65891. export interface INavMeshParameters {
  65892. /**
  65893. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65894. */
  65895. cs: number;
  65896. /**
  65897. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65898. */
  65899. ch: number;
  65900. /**
  65901. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65902. */
  65903. walkableSlopeAngle: number;
  65904. /**
  65905. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65906. * be considered walkable. [Limit: >= 3] [Units: vx]
  65907. */
  65908. walkableHeight: number;
  65909. /**
  65910. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65911. */
  65912. walkableClimb: number;
  65913. /**
  65914. * The distance to erode/shrink the walkable area of the heightfield away from
  65915. * obstructions. [Limit: >=0] [Units: vx]
  65916. */
  65917. walkableRadius: number;
  65918. /**
  65919. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65920. */
  65921. maxEdgeLen: number;
  65922. /**
  65923. * The maximum distance a simplfied contour's border edges should deviate
  65924. * the original raw contour. [Limit: >=0] [Units: vx]
  65925. */
  65926. maxSimplificationError: number;
  65927. /**
  65928. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65929. */
  65930. minRegionArea: number;
  65931. /**
  65932. * Any regions with a span count smaller than this value will, if possible,
  65933. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65934. */
  65935. mergeRegionArea: number;
  65936. /**
  65937. * The maximum number of vertices allowed for polygons generated during the
  65938. * contour to polygon conversion process. [Limit: >= 3]
  65939. */
  65940. maxVertsPerPoly: number;
  65941. /**
  65942. * Sets the sampling distance to use when generating the detail mesh.
  65943. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65944. */
  65945. detailSampleDist: number;
  65946. /**
  65947. * The maximum distance the detail mesh surface should deviate from heightfield
  65948. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65949. */
  65950. detailSampleMaxError: number;
  65951. }
  65952. }
  65953. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65954. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65955. import { Mesh } from "babylonjs/Meshes/mesh";
  65956. import { Scene } from "babylonjs/scene";
  65957. import { Vector3 } from "babylonjs/Maths/math";
  65958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65959. /**
  65960. * RecastJS navigation plugin
  65961. */
  65962. export class RecastJSPlugin implements INavigationEnginePlugin {
  65963. /**
  65964. * Reference to the Recast library
  65965. */
  65966. bjsRECAST: any;
  65967. /**
  65968. * plugin name
  65969. */
  65970. name: string;
  65971. /**
  65972. * the first navmesh created. We might extend this to support multiple navmeshes
  65973. */
  65974. navMesh: any;
  65975. /**
  65976. * Initializes the recastJS plugin
  65977. * @param recastInjection can be used to inject your own recast reference
  65978. */
  65979. constructor(recastInjection?: any);
  65980. /**
  65981. * Creates a navigation mesh
  65982. * @param meshes array of all the geometry used to compute the navigatio mesh
  65983. * @param parameters bunch of parameters used to filter geometry
  65984. */
  65985. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65986. /**
  65987. * Create a navigation mesh debug mesh
  65988. * @param scene is where the mesh will be added
  65989. * @returns debug display mesh
  65990. */
  65991. createDebugNavMesh(scene: Scene): Mesh;
  65992. /**
  65993. * Get a navigation mesh constrained position, closest to the parameter position
  65994. * @param position world position
  65995. * @returns the closest point to position constrained by the navigation mesh
  65996. */
  65997. getClosestPoint(position: Vector3): Vector3;
  65998. /**
  65999. * Get a navigation mesh constrained position, closest to the parameter position
  66000. * @param position world position
  66001. * @param result output the closest point to position constrained by the navigation mesh
  66002. */
  66003. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66004. /**
  66005. * Get a navigation mesh constrained position, within a particular radius
  66006. * @param position world position
  66007. * @param maxRadius the maximum distance to the constrained world position
  66008. * @returns the closest point to position constrained by the navigation mesh
  66009. */
  66010. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66011. /**
  66012. * Get a navigation mesh constrained position, within a particular radius
  66013. * @param position world position
  66014. * @param maxRadius the maximum distance to the constrained world position
  66015. * @param result output the closest point to position constrained by the navigation mesh
  66016. */
  66017. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66018. /**
  66019. * Compute the final position from a segment made of destination-position
  66020. * @param position world position
  66021. * @param destination world position
  66022. * @returns the resulting point along the navmesh
  66023. */
  66024. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66025. /**
  66026. * Compute the final position from a segment made of destination-position
  66027. * @param position world position
  66028. * @param destination world position
  66029. * @param result output the resulting point along the navmesh
  66030. */
  66031. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66032. /**
  66033. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66034. * @param start world position
  66035. * @param end world position
  66036. * @returns array containing world position composing the path
  66037. */
  66038. computePath(start: Vector3, end: Vector3): Vector3[];
  66039. /**
  66040. * Create a new Crowd so you can add agents
  66041. * @param maxAgents the maximum agent count in the crowd
  66042. * @param maxAgentRadius the maximum radius an agent can have
  66043. * @param scene to attach the crowd to
  66044. * @returns the crowd you can add agents to
  66045. */
  66046. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66047. /**
  66048. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66049. * The queries will try to find a solution within those bounds
  66050. * default is (1,1,1)
  66051. * @param extent x,y,z value that define the extent around the queries point of reference
  66052. */
  66053. setDefaultQueryExtent(extent: Vector3): void;
  66054. /**
  66055. * Get the Bounding box extent specified by setDefaultQueryExtent
  66056. * @returns the box extent values
  66057. */
  66058. getDefaultQueryExtent(): Vector3;
  66059. /**
  66060. * build the navmesh from a previously saved state using getNavmeshData
  66061. * @param data the Uint8Array returned by getNavmeshData
  66062. */
  66063. buildFromNavmeshData(data: Uint8Array): void;
  66064. /**
  66065. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66066. * @returns data the Uint8Array that can be saved and reused
  66067. */
  66068. getNavmeshData(): Uint8Array;
  66069. /**
  66070. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66071. * @param result output the box extent values
  66072. */
  66073. getDefaultQueryExtentToRef(result: Vector3): void;
  66074. /**
  66075. * Disposes
  66076. */
  66077. dispose(): void;
  66078. /**
  66079. * If this plugin is supported
  66080. * @returns true if plugin is supported
  66081. */
  66082. isSupported(): boolean;
  66083. }
  66084. /**
  66085. * Recast detour crowd implementation
  66086. */
  66087. export class RecastJSCrowd implements ICrowd {
  66088. /**
  66089. * Recast/detour plugin
  66090. */
  66091. bjsRECASTPlugin: RecastJSPlugin;
  66092. /**
  66093. * Link to the detour crowd
  66094. */
  66095. recastCrowd: any;
  66096. /**
  66097. * One transform per agent
  66098. */
  66099. transforms: TransformNode[];
  66100. /**
  66101. * All agents created
  66102. */
  66103. agents: number[];
  66104. /**
  66105. * Link to the scene is kept to unregister the crowd from the scene
  66106. */
  66107. private _scene;
  66108. /**
  66109. * Observer for crowd updates
  66110. */
  66111. private _onBeforeAnimationsObserver;
  66112. /**
  66113. * Constructor
  66114. * @param plugin recastJS plugin
  66115. * @param maxAgents the maximum agent count in the crowd
  66116. * @param maxAgentRadius the maximum radius an agent can have
  66117. * @param scene to attach the crowd to
  66118. * @returns the crowd you can add agents to
  66119. */
  66120. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66121. /**
  66122. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66123. * You can attach anything to that node. The node position is updated in the scene update tick.
  66124. * @param pos world position that will be constrained by the navigation mesh
  66125. * @param parameters agent parameters
  66126. * @param transform hooked to the agent that will be update by the scene
  66127. * @returns agent index
  66128. */
  66129. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66130. /**
  66131. * Returns the agent position in world space
  66132. * @param index agent index returned by addAgent
  66133. * @returns world space position
  66134. */
  66135. getAgentPosition(index: number): Vector3;
  66136. /**
  66137. * Returns the agent position result in world space
  66138. * @param index agent index returned by addAgent
  66139. * @param result output world space position
  66140. */
  66141. getAgentPositionToRef(index: number, result: Vector3): void;
  66142. /**
  66143. * Returns the agent velocity in world space
  66144. * @param index agent index returned by addAgent
  66145. * @returns world space velocity
  66146. */
  66147. getAgentVelocity(index: number): Vector3;
  66148. /**
  66149. * Returns the agent velocity result in world space
  66150. * @param index agent index returned by addAgent
  66151. * @param result output world space velocity
  66152. */
  66153. getAgentVelocityToRef(index: number, result: Vector3): void;
  66154. /**
  66155. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66156. * @param index agent index returned by addAgent
  66157. * @param destination targeted world position
  66158. */
  66159. agentGoto(index: number, destination: Vector3): void;
  66160. /**
  66161. * Teleport the agent to a new position
  66162. * @param index agent index returned by addAgent
  66163. * @param destination targeted world position
  66164. */
  66165. agentTeleport(index: number, destination: Vector3): void;
  66166. /**
  66167. * Update agent parameters
  66168. * @param index agent index returned by addAgent
  66169. * @param parameters agent parameters
  66170. */
  66171. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66172. /**
  66173. * remove a particular agent previously created
  66174. * @param index agent index returned by addAgent
  66175. */
  66176. removeAgent(index: number): void;
  66177. /**
  66178. * get the list of all agents attached to this crowd
  66179. * @returns list of agent indices
  66180. */
  66181. getAgents(): number[];
  66182. /**
  66183. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66184. * @param deltaTime in seconds
  66185. */
  66186. update(deltaTime: number): void;
  66187. /**
  66188. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66189. * The queries will try to find a solution within those bounds
  66190. * default is (1,1,1)
  66191. * @param extent x,y,z value that define the extent around the queries point of reference
  66192. */
  66193. setDefaultQueryExtent(extent: Vector3): void;
  66194. /**
  66195. * Get the Bounding box extent specified by setDefaultQueryExtent
  66196. * @returns the box extent values
  66197. */
  66198. getDefaultQueryExtent(): Vector3;
  66199. /**
  66200. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66201. * @param result output the box extent values
  66202. */
  66203. getDefaultQueryExtentToRef(result: Vector3): void;
  66204. /**
  66205. * Release all resources
  66206. */
  66207. dispose(): void;
  66208. }
  66209. }
  66210. declare module "babylonjs/Navigation/Plugins/index" {
  66211. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66212. }
  66213. declare module "babylonjs/Navigation/index" {
  66214. export * from "babylonjs/Navigation/INavigationEngine";
  66215. export * from "babylonjs/Navigation/Plugins/index";
  66216. }
  66217. declare module "babylonjs/Offline/database" {
  66218. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66219. /**
  66220. * Class used to enable access to IndexedDB
  66221. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66222. */
  66223. export class Database implements IOfflineProvider {
  66224. private _callbackManifestChecked;
  66225. private _currentSceneUrl;
  66226. private _db;
  66227. private _enableSceneOffline;
  66228. private _enableTexturesOffline;
  66229. private _manifestVersionFound;
  66230. private _mustUpdateRessources;
  66231. private _hasReachedQuota;
  66232. private _isSupported;
  66233. private _idbFactory;
  66234. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66235. private static IsUASupportingBlobStorage;
  66236. /**
  66237. * Gets a boolean indicating if Database storate is enabled (off by default)
  66238. */
  66239. static IDBStorageEnabled: boolean;
  66240. /**
  66241. * Gets a boolean indicating if scene must be saved in the database
  66242. */
  66243. get enableSceneOffline(): boolean;
  66244. /**
  66245. * Gets a boolean indicating if textures must be saved in the database
  66246. */
  66247. get enableTexturesOffline(): boolean;
  66248. /**
  66249. * Creates a new Database
  66250. * @param urlToScene defines the url to load the scene
  66251. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66252. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66253. */
  66254. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66255. private static _ParseURL;
  66256. private static _ReturnFullUrlLocation;
  66257. private _checkManifestFile;
  66258. /**
  66259. * Open the database and make it available
  66260. * @param successCallback defines the callback to call on success
  66261. * @param errorCallback defines the callback to call on error
  66262. */
  66263. open(successCallback: () => void, errorCallback: () => void): void;
  66264. /**
  66265. * Loads an image from the database
  66266. * @param url defines the url to load from
  66267. * @param image defines the target DOM image
  66268. */
  66269. loadImage(url: string, image: HTMLImageElement): void;
  66270. private _loadImageFromDBAsync;
  66271. private _saveImageIntoDBAsync;
  66272. private _checkVersionFromDB;
  66273. private _loadVersionFromDBAsync;
  66274. private _saveVersionIntoDBAsync;
  66275. /**
  66276. * Loads a file from database
  66277. * @param url defines the URL to load from
  66278. * @param sceneLoaded defines a callback to call on success
  66279. * @param progressCallBack defines a callback to call when progress changed
  66280. * @param errorCallback defines a callback to call on error
  66281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66282. */
  66283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66284. private _loadFileAsync;
  66285. private _saveFileAsync;
  66286. /**
  66287. * Validates if xhr data is correct
  66288. * @param xhr defines the request to validate
  66289. * @param dataType defines the expected data type
  66290. * @returns true if data is correct
  66291. */
  66292. private static _ValidateXHRData;
  66293. }
  66294. }
  66295. declare module "babylonjs/Offline/index" {
  66296. export * from "babylonjs/Offline/database";
  66297. export * from "babylonjs/Offline/IOfflineProvider";
  66298. }
  66299. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66300. /** @hidden */
  66301. export var gpuUpdateParticlesPixelShader: {
  66302. name: string;
  66303. shader: string;
  66304. };
  66305. }
  66306. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66307. /** @hidden */
  66308. export var gpuUpdateParticlesVertexShader: {
  66309. name: string;
  66310. shader: string;
  66311. };
  66312. }
  66313. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66314. /** @hidden */
  66315. export var clipPlaneFragmentDeclaration2: {
  66316. name: string;
  66317. shader: string;
  66318. };
  66319. }
  66320. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66322. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66326. /** @hidden */
  66327. export var gpuRenderParticlesPixelShader: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66333. /** @hidden */
  66334. export var clipPlaneVertexDeclaration2: {
  66335. name: string;
  66336. shader: string;
  66337. };
  66338. }
  66339. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66340. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66342. /** @hidden */
  66343. export var gpuRenderParticlesVertexShader: {
  66344. name: string;
  66345. shader: string;
  66346. };
  66347. }
  66348. declare module "babylonjs/Particles/gpuParticleSystem" {
  66349. import { Nullable } from "babylonjs/types";
  66350. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66351. import { Observable } from "babylonjs/Misc/observable";
  66352. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66353. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66354. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66355. import { Scene, IDisposable } from "babylonjs/scene";
  66356. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66357. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66358. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66359. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66360. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66361. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66362. /**
  66363. * This represents a GPU particle system in Babylon
  66364. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66365. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66366. */
  66367. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66368. /**
  66369. * The layer mask we are rendering the particles through.
  66370. */
  66371. layerMask: number;
  66372. private _capacity;
  66373. private _activeCount;
  66374. private _currentActiveCount;
  66375. private _accumulatedCount;
  66376. private _renderEffect;
  66377. private _updateEffect;
  66378. private _buffer0;
  66379. private _buffer1;
  66380. private _spriteBuffer;
  66381. private _updateVAO;
  66382. private _renderVAO;
  66383. private _targetIndex;
  66384. private _sourceBuffer;
  66385. private _targetBuffer;
  66386. private _engine;
  66387. private _currentRenderId;
  66388. private _started;
  66389. private _stopped;
  66390. private _timeDelta;
  66391. private _randomTexture;
  66392. private _randomTexture2;
  66393. private _attributesStrideSize;
  66394. private _updateEffectOptions;
  66395. private _randomTextureSize;
  66396. private _actualFrame;
  66397. private readonly _rawTextureWidth;
  66398. /**
  66399. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66400. */
  66401. static get IsSupported(): boolean;
  66402. /**
  66403. * An event triggered when the system is disposed.
  66404. */
  66405. onDisposeObservable: Observable<GPUParticleSystem>;
  66406. /**
  66407. * Gets the maximum number of particles active at the same time.
  66408. * @returns The max number of active particles.
  66409. */
  66410. getCapacity(): number;
  66411. /**
  66412. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66413. * to override the particles.
  66414. */
  66415. forceDepthWrite: boolean;
  66416. /**
  66417. * Gets or set the number of active particles
  66418. */
  66419. get activeParticleCount(): number;
  66420. set activeParticleCount(value: number);
  66421. private _preWarmDone;
  66422. /**
  66423. * Specifies if the particles are updated in emitter local space or world space.
  66424. * This is always false for GPU particles
  66425. */
  66426. get isLocal(): boolean;
  66427. set isLocal(value: boolean);
  66428. /**
  66429. * Is this system ready to be used/rendered
  66430. * @return true if the system is ready
  66431. */
  66432. isReady(): boolean;
  66433. /**
  66434. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66435. * @returns True if it has been started, otherwise false.
  66436. */
  66437. isStarted(): boolean;
  66438. /**
  66439. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66440. * @returns True if it has been stopped, otherwise false.
  66441. */
  66442. isStopped(): boolean;
  66443. /**
  66444. * Gets a boolean indicating that the system is stopping
  66445. * @returns true if the system is currently stopping
  66446. */
  66447. isStopping(): boolean;
  66448. /**
  66449. * Gets the number of particles active at the same time.
  66450. * @returns The number of active particles.
  66451. */
  66452. getActiveCount(): number;
  66453. /**
  66454. * Starts the particle system and begins to emit
  66455. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66456. */
  66457. start(delay?: number): void;
  66458. /**
  66459. * Stops the particle system.
  66460. */
  66461. stop(): void;
  66462. /**
  66463. * Remove all active particles
  66464. */
  66465. reset(): void;
  66466. /**
  66467. * Returns the string "GPUParticleSystem"
  66468. * @returns a string containing the class name
  66469. */
  66470. getClassName(): string;
  66471. private _colorGradientsTexture;
  66472. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66473. /**
  66474. * Adds a new color gradient
  66475. * @param gradient defines the gradient to use (between 0 and 1)
  66476. * @param color1 defines the color to affect to the specified gradient
  66477. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66478. * @returns the current particle system
  66479. */
  66480. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66481. private _refreshColorGradient;
  66482. /** Force the system to rebuild all gradients */
  66483. forceRefreshGradients(): void;
  66484. /**
  66485. * Remove a specific color gradient
  66486. * @param gradient defines the gradient to remove
  66487. * @returns the current particle system
  66488. */
  66489. removeColorGradient(gradient: number): GPUParticleSystem;
  66490. private _angularSpeedGradientsTexture;
  66491. private _sizeGradientsTexture;
  66492. private _velocityGradientsTexture;
  66493. private _limitVelocityGradientsTexture;
  66494. private _dragGradientsTexture;
  66495. private _addFactorGradient;
  66496. /**
  66497. * Adds a new size gradient
  66498. * @param gradient defines the gradient to use (between 0 and 1)
  66499. * @param factor defines the size factor to affect to the specified gradient
  66500. * @returns the current particle system
  66501. */
  66502. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66503. /**
  66504. * Remove a specific size gradient
  66505. * @param gradient defines the gradient to remove
  66506. * @returns the current particle system
  66507. */
  66508. removeSizeGradient(gradient: number): GPUParticleSystem;
  66509. private _refreshFactorGradient;
  66510. /**
  66511. * Adds a new angular speed gradient
  66512. * @param gradient defines the gradient to use (between 0 and 1)
  66513. * @param factor defines the angular speed to affect to the specified gradient
  66514. * @returns the current particle system
  66515. */
  66516. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66517. /**
  66518. * Remove a specific angular speed gradient
  66519. * @param gradient defines the gradient to remove
  66520. * @returns the current particle system
  66521. */
  66522. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66523. /**
  66524. * Adds a new velocity gradient
  66525. * @param gradient defines the gradient to use (between 0 and 1)
  66526. * @param factor defines the velocity to affect to the specified gradient
  66527. * @returns the current particle system
  66528. */
  66529. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66530. /**
  66531. * Remove a specific velocity gradient
  66532. * @param gradient defines the gradient to remove
  66533. * @returns the current particle system
  66534. */
  66535. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66536. /**
  66537. * Adds a new limit velocity gradient
  66538. * @param gradient defines the gradient to use (between 0 and 1)
  66539. * @param factor defines the limit velocity value to affect to the specified gradient
  66540. * @returns the current particle system
  66541. */
  66542. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66543. /**
  66544. * Remove a specific limit velocity gradient
  66545. * @param gradient defines the gradient to remove
  66546. * @returns the current particle system
  66547. */
  66548. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66549. /**
  66550. * Adds a new drag gradient
  66551. * @param gradient defines the gradient to use (between 0 and 1)
  66552. * @param factor defines the drag value to affect to the specified gradient
  66553. * @returns the current particle system
  66554. */
  66555. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66556. /**
  66557. * Remove a specific drag gradient
  66558. * @param gradient defines the gradient to remove
  66559. * @returns the current particle system
  66560. */
  66561. removeDragGradient(gradient: number): GPUParticleSystem;
  66562. /**
  66563. * Not supported by GPUParticleSystem
  66564. * @param gradient defines the gradient to use (between 0 and 1)
  66565. * @param factor defines the emit rate value to affect to the specified gradient
  66566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66567. * @returns the current particle system
  66568. */
  66569. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66570. /**
  66571. * Not supported by GPUParticleSystem
  66572. * @param gradient defines the gradient to remove
  66573. * @returns the current particle system
  66574. */
  66575. removeEmitRateGradient(gradient: number): IParticleSystem;
  66576. /**
  66577. * Not supported by GPUParticleSystem
  66578. * @param gradient defines the gradient to use (between 0 and 1)
  66579. * @param factor defines the start size value to affect to the specified gradient
  66580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66581. * @returns the current particle system
  66582. */
  66583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66584. /**
  66585. * Not supported by GPUParticleSystem
  66586. * @param gradient defines the gradient to remove
  66587. * @returns the current particle system
  66588. */
  66589. removeStartSizeGradient(gradient: number): IParticleSystem;
  66590. /**
  66591. * Not supported by GPUParticleSystem
  66592. * @param gradient defines the gradient to use (between 0 and 1)
  66593. * @param min defines the color remap minimal range
  66594. * @param max defines the color remap maximal range
  66595. * @returns the current particle system
  66596. */
  66597. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66598. /**
  66599. * Not supported by GPUParticleSystem
  66600. * @param gradient defines the gradient to remove
  66601. * @returns the current particle system
  66602. */
  66603. removeColorRemapGradient(): IParticleSystem;
  66604. /**
  66605. * Not supported by GPUParticleSystem
  66606. * @param gradient defines the gradient to use (between 0 and 1)
  66607. * @param min defines the alpha remap minimal range
  66608. * @param max defines the alpha remap maximal range
  66609. * @returns the current particle system
  66610. */
  66611. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66612. /**
  66613. * Not supported by GPUParticleSystem
  66614. * @param gradient defines the gradient to remove
  66615. * @returns the current particle system
  66616. */
  66617. removeAlphaRemapGradient(): IParticleSystem;
  66618. /**
  66619. * Not supported by GPUParticleSystem
  66620. * @param gradient defines the gradient to use (between 0 and 1)
  66621. * @param color defines the color to affect to the specified gradient
  66622. * @returns the current particle system
  66623. */
  66624. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66625. /**
  66626. * Not supported by GPUParticleSystem
  66627. * @param gradient defines the gradient to remove
  66628. * @returns the current particle system
  66629. */
  66630. removeRampGradient(): IParticleSystem;
  66631. /**
  66632. * Not supported by GPUParticleSystem
  66633. * @returns the list of ramp gradients
  66634. */
  66635. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66636. /**
  66637. * Not supported by GPUParticleSystem
  66638. * Gets or sets a boolean indicating that ramp gradients must be used
  66639. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66640. */
  66641. get useRampGradients(): boolean;
  66642. set useRampGradients(value: boolean);
  66643. /**
  66644. * Not supported by GPUParticleSystem
  66645. * @param gradient defines the gradient to use (between 0 and 1)
  66646. * @param factor defines the life time factor to affect to the specified gradient
  66647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66648. * @returns the current particle system
  66649. */
  66650. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66651. /**
  66652. * Not supported by GPUParticleSystem
  66653. * @param gradient defines the gradient to remove
  66654. * @returns the current particle system
  66655. */
  66656. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66657. /**
  66658. * Instantiates a GPU particle system.
  66659. * 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.
  66660. * @param name The name of the particle system
  66661. * @param options The options used to create the system
  66662. * @param scene The scene the particle system belongs to
  66663. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66664. */
  66665. constructor(name: string, options: Partial<{
  66666. capacity: number;
  66667. randomTextureSize: number;
  66668. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66669. protected _reset(): void;
  66670. private _createUpdateVAO;
  66671. private _createRenderVAO;
  66672. private _initialize;
  66673. /** @hidden */
  66674. _recreateUpdateEffect(): void;
  66675. /** @hidden */
  66676. _recreateRenderEffect(): void;
  66677. /**
  66678. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66679. * @param preWarm defines if we are in the pre-warmimg phase
  66680. */
  66681. animate(preWarm?: boolean): void;
  66682. private _createFactorGradientTexture;
  66683. private _createSizeGradientTexture;
  66684. private _createAngularSpeedGradientTexture;
  66685. private _createVelocityGradientTexture;
  66686. private _createLimitVelocityGradientTexture;
  66687. private _createDragGradientTexture;
  66688. private _createColorGradientTexture;
  66689. /**
  66690. * Renders the particle system in its current state
  66691. * @param preWarm defines if the system should only update the particles but not render them
  66692. * @returns the current number of particles
  66693. */
  66694. render(preWarm?: boolean): number;
  66695. /**
  66696. * Rebuilds the particle system
  66697. */
  66698. rebuild(): void;
  66699. private _releaseBuffers;
  66700. private _releaseVAOs;
  66701. /**
  66702. * Disposes the particle system and free the associated resources
  66703. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66704. */
  66705. dispose(disposeTexture?: boolean): void;
  66706. /**
  66707. * Clones the particle system.
  66708. * @param name The name of the cloned object
  66709. * @param newEmitter The new emitter to use
  66710. * @returns the cloned particle system
  66711. */
  66712. clone(name: string, newEmitter: any): GPUParticleSystem;
  66713. /**
  66714. * Serializes the particle system to a JSON object.
  66715. * @returns the JSON object
  66716. */
  66717. serialize(): any;
  66718. /**
  66719. * Parses a JSON object to create a GPU particle system.
  66720. * @param parsedParticleSystem The JSON object to parse
  66721. * @param scene The scene to create the particle system in
  66722. * @param rootUrl The root url to use to load external dependencies like texture
  66723. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66724. * @returns the parsed GPU particle system
  66725. */
  66726. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66727. }
  66728. }
  66729. declare module "babylonjs/Particles/particleSystemSet" {
  66730. import { Nullable } from "babylonjs/types";
  66731. import { Color3 } from "babylonjs/Maths/math.color";
  66732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66734. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66735. import { Scene, IDisposable } from "babylonjs/scene";
  66736. /**
  66737. * Represents a set of particle systems working together to create a specific effect
  66738. */
  66739. export class ParticleSystemSet implements IDisposable {
  66740. /**
  66741. * Gets or sets base Assets URL
  66742. */
  66743. static BaseAssetsUrl: string;
  66744. private _emitterCreationOptions;
  66745. private _emitterNode;
  66746. /**
  66747. * Gets the particle system list
  66748. */
  66749. systems: IParticleSystem[];
  66750. /**
  66751. * Gets the emitter node used with this set
  66752. */
  66753. get emitterNode(): Nullable<TransformNode>;
  66754. /**
  66755. * Creates a new emitter mesh as a sphere
  66756. * @param options defines the options used to create the sphere
  66757. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66758. * @param scene defines the hosting scene
  66759. */
  66760. setEmitterAsSphere(options: {
  66761. diameter: number;
  66762. segments: number;
  66763. color: Color3;
  66764. }, renderingGroupId: number, scene: Scene): void;
  66765. /**
  66766. * Starts all particle systems of the set
  66767. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66768. */
  66769. start(emitter?: AbstractMesh): void;
  66770. /**
  66771. * Release all associated resources
  66772. */
  66773. dispose(): void;
  66774. /**
  66775. * Serialize the set into a JSON compatible object
  66776. * @returns a JSON compatible representation of the set
  66777. */
  66778. serialize(): any;
  66779. /**
  66780. * Parse a new ParticleSystemSet from a serialized source
  66781. * @param data defines a JSON compatible representation of the set
  66782. * @param scene defines the hosting scene
  66783. * @param gpu defines if we want GPU particles or CPU particles
  66784. * @returns a new ParticleSystemSet
  66785. */
  66786. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66787. }
  66788. }
  66789. declare module "babylonjs/Particles/particleHelper" {
  66790. import { Nullable } from "babylonjs/types";
  66791. import { Scene } from "babylonjs/scene";
  66792. import { Vector3 } from "babylonjs/Maths/math.vector";
  66793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66794. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66795. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66796. /**
  66797. * This class is made for on one-liner static method to help creating particle system set.
  66798. */
  66799. export class ParticleHelper {
  66800. /**
  66801. * Gets or sets base Assets URL
  66802. */
  66803. static BaseAssetsUrl: string;
  66804. /** Define the Url to load snippets */
  66805. static SnippetUrl: string;
  66806. /**
  66807. * Create a default particle system that you can tweak
  66808. * @param emitter defines the emitter to use
  66809. * @param capacity defines the system capacity (default is 500 particles)
  66810. * @param scene defines the hosting scene
  66811. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66812. * @returns the new Particle system
  66813. */
  66814. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66815. /**
  66816. * This is the main static method (one-liner) of this helper to create different particle systems
  66817. * @param type This string represents the type to the particle system to create
  66818. * @param scene The scene where the particle system should live
  66819. * @param gpu If the system will use gpu
  66820. * @returns the ParticleSystemSet created
  66821. */
  66822. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66823. /**
  66824. * Static function used to export a particle system to a ParticleSystemSet variable.
  66825. * Please note that the emitter shape is not exported
  66826. * @param systems defines the particle systems to export
  66827. * @returns the created particle system set
  66828. */
  66829. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66830. /**
  66831. * Creates a node material from a snippet saved by the node material editor
  66832. * @param snippetId defines the snippet to load
  66833. * @param scene defines the hosting scene
  66834. * @param gpu If the system will use gpu
  66835. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66836. * @returns a promise that will resolve to the new node material
  66837. */
  66838. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66839. }
  66840. }
  66841. declare module "babylonjs/Particles/particleSystemComponent" {
  66842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66843. import { Effect } from "babylonjs/Materials/effect";
  66844. import "babylonjs/Shaders/particles.vertex";
  66845. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66846. module "babylonjs/Engines/engine" {
  66847. interface Engine {
  66848. /**
  66849. * Create an effect to use with particle systems.
  66850. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66851. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66852. * @param uniformsNames defines a list of attribute names
  66853. * @param samplers defines an array of string used to represent textures
  66854. * @param defines defines the string containing the defines to use to compile the shaders
  66855. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66856. * @param onCompiled defines a function to call when the effect creation is successful
  66857. * @param onError defines a function to call when the effect creation has failed
  66858. * @returns the new Effect
  66859. */
  66860. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66861. }
  66862. }
  66863. module "babylonjs/Meshes/mesh" {
  66864. interface Mesh {
  66865. /**
  66866. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66867. * @returns an array of IParticleSystem
  66868. */
  66869. getEmittedParticleSystems(): IParticleSystem[];
  66870. /**
  66871. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66872. * @returns an array of IParticleSystem
  66873. */
  66874. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66875. }
  66876. }
  66877. /**
  66878. * @hidden
  66879. */
  66880. export var _IDoNeedToBeInTheBuild: number;
  66881. }
  66882. declare module "babylonjs/Particles/pointsCloudSystem" {
  66883. import { Color4 } from "babylonjs/Maths/math";
  66884. import { Mesh } from "babylonjs/Meshes/mesh";
  66885. import { Scene, IDisposable } from "babylonjs/scene";
  66886. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66887. /** Defines the 4 color options */
  66888. export enum PointColor {
  66889. /** color value */
  66890. Color = 2,
  66891. /** uv value */
  66892. UV = 1,
  66893. /** random value */
  66894. Random = 0,
  66895. /** stated value */
  66896. Stated = 3
  66897. }
  66898. /**
  66899. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66900. * 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.
  66901. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66902. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66903. *
  66904. * Full documentation here : TO BE ENTERED
  66905. */
  66906. export class PointsCloudSystem implements IDisposable {
  66907. /**
  66908. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66909. * Example : var p = SPS.particles[i];
  66910. */
  66911. particles: CloudPoint[];
  66912. /**
  66913. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66914. */
  66915. nbParticles: number;
  66916. /**
  66917. * This a counter for your own usage. It's not set by any SPS functions.
  66918. */
  66919. counter: number;
  66920. /**
  66921. * The PCS name. This name is also given to the underlying mesh.
  66922. */
  66923. name: string;
  66924. /**
  66925. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66926. */
  66927. mesh: Mesh;
  66928. /**
  66929. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66930. * Please read :
  66931. */
  66932. vars: any;
  66933. /**
  66934. * @hidden
  66935. */
  66936. _size: number;
  66937. private _scene;
  66938. private _promises;
  66939. private _positions;
  66940. private _indices;
  66941. private _normals;
  66942. private _colors;
  66943. private _uvs;
  66944. private _indices32;
  66945. private _positions32;
  66946. private _colors32;
  66947. private _uvs32;
  66948. private _updatable;
  66949. private _isVisibilityBoxLocked;
  66950. private _alwaysVisible;
  66951. private _groups;
  66952. private _groupCounter;
  66953. private _computeParticleColor;
  66954. private _computeParticleTexture;
  66955. private _computeParticleRotation;
  66956. private _computeBoundingBox;
  66957. private _isReady;
  66958. /**
  66959. * Creates a PCS (Points Cloud System) object
  66960. * @param name (String) is the PCS name, this will be the underlying mesh name
  66961. * @param pointSize (number) is the size for each point
  66962. * @param scene (Scene) is the scene in which the PCS is added
  66963. * @param options defines the options of the PCS e.g.
  66964. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66965. */
  66966. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66967. updatable?: boolean;
  66968. });
  66969. /**
  66970. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66971. * If no points were added to the PCS, the returned mesh is just a single point.
  66972. * @returns a promise for the created mesh
  66973. */
  66974. buildMeshAsync(): Promise<Mesh>;
  66975. /**
  66976. * @hidden
  66977. */
  66978. private _buildMesh;
  66979. private _addParticle;
  66980. private _randomUnitVector;
  66981. private _getColorIndicesForCoord;
  66982. private _setPointsColorOrUV;
  66983. private _colorFromTexture;
  66984. private _calculateDensity;
  66985. /**
  66986. * Adds points to the PCS in random positions within a unit sphere
  66987. * @param nb (positive integer) the number of particles to be created from this model
  66988. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66989. * @returns the number of groups in the system
  66990. */
  66991. addPoints(nb: number, pointFunction?: any): number;
  66992. /**
  66993. * Adds points to the PCS from the surface of the model shape
  66994. * @param mesh is any Mesh object that will be used as a surface model for the points
  66995. * @param nb (positive integer) the number of particles to be created from this model
  66996. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66997. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66998. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66999. * @returns the number of groups in the system
  67000. */
  67001. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67002. /**
  67003. * Adds points to the PCS inside the model shape
  67004. * @param mesh is any Mesh object that will be used as a surface model for the points
  67005. * @param nb (positive integer) the number of particles to be created from this model
  67006. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67007. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67008. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67009. * @returns the number of groups in the system
  67010. */
  67011. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67012. /**
  67013. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67014. * This method calls `updateParticle()` for each particle of the SPS.
  67015. * For an animated SPS, it is usually called within the render loop.
  67016. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67017. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67018. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67019. * @returns the PCS.
  67020. */
  67021. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67022. /**
  67023. * Disposes the PCS.
  67024. */
  67025. dispose(): void;
  67026. /**
  67027. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67028. * doc :
  67029. * @returns the PCS.
  67030. */
  67031. refreshVisibleSize(): PointsCloudSystem;
  67032. /**
  67033. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67034. * @param size the size (float) of the visibility box
  67035. * note : this doesn't lock the PCS mesh bounding box.
  67036. * doc :
  67037. */
  67038. setVisibilityBox(size: number): void;
  67039. /**
  67040. * Gets whether the PCS is always visible or not
  67041. * doc :
  67042. */
  67043. get isAlwaysVisible(): boolean;
  67044. /**
  67045. * Sets the PCS as always visible or not
  67046. * doc :
  67047. */
  67048. set isAlwaysVisible(val: boolean);
  67049. /**
  67050. * Tells to `setParticles()` to compute the particle rotations or not
  67051. * Default value : false. The PCS is faster when it's set to false
  67052. * Note : particle rotations are only applied to parent particles
  67053. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67054. */
  67055. set computeParticleRotation(val: boolean);
  67056. /**
  67057. * Tells to `setParticles()` to compute the particle colors or not.
  67058. * Default value : true. The PCS is faster when it's set to false.
  67059. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67060. */
  67061. set computeParticleColor(val: boolean);
  67062. set computeParticleTexture(val: boolean);
  67063. /**
  67064. * Gets if `setParticles()` computes the particle colors or not.
  67065. * Default value : false. The PCS is faster when it's set to false.
  67066. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67067. */
  67068. get computeParticleColor(): boolean;
  67069. /**
  67070. * Gets if `setParticles()` computes the particle textures or not.
  67071. * Default value : false. The PCS is faster when it's set to false.
  67072. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67073. */
  67074. get computeParticleTexture(): boolean;
  67075. /**
  67076. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67077. */
  67078. set computeBoundingBox(val: boolean);
  67079. /**
  67080. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67081. */
  67082. get computeBoundingBox(): boolean;
  67083. /**
  67084. * This function does nothing. It may be overwritten to set all the particle first values.
  67085. * The PCS doesn't call this function, you may have to call it by your own.
  67086. * doc :
  67087. */
  67088. initParticles(): void;
  67089. /**
  67090. * This function does nothing. It may be overwritten to recycle a particle
  67091. * The PCS doesn't call this function, you can to call it
  67092. * doc :
  67093. * @param particle The particle to recycle
  67094. * @returns the recycled particle
  67095. */
  67096. recycleParticle(particle: CloudPoint): CloudPoint;
  67097. /**
  67098. * Updates a particle : this function should be overwritten by the user.
  67099. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67100. * doc :
  67101. * @example : just set a particle position or velocity and recycle conditions
  67102. * @param particle The particle to update
  67103. * @returns the updated particle
  67104. */
  67105. updateParticle(particle: CloudPoint): CloudPoint;
  67106. /**
  67107. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67108. * This does nothing and may be overwritten by the user.
  67109. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67110. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67111. * @param update the boolean update value actually passed to setParticles()
  67112. */
  67113. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67114. /**
  67115. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67116. * This will be passed three parameters.
  67117. * This does nothing and may be overwritten by the user.
  67118. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67120. * @param update the boolean update value actually passed to setParticles()
  67121. */
  67122. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67123. }
  67124. }
  67125. declare module "babylonjs/Particles/cloudPoint" {
  67126. import { Nullable } from "babylonjs/types";
  67127. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67128. import { Mesh } from "babylonjs/Meshes/mesh";
  67129. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67130. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67131. /**
  67132. * Represents one particle of a points cloud system.
  67133. */
  67134. export class CloudPoint {
  67135. /**
  67136. * particle global index
  67137. */
  67138. idx: number;
  67139. /**
  67140. * The color of the particle
  67141. */
  67142. color: Nullable<Color4>;
  67143. /**
  67144. * The world space position of the particle.
  67145. */
  67146. position: Vector3;
  67147. /**
  67148. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67149. */
  67150. rotation: Vector3;
  67151. /**
  67152. * The world space rotation quaternion of the particle.
  67153. */
  67154. rotationQuaternion: Nullable<Quaternion>;
  67155. /**
  67156. * The uv of the particle.
  67157. */
  67158. uv: Nullable<Vector2>;
  67159. /**
  67160. * The current speed of the particle.
  67161. */
  67162. velocity: Vector3;
  67163. /**
  67164. * The pivot point in the particle local space.
  67165. */
  67166. pivot: Vector3;
  67167. /**
  67168. * Must the particle be translated from its pivot point in its local space ?
  67169. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67170. * Default : false
  67171. */
  67172. translateFromPivot: boolean;
  67173. /**
  67174. * Index of this particle in the global "positions" array (Internal use)
  67175. * @hidden
  67176. */
  67177. _pos: number;
  67178. /**
  67179. * @hidden Index of this particle in the global "indices" array (Internal use)
  67180. */
  67181. _ind: number;
  67182. /**
  67183. * Group this particle belongs to
  67184. */
  67185. _group: PointsGroup;
  67186. /**
  67187. * Group id of this particle
  67188. */
  67189. groupId: number;
  67190. /**
  67191. * Index of the particle in its group id (Internal use)
  67192. */
  67193. idxInGroup: number;
  67194. /**
  67195. * @hidden Particle BoundingInfo object (Internal use)
  67196. */
  67197. _boundingInfo: BoundingInfo;
  67198. /**
  67199. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67200. */
  67201. _pcs: PointsCloudSystem;
  67202. /**
  67203. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67204. */
  67205. _stillInvisible: boolean;
  67206. /**
  67207. * @hidden Last computed particle rotation matrix
  67208. */
  67209. _rotationMatrix: number[];
  67210. /**
  67211. * Parent particle Id, if any.
  67212. * Default null.
  67213. */
  67214. parentId: Nullable<number>;
  67215. /**
  67216. * @hidden Internal global position in the PCS.
  67217. */
  67218. _globalPosition: Vector3;
  67219. /**
  67220. * Creates a Point Cloud object.
  67221. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67222. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67223. * @param group (PointsGroup) is the group the particle belongs to
  67224. * @param groupId (integer) is the group identifier in the PCS.
  67225. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67226. * @param pcs defines the PCS it is associated to
  67227. */
  67228. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67229. /**
  67230. * get point size
  67231. */
  67232. get size(): Vector3;
  67233. /**
  67234. * Set point size
  67235. */
  67236. set size(scale: Vector3);
  67237. /**
  67238. * Legacy support, changed quaternion to rotationQuaternion
  67239. */
  67240. get quaternion(): Nullable<Quaternion>;
  67241. /**
  67242. * Legacy support, changed quaternion to rotationQuaternion
  67243. */
  67244. set quaternion(q: Nullable<Quaternion>);
  67245. /**
  67246. * Returns a boolean. True if the particle intersects a mesh, else false
  67247. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67248. * @param target is the object (point or mesh) what the intersection is computed against
  67249. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67250. * @returns true if it intersects
  67251. */
  67252. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67253. /**
  67254. * get the rotation matrix of the particle
  67255. * @hidden
  67256. */
  67257. getRotationMatrix(m: Matrix): void;
  67258. }
  67259. /**
  67260. * Represents a group of points in a points cloud system
  67261. * * PCS internal tool, don't use it manually.
  67262. */
  67263. export class PointsGroup {
  67264. /**
  67265. * The group id
  67266. * @hidden
  67267. */
  67268. groupID: number;
  67269. /**
  67270. * image data for group (internal use)
  67271. * @hidden
  67272. */
  67273. _groupImageData: Nullable<ArrayBufferView>;
  67274. /**
  67275. * Image Width (internal use)
  67276. * @hidden
  67277. */
  67278. _groupImgWidth: number;
  67279. /**
  67280. * Image Height (internal use)
  67281. * @hidden
  67282. */
  67283. _groupImgHeight: number;
  67284. /**
  67285. * Custom position function (internal use)
  67286. * @hidden
  67287. */
  67288. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67289. /**
  67290. * density per facet for surface points
  67291. * @hidden
  67292. */
  67293. _groupDensity: number[];
  67294. /**
  67295. * Only when points are colored by texture carries pointer to texture list array
  67296. * @hidden
  67297. */
  67298. _textureNb: number;
  67299. /**
  67300. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67301. * PCS internal tool, don't use it manually.
  67302. * @hidden
  67303. */
  67304. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67305. }
  67306. }
  67307. declare module "babylonjs/Particles/particleSystemDebugger" {
  67308. import { IDisposable } from "babylonjs/scene";
  67309. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67310. /**
  67311. * Represents a set of particle systems working together to create a specific effect
  67312. */
  67313. export class ParticleSystemDebugger implements IDisposable {
  67314. /**
  67315. * Defines the particle system to debug
  67316. */
  67317. system: IParticleSystem;
  67318. /**
  67319. * Creates a new particle system debugger
  67320. * @param system defines the particle system to debug
  67321. */
  67322. constructor(
  67323. /**
  67324. * Defines the particle system to debug
  67325. */
  67326. system: IParticleSystem);
  67327. /** Clear all the resources */
  67328. dispose(): void;
  67329. }
  67330. }
  67331. declare module "babylonjs/Particles/index" {
  67332. export * from "babylonjs/Particles/baseParticleSystem";
  67333. export * from "babylonjs/Particles/EmitterTypes/index";
  67334. export * from "babylonjs/Particles/gpuParticleSystem";
  67335. export * from "babylonjs/Particles/IParticleSystem";
  67336. export * from "babylonjs/Particles/particle";
  67337. export * from "babylonjs/Particles/particleHelper";
  67338. export * from "babylonjs/Particles/particleSystem";
  67339. export * from "babylonjs/Particles/particleSystemComponent";
  67340. export * from "babylonjs/Particles/particleSystemSet";
  67341. export * from "babylonjs/Particles/solidParticle";
  67342. export * from "babylonjs/Particles/solidParticleSystem";
  67343. export * from "babylonjs/Particles/cloudPoint";
  67344. export * from "babylonjs/Particles/pointsCloudSystem";
  67345. export * from "babylonjs/Particles/subEmitter";
  67346. export * from "babylonjs/Particles/particleSystemDebugger";
  67347. }
  67348. declare module "babylonjs/Physics/physicsEngineComponent" {
  67349. import { Nullable } from "babylonjs/types";
  67350. import { Observable, Observer } from "babylonjs/Misc/observable";
  67351. import { Vector3 } from "babylonjs/Maths/math.vector";
  67352. import { Mesh } from "babylonjs/Meshes/mesh";
  67353. import { ISceneComponent } from "babylonjs/sceneComponent";
  67354. import { Scene } from "babylonjs/scene";
  67355. import { Node } from "babylonjs/node";
  67356. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67358. module "babylonjs/scene" {
  67359. interface Scene {
  67360. /** @hidden (Backing field) */
  67361. _physicsEngine: Nullable<IPhysicsEngine>;
  67362. /** @hidden */
  67363. _physicsTimeAccumulator: number;
  67364. /**
  67365. * Gets the current physics engine
  67366. * @returns a IPhysicsEngine or null if none attached
  67367. */
  67368. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67369. /**
  67370. * Enables physics to the current scene
  67371. * @param gravity defines the scene's gravity for the physics engine
  67372. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67373. * @return a boolean indicating if the physics engine was initialized
  67374. */
  67375. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67376. /**
  67377. * Disables and disposes the physics engine associated with the scene
  67378. */
  67379. disablePhysicsEngine(): void;
  67380. /**
  67381. * Gets a boolean indicating if there is an active physics engine
  67382. * @returns a boolean indicating if there is an active physics engine
  67383. */
  67384. isPhysicsEnabled(): boolean;
  67385. /**
  67386. * Deletes a physics compound impostor
  67387. * @param compound defines the compound to delete
  67388. */
  67389. deleteCompoundImpostor(compound: any): void;
  67390. /**
  67391. * An event triggered when physic simulation is about to be run
  67392. */
  67393. onBeforePhysicsObservable: Observable<Scene>;
  67394. /**
  67395. * An event triggered when physic simulation has been done
  67396. */
  67397. onAfterPhysicsObservable: Observable<Scene>;
  67398. }
  67399. }
  67400. module "babylonjs/Meshes/abstractMesh" {
  67401. interface AbstractMesh {
  67402. /** @hidden */
  67403. _physicsImpostor: Nullable<PhysicsImpostor>;
  67404. /**
  67405. * Gets or sets impostor used for physic simulation
  67406. * @see http://doc.babylonjs.com/features/physics_engine
  67407. */
  67408. physicsImpostor: Nullable<PhysicsImpostor>;
  67409. /**
  67410. * Gets the current physics impostor
  67411. * @see http://doc.babylonjs.com/features/physics_engine
  67412. * @returns a physics impostor or null
  67413. */
  67414. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67415. /** Apply a physic impulse to the mesh
  67416. * @param force defines the force to apply
  67417. * @param contactPoint defines where to apply the force
  67418. * @returns the current mesh
  67419. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67420. */
  67421. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67422. /**
  67423. * Creates a physic joint between two meshes
  67424. * @param otherMesh defines the other mesh to use
  67425. * @param pivot1 defines the pivot to use on this mesh
  67426. * @param pivot2 defines the pivot to use on the other mesh
  67427. * @param options defines additional options (can be plugin dependent)
  67428. * @returns the current mesh
  67429. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67430. */
  67431. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67432. /** @hidden */
  67433. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67434. }
  67435. }
  67436. /**
  67437. * Defines the physics engine scene component responsible to manage a physics engine
  67438. */
  67439. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67440. /**
  67441. * The component name helpful to identify the component in the list of scene components.
  67442. */
  67443. readonly name: string;
  67444. /**
  67445. * The scene the component belongs to.
  67446. */
  67447. scene: Scene;
  67448. /**
  67449. * Creates a new instance of the component for the given scene
  67450. * @param scene Defines the scene to register the component in
  67451. */
  67452. constructor(scene: Scene);
  67453. /**
  67454. * Registers the component in a given scene
  67455. */
  67456. register(): void;
  67457. /**
  67458. * Rebuilds the elements related to this component in case of
  67459. * context lost for instance.
  67460. */
  67461. rebuild(): void;
  67462. /**
  67463. * Disposes the component and the associated ressources
  67464. */
  67465. dispose(): void;
  67466. }
  67467. }
  67468. declare module "babylonjs/Physics/physicsHelper" {
  67469. import { Nullable } from "babylonjs/types";
  67470. import { Vector3 } from "babylonjs/Maths/math.vector";
  67471. import { Mesh } from "babylonjs/Meshes/mesh";
  67472. import { Scene } from "babylonjs/scene";
  67473. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67474. /**
  67475. * A helper for physics simulations
  67476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67477. */
  67478. export class PhysicsHelper {
  67479. private _scene;
  67480. private _physicsEngine;
  67481. /**
  67482. * Initializes the Physics helper
  67483. * @param scene Babylon.js scene
  67484. */
  67485. constructor(scene: Scene);
  67486. /**
  67487. * Applies a radial explosion impulse
  67488. * @param origin the origin of the explosion
  67489. * @param radiusOrEventOptions the radius or the options of radial explosion
  67490. * @param strength the explosion strength
  67491. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67492. * @returns A physics radial explosion event, or null
  67493. */
  67494. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67495. /**
  67496. * Applies a radial explosion force
  67497. * @param origin the origin of the explosion
  67498. * @param radiusOrEventOptions the radius or the options of radial explosion
  67499. * @param strength the explosion strength
  67500. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67501. * @returns A physics radial explosion event, or null
  67502. */
  67503. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67504. /**
  67505. * Creates a gravitational field
  67506. * @param origin the origin of the explosion
  67507. * @param radiusOrEventOptions the radius or the options of radial explosion
  67508. * @param strength the explosion strength
  67509. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67510. * @returns A physics gravitational field event, or null
  67511. */
  67512. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67513. /**
  67514. * Creates a physics updraft event
  67515. * @param origin the origin of the updraft
  67516. * @param radiusOrEventOptions the radius or the options of the updraft
  67517. * @param strength the strength of the updraft
  67518. * @param height the height of the updraft
  67519. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67520. * @returns A physics updraft event, or null
  67521. */
  67522. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67523. /**
  67524. * Creates a physics vortex event
  67525. * @param origin the of the vortex
  67526. * @param radiusOrEventOptions the radius or the options of the vortex
  67527. * @param strength the strength of the vortex
  67528. * @param height the height of the vortex
  67529. * @returns a Physics vortex event, or null
  67530. * A physics vortex event or null
  67531. */
  67532. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67533. }
  67534. /**
  67535. * Represents a physics radial explosion event
  67536. */
  67537. class PhysicsRadialExplosionEvent {
  67538. private _scene;
  67539. private _options;
  67540. private _sphere;
  67541. private _dataFetched;
  67542. /**
  67543. * Initializes a radial explosioin event
  67544. * @param _scene BabylonJS scene
  67545. * @param _options The options for the vortex event
  67546. */
  67547. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67548. /**
  67549. * Returns the data related to the radial explosion event (sphere).
  67550. * @returns The radial explosion event data
  67551. */
  67552. getData(): PhysicsRadialExplosionEventData;
  67553. /**
  67554. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67555. * @param impostor A physics imposter
  67556. * @param origin the origin of the explosion
  67557. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67558. */
  67559. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67560. /**
  67561. * Triggers affecterd impostors callbacks
  67562. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67563. */
  67564. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67565. /**
  67566. * Disposes the sphere.
  67567. * @param force Specifies if the sphere should be disposed by force
  67568. */
  67569. dispose(force?: boolean): void;
  67570. /*** Helpers ***/
  67571. private _prepareSphere;
  67572. private _intersectsWithSphere;
  67573. }
  67574. /**
  67575. * Represents a gravitational field event
  67576. */
  67577. class PhysicsGravitationalFieldEvent {
  67578. private _physicsHelper;
  67579. private _scene;
  67580. private _origin;
  67581. private _options;
  67582. private _tickCallback;
  67583. private _sphere;
  67584. private _dataFetched;
  67585. /**
  67586. * Initializes the physics gravitational field event
  67587. * @param _physicsHelper A physics helper
  67588. * @param _scene BabylonJS scene
  67589. * @param _origin The origin position of the gravitational field event
  67590. * @param _options The options for the vortex event
  67591. */
  67592. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67593. /**
  67594. * Returns the data related to the gravitational field event (sphere).
  67595. * @returns A gravitational field event
  67596. */
  67597. getData(): PhysicsGravitationalFieldEventData;
  67598. /**
  67599. * Enables the gravitational field.
  67600. */
  67601. enable(): void;
  67602. /**
  67603. * Disables the gravitational field.
  67604. */
  67605. disable(): void;
  67606. /**
  67607. * Disposes the sphere.
  67608. * @param force The force to dispose from the gravitational field event
  67609. */
  67610. dispose(force?: boolean): void;
  67611. private _tick;
  67612. }
  67613. /**
  67614. * Represents a physics updraft event
  67615. */
  67616. class PhysicsUpdraftEvent {
  67617. private _scene;
  67618. private _origin;
  67619. private _options;
  67620. private _physicsEngine;
  67621. private _originTop;
  67622. private _originDirection;
  67623. private _tickCallback;
  67624. private _cylinder;
  67625. private _cylinderPosition;
  67626. private _dataFetched;
  67627. /**
  67628. * Initializes the physics updraft event
  67629. * @param _scene BabylonJS scene
  67630. * @param _origin The origin position of the updraft
  67631. * @param _options The options for the updraft event
  67632. */
  67633. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67634. /**
  67635. * Returns the data related to the updraft event (cylinder).
  67636. * @returns A physics updraft event
  67637. */
  67638. getData(): PhysicsUpdraftEventData;
  67639. /**
  67640. * Enables the updraft.
  67641. */
  67642. enable(): void;
  67643. /**
  67644. * Disables the updraft.
  67645. */
  67646. disable(): void;
  67647. /**
  67648. * Disposes the cylinder.
  67649. * @param force Specifies if the updraft should be disposed by force
  67650. */
  67651. dispose(force?: boolean): void;
  67652. private getImpostorHitData;
  67653. private _tick;
  67654. /*** Helpers ***/
  67655. private _prepareCylinder;
  67656. private _intersectsWithCylinder;
  67657. }
  67658. /**
  67659. * Represents a physics vortex event
  67660. */
  67661. class PhysicsVortexEvent {
  67662. private _scene;
  67663. private _origin;
  67664. private _options;
  67665. private _physicsEngine;
  67666. private _originTop;
  67667. private _tickCallback;
  67668. private _cylinder;
  67669. private _cylinderPosition;
  67670. private _dataFetched;
  67671. /**
  67672. * Initializes the physics vortex event
  67673. * @param _scene The BabylonJS scene
  67674. * @param _origin The origin position of the vortex
  67675. * @param _options The options for the vortex event
  67676. */
  67677. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67678. /**
  67679. * Returns the data related to the vortex event (cylinder).
  67680. * @returns The physics vortex event data
  67681. */
  67682. getData(): PhysicsVortexEventData;
  67683. /**
  67684. * Enables the vortex.
  67685. */
  67686. enable(): void;
  67687. /**
  67688. * Disables the cortex.
  67689. */
  67690. disable(): void;
  67691. /**
  67692. * Disposes the sphere.
  67693. * @param force
  67694. */
  67695. dispose(force?: boolean): void;
  67696. private getImpostorHitData;
  67697. private _tick;
  67698. /*** Helpers ***/
  67699. private _prepareCylinder;
  67700. private _intersectsWithCylinder;
  67701. }
  67702. /**
  67703. * Options fot the radial explosion event
  67704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67705. */
  67706. export class PhysicsRadialExplosionEventOptions {
  67707. /**
  67708. * The radius of the sphere for the radial explosion.
  67709. */
  67710. radius: number;
  67711. /**
  67712. * The strenth of the explosion.
  67713. */
  67714. strength: number;
  67715. /**
  67716. * The strenght of the force in correspondence to the distance of the affected object
  67717. */
  67718. falloff: PhysicsRadialImpulseFalloff;
  67719. /**
  67720. * Sphere options for the radial explosion.
  67721. */
  67722. sphere: {
  67723. segments: number;
  67724. diameter: number;
  67725. };
  67726. /**
  67727. * Sphere options for the radial explosion.
  67728. */
  67729. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67730. }
  67731. /**
  67732. * Options fot the updraft event
  67733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67734. */
  67735. export class PhysicsUpdraftEventOptions {
  67736. /**
  67737. * The radius of the cylinder for the vortex
  67738. */
  67739. radius: number;
  67740. /**
  67741. * The strenth of the updraft.
  67742. */
  67743. strength: number;
  67744. /**
  67745. * The height of the cylinder for the updraft.
  67746. */
  67747. height: number;
  67748. /**
  67749. * The mode for the the updraft.
  67750. */
  67751. updraftMode: PhysicsUpdraftMode;
  67752. }
  67753. /**
  67754. * Options fot the vortex event
  67755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67756. */
  67757. export class PhysicsVortexEventOptions {
  67758. /**
  67759. * The radius of the cylinder for the vortex
  67760. */
  67761. radius: number;
  67762. /**
  67763. * The strenth of the vortex.
  67764. */
  67765. strength: number;
  67766. /**
  67767. * The height of the cylinder for the vortex.
  67768. */
  67769. height: number;
  67770. /**
  67771. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67772. */
  67773. centripetalForceThreshold: number;
  67774. /**
  67775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67776. */
  67777. centripetalForceMultiplier: number;
  67778. /**
  67779. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67780. */
  67781. centrifugalForceMultiplier: number;
  67782. /**
  67783. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67784. */
  67785. updraftForceMultiplier: number;
  67786. }
  67787. /**
  67788. * The strenght of the force in correspondence to the distance of the affected object
  67789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67790. */
  67791. export enum PhysicsRadialImpulseFalloff {
  67792. /** Defines that impulse is constant in strength across it's whole radius */
  67793. Constant = 0,
  67794. /** Defines that impulse gets weaker if it's further from the origin */
  67795. Linear = 1
  67796. }
  67797. /**
  67798. * The strength of the force in correspondence to the distance of the affected object
  67799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67800. */
  67801. export enum PhysicsUpdraftMode {
  67802. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67803. Center = 0,
  67804. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67805. Perpendicular = 1
  67806. }
  67807. /**
  67808. * Interface for a physics hit data
  67809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67810. */
  67811. export interface PhysicsHitData {
  67812. /**
  67813. * The force applied at the contact point
  67814. */
  67815. force: Vector3;
  67816. /**
  67817. * The contact point
  67818. */
  67819. contactPoint: Vector3;
  67820. /**
  67821. * The distance from the origin to the contact point
  67822. */
  67823. distanceFromOrigin: number;
  67824. }
  67825. /**
  67826. * Interface for radial explosion event data
  67827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67828. */
  67829. export interface PhysicsRadialExplosionEventData {
  67830. /**
  67831. * A sphere used for the radial explosion event
  67832. */
  67833. sphere: Mesh;
  67834. }
  67835. /**
  67836. * Interface for gravitational field event data
  67837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67838. */
  67839. export interface PhysicsGravitationalFieldEventData {
  67840. /**
  67841. * A sphere mesh used for the gravitational field event
  67842. */
  67843. sphere: Mesh;
  67844. }
  67845. /**
  67846. * Interface for updraft event data
  67847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67848. */
  67849. export interface PhysicsUpdraftEventData {
  67850. /**
  67851. * A cylinder used for the updraft event
  67852. */
  67853. cylinder: Mesh;
  67854. }
  67855. /**
  67856. * Interface for vortex event data
  67857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67858. */
  67859. export interface PhysicsVortexEventData {
  67860. /**
  67861. * A cylinder used for the vortex event
  67862. */
  67863. cylinder: Mesh;
  67864. }
  67865. /**
  67866. * Interface for an affected physics impostor
  67867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67868. */
  67869. export interface PhysicsAffectedImpostorWithData {
  67870. /**
  67871. * The impostor affected by the effect
  67872. */
  67873. impostor: PhysicsImpostor;
  67874. /**
  67875. * The data about the hit/horce from the explosion
  67876. */
  67877. hitData: PhysicsHitData;
  67878. }
  67879. }
  67880. declare module "babylonjs/Physics/Plugins/index" {
  67881. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67882. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67883. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67884. }
  67885. declare module "babylonjs/Physics/index" {
  67886. export * from "babylonjs/Physics/IPhysicsEngine";
  67887. export * from "babylonjs/Physics/physicsEngine";
  67888. export * from "babylonjs/Physics/physicsEngineComponent";
  67889. export * from "babylonjs/Physics/physicsHelper";
  67890. export * from "babylonjs/Physics/physicsImpostor";
  67891. export * from "babylonjs/Physics/physicsJoint";
  67892. export * from "babylonjs/Physics/Plugins/index";
  67893. }
  67894. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67895. /** @hidden */
  67896. export var blackAndWhitePixelShader: {
  67897. name: string;
  67898. shader: string;
  67899. };
  67900. }
  67901. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67903. import { Camera } from "babylonjs/Cameras/camera";
  67904. import { Engine } from "babylonjs/Engines/engine";
  67905. import "babylonjs/Shaders/blackAndWhite.fragment";
  67906. /**
  67907. * Post process used to render in black and white
  67908. */
  67909. export class BlackAndWhitePostProcess extends PostProcess {
  67910. /**
  67911. * Linear about to convert he result to black and white (default: 1)
  67912. */
  67913. degree: number;
  67914. /**
  67915. * Creates a black and white post process
  67916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67917. * @param name The name of the effect.
  67918. * @param options The required width/height ratio to downsize to before computing the render pass.
  67919. * @param camera The camera to apply the render pass to.
  67920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67921. * @param engine The engine which the post process will be applied. (default: current engine)
  67922. * @param reusable If the post process can be reused on the same frame. (default: false)
  67923. */
  67924. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67925. }
  67926. }
  67927. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67928. import { Nullable } from "babylonjs/types";
  67929. import { Camera } from "babylonjs/Cameras/camera";
  67930. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67931. import { Engine } from "babylonjs/Engines/engine";
  67932. /**
  67933. * This represents a set of one or more post processes in Babylon.
  67934. * A post process can be used to apply a shader to a texture after it is rendered.
  67935. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67936. */
  67937. export class PostProcessRenderEffect {
  67938. private _postProcesses;
  67939. private _getPostProcesses;
  67940. private _singleInstance;
  67941. private _cameras;
  67942. private _indicesForCamera;
  67943. /**
  67944. * Name of the effect
  67945. * @hidden
  67946. */
  67947. _name: string;
  67948. /**
  67949. * Instantiates a post process render effect.
  67950. * A post process can be used to apply a shader to a texture after it is rendered.
  67951. * @param engine The engine the effect is tied to
  67952. * @param name The name of the effect
  67953. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67954. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67955. */
  67956. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67957. /**
  67958. * Checks if all the post processes in the effect are supported.
  67959. */
  67960. get isSupported(): boolean;
  67961. /**
  67962. * Updates the current state of the effect
  67963. * @hidden
  67964. */
  67965. _update(): void;
  67966. /**
  67967. * Attaches the effect on cameras
  67968. * @param cameras The camera to attach to.
  67969. * @hidden
  67970. */
  67971. _attachCameras(cameras: Camera): void;
  67972. /**
  67973. * Attaches the effect on cameras
  67974. * @param cameras The camera to attach to.
  67975. * @hidden
  67976. */
  67977. _attachCameras(cameras: Camera[]): void;
  67978. /**
  67979. * Detaches the effect on cameras
  67980. * @param cameras The camera to detatch from.
  67981. * @hidden
  67982. */
  67983. _detachCameras(cameras: Camera): void;
  67984. /**
  67985. * Detatches the effect on cameras
  67986. * @param cameras The camera to detatch from.
  67987. * @hidden
  67988. */
  67989. _detachCameras(cameras: Camera[]): void;
  67990. /**
  67991. * Enables the effect on given cameras
  67992. * @param cameras The camera to enable.
  67993. * @hidden
  67994. */
  67995. _enable(cameras: Camera): void;
  67996. /**
  67997. * Enables the effect on given cameras
  67998. * @param cameras The camera to enable.
  67999. * @hidden
  68000. */
  68001. _enable(cameras: Nullable<Camera[]>): void;
  68002. /**
  68003. * Disables the effect on the given cameras
  68004. * @param cameras The camera to disable.
  68005. * @hidden
  68006. */
  68007. _disable(cameras: Camera): void;
  68008. /**
  68009. * Disables the effect on the given cameras
  68010. * @param cameras The camera to disable.
  68011. * @hidden
  68012. */
  68013. _disable(cameras: Nullable<Camera[]>): void;
  68014. /**
  68015. * Gets a list of the post processes contained in the effect.
  68016. * @param camera The camera to get the post processes on.
  68017. * @returns The list of the post processes in the effect.
  68018. */
  68019. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68020. }
  68021. }
  68022. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68023. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68024. /** @hidden */
  68025. export var extractHighlightsPixelShader: {
  68026. name: string;
  68027. shader: string;
  68028. };
  68029. }
  68030. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68031. import { Nullable } from "babylonjs/types";
  68032. import { Camera } from "babylonjs/Cameras/camera";
  68033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68034. import { Engine } from "babylonjs/Engines/engine";
  68035. import "babylonjs/Shaders/extractHighlights.fragment";
  68036. /**
  68037. * 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.
  68038. */
  68039. export class ExtractHighlightsPostProcess extends PostProcess {
  68040. /**
  68041. * The luminance threshold, pixels below this value will be set to black.
  68042. */
  68043. threshold: number;
  68044. /** @hidden */
  68045. _exposure: number;
  68046. /**
  68047. * Post process which has the input texture to be used when performing highlight extraction
  68048. * @hidden
  68049. */
  68050. _inputPostProcess: Nullable<PostProcess>;
  68051. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68052. }
  68053. }
  68054. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68055. /** @hidden */
  68056. export var bloomMergePixelShader: {
  68057. name: string;
  68058. shader: string;
  68059. };
  68060. }
  68061. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68063. import { Nullable } from "babylonjs/types";
  68064. import { Engine } from "babylonjs/Engines/engine";
  68065. import { Camera } from "babylonjs/Cameras/camera";
  68066. import "babylonjs/Shaders/bloomMerge.fragment";
  68067. /**
  68068. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68069. */
  68070. export class BloomMergePostProcess extends PostProcess {
  68071. /** Weight of the bloom to be added to the original input. */
  68072. weight: number;
  68073. /**
  68074. * Creates a new instance of @see BloomMergePostProcess
  68075. * @param name The name of the effect.
  68076. * @param originalFromInput Post process which's input will be used for the merge.
  68077. * @param blurred Blurred highlights post process which's output will be used.
  68078. * @param weight Weight of the bloom to be added to the original input.
  68079. * @param options The required width/height ratio to downsize to before computing the render pass.
  68080. * @param camera The camera to apply the render pass to.
  68081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68082. * @param engine The engine which the post process will be applied. (default: current engine)
  68083. * @param reusable If the post process can be reused on the same frame. (default: false)
  68084. * @param textureType Type of textures used when performing the post process. (default: 0)
  68085. * @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)
  68086. */
  68087. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68088. /** Weight of the bloom to be added to the original input. */
  68089. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68090. }
  68091. }
  68092. declare module "babylonjs/PostProcesses/bloomEffect" {
  68093. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68095. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68096. import { Camera } from "babylonjs/Cameras/camera";
  68097. import { Scene } from "babylonjs/scene";
  68098. /**
  68099. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68100. */
  68101. export class BloomEffect extends PostProcessRenderEffect {
  68102. private bloomScale;
  68103. /**
  68104. * @hidden Internal
  68105. */
  68106. _effects: Array<PostProcess>;
  68107. /**
  68108. * @hidden Internal
  68109. */
  68110. _downscale: ExtractHighlightsPostProcess;
  68111. private _blurX;
  68112. private _blurY;
  68113. private _merge;
  68114. /**
  68115. * The luminance threshold to find bright areas of the image to bloom.
  68116. */
  68117. get threshold(): number;
  68118. set threshold(value: number);
  68119. /**
  68120. * The strength of the bloom.
  68121. */
  68122. get weight(): number;
  68123. set weight(value: number);
  68124. /**
  68125. * Specifies the size of the bloom blur kernel, relative to the final output size
  68126. */
  68127. get kernel(): number;
  68128. set kernel(value: number);
  68129. /**
  68130. * Creates a new instance of @see BloomEffect
  68131. * @param scene The scene the effect belongs to.
  68132. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68133. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68134. * @param bloomWeight The the strength of bloom.
  68135. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68136. * @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)
  68137. */
  68138. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68139. /**
  68140. * Disposes each of the internal effects for a given camera.
  68141. * @param camera The camera to dispose the effect on.
  68142. */
  68143. disposeEffects(camera: Camera): void;
  68144. /**
  68145. * @hidden Internal
  68146. */
  68147. _updateEffects(): void;
  68148. /**
  68149. * Internal
  68150. * @returns if all the contained post processes are ready.
  68151. * @hidden
  68152. */
  68153. _isReady(): boolean;
  68154. }
  68155. }
  68156. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68157. /** @hidden */
  68158. export var chromaticAberrationPixelShader: {
  68159. name: string;
  68160. shader: string;
  68161. };
  68162. }
  68163. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68164. import { Vector2 } from "babylonjs/Maths/math.vector";
  68165. import { Nullable } from "babylonjs/types";
  68166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68167. import { Camera } from "babylonjs/Cameras/camera";
  68168. import { Engine } from "babylonjs/Engines/engine";
  68169. import "babylonjs/Shaders/chromaticAberration.fragment";
  68170. /**
  68171. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68172. */
  68173. export class ChromaticAberrationPostProcess extends PostProcess {
  68174. /**
  68175. * The amount of seperation of rgb channels (default: 30)
  68176. */
  68177. aberrationAmount: number;
  68178. /**
  68179. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68180. */
  68181. radialIntensity: number;
  68182. /**
  68183. * 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))
  68184. */
  68185. direction: Vector2;
  68186. /**
  68187. * 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))
  68188. */
  68189. centerPosition: Vector2;
  68190. /**
  68191. * Creates a new instance ChromaticAberrationPostProcess
  68192. * @param name The name of the effect.
  68193. * @param screenWidth The width of the screen to apply the effect on.
  68194. * @param screenHeight The height of the screen to apply the effect on.
  68195. * @param options The required width/height ratio to downsize to before computing the render pass.
  68196. * @param camera The camera to apply the render pass to.
  68197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68198. * @param engine The engine which the post process will be applied. (default: current engine)
  68199. * @param reusable If the post process can be reused on the same frame. (default: false)
  68200. * @param textureType Type of textures used when performing the post process. (default: 0)
  68201. * @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)
  68202. */
  68203. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68204. }
  68205. }
  68206. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68207. /** @hidden */
  68208. export var circleOfConfusionPixelShader: {
  68209. name: string;
  68210. shader: string;
  68211. };
  68212. }
  68213. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68214. import { Nullable } from "babylonjs/types";
  68215. import { Engine } from "babylonjs/Engines/engine";
  68216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68218. import { Camera } from "babylonjs/Cameras/camera";
  68219. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68220. /**
  68221. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68222. */
  68223. export class CircleOfConfusionPostProcess extends PostProcess {
  68224. /**
  68225. * 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.
  68226. */
  68227. lensSize: number;
  68228. /**
  68229. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68230. */
  68231. fStop: number;
  68232. /**
  68233. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68234. */
  68235. focusDistance: number;
  68236. /**
  68237. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68238. */
  68239. focalLength: number;
  68240. private _depthTexture;
  68241. /**
  68242. * Creates a new instance CircleOfConfusionPostProcess
  68243. * @param name The name of the effect.
  68244. * @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.
  68245. * @param options The required width/height ratio to downsize to before computing the render pass.
  68246. * @param camera The camera to apply the render pass to.
  68247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68248. * @param engine The engine which the post process will be applied. (default: current engine)
  68249. * @param reusable If the post process can be reused on the same frame. (default: false)
  68250. * @param textureType Type of textures used when performing the post process. (default: 0)
  68251. * @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)
  68252. */
  68253. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68254. /**
  68255. * 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.
  68256. */
  68257. set depthTexture(value: RenderTargetTexture);
  68258. }
  68259. }
  68260. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68261. /** @hidden */
  68262. export var colorCorrectionPixelShader: {
  68263. name: string;
  68264. shader: string;
  68265. };
  68266. }
  68267. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68268. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68269. import { Engine } from "babylonjs/Engines/engine";
  68270. import { Camera } from "babylonjs/Cameras/camera";
  68271. import "babylonjs/Shaders/colorCorrection.fragment";
  68272. /**
  68273. *
  68274. * This post-process allows the modification of rendered colors by using
  68275. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68276. *
  68277. * The object needs to be provided an url to a texture containing the color
  68278. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68279. * Use an image editing software to tweak the LUT to match your needs.
  68280. *
  68281. * For an example of a color LUT, see here:
  68282. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68283. * For explanations on color grading, see here:
  68284. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68285. *
  68286. */
  68287. export class ColorCorrectionPostProcess extends PostProcess {
  68288. private _colorTableTexture;
  68289. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68290. }
  68291. }
  68292. declare module "babylonjs/Shaders/convolution.fragment" {
  68293. /** @hidden */
  68294. export var convolutionPixelShader: {
  68295. name: string;
  68296. shader: string;
  68297. };
  68298. }
  68299. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68301. import { Nullable } from "babylonjs/types";
  68302. import { Camera } from "babylonjs/Cameras/camera";
  68303. import { Engine } from "babylonjs/Engines/engine";
  68304. import "babylonjs/Shaders/convolution.fragment";
  68305. /**
  68306. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68307. * input texture to perform effects such as edge detection or sharpening
  68308. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68309. */
  68310. export class ConvolutionPostProcess extends PostProcess {
  68311. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68312. kernel: number[];
  68313. /**
  68314. * Creates a new instance ConvolutionPostProcess
  68315. * @param name The name of the effect.
  68316. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68317. * @param options The required width/height ratio to downsize to before computing the render pass.
  68318. * @param camera The camera to apply the render pass to.
  68319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68320. * @param engine The engine which the post process will be applied. (default: current engine)
  68321. * @param reusable If the post process can be reused on the same frame. (default: false)
  68322. * @param textureType Type of textures used when performing the post process. (default: 0)
  68323. */
  68324. constructor(name: string,
  68325. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68326. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68327. /**
  68328. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68329. */
  68330. static EdgeDetect0Kernel: number[];
  68331. /**
  68332. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68333. */
  68334. static EdgeDetect1Kernel: number[];
  68335. /**
  68336. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68337. */
  68338. static EdgeDetect2Kernel: number[];
  68339. /**
  68340. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68341. */
  68342. static SharpenKernel: number[];
  68343. /**
  68344. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68345. */
  68346. static EmbossKernel: number[];
  68347. /**
  68348. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68349. */
  68350. static GaussianKernel: number[];
  68351. }
  68352. }
  68353. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68354. import { Nullable } from "babylonjs/types";
  68355. import { Vector2 } from "babylonjs/Maths/math.vector";
  68356. import { Camera } from "babylonjs/Cameras/camera";
  68357. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68358. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68359. import { Engine } from "babylonjs/Engines/engine";
  68360. import { Scene } from "babylonjs/scene";
  68361. /**
  68362. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68363. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68364. * based on samples that have a large difference in distance than the center pixel.
  68365. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68366. */
  68367. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68368. direction: Vector2;
  68369. /**
  68370. * Creates a new instance CircleOfConfusionPostProcess
  68371. * @param name The name of the effect.
  68372. * @param scene The scene the effect belongs to.
  68373. * @param direction The direction the blur should be applied.
  68374. * @param kernel The size of the kernel used to blur.
  68375. * @param options The required width/height ratio to downsize to before computing the render pass.
  68376. * @param camera The camera to apply the render pass to.
  68377. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68378. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68380. * @param engine The engine which the post process will be applied. (default: current engine)
  68381. * @param reusable If the post process can be reused on the same frame. (default: false)
  68382. * @param textureType Type of textures used when performing the post process. (default: 0)
  68383. * @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)
  68384. */
  68385. 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);
  68386. }
  68387. }
  68388. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68389. /** @hidden */
  68390. export var depthOfFieldMergePixelShader: {
  68391. name: string;
  68392. shader: string;
  68393. };
  68394. }
  68395. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68396. import { Nullable } from "babylonjs/types";
  68397. import { Camera } from "babylonjs/Cameras/camera";
  68398. import { Effect } from "babylonjs/Materials/effect";
  68399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68400. import { Engine } from "babylonjs/Engines/engine";
  68401. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68402. /**
  68403. * Options to be set when merging outputs from the default pipeline.
  68404. */
  68405. export class DepthOfFieldMergePostProcessOptions {
  68406. /**
  68407. * The original image to merge on top of
  68408. */
  68409. originalFromInput: PostProcess;
  68410. /**
  68411. * Parameters to perform the merge of the depth of field effect
  68412. */
  68413. depthOfField?: {
  68414. circleOfConfusion: PostProcess;
  68415. blurSteps: Array<PostProcess>;
  68416. };
  68417. /**
  68418. * Parameters to perform the merge of bloom effect
  68419. */
  68420. bloom?: {
  68421. blurred: PostProcess;
  68422. weight: number;
  68423. };
  68424. }
  68425. /**
  68426. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68427. */
  68428. export class DepthOfFieldMergePostProcess extends PostProcess {
  68429. private blurSteps;
  68430. /**
  68431. * Creates a new instance of DepthOfFieldMergePostProcess
  68432. * @param name The name of the effect.
  68433. * @param originalFromInput Post process which's input will be used for the merge.
  68434. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68435. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68436. * @param options The required width/height ratio to downsize to before computing the render pass.
  68437. * @param camera The camera to apply the render pass to.
  68438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68439. * @param engine The engine which the post process will be applied. (default: current engine)
  68440. * @param reusable If the post process can be reused on the same frame. (default: false)
  68441. * @param textureType Type of textures used when performing the post process. (default: 0)
  68442. * @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)
  68443. */
  68444. 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);
  68445. /**
  68446. * Updates the effect with the current post process compile time values and recompiles the shader.
  68447. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68448. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68449. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68450. * @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
  68451. * @param onCompiled Called when the shader has been compiled.
  68452. * @param onError Called if there is an error when compiling a shader.
  68453. */
  68454. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68455. }
  68456. }
  68457. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68458. import { Nullable } from "babylonjs/types";
  68459. import { Camera } from "babylonjs/Cameras/camera";
  68460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68461. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68462. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68463. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68464. import { Scene } from "babylonjs/scene";
  68465. /**
  68466. * Specifies the level of max blur that should be applied when using the depth of field effect
  68467. */
  68468. export enum DepthOfFieldEffectBlurLevel {
  68469. /**
  68470. * Subtle blur
  68471. */
  68472. Low = 0,
  68473. /**
  68474. * Medium blur
  68475. */
  68476. Medium = 1,
  68477. /**
  68478. * Large blur
  68479. */
  68480. High = 2
  68481. }
  68482. /**
  68483. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68484. */
  68485. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68486. private _circleOfConfusion;
  68487. /**
  68488. * @hidden Internal, blurs from high to low
  68489. */
  68490. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68491. private _depthOfFieldBlurY;
  68492. private _dofMerge;
  68493. /**
  68494. * @hidden Internal post processes in depth of field effect
  68495. */
  68496. _effects: Array<PostProcess>;
  68497. /**
  68498. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68499. */
  68500. set focalLength(value: number);
  68501. get focalLength(): number;
  68502. /**
  68503. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68504. */
  68505. set fStop(value: number);
  68506. get fStop(): number;
  68507. /**
  68508. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68509. */
  68510. set focusDistance(value: number);
  68511. get focusDistance(): number;
  68512. /**
  68513. * 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.
  68514. */
  68515. set lensSize(value: number);
  68516. get lensSize(): number;
  68517. /**
  68518. * Creates a new instance DepthOfFieldEffect
  68519. * @param scene The scene the effect belongs to.
  68520. * @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.
  68521. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68522. * @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)
  68523. */
  68524. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68525. /**
  68526. * Get the current class name of the current effet
  68527. * @returns "DepthOfFieldEffect"
  68528. */
  68529. getClassName(): string;
  68530. /**
  68531. * 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.
  68532. */
  68533. set depthTexture(value: RenderTargetTexture);
  68534. /**
  68535. * Disposes each of the internal effects for a given camera.
  68536. * @param camera The camera to dispose the effect on.
  68537. */
  68538. disposeEffects(camera: Camera): void;
  68539. /**
  68540. * @hidden Internal
  68541. */
  68542. _updateEffects(): void;
  68543. /**
  68544. * Internal
  68545. * @returns if all the contained post processes are ready.
  68546. * @hidden
  68547. */
  68548. _isReady(): boolean;
  68549. }
  68550. }
  68551. declare module "babylonjs/Shaders/displayPass.fragment" {
  68552. /** @hidden */
  68553. export var displayPassPixelShader: {
  68554. name: string;
  68555. shader: string;
  68556. };
  68557. }
  68558. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68559. import { Nullable } from "babylonjs/types";
  68560. import { Camera } from "babylonjs/Cameras/camera";
  68561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68562. import { Engine } from "babylonjs/Engines/engine";
  68563. import "babylonjs/Shaders/displayPass.fragment";
  68564. /**
  68565. * DisplayPassPostProcess which produces an output the same as it's input
  68566. */
  68567. export class DisplayPassPostProcess extends PostProcess {
  68568. /**
  68569. * Creates the DisplayPassPostProcess
  68570. * @param name The name of the effect.
  68571. * @param options The required width/height ratio to downsize to before computing the render pass.
  68572. * @param camera The camera to apply the render pass to.
  68573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68574. * @param engine The engine which the post process will be applied. (default: current engine)
  68575. * @param reusable If the post process can be reused on the same frame. (default: false)
  68576. */
  68577. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68578. }
  68579. }
  68580. declare module "babylonjs/Shaders/filter.fragment" {
  68581. /** @hidden */
  68582. export var filterPixelShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68588. import { Nullable } from "babylonjs/types";
  68589. import { Matrix } from "babylonjs/Maths/math.vector";
  68590. import { Camera } from "babylonjs/Cameras/camera";
  68591. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68592. import { Engine } from "babylonjs/Engines/engine";
  68593. import "babylonjs/Shaders/filter.fragment";
  68594. /**
  68595. * Applies a kernel filter to the image
  68596. */
  68597. export class FilterPostProcess extends PostProcess {
  68598. /** The matrix to be applied to the image */
  68599. kernelMatrix: Matrix;
  68600. /**
  68601. *
  68602. * @param name The name of the effect.
  68603. * @param kernelMatrix The matrix to be applied to the image
  68604. * @param options The required width/height ratio to downsize to before computing the render pass.
  68605. * @param camera The camera to apply the render pass to.
  68606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68607. * @param engine The engine which the post process will be applied. (default: current engine)
  68608. * @param reusable If the post process can be reused on the same frame. (default: false)
  68609. */
  68610. constructor(name: string,
  68611. /** The matrix to be applied to the image */
  68612. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68613. }
  68614. }
  68615. declare module "babylonjs/Shaders/fxaa.fragment" {
  68616. /** @hidden */
  68617. export var fxaaPixelShader: {
  68618. name: string;
  68619. shader: string;
  68620. };
  68621. }
  68622. declare module "babylonjs/Shaders/fxaa.vertex" {
  68623. /** @hidden */
  68624. export var fxaaVertexShader: {
  68625. name: string;
  68626. shader: string;
  68627. };
  68628. }
  68629. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68630. import { Nullable } from "babylonjs/types";
  68631. import { Camera } from "babylonjs/Cameras/camera";
  68632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68633. import { Engine } from "babylonjs/Engines/engine";
  68634. import "babylonjs/Shaders/fxaa.fragment";
  68635. import "babylonjs/Shaders/fxaa.vertex";
  68636. /**
  68637. * Fxaa post process
  68638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68639. */
  68640. export class FxaaPostProcess extends PostProcess {
  68641. /** @hidden */
  68642. texelWidth: number;
  68643. /** @hidden */
  68644. texelHeight: number;
  68645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68646. private _getDefines;
  68647. }
  68648. }
  68649. declare module "babylonjs/Shaders/grain.fragment" {
  68650. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68651. /** @hidden */
  68652. export var grainPixelShader: {
  68653. name: string;
  68654. shader: string;
  68655. };
  68656. }
  68657. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68658. import { Nullable } from "babylonjs/types";
  68659. import { Camera } from "babylonjs/Cameras/camera";
  68660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68661. import { Engine } from "babylonjs/Engines/engine";
  68662. import "babylonjs/Shaders/grain.fragment";
  68663. /**
  68664. * The GrainPostProcess adds noise to the image at mid luminance levels
  68665. */
  68666. export class GrainPostProcess extends PostProcess {
  68667. /**
  68668. * The intensity of the grain added (default: 30)
  68669. */
  68670. intensity: number;
  68671. /**
  68672. * If the grain should be randomized on every frame
  68673. */
  68674. animated: boolean;
  68675. /**
  68676. * Creates a new instance of @see GrainPostProcess
  68677. * @param name The name of the effect.
  68678. * @param options The required width/height ratio to downsize to before computing the render pass.
  68679. * @param camera The camera to apply the render pass to.
  68680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68681. * @param engine The engine which the post process will be applied. (default: current engine)
  68682. * @param reusable If the post process can be reused on the same frame. (default: false)
  68683. * @param textureType Type of textures used when performing the post process. (default: 0)
  68684. * @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)
  68685. */
  68686. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68687. }
  68688. }
  68689. declare module "babylonjs/Shaders/highlights.fragment" {
  68690. /** @hidden */
  68691. export var highlightsPixelShader: {
  68692. name: string;
  68693. shader: string;
  68694. };
  68695. }
  68696. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68697. import { Nullable } from "babylonjs/types";
  68698. import { Camera } from "babylonjs/Cameras/camera";
  68699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68700. import { Engine } from "babylonjs/Engines/engine";
  68701. import "babylonjs/Shaders/highlights.fragment";
  68702. /**
  68703. * Extracts highlights from the image
  68704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68705. */
  68706. export class HighlightsPostProcess extends PostProcess {
  68707. /**
  68708. * Extracts highlights from the image
  68709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68710. * @param name The name of the effect.
  68711. * @param options The required width/height ratio to downsize to before computing the render pass.
  68712. * @param camera The camera to apply the render pass to.
  68713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68714. * @param engine The engine which the post process will be applied. (default: current engine)
  68715. * @param reusable If the post process can be reused on the same frame. (default: false)
  68716. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68717. */
  68718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68719. }
  68720. }
  68721. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68722. /** @hidden */
  68723. export var mrtFragmentDeclaration: {
  68724. name: string;
  68725. shader: string;
  68726. };
  68727. }
  68728. declare module "babylonjs/Shaders/geometry.fragment" {
  68729. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68730. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68731. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68732. /** @hidden */
  68733. export var geometryPixelShader: {
  68734. name: string;
  68735. shader: string;
  68736. };
  68737. }
  68738. declare module "babylonjs/Shaders/geometry.vertex" {
  68739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68742. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68743. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68744. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68745. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68746. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68747. /** @hidden */
  68748. export var geometryVertexShader: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68754. import { Matrix } from "babylonjs/Maths/math.vector";
  68755. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68756. import { Mesh } from "babylonjs/Meshes/mesh";
  68757. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68758. import { Effect } from "babylonjs/Materials/effect";
  68759. import { Scene } from "babylonjs/scene";
  68760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68761. import "babylonjs/Shaders/geometry.fragment";
  68762. import "babylonjs/Shaders/geometry.vertex";
  68763. /** @hidden */
  68764. interface ISavedTransformationMatrix {
  68765. world: Matrix;
  68766. viewProjection: Matrix;
  68767. }
  68768. /**
  68769. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68770. */
  68771. export class GeometryBufferRenderer {
  68772. /**
  68773. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68774. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68775. */
  68776. static readonly POSITION_TEXTURE_TYPE: number;
  68777. /**
  68778. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68779. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68780. */
  68781. static readonly VELOCITY_TEXTURE_TYPE: number;
  68782. /**
  68783. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68784. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68785. */
  68786. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68787. /**
  68788. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68789. * in order to compute objects velocities when enableVelocity is set to "true"
  68790. * @hidden
  68791. */
  68792. _previousTransformationMatrices: {
  68793. [index: number]: ISavedTransformationMatrix;
  68794. };
  68795. /**
  68796. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68797. * in order to compute objects velocities when enableVelocity is set to "true"
  68798. * @hidden
  68799. */
  68800. _previousBonesTransformationMatrices: {
  68801. [index: number]: Float32Array;
  68802. };
  68803. /**
  68804. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68805. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68806. */
  68807. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68808. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68809. renderTransparentMeshes: boolean;
  68810. private _scene;
  68811. private _multiRenderTarget;
  68812. private _ratio;
  68813. private _enablePosition;
  68814. private _enableVelocity;
  68815. private _enableReflectivity;
  68816. private _positionIndex;
  68817. private _velocityIndex;
  68818. private _reflectivityIndex;
  68819. protected _effect: Effect;
  68820. protected _cachedDefines: string;
  68821. /**
  68822. * Set the render list (meshes to be rendered) used in the G buffer.
  68823. */
  68824. set renderList(meshes: Mesh[]);
  68825. /**
  68826. * Gets wether or not G buffer are supported by the running hardware.
  68827. * This requires draw buffer supports
  68828. */
  68829. get isSupported(): boolean;
  68830. /**
  68831. * Returns the index of the given texture type in the G-Buffer textures array
  68832. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68833. * @returns the index of the given texture type in the G-Buffer textures array
  68834. */
  68835. getTextureIndex(textureType: number): number;
  68836. /**
  68837. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68838. */
  68839. get enablePosition(): boolean;
  68840. /**
  68841. * Sets whether or not objects positions are enabled for the G buffer.
  68842. */
  68843. set enablePosition(enable: boolean);
  68844. /**
  68845. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68846. */
  68847. get enableVelocity(): boolean;
  68848. /**
  68849. * Sets wether or not objects velocities are enabled for the G buffer.
  68850. */
  68851. set enableVelocity(enable: boolean);
  68852. /**
  68853. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68854. */
  68855. get enableReflectivity(): boolean;
  68856. /**
  68857. * Sets wether or not objects roughness are enabled for the G buffer.
  68858. */
  68859. set enableReflectivity(enable: boolean);
  68860. /**
  68861. * Gets the scene associated with the buffer.
  68862. */
  68863. get scene(): Scene;
  68864. /**
  68865. * Gets the ratio used by the buffer during its creation.
  68866. * How big is the buffer related to the main canvas.
  68867. */
  68868. get ratio(): number;
  68869. /** @hidden */
  68870. static _SceneComponentInitialization: (scene: Scene) => void;
  68871. /**
  68872. * Creates a new G Buffer for the scene
  68873. * @param scene The scene the buffer belongs to
  68874. * @param ratio How big is the buffer related to the main canvas.
  68875. */
  68876. constructor(scene: Scene, ratio?: number);
  68877. /**
  68878. * Checks wether everything is ready to render a submesh to the G buffer.
  68879. * @param subMesh the submesh to check readiness for
  68880. * @param useInstances is the mesh drawn using instance or not
  68881. * @returns true if ready otherwise false
  68882. */
  68883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68884. /**
  68885. * Gets the current underlying G Buffer.
  68886. * @returns the buffer
  68887. */
  68888. getGBuffer(): MultiRenderTarget;
  68889. /**
  68890. * Gets the number of samples used to render the buffer (anti aliasing).
  68891. */
  68892. get samples(): number;
  68893. /**
  68894. * Sets the number of samples used to render the buffer (anti aliasing).
  68895. */
  68896. set samples(value: number);
  68897. /**
  68898. * Disposes the renderer and frees up associated resources.
  68899. */
  68900. dispose(): void;
  68901. protected _createRenderTargets(): void;
  68902. private _copyBonesTransformationMatrices;
  68903. }
  68904. }
  68905. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68906. import { Nullable } from "babylonjs/types";
  68907. import { Scene } from "babylonjs/scene";
  68908. import { ISceneComponent } from "babylonjs/sceneComponent";
  68909. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68910. module "babylonjs/scene" {
  68911. interface Scene {
  68912. /** @hidden (Backing field) */
  68913. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68914. /**
  68915. * Gets or Sets the current geometry buffer associated to the scene.
  68916. */
  68917. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68918. /**
  68919. * Enables a GeometryBufferRender and associates it with the scene
  68920. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68921. * @returns the GeometryBufferRenderer
  68922. */
  68923. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68924. /**
  68925. * Disables the GeometryBufferRender associated with the scene
  68926. */
  68927. disableGeometryBufferRenderer(): void;
  68928. }
  68929. }
  68930. /**
  68931. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68932. * in several rendering techniques.
  68933. */
  68934. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68935. /**
  68936. * The component name helpful to identify the component in the list of scene components.
  68937. */
  68938. readonly name: string;
  68939. /**
  68940. * The scene the component belongs to.
  68941. */
  68942. scene: Scene;
  68943. /**
  68944. * Creates a new instance of the component for the given scene
  68945. * @param scene Defines the scene to register the component in
  68946. */
  68947. constructor(scene: Scene);
  68948. /**
  68949. * Registers the component in a given scene
  68950. */
  68951. register(): void;
  68952. /**
  68953. * Rebuilds the elements related to this component in case of
  68954. * context lost for instance.
  68955. */
  68956. rebuild(): void;
  68957. /**
  68958. * Disposes the component and the associated ressources
  68959. */
  68960. dispose(): void;
  68961. private _gatherRenderTargets;
  68962. }
  68963. }
  68964. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68965. /** @hidden */
  68966. export var motionBlurPixelShader: {
  68967. name: string;
  68968. shader: string;
  68969. };
  68970. }
  68971. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68972. import { Nullable } from "babylonjs/types";
  68973. import { Camera } from "babylonjs/Cameras/camera";
  68974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68975. import { Scene } from "babylonjs/scene";
  68976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68977. import "babylonjs/Animations/animatable";
  68978. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68979. import "babylonjs/Shaders/motionBlur.fragment";
  68980. import { Engine } from "babylonjs/Engines/engine";
  68981. /**
  68982. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68983. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68984. * As an example, all you have to do is to create the post-process:
  68985. * var mb = new BABYLON.MotionBlurPostProcess(
  68986. * 'mb', // The name of the effect.
  68987. * scene, // The scene containing the objects to blur according to their velocity.
  68988. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68989. * camera // The camera to apply the render pass to.
  68990. * );
  68991. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68992. */
  68993. export class MotionBlurPostProcess extends PostProcess {
  68994. /**
  68995. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68996. */
  68997. motionStrength: number;
  68998. /**
  68999. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69000. */
  69001. get motionBlurSamples(): number;
  69002. /**
  69003. * Sets the number of iterations to be used for motion blur quality
  69004. */
  69005. set motionBlurSamples(samples: number);
  69006. private _motionBlurSamples;
  69007. private _geometryBufferRenderer;
  69008. /**
  69009. * Creates a new instance MotionBlurPostProcess
  69010. * @param name The name of the effect.
  69011. * @param scene The scene containing the objects to blur according to their velocity.
  69012. * @param options The required width/height ratio to downsize to before computing the render pass.
  69013. * @param camera The camera to apply the render pass to.
  69014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69015. * @param engine The engine which the post process will be applied. (default: current engine)
  69016. * @param reusable If the post process can be reused on the same frame. (default: false)
  69017. * @param textureType Type of textures used when performing the post process. (default: 0)
  69018. * @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)
  69019. */
  69020. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69021. /**
  69022. * Excludes the given skinned mesh from computing bones velocities.
  69023. * 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.
  69024. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69025. */
  69026. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69027. /**
  69028. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69029. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69030. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69031. */
  69032. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69033. /**
  69034. * Disposes the post process.
  69035. * @param camera The camera to dispose the post process on.
  69036. */
  69037. dispose(camera?: Camera): void;
  69038. }
  69039. }
  69040. declare module "babylonjs/Shaders/refraction.fragment" {
  69041. /** @hidden */
  69042. export var refractionPixelShader: {
  69043. name: string;
  69044. shader: string;
  69045. };
  69046. }
  69047. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69048. import { Color3 } from "babylonjs/Maths/math.color";
  69049. import { Camera } from "babylonjs/Cameras/camera";
  69050. import { Texture } from "babylonjs/Materials/Textures/texture";
  69051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69052. import { Engine } from "babylonjs/Engines/engine";
  69053. import "babylonjs/Shaders/refraction.fragment";
  69054. /**
  69055. * Post process which applies a refractin texture
  69056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69057. */
  69058. export class RefractionPostProcess extends PostProcess {
  69059. /** the base color of the refraction (used to taint the rendering) */
  69060. color: Color3;
  69061. /** simulated refraction depth */
  69062. depth: number;
  69063. /** the coefficient of the base color (0 to remove base color tainting) */
  69064. colorLevel: number;
  69065. private _refTexture;
  69066. private _ownRefractionTexture;
  69067. /**
  69068. * Gets or sets the refraction texture
  69069. * Please note that you are responsible for disposing the texture if you set it manually
  69070. */
  69071. get refractionTexture(): Texture;
  69072. set refractionTexture(value: Texture);
  69073. /**
  69074. * Initializes the RefractionPostProcess
  69075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69076. * @param name The name of the effect.
  69077. * @param refractionTextureUrl Url of the refraction texture to use
  69078. * @param color the base color of the refraction (used to taint the rendering)
  69079. * @param depth simulated refraction depth
  69080. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69081. * @param camera The camera to apply the render pass to.
  69082. * @param options The required width/height ratio to downsize to before computing the render pass.
  69083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69084. * @param engine The engine which the post process will be applied. (default: current engine)
  69085. * @param reusable If the post process can be reused on the same frame. (default: false)
  69086. */
  69087. constructor(name: string, refractionTextureUrl: string,
  69088. /** the base color of the refraction (used to taint the rendering) */
  69089. color: Color3,
  69090. /** simulated refraction depth */
  69091. depth: number,
  69092. /** the coefficient of the base color (0 to remove base color tainting) */
  69093. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69094. /**
  69095. * Disposes of the post process
  69096. * @param camera Camera to dispose post process on
  69097. */
  69098. dispose(camera: Camera): void;
  69099. }
  69100. }
  69101. declare module "babylonjs/Shaders/sharpen.fragment" {
  69102. /** @hidden */
  69103. export var sharpenPixelShader: {
  69104. name: string;
  69105. shader: string;
  69106. };
  69107. }
  69108. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69109. import { Nullable } from "babylonjs/types";
  69110. import { Camera } from "babylonjs/Cameras/camera";
  69111. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69112. import "babylonjs/Shaders/sharpen.fragment";
  69113. import { Engine } from "babylonjs/Engines/engine";
  69114. /**
  69115. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69116. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69117. */
  69118. export class SharpenPostProcess extends PostProcess {
  69119. /**
  69120. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69121. */
  69122. colorAmount: number;
  69123. /**
  69124. * How much sharpness should be applied (default: 0.3)
  69125. */
  69126. edgeAmount: number;
  69127. /**
  69128. * Creates a new instance ConvolutionPostProcess
  69129. * @param name The name of the effect.
  69130. * @param options The required width/height ratio to downsize to before computing the render pass.
  69131. * @param camera The camera to apply the render pass to.
  69132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69133. * @param engine The engine which the post process will be applied. (default: current engine)
  69134. * @param reusable If the post process can be reused on the same frame. (default: false)
  69135. * @param textureType Type of textures used when performing the post process. (default: 0)
  69136. * @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)
  69137. */
  69138. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69139. }
  69140. }
  69141. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69142. import { Nullable } from "babylonjs/types";
  69143. import { Camera } from "babylonjs/Cameras/camera";
  69144. import { Engine } from "babylonjs/Engines/engine";
  69145. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69146. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69147. /**
  69148. * PostProcessRenderPipeline
  69149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69150. */
  69151. export class PostProcessRenderPipeline {
  69152. private engine;
  69153. private _renderEffects;
  69154. private _renderEffectsForIsolatedPass;
  69155. /**
  69156. * List of inspectable custom properties (used by the Inspector)
  69157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69158. */
  69159. inspectableCustomProperties: IInspectable[];
  69160. /**
  69161. * @hidden
  69162. */
  69163. protected _cameras: Camera[];
  69164. /** @hidden */
  69165. _name: string;
  69166. /**
  69167. * Gets pipeline name
  69168. */
  69169. get name(): string;
  69170. /** Gets the list of attached cameras */
  69171. get cameras(): Camera[];
  69172. /**
  69173. * Initializes a PostProcessRenderPipeline
  69174. * @param engine engine to add the pipeline to
  69175. * @param name name of the pipeline
  69176. */
  69177. constructor(engine: Engine, name: string);
  69178. /**
  69179. * Gets the class name
  69180. * @returns "PostProcessRenderPipeline"
  69181. */
  69182. getClassName(): string;
  69183. /**
  69184. * If all the render effects in the pipeline are supported
  69185. */
  69186. get isSupported(): boolean;
  69187. /**
  69188. * Adds an effect to the pipeline
  69189. * @param renderEffect the effect to add
  69190. */
  69191. addEffect(renderEffect: PostProcessRenderEffect): void;
  69192. /** @hidden */
  69193. _rebuild(): void;
  69194. /** @hidden */
  69195. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69196. /** @hidden */
  69197. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69198. /** @hidden */
  69199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69200. /** @hidden */
  69201. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69202. /** @hidden */
  69203. _attachCameras(cameras: Camera, unique: boolean): void;
  69204. /** @hidden */
  69205. _attachCameras(cameras: Camera[], unique: boolean): void;
  69206. /** @hidden */
  69207. _detachCameras(cameras: Camera): void;
  69208. /** @hidden */
  69209. _detachCameras(cameras: Nullable<Camera[]>): void;
  69210. /** @hidden */
  69211. _update(): void;
  69212. /** @hidden */
  69213. _reset(): void;
  69214. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69215. /**
  69216. * Disposes of the pipeline
  69217. */
  69218. dispose(): void;
  69219. }
  69220. }
  69221. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69222. import { Camera } from "babylonjs/Cameras/camera";
  69223. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69224. /**
  69225. * PostProcessRenderPipelineManager class
  69226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69227. */
  69228. export class PostProcessRenderPipelineManager {
  69229. private _renderPipelines;
  69230. /**
  69231. * Initializes a PostProcessRenderPipelineManager
  69232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69233. */
  69234. constructor();
  69235. /**
  69236. * Gets the list of supported render pipelines
  69237. */
  69238. get supportedPipelines(): PostProcessRenderPipeline[];
  69239. /**
  69240. * Adds a pipeline to the manager
  69241. * @param renderPipeline The pipeline to add
  69242. */
  69243. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69244. /**
  69245. * Attaches a camera to the pipeline
  69246. * @param renderPipelineName The name of the pipeline to attach to
  69247. * @param cameras the camera to attach
  69248. * @param unique if the camera can be attached multiple times to the pipeline
  69249. */
  69250. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69251. /**
  69252. * Detaches a camera from the pipeline
  69253. * @param renderPipelineName The name of the pipeline to detach from
  69254. * @param cameras the camera to detach
  69255. */
  69256. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69257. /**
  69258. * Enables an effect by name on a pipeline
  69259. * @param renderPipelineName the name of the pipeline to enable the effect in
  69260. * @param renderEffectName the name of the effect to enable
  69261. * @param cameras the cameras that the effect should be enabled on
  69262. */
  69263. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69264. /**
  69265. * Disables an effect by name on a pipeline
  69266. * @param renderPipelineName the name of the pipeline to disable the effect in
  69267. * @param renderEffectName the name of the effect to disable
  69268. * @param cameras the cameras that the effect should be disabled on
  69269. */
  69270. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69271. /**
  69272. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69273. */
  69274. update(): void;
  69275. /** @hidden */
  69276. _rebuild(): void;
  69277. /**
  69278. * Disposes of the manager and pipelines
  69279. */
  69280. dispose(): void;
  69281. }
  69282. }
  69283. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69284. import { ISceneComponent } from "babylonjs/sceneComponent";
  69285. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69286. import { Scene } from "babylonjs/scene";
  69287. module "babylonjs/scene" {
  69288. interface Scene {
  69289. /** @hidden (Backing field) */
  69290. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69291. /**
  69292. * Gets the postprocess render pipeline manager
  69293. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69294. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69295. */
  69296. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69297. }
  69298. }
  69299. /**
  69300. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69301. */
  69302. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69303. /**
  69304. * The component name helpfull to identify the component in the list of scene components.
  69305. */
  69306. readonly name: string;
  69307. /**
  69308. * The scene the component belongs to.
  69309. */
  69310. scene: Scene;
  69311. /**
  69312. * Creates a new instance of the component for the given scene
  69313. * @param scene Defines the scene to register the component in
  69314. */
  69315. constructor(scene: Scene);
  69316. /**
  69317. * Registers the component in a given scene
  69318. */
  69319. register(): void;
  69320. /**
  69321. * Rebuilds the elements related to this component in case of
  69322. * context lost for instance.
  69323. */
  69324. rebuild(): void;
  69325. /**
  69326. * Disposes the component and the associated ressources
  69327. */
  69328. dispose(): void;
  69329. private _gatherRenderTargets;
  69330. }
  69331. }
  69332. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69333. import { Nullable } from "babylonjs/types";
  69334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69335. import { Camera } from "babylonjs/Cameras/camera";
  69336. import { IDisposable } from "babylonjs/scene";
  69337. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69338. import { Scene } from "babylonjs/scene";
  69339. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69340. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69341. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69342. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69343. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69344. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69345. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69346. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69347. import { Animation } from "babylonjs/Animations/animation";
  69348. /**
  69349. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69350. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69351. */
  69352. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69353. private _scene;
  69354. private _camerasToBeAttached;
  69355. /**
  69356. * ID of the sharpen post process,
  69357. */
  69358. private readonly SharpenPostProcessId;
  69359. /**
  69360. * @ignore
  69361. * ID of the image processing post process;
  69362. */
  69363. readonly ImageProcessingPostProcessId: string;
  69364. /**
  69365. * @ignore
  69366. * ID of the Fast Approximate Anti-Aliasing post process;
  69367. */
  69368. readonly FxaaPostProcessId: string;
  69369. /**
  69370. * ID of the chromatic aberration post process,
  69371. */
  69372. private readonly ChromaticAberrationPostProcessId;
  69373. /**
  69374. * ID of the grain post process
  69375. */
  69376. private readonly GrainPostProcessId;
  69377. /**
  69378. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69379. */
  69380. sharpen: SharpenPostProcess;
  69381. private _sharpenEffect;
  69382. private bloom;
  69383. /**
  69384. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69385. */
  69386. depthOfField: DepthOfFieldEffect;
  69387. /**
  69388. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69389. */
  69390. fxaa: FxaaPostProcess;
  69391. /**
  69392. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69393. */
  69394. imageProcessing: ImageProcessingPostProcess;
  69395. /**
  69396. * Chromatic aberration post process which will shift rgb colors in the image
  69397. */
  69398. chromaticAberration: ChromaticAberrationPostProcess;
  69399. private _chromaticAberrationEffect;
  69400. /**
  69401. * Grain post process which add noise to the image
  69402. */
  69403. grain: GrainPostProcess;
  69404. private _grainEffect;
  69405. /**
  69406. * Glow post process which adds a glow to emissive areas of the image
  69407. */
  69408. private _glowLayer;
  69409. /**
  69410. * Animations which can be used to tweak settings over a period of time
  69411. */
  69412. animations: Animation[];
  69413. private _imageProcessingConfigurationObserver;
  69414. private _sharpenEnabled;
  69415. private _bloomEnabled;
  69416. private _depthOfFieldEnabled;
  69417. private _depthOfFieldBlurLevel;
  69418. private _fxaaEnabled;
  69419. private _imageProcessingEnabled;
  69420. private _defaultPipelineTextureType;
  69421. private _bloomScale;
  69422. private _chromaticAberrationEnabled;
  69423. private _grainEnabled;
  69424. private _buildAllowed;
  69425. /**
  69426. * Gets active scene
  69427. */
  69428. get scene(): Scene;
  69429. /**
  69430. * Enable or disable the sharpen process from the pipeline
  69431. */
  69432. set sharpenEnabled(enabled: boolean);
  69433. get sharpenEnabled(): boolean;
  69434. private _resizeObserver;
  69435. private _hardwareScaleLevel;
  69436. private _bloomKernel;
  69437. /**
  69438. * Specifies the size of the bloom blur kernel, relative to the final output size
  69439. */
  69440. get bloomKernel(): number;
  69441. set bloomKernel(value: number);
  69442. /**
  69443. * Specifies the weight of the bloom in the final rendering
  69444. */
  69445. private _bloomWeight;
  69446. /**
  69447. * Specifies the luma threshold for the area that will be blurred by the bloom
  69448. */
  69449. private _bloomThreshold;
  69450. private _hdr;
  69451. /**
  69452. * The strength of the bloom.
  69453. */
  69454. set bloomWeight(value: number);
  69455. get bloomWeight(): number;
  69456. /**
  69457. * The strength of the bloom.
  69458. */
  69459. set bloomThreshold(value: number);
  69460. get bloomThreshold(): number;
  69461. /**
  69462. * The scale of the bloom, lower value will provide better performance.
  69463. */
  69464. set bloomScale(value: number);
  69465. get bloomScale(): number;
  69466. /**
  69467. * Enable or disable the bloom from the pipeline
  69468. */
  69469. set bloomEnabled(enabled: boolean);
  69470. get bloomEnabled(): boolean;
  69471. private _rebuildBloom;
  69472. /**
  69473. * If the depth of field is enabled.
  69474. */
  69475. get depthOfFieldEnabled(): boolean;
  69476. set depthOfFieldEnabled(enabled: boolean);
  69477. /**
  69478. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69479. */
  69480. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69481. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69482. /**
  69483. * If the anti aliasing is enabled.
  69484. */
  69485. set fxaaEnabled(enabled: boolean);
  69486. get fxaaEnabled(): boolean;
  69487. private _samples;
  69488. /**
  69489. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69490. */
  69491. set samples(sampleCount: number);
  69492. get samples(): number;
  69493. /**
  69494. * If image processing is enabled.
  69495. */
  69496. set imageProcessingEnabled(enabled: boolean);
  69497. get imageProcessingEnabled(): boolean;
  69498. /**
  69499. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69500. */
  69501. set glowLayerEnabled(enabled: boolean);
  69502. get glowLayerEnabled(): boolean;
  69503. /**
  69504. * Gets the glow layer (or null if not defined)
  69505. */
  69506. get glowLayer(): Nullable<GlowLayer>;
  69507. /**
  69508. * Enable or disable the chromaticAberration process from the pipeline
  69509. */
  69510. set chromaticAberrationEnabled(enabled: boolean);
  69511. get chromaticAberrationEnabled(): boolean;
  69512. /**
  69513. * Enable or disable the grain process from the pipeline
  69514. */
  69515. set grainEnabled(enabled: boolean);
  69516. get grainEnabled(): boolean;
  69517. /**
  69518. * @constructor
  69519. * @param name - The rendering pipeline name (default: "")
  69520. * @param hdr - If high dynamic range textures should be used (default: true)
  69521. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69522. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69523. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69524. */
  69525. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69526. /**
  69527. * Get the class name
  69528. * @returns "DefaultRenderingPipeline"
  69529. */
  69530. getClassName(): string;
  69531. /**
  69532. * Force the compilation of the entire pipeline.
  69533. */
  69534. prepare(): void;
  69535. private _hasCleared;
  69536. private _prevPostProcess;
  69537. private _prevPrevPostProcess;
  69538. private _setAutoClearAndTextureSharing;
  69539. private _depthOfFieldSceneObserver;
  69540. private _buildPipeline;
  69541. private _disposePostProcesses;
  69542. /**
  69543. * Adds a camera to the pipeline
  69544. * @param camera the camera to be added
  69545. */
  69546. addCamera(camera: Camera): void;
  69547. /**
  69548. * Removes a camera from the pipeline
  69549. * @param camera the camera to remove
  69550. */
  69551. removeCamera(camera: Camera): void;
  69552. /**
  69553. * Dispose of the pipeline and stop all post processes
  69554. */
  69555. dispose(): void;
  69556. /**
  69557. * Serialize the rendering pipeline (Used when exporting)
  69558. * @returns the serialized object
  69559. */
  69560. serialize(): any;
  69561. /**
  69562. * Parse the serialized pipeline
  69563. * @param source Source pipeline.
  69564. * @param scene The scene to load the pipeline to.
  69565. * @param rootUrl The URL of the serialized pipeline.
  69566. * @returns An instantiated pipeline from the serialized object.
  69567. */
  69568. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69569. }
  69570. }
  69571. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69572. /** @hidden */
  69573. export var lensHighlightsPixelShader: {
  69574. name: string;
  69575. shader: string;
  69576. };
  69577. }
  69578. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69579. /** @hidden */
  69580. export var depthOfFieldPixelShader: {
  69581. name: string;
  69582. shader: string;
  69583. };
  69584. }
  69585. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69586. import { Camera } from "babylonjs/Cameras/camera";
  69587. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69588. import { Scene } from "babylonjs/scene";
  69589. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69590. import "babylonjs/Shaders/chromaticAberration.fragment";
  69591. import "babylonjs/Shaders/lensHighlights.fragment";
  69592. import "babylonjs/Shaders/depthOfField.fragment";
  69593. /**
  69594. * BABYLON.JS Chromatic Aberration GLSL Shader
  69595. * Author: Olivier Guyot
  69596. * Separates very slightly R, G and B colors on the edges of the screen
  69597. * Inspired by Francois Tarlier & Martins Upitis
  69598. */
  69599. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69600. /**
  69601. * @ignore
  69602. * The chromatic aberration PostProcess id in the pipeline
  69603. */
  69604. LensChromaticAberrationEffect: string;
  69605. /**
  69606. * @ignore
  69607. * The highlights enhancing PostProcess id in the pipeline
  69608. */
  69609. HighlightsEnhancingEffect: string;
  69610. /**
  69611. * @ignore
  69612. * The depth-of-field PostProcess id in the pipeline
  69613. */
  69614. LensDepthOfFieldEffect: string;
  69615. private _scene;
  69616. private _depthTexture;
  69617. private _grainTexture;
  69618. private _chromaticAberrationPostProcess;
  69619. private _highlightsPostProcess;
  69620. private _depthOfFieldPostProcess;
  69621. private _edgeBlur;
  69622. private _grainAmount;
  69623. private _chromaticAberration;
  69624. private _distortion;
  69625. private _highlightsGain;
  69626. private _highlightsThreshold;
  69627. private _dofDistance;
  69628. private _dofAperture;
  69629. private _dofDarken;
  69630. private _dofPentagon;
  69631. private _blurNoise;
  69632. /**
  69633. * @constructor
  69634. *
  69635. * Effect parameters are as follow:
  69636. * {
  69637. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69638. * edge_blur: number; // from 0 to x (1 for realism)
  69639. * distortion: number; // from 0 to x (1 for realism)
  69640. * grain_amount: number; // from 0 to 1
  69641. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69642. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69643. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69644. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69645. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69646. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69647. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69648. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69649. * }
  69650. * Note: if an effect parameter is unset, effect is disabled
  69651. *
  69652. * @param name The rendering pipeline name
  69653. * @param parameters - An object containing all parameters (see above)
  69654. * @param scene The scene linked to this pipeline
  69655. * @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)
  69656. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69657. */
  69658. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69659. /**
  69660. * Get the class name
  69661. * @returns "LensRenderingPipeline"
  69662. */
  69663. getClassName(): string;
  69664. /**
  69665. * Gets associated scene
  69666. */
  69667. get scene(): Scene;
  69668. /**
  69669. * Gets or sets the edge blur
  69670. */
  69671. get edgeBlur(): number;
  69672. set edgeBlur(value: number);
  69673. /**
  69674. * Gets or sets the grain amount
  69675. */
  69676. get grainAmount(): number;
  69677. set grainAmount(value: number);
  69678. /**
  69679. * Gets or sets the chromatic aberration amount
  69680. */
  69681. get chromaticAberration(): number;
  69682. set chromaticAberration(value: number);
  69683. /**
  69684. * Gets or sets the depth of field aperture
  69685. */
  69686. get dofAperture(): number;
  69687. set dofAperture(value: number);
  69688. /**
  69689. * Gets or sets the edge distortion
  69690. */
  69691. get edgeDistortion(): number;
  69692. set edgeDistortion(value: number);
  69693. /**
  69694. * Gets or sets the depth of field distortion
  69695. */
  69696. get dofDistortion(): number;
  69697. set dofDistortion(value: number);
  69698. /**
  69699. * Gets or sets the darken out of focus amount
  69700. */
  69701. get darkenOutOfFocus(): number;
  69702. set darkenOutOfFocus(value: number);
  69703. /**
  69704. * Gets or sets a boolean indicating if blur noise is enabled
  69705. */
  69706. get blurNoise(): boolean;
  69707. set blurNoise(value: boolean);
  69708. /**
  69709. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69710. */
  69711. get pentagonBokeh(): boolean;
  69712. set pentagonBokeh(value: boolean);
  69713. /**
  69714. * Gets or sets the highlight grain amount
  69715. */
  69716. get highlightsGain(): number;
  69717. set highlightsGain(value: number);
  69718. /**
  69719. * Gets or sets the highlight threshold
  69720. */
  69721. get highlightsThreshold(): number;
  69722. set highlightsThreshold(value: number);
  69723. /**
  69724. * Sets the amount of blur at the edges
  69725. * @param amount blur amount
  69726. */
  69727. setEdgeBlur(amount: number): void;
  69728. /**
  69729. * Sets edge blur to 0
  69730. */
  69731. disableEdgeBlur(): void;
  69732. /**
  69733. * Sets the amout of grain
  69734. * @param amount Amount of grain
  69735. */
  69736. setGrainAmount(amount: number): void;
  69737. /**
  69738. * Set grain amount to 0
  69739. */
  69740. disableGrain(): void;
  69741. /**
  69742. * Sets the chromatic aberration amount
  69743. * @param amount amount of chromatic aberration
  69744. */
  69745. setChromaticAberration(amount: number): void;
  69746. /**
  69747. * Sets chromatic aberration amount to 0
  69748. */
  69749. disableChromaticAberration(): void;
  69750. /**
  69751. * Sets the EdgeDistortion amount
  69752. * @param amount amount of EdgeDistortion
  69753. */
  69754. setEdgeDistortion(amount: number): void;
  69755. /**
  69756. * Sets edge distortion to 0
  69757. */
  69758. disableEdgeDistortion(): void;
  69759. /**
  69760. * Sets the FocusDistance amount
  69761. * @param amount amount of FocusDistance
  69762. */
  69763. setFocusDistance(amount: number): void;
  69764. /**
  69765. * Disables depth of field
  69766. */
  69767. disableDepthOfField(): void;
  69768. /**
  69769. * Sets the Aperture amount
  69770. * @param amount amount of Aperture
  69771. */
  69772. setAperture(amount: number): void;
  69773. /**
  69774. * Sets the DarkenOutOfFocus amount
  69775. * @param amount amount of DarkenOutOfFocus
  69776. */
  69777. setDarkenOutOfFocus(amount: number): void;
  69778. private _pentagonBokehIsEnabled;
  69779. /**
  69780. * Creates a pentagon bokeh effect
  69781. */
  69782. enablePentagonBokeh(): void;
  69783. /**
  69784. * Disables the pentagon bokeh effect
  69785. */
  69786. disablePentagonBokeh(): void;
  69787. /**
  69788. * Enables noise blur
  69789. */
  69790. enableNoiseBlur(): void;
  69791. /**
  69792. * Disables noise blur
  69793. */
  69794. disableNoiseBlur(): void;
  69795. /**
  69796. * Sets the HighlightsGain amount
  69797. * @param amount amount of HighlightsGain
  69798. */
  69799. setHighlightsGain(amount: number): void;
  69800. /**
  69801. * Sets the HighlightsThreshold amount
  69802. * @param amount amount of HighlightsThreshold
  69803. */
  69804. setHighlightsThreshold(amount: number): void;
  69805. /**
  69806. * Disables highlights
  69807. */
  69808. disableHighlights(): void;
  69809. /**
  69810. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69811. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69812. */
  69813. dispose(disableDepthRender?: boolean): void;
  69814. private _createChromaticAberrationPostProcess;
  69815. private _createHighlightsPostProcess;
  69816. private _createDepthOfFieldPostProcess;
  69817. private _createGrainTexture;
  69818. }
  69819. }
  69820. declare module "babylonjs/Shaders/ssao2.fragment" {
  69821. /** @hidden */
  69822. export var ssao2PixelShader: {
  69823. name: string;
  69824. shader: string;
  69825. };
  69826. }
  69827. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69828. /** @hidden */
  69829. export var ssaoCombinePixelShader: {
  69830. name: string;
  69831. shader: string;
  69832. };
  69833. }
  69834. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69835. import { Camera } from "babylonjs/Cameras/camera";
  69836. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69837. import { Scene } from "babylonjs/scene";
  69838. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69839. import "babylonjs/Shaders/ssao2.fragment";
  69840. import "babylonjs/Shaders/ssaoCombine.fragment";
  69841. /**
  69842. * Render pipeline to produce ssao effect
  69843. */
  69844. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69845. /**
  69846. * @ignore
  69847. * The PassPostProcess id in the pipeline that contains the original scene color
  69848. */
  69849. SSAOOriginalSceneColorEffect: string;
  69850. /**
  69851. * @ignore
  69852. * The SSAO PostProcess id in the pipeline
  69853. */
  69854. SSAORenderEffect: string;
  69855. /**
  69856. * @ignore
  69857. * The horizontal blur PostProcess id in the pipeline
  69858. */
  69859. SSAOBlurHRenderEffect: string;
  69860. /**
  69861. * @ignore
  69862. * The vertical blur PostProcess id in the pipeline
  69863. */
  69864. SSAOBlurVRenderEffect: string;
  69865. /**
  69866. * @ignore
  69867. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69868. */
  69869. SSAOCombineRenderEffect: string;
  69870. /**
  69871. * The output strength of the SSAO post-process. Default value is 1.0.
  69872. */
  69873. totalStrength: number;
  69874. /**
  69875. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69876. */
  69877. maxZ: number;
  69878. /**
  69879. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69880. */
  69881. minZAspect: number;
  69882. private _samples;
  69883. /**
  69884. * Number of samples used for the SSAO calculations. Default value is 8
  69885. */
  69886. set samples(n: number);
  69887. get samples(): number;
  69888. private _textureSamples;
  69889. /**
  69890. * Number of samples to use for antialiasing
  69891. */
  69892. set textureSamples(n: number);
  69893. get textureSamples(): number;
  69894. /**
  69895. * Ratio object used for SSAO ratio and blur ratio
  69896. */
  69897. private _ratio;
  69898. /**
  69899. * Dynamically generated sphere sampler.
  69900. */
  69901. private _sampleSphere;
  69902. /**
  69903. * Blur filter offsets
  69904. */
  69905. private _samplerOffsets;
  69906. private _expensiveBlur;
  69907. /**
  69908. * If bilateral blur should be used
  69909. */
  69910. set expensiveBlur(b: boolean);
  69911. get expensiveBlur(): boolean;
  69912. /**
  69913. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69914. */
  69915. radius: number;
  69916. /**
  69917. * The base color of the SSAO post-process
  69918. * The final result is "base + ssao" between [0, 1]
  69919. */
  69920. base: number;
  69921. /**
  69922. * Support test.
  69923. */
  69924. static get IsSupported(): boolean;
  69925. private _scene;
  69926. private _depthTexture;
  69927. private _normalTexture;
  69928. private _randomTexture;
  69929. private _originalColorPostProcess;
  69930. private _ssaoPostProcess;
  69931. private _blurHPostProcess;
  69932. private _blurVPostProcess;
  69933. private _ssaoCombinePostProcess;
  69934. /**
  69935. * Gets active scene
  69936. */
  69937. get scene(): Scene;
  69938. /**
  69939. * @constructor
  69940. * @param name The rendering pipeline name
  69941. * @param scene The scene linked to this pipeline
  69942. * @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 }
  69943. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69944. */
  69945. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69946. /**
  69947. * Get the class name
  69948. * @returns "SSAO2RenderingPipeline"
  69949. */
  69950. getClassName(): string;
  69951. /**
  69952. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69953. */
  69954. dispose(disableGeometryBufferRenderer?: boolean): void;
  69955. private _createBlurPostProcess;
  69956. /** @hidden */
  69957. _rebuild(): void;
  69958. private _bits;
  69959. private _radicalInverse_VdC;
  69960. private _hammersley;
  69961. private _hemisphereSample_uniform;
  69962. private _generateHemisphere;
  69963. private _createSSAOPostProcess;
  69964. private _createSSAOCombinePostProcess;
  69965. private _createRandomTexture;
  69966. /**
  69967. * Serialize the rendering pipeline (Used when exporting)
  69968. * @returns the serialized object
  69969. */
  69970. serialize(): any;
  69971. /**
  69972. * Parse the serialized pipeline
  69973. * @param source Source pipeline.
  69974. * @param scene The scene to load the pipeline to.
  69975. * @param rootUrl The URL of the serialized pipeline.
  69976. * @returns An instantiated pipeline from the serialized object.
  69977. */
  69978. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69979. }
  69980. }
  69981. declare module "babylonjs/Shaders/ssao.fragment" {
  69982. /** @hidden */
  69983. export var ssaoPixelShader: {
  69984. name: string;
  69985. shader: string;
  69986. };
  69987. }
  69988. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69989. import { Camera } from "babylonjs/Cameras/camera";
  69990. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69991. import { Scene } from "babylonjs/scene";
  69992. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69993. import "babylonjs/Shaders/ssao.fragment";
  69994. import "babylonjs/Shaders/ssaoCombine.fragment";
  69995. /**
  69996. * Render pipeline to produce ssao effect
  69997. */
  69998. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69999. /**
  70000. * @ignore
  70001. * The PassPostProcess id in the pipeline that contains the original scene color
  70002. */
  70003. SSAOOriginalSceneColorEffect: string;
  70004. /**
  70005. * @ignore
  70006. * The SSAO PostProcess id in the pipeline
  70007. */
  70008. SSAORenderEffect: string;
  70009. /**
  70010. * @ignore
  70011. * The horizontal blur PostProcess id in the pipeline
  70012. */
  70013. SSAOBlurHRenderEffect: string;
  70014. /**
  70015. * @ignore
  70016. * The vertical blur PostProcess id in the pipeline
  70017. */
  70018. SSAOBlurVRenderEffect: string;
  70019. /**
  70020. * @ignore
  70021. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70022. */
  70023. SSAOCombineRenderEffect: string;
  70024. /**
  70025. * The output strength of the SSAO post-process. Default value is 1.0.
  70026. */
  70027. totalStrength: number;
  70028. /**
  70029. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70030. */
  70031. radius: number;
  70032. /**
  70033. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70034. * Must not be equal to fallOff and superior to fallOff.
  70035. * Default value is 0.0075
  70036. */
  70037. area: number;
  70038. /**
  70039. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70040. * Must not be equal to area and inferior to area.
  70041. * Default value is 0.000001
  70042. */
  70043. fallOff: number;
  70044. /**
  70045. * The base color of the SSAO post-process
  70046. * The final result is "base + ssao" between [0, 1]
  70047. */
  70048. base: number;
  70049. private _scene;
  70050. private _depthTexture;
  70051. private _randomTexture;
  70052. private _originalColorPostProcess;
  70053. private _ssaoPostProcess;
  70054. private _blurHPostProcess;
  70055. private _blurVPostProcess;
  70056. private _ssaoCombinePostProcess;
  70057. private _firstUpdate;
  70058. /**
  70059. * Gets active scene
  70060. */
  70061. get scene(): Scene;
  70062. /**
  70063. * @constructor
  70064. * @param name - The rendering pipeline name
  70065. * @param scene - The scene linked to this pipeline
  70066. * @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 }
  70067. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70068. */
  70069. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70070. /**
  70071. * Get the class name
  70072. * @returns "SSAORenderingPipeline"
  70073. */
  70074. getClassName(): string;
  70075. /**
  70076. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70077. */
  70078. dispose(disableDepthRender?: boolean): void;
  70079. private _createBlurPostProcess;
  70080. /** @hidden */
  70081. _rebuild(): void;
  70082. private _createSSAOPostProcess;
  70083. private _createSSAOCombinePostProcess;
  70084. private _createRandomTexture;
  70085. }
  70086. }
  70087. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70088. /** @hidden */
  70089. export var screenSpaceReflectionPixelShader: {
  70090. name: string;
  70091. shader: string;
  70092. };
  70093. }
  70094. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70095. import { Nullable } from "babylonjs/types";
  70096. import { Camera } from "babylonjs/Cameras/camera";
  70097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70098. import { Scene } from "babylonjs/scene";
  70099. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70100. import { Engine } from "babylonjs/Engines/engine";
  70101. /**
  70102. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70103. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70104. */
  70105. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70106. /**
  70107. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70108. */
  70109. threshold: number;
  70110. /**
  70111. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70112. */
  70113. strength: number;
  70114. /**
  70115. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70116. */
  70117. reflectionSpecularFalloffExponent: number;
  70118. /**
  70119. * 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]
  70120. */
  70121. step: number;
  70122. /**
  70123. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70124. */
  70125. roughnessFactor: number;
  70126. private _geometryBufferRenderer;
  70127. private _enableSmoothReflections;
  70128. private _reflectionSamples;
  70129. private _smoothSteps;
  70130. /**
  70131. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70132. * @param name The name of the effect.
  70133. * @param scene The scene containing the objects to calculate reflections.
  70134. * @param options The required width/height ratio to downsize to before computing the render pass.
  70135. * @param camera The camera to apply the render pass to.
  70136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70137. * @param engine The engine which the post process will be applied. (default: current engine)
  70138. * @param reusable If the post process can be reused on the same frame. (default: false)
  70139. * @param textureType Type of textures used when performing the post process. (default: 0)
  70140. * @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)
  70141. */
  70142. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70143. /**
  70144. * Gets wether or not smoothing reflections is enabled.
  70145. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70146. */
  70147. get enableSmoothReflections(): boolean;
  70148. /**
  70149. * Sets wether or not smoothing reflections is enabled.
  70150. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70151. */
  70152. set enableSmoothReflections(enabled: boolean);
  70153. /**
  70154. * Gets the number of samples taken while computing reflections. More samples count is high,
  70155. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70156. */
  70157. get reflectionSamples(): number;
  70158. /**
  70159. * Sets the number of samples taken while computing reflections. More samples count is high,
  70160. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70161. */
  70162. set reflectionSamples(samples: number);
  70163. /**
  70164. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70165. * more the post-process will require GPU power and can generate a drop in FPS.
  70166. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70167. */
  70168. get smoothSteps(): number;
  70169. set smoothSteps(steps: number);
  70170. private _updateEffectDefines;
  70171. }
  70172. }
  70173. declare module "babylonjs/Shaders/standard.fragment" {
  70174. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70175. /** @hidden */
  70176. export var standardPixelShader: {
  70177. name: string;
  70178. shader: string;
  70179. };
  70180. }
  70181. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70182. import { Nullable } from "babylonjs/types";
  70183. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70184. import { Camera } from "babylonjs/Cameras/camera";
  70185. import { Texture } from "babylonjs/Materials/Textures/texture";
  70186. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70187. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70188. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70189. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70190. import { IDisposable } from "babylonjs/scene";
  70191. import { SpotLight } from "babylonjs/Lights/spotLight";
  70192. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70193. import { Scene } from "babylonjs/scene";
  70194. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70195. import { Animation } from "babylonjs/Animations/animation";
  70196. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70197. import "babylonjs/Shaders/standard.fragment";
  70198. /**
  70199. * Standard rendering pipeline
  70200. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70201. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70202. */
  70203. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70204. /**
  70205. * Public members
  70206. */
  70207. /**
  70208. * Post-process which contains the original scene color before the pipeline applies all the effects
  70209. */
  70210. originalPostProcess: Nullable<PostProcess>;
  70211. /**
  70212. * Post-process used to down scale an image x4
  70213. */
  70214. downSampleX4PostProcess: Nullable<PostProcess>;
  70215. /**
  70216. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70217. */
  70218. brightPassPostProcess: Nullable<PostProcess>;
  70219. /**
  70220. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70221. */
  70222. blurHPostProcesses: PostProcess[];
  70223. /**
  70224. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70225. */
  70226. blurVPostProcesses: PostProcess[];
  70227. /**
  70228. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70229. */
  70230. textureAdderPostProcess: Nullable<PostProcess>;
  70231. /**
  70232. * Post-process used to create volumetric lighting effect
  70233. */
  70234. volumetricLightPostProcess: Nullable<PostProcess>;
  70235. /**
  70236. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70237. */
  70238. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70239. /**
  70240. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70241. */
  70242. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70243. /**
  70244. * Post-process used to merge the volumetric light effect and the real scene color
  70245. */
  70246. volumetricLightMergePostProces: Nullable<PostProcess>;
  70247. /**
  70248. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70249. */
  70250. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70251. /**
  70252. * Base post-process used to calculate the average luminance of the final image for HDR
  70253. */
  70254. luminancePostProcess: Nullable<PostProcess>;
  70255. /**
  70256. * Post-processes used to create down sample post-processes in order to get
  70257. * the average luminance of the final image for HDR
  70258. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70259. */
  70260. luminanceDownSamplePostProcesses: PostProcess[];
  70261. /**
  70262. * Post-process used to create a HDR effect (light adaptation)
  70263. */
  70264. hdrPostProcess: Nullable<PostProcess>;
  70265. /**
  70266. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70267. */
  70268. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70269. /**
  70270. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70271. */
  70272. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70273. /**
  70274. * Post-process used to merge the final HDR post-process and the real scene color
  70275. */
  70276. hdrFinalPostProcess: Nullable<PostProcess>;
  70277. /**
  70278. * Post-process used to create a lens flare effect
  70279. */
  70280. lensFlarePostProcess: Nullable<PostProcess>;
  70281. /**
  70282. * Post-process that merges the result of the lens flare post-process and the real scene color
  70283. */
  70284. lensFlareComposePostProcess: Nullable<PostProcess>;
  70285. /**
  70286. * Post-process used to create a motion blur effect
  70287. */
  70288. motionBlurPostProcess: Nullable<PostProcess>;
  70289. /**
  70290. * Post-process used to create a depth of field effect
  70291. */
  70292. depthOfFieldPostProcess: Nullable<PostProcess>;
  70293. /**
  70294. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70295. */
  70296. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70297. /**
  70298. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70299. */
  70300. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70301. /**
  70302. * Represents the brightness threshold in order to configure the illuminated surfaces
  70303. */
  70304. brightThreshold: number;
  70305. /**
  70306. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70307. */
  70308. blurWidth: number;
  70309. /**
  70310. * Sets if the blur for highlighted surfaces must be only horizontal
  70311. */
  70312. horizontalBlur: boolean;
  70313. /**
  70314. * Gets the overall exposure used by the pipeline
  70315. */
  70316. get exposure(): number;
  70317. /**
  70318. * Sets the overall exposure used by the pipeline
  70319. */
  70320. set exposure(value: number);
  70321. /**
  70322. * Texture used typically to simulate "dirty" on camera lens
  70323. */
  70324. lensTexture: Nullable<Texture>;
  70325. /**
  70326. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70327. */
  70328. volumetricLightCoefficient: number;
  70329. /**
  70330. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70331. */
  70332. volumetricLightPower: number;
  70333. /**
  70334. * Used the set the blur intensity to smooth the volumetric lights
  70335. */
  70336. volumetricLightBlurScale: number;
  70337. /**
  70338. * Light (spot or directional) used to generate the volumetric lights rays
  70339. * The source light must have a shadow generate so the pipeline can get its
  70340. * depth map
  70341. */
  70342. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70343. /**
  70344. * For eye adaptation, represents the minimum luminance the eye can see
  70345. */
  70346. hdrMinimumLuminance: number;
  70347. /**
  70348. * For eye adaptation, represents the decrease luminance speed
  70349. */
  70350. hdrDecreaseRate: number;
  70351. /**
  70352. * For eye adaptation, represents the increase luminance speed
  70353. */
  70354. hdrIncreaseRate: number;
  70355. /**
  70356. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70357. */
  70358. get hdrAutoExposure(): boolean;
  70359. /**
  70360. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70361. */
  70362. set hdrAutoExposure(value: boolean);
  70363. /**
  70364. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70365. */
  70366. lensColorTexture: Nullable<Texture>;
  70367. /**
  70368. * The overall strengh for the lens flare effect
  70369. */
  70370. lensFlareStrength: number;
  70371. /**
  70372. * Dispersion coefficient for lens flare ghosts
  70373. */
  70374. lensFlareGhostDispersal: number;
  70375. /**
  70376. * Main lens flare halo width
  70377. */
  70378. lensFlareHaloWidth: number;
  70379. /**
  70380. * Based on the lens distortion effect, defines how much the lens flare result
  70381. * is distorted
  70382. */
  70383. lensFlareDistortionStrength: number;
  70384. /**
  70385. * Configures the blur intensity used for for lens flare (halo)
  70386. */
  70387. lensFlareBlurWidth: number;
  70388. /**
  70389. * Lens star texture must be used to simulate rays on the flares and is available
  70390. * in the documentation
  70391. */
  70392. lensStarTexture: Nullable<Texture>;
  70393. /**
  70394. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70395. * flare effect by taking account of the dirt texture
  70396. */
  70397. lensFlareDirtTexture: Nullable<Texture>;
  70398. /**
  70399. * Represents the focal length for the depth of field effect
  70400. */
  70401. depthOfFieldDistance: number;
  70402. /**
  70403. * Represents the blur intensity for the blurred part of the depth of field effect
  70404. */
  70405. depthOfFieldBlurWidth: number;
  70406. /**
  70407. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70408. */
  70409. get motionStrength(): number;
  70410. /**
  70411. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70412. */
  70413. set motionStrength(strength: number);
  70414. /**
  70415. * Gets wether or not the motion blur post-process is object based or screen based.
  70416. */
  70417. get objectBasedMotionBlur(): boolean;
  70418. /**
  70419. * Sets wether or not the motion blur post-process should be object based or screen based
  70420. */
  70421. set objectBasedMotionBlur(value: boolean);
  70422. /**
  70423. * List of animations for the pipeline (IAnimatable implementation)
  70424. */
  70425. animations: Animation[];
  70426. /**
  70427. * Private members
  70428. */
  70429. private _scene;
  70430. private _currentDepthOfFieldSource;
  70431. private _basePostProcess;
  70432. private _fixedExposure;
  70433. private _currentExposure;
  70434. private _hdrAutoExposure;
  70435. private _hdrCurrentLuminance;
  70436. private _motionStrength;
  70437. private _isObjectBasedMotionBlur;
  70438. private _floatTextureType;
  70439. private _camerasToBeAttached;
  70440. private _ratio;
  70441. private _bloomEnabled;
  70442. private _depthOfFieldEnabled;
  70443. private _vlsEnabled;
  70444. private _lensFlareEnabled;
  70445. private _hdrEnabled;
  70446. private _motionBlurEnabled;
  70447. private _fxaaEnabled;
  70448. private _screenSpaceReflectionsEnabled;
  70449. private _motionBlurSamples;
  70450. private _volumetricLightStepsCount;
  70451. private _samples;
  70452. /**
  70453. * @ignore
  70454. * Specifies if the bloom pipeline is enabled
  70455. */
  70456. get BloomEnabled(): boolean;
  70457. set BloomEnabled(enabled: boolean);
  70458. /**
  70459. * @ignore
  70460. * Specifies if the depth of field pipeline is enabed
  70461. */
  70462. get DepthOfFieldEnabled(): boolean;
  70463. set DepthOfFieldEnabled(enabled: boolean);
  70464. /**
  70465. * @ignore
  70466. * Specifies if the lens flare pipeline is enabed
  70467. */
  70468. get LensFlareEnabled(): boolean;
  70469. set LensFlareEnabled(enabled: boolean);
  70470. /**
  70471. * @ignore
  70472. * Specifies if the HDR pipeline is enabled
  70473. */
  70474. get HDREnabled(): boolean;
  70475. set HDREnabled(enabled: boolean);
  70476. /**
  70477. * @ignore
  70478. * Specifies if the volumetric lights scattering effect is enabled
  70479. */
  70480. get VLSEnabled(): boolean;
  70481. set VLSEnabled(enabled: boolean);
  70482. /**
  70483. * @ignore
  70484. * Specifies if the motion blur effect is enabled
  70485. */
  70486. get MotionBlurEnabled(): boolean;
  70487. set MotionBlurEnabled(enabled: boolean);
  70488. /**
  70489. * Specifies if anti-aliasing is enabled
  70490. */
  70491. get fxaaEnabled(): boolean;
  70492. set fxaaEnabled(enabled: boolean);
  70493. /**
  70494. * Specifies if screen space reflections are enabled.
  70495. */
  70496. get screenSpaceReflectionsEnabled(): boolean;
  70497. set screenSpaceReflectionsEnabled(enabled: boolean);
  70498. /**
  70499. * Specifies the number of steps used to calculate the volumetric lights
  70500. * Typically in interval [50, 200]
  70501. */
  70502. get volumetricLightStepsCount(): number;
  70503. set volumetricLightStepsCount(count: number);
  70504. /**
  70505. * Specifies the number of samples used for the motion blur effect
  70506. * Typically in interval [16, 64]
  70507. */
  70508. get motionBlurSamples(): number;
  70509. set motionBlurSamples(samples: number);
  70510. /**
  70511. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70512. */
  70513. get samples(): number;
  70514. set samples(sampleCount: number);
  70515. /**
  70516. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70517. * @constructor
  70518. * @param name The rendering pipeline name
  70519. * @param scene The scene linked to this pipeline
  70520. * @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)
  70521. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70522. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70523. */
  70524. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70525. private _buildPipeline;
  70526. private _createDownSampleX4PostProcess;
  70527. private _createBrightPassPostProcess;
  70528. private _createBlurPostProcesses;
  70529. private _createTextureAdderPostProcess;
  70530. private _createVolumetricLightPostProcess;
  70531. private _createLuminancePostProcesses;
  70532. private _createHdrPostProcess;
  70533. private _createLensFlarePostProcess;
  70534. private _createDepthOfFieldPostProcess;
  70535. private _createMotionBlurPostProcess;
  70536. private _getDepthTexture;
  70537. private _disposePostProcesses;
  70538. /**
  70539. * Dispose of the pipeline and stop all post processes
  70540. */
  70541. dispose(): void;
  70542. /**
  70543. * Serialize the rendering pipeline (Used when exporting)
  70544. * @returns the serialized object
  70545. */
  70546. serialize(): any;
  70547. /**
  70548. * Parse the serialized pipeline
  70549. * @param source Source pipeline.
  70550. * @param scene The scene to load the pipeline to.
  70551. * @param rootUrl The URL of the serialized pipeline.
  70552. * @returns An instantiated pipeline from the serialized object.
  70553. */
  70554. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70555. /**
  70556. * Luminance steps
  70557. */
  70558. static LuminanceSteps: number;
  70559. }
  70560. }
  70561. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70562. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70563. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70564. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70565. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70566. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70567. }
  70568. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70570. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70571. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70572. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70573. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70574. }
  70575. declare module "babylonjs/Shaders/tonemap.fragment" {
  70576. /** @hidden */
  70577. export var tonemapPixelShader: {
  70578. name: string;
  70579. shader: string;
  70580. };
  70581. }
  70582. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70583. import { Camera } from "babylonjs/Cameras/camera";
  70584. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70585. import "babylonjs/Shaders/tonemap.fragment";
  70586. import { Engine } from "babylonjs/Engines/engine";
  70587. /** Defines operator used for tonemapping */
  70588. export enum TonemappingOperator {
  70589. /** Hable */
  70590. Hable = 0,
  70591. /** Reinhard */
  70592. Reinhard = 1,
  70593. /** HejiDawson */
  70594. HejiDawson = 2,
  70595. /** Photographic */
  70596. Photographic = 3
  70597. }
  70598. /**
  70599. * Defines a post process to apply tone mapping
  70600. */
  70601. export class TonemapPostProcess extends PostProcess {
  70602. private _operator;
  70603. /** Defines the required exposure adjustement */
  70604. exposureAdjustment: number;
  70605. /**
  70606. * Creates a new TonemapPostProcess
  70607. * @param name defines the name of the postprocess
  70608. * @param _operator defines the operator to use
  70609. * @param exposureAdjustment defines the required exposure adjustement
  70610. * @param camera defines the camera to use (can be null)
  70611. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70612. * @param engine defines the hosting engine (can be ignore if camera is set)
  70613. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70614. */
  70615. constructor(name: string, _operator: TonemappingOperator,
  70616. /** Defines the required exposure adjustement */
  70617. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70618. }
  70619. }
  70620. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70621. /** @hidden */
  70622. export var volumetricLightScatteringPixelShader: {
  70623. name: string;
  70624. shader: string;
  70625. };
  70626. }
  70627. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70628. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70631. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70633. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70634. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70635. /** @hidden */
  70636. export var volumetricLightScatteringPassVertexShader: {
  70637. name: string;
  70638. shader: string;
  70639. };
  70640. }
  70641. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70642. /** @hidden */
  70643. export var volumetricLightScatteringPassPixelShader: {
  70644. name: string;
  70645. shader: string;
  70646. };
  70647. }
  70648. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70649. import { Vector3 } from "babylonjs/Maths/math.vector";
  70650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70651. import { Mesh } from "babylonjs/Meshes/mesh";
  70652. import { Camera } from "babylonjs/Cameras/camera";
  70653. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70654. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70655. import { Scene } from "babylonjs/scene";
  70656. import "babylonjs/Meshes/Builders/planeBuilder";
  70657. import "babylonjs/Shaders/depth.vertex";
  70658. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70659. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70660. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70661. import { Engine } from "babylonjs/Engines/engine";
  70662. /**
  70663. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70664. */
  70665. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70666. private _volumetricLightScatteringPass;
  70667. private _volumetricLightScatteringRTT;
  70668. private _viewPort;
  70669. private _screenCoordinates;
  70670. private _cachedDefines;
  70671. /**
  70672. * If not undefined, the mesh position is computed from the attached node position
  70673. */
  70674. attachedNode: {
  70675. position: Vector3;
  70676. };
  70677. /**
  70678. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70679. */
  70680. customMeshPosition: Vector3;
  70681. /**
  70682. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70683. */
  70684. useCustomMeshPosition: boolean;
  70685. /**
  70686. * If the post-process should inverse the light scattering direction
  70687. */
  70688. invert: boolean;
  70689. /**
  70690. * The internal mesh used by the post-process
  70691. */
  70692. mesh: Mesh;
  70693. /**
  70694. * @hidden
  70695. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70696. */
  70697. get useDiffuseColor(): boolean;
  70698. set useDiffuseColor(useDiffuseColor: boolean);
  70699. /**
  70700. * Array containing the excluded meshes not rendered in the internal pass
  70701. */
  70702. excludedMeshes: AbstractMesh[];
  70703. /**
  70704. * Controls the overall intensity of the post-process
  70705. */
  70706. exposure: number;
  70707. /**
  70708. * Dissipates each sample's contribution in range [0, 1]
  70709. */
  70710. decay: number;
  70711. /**
  70712. * Controls the overall intensity of each sample
  70713. */
  70714. weight: number;
  70715. /**
  70716. * Controls the density of each sample
  70717. */
  70718. density: number;
  70719. /**
  70720. * @constructor
  70721. * @param name The post-process name
  70722. * @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)
  70723. * @param camera The camera that the post-process will be attached to
  70724. * @param mesh The mesh used to create the light scattering
  70725. * @param samples The post-process quality, default 100
  70726. * @param samplingModeThe post-process filtering mode
  70727. * @param engine The babylon engine
  70728. * @param reusable If the post-process is reusable
  70729. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70730. */
  70731. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70732. /**
  70733. * Returns the string "VolumetricLightScatteringPostProcess"
  70734. * @returns "VolumetricLightScatteringPostProcess"
  70735. */
  70736. getClassName(): string;
  70737. private _isReady;
  70738. /**
  70739. * Sets the new light position for light scattering effect
  70740. * @param position The new custom light position
  70741. */
  70742. setCustomMeshPosition(position: Vector3): void;
  70743. /**
  70744. * Returns the light position for light scattering effect
  70745. * @return Vector3 The custom light position
  70746. */
  70747. getCustomMeshPosition(): Vector3;
  70748. /**
  70749. * Disposes the internal assets and detaches the post-process from the camera
  70750. */
  70751. dispose(camera: Camera): void;
  70752. /**
  70753. * Returns the render target texture used by the post-process
  70754. * @return the render target texture used by the post-process
  70755. */
  70756. getPass(): RenderTargetTexture;
  70757. private _meshExcluded;
  70758. private _createPass;
  70759. private _updateMeshScreenCoordinates;
  70760. /**
  70761. * Creates a default mesh for the Volumeric Light Scattering post-process
  70762. * @param name The mesh name
  70763. * @param scene The scene where to create the mesh
  70764. * @return the default mesh
  70765. */
  70766. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70767. }
  70768. }
  70769. declare module "babylonjs/PostProcesses/index" {
  70770. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70771. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70772. export * from "babylonjs/PostProcesses/bloomEffect";
  70773. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70774. export * from "babylonjs/PostProcesses/blurPostProcess";
  70775. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70776. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70777. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70778. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70779. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70780. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70781. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70782. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70783. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70784. export * from "babylonjs/PostProcesses/filterPostProcess";
  70785. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70786. export * from "babylonjs/PostProcesses/grainPostProcess";
  70787. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70788. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70789. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70790. export * from "babylonjs/PostProcesses/passPostProcess";
  70791. export * from "babylonjs/PostProcesses/postProcess";
  70792. export * from "babylonjs/PostProcesses/postProcessManager";
  70793. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70794. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70795. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70796. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70797. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70798. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70799. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70800. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70801. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70802. }
  70803. declare module "babylonjs/Probes/index" {
  70804. export * from "babylonjs/Probes/reflectionProbe";
  70805. }
  70806. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70807. import { Scene } from "babylonjs/scene";
  70808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70809. import { SmartArray } from "babylonjs/Misc/smartArray";
  70810. import { ISceneComponent } from "babylonjs/sceneComponent";
  70811. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70812. import "babylonjs/Meshes/Builders/boxBuilder";
  70813. import "babylonjs/Shaders/color.fragment";
  70814. import "babylonjs/Shaders/color.vertex";
  70815. import { Color3 } from "babylonjs/Maths/math.color";
  70816. module "babylonjs/scene" {
  70817. interface Scene {
  70818. /** @hidden (Backing field) */
  70819. _boundingBoxRenderer: BoundingBoxRenderer;
  70820. /** @hidden (Backing field) */
  70821. _forceShowBoundingBoxes: boolean;
  70822. /**
  70823. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70824. */
  70825. forceShowBoundingBoxes: boolean;
  70826. /**
  70827. * Gets the bounding box renderer associated with the scene
  70828. * @returns a BoundingBoxRenderer
  70829. */
  70830. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70831. }
  70832. }
  70833. module "babylonjs/Meshes/abstractMesh" {
  70834. interface AbstractMesh {
  70835. /** @hidden (Backing field) */
  70836. _showBoundingBox: boolean;
  70837. /**
  70838. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70839. */
  70840. showBoundingBox: boolean;
  70841. }
  70842. }
  70843. /**
  70844. * Component responsible of rendering the bounding box of the meshes in a scene.
  70845. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70846. */
  70847. export class BoundingBoxRenderer implements ISceneComponent {
  70848. /**
  70849. * The component name helpfull to identify the component in the list of scene components.
  70850. */
  70851. readonly name: string;
  70852. /**
  70853. * The scene the component belongs to.
  70854. */
  70855. scene: Scene;
  70856. /**
  70857. * Color of the bounding box lines placed in front of an object
  70858. */
  70859. frontColor: Color3;
  70860. /**
  70861. * Color of the bounding box lines placed behind an object
  70862. */
  70863. backColor: Color3;
  70864. /**
  70865. * Defines if the renderer should show the back lines or not
  70866. */
  70867. showBackLines: boolean;
  70868. /**
  70869. * @hidden
  70870. */
  70871. renderList: SmartArray<BoundingBox>;
  70872. private _colorShader;
  70873. private _vertexBuffers;
  70874. private _indexBuffer;
  70875. private _fillIndexBuffer;
  70876. private _fillIndexData;
  70877. /**
  70878. * Instantiates a new bounding box renderer in a scene.
  70879. * @param scene the scene the renderer renders in
  70880. */
  70881. constructor(scene: Scene);
  70882. /**
  70883. * Registers the component in a given scene
  70884. */
  70885. register(): void;
  70886. private _evaluateSubMesh;
  70887. private _activeMesh;
  70888. private _prepareRessources;
  70889. private _createIndexBuffer;
  70890. /**
  70891. * Rebuilds the elements related to this component in case of
  70892. * context lost for instance.
  70893. */
  70894. rebuild(): void;
  70895. /**
  70896. * @hidden
  70897. */
  70898. reset(): void;
  70899. /**
  70900. * Render the bounding boxes of a specific rendering group
  70901. * @param renderingGroupId defines the rendering group to render
  70902. */
  70903. render(renderingGroupId: number): void;
  70904. /**
  70905. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70906. * @param mesh Define the mesh to render the occlusion bounding box for
  70907. */
  70908. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70909. /**
  70910. * Dispose and release the resources attached to this renderer.
  70911. */
  70912. dispose(): void;
  70913. }
  70914. }
  70915. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70916. import { Nullable } from "babylonjs/types";
  70917. import { Scene } from "babylonjs/scene";
  70918. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70919. import { Camera } from "babylonjs/Cameras/camera";
  70920. import { ISceneComponent } from "babylonjs/sceneComponent";
  70921. module "babylonjs/scene" {
  70922. interface Scene {
  70923. /** @hidden (Backing field) */
  70924. _depthRenderer: {
  70925. [id: string]: DepthRenderer;
  70926. };
  70927. /**
  70928. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70929. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70930. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70931. * @returns the created depth renderer
  70932. */
  70933. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70934. /**
  70935. * Disables a depth renderer for a given camera
  70936. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70937. */
  70938. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70939. }
  70940. }
  70941. /**
  70942. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70943. * in several rendering techniques.
  70944. */
  70945. export class DepthRendererSceneComponent implements ISceneComponent {
  70946. /**
  70947. * The component name helpfull to identify the component in the list of scene components.
  70948. */
  70949. readonly name: string;
  70950. /**
  70951. * The scene the component belongs to.
  70952. */
  70953. scene: Scene;
  70954. /**
  70955. * Creates a new instance of the component for the given scene
  70956. * @param scene Defines the scene to register the component in
  70957. */
  70958. constructor(scene: Scene);
  70959. /**
  70960. * Registers the component in a given scene
  70961. */
  70962. register(): void;
  70963. /**
  70964. * Rebuilds the elements related to this component in case of
  70965. * context lost for instance.
  70966. */
  70967. rebuild(): void;
  70968. /**
  70969. * Disposes the component and the associated ressources
  70970. */
  70971. dispose(): void;
  70972. private _gatherRenderTargets;
  70973. private _gatherActiveCameraRenderTargets;
  70974. }
  70975. }
  70976. declare module "babylonjs/Shaders/outline.fragment" {
  70977. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70978. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70979. /** @hidden */
  70980. export var outlinePixelShader: {
  70981. name: string;
  70982. shader: string;
  70983. };
  70984. }
  70985. declare module "babylonjs/Shaders/outline.vertex" {
  70986. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70989. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70990. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70994. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70995. /** @hidden */
  70996. export var outlineVertexShader: {
  70997. name: string;
  70998. shader: string;
  70999. };
  71000. }
  71001. declare module "babylonjs/Rendering/outlineRenderer" {
  71002. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71003. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71004. import { Scene } from "babylonjs/scene";
  71005. import { ISceneComponent } from "babylonjs/sceneComponent";
  71006. import "babylonjs/Shaders/outline.fragment";
  71007. import "babylonjs/Shaders/outline.vertex";
  71008. module "babylonjs/scene" {
  71009. interface Scene {
  71010. /** @hidden */
  71011. _outlineRenderer: OutlineRenderer;
  71012. /**
  71013. * Gets the outline renderer associated with the scene
  71014. * @returns a OutlineRenderer
  71015. */
  71016. getOutlineRenderer(): OutlineRenderer;
  71017. }
  71018. }
  71019. module "babylonjs/Meshes/abstractMesh" {
  71020. interface AbstractMesh {
  71021. /** @hidden (Backing field) */
  71022. _renderOutline: boolean;
  71023. /**
  71024. * Gets or sets a boolean indicating if the outline must be rendered as well
  71025. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71026. */
  71027. renderOutline: boolean;
  71028. /** @hidden (Backing field) */
  71029. _renderOverlay: boolean;
  71030. /**
  71031. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71032. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71033. */
  71034. renderOverlay: boolean;
  71035. }
  71036. }
  71037. /**
  71038. * This class is responsible to draw bothe outline/overlay of meshes.
  71039. * It should not be used directly but through the available method on mesh.
  71040. */
  71041. export class OutlineRenderer implements ISceneComponent {
  71042. /**
  71043. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71044. */
  71045. private static _StencilReference;
  71046. /**
  71047. * The name of the component. Each component must have a unique name.
  71048. */
  71049. name: string;
  71050. /**
  71051. * The scene the component belongs to.
  71052. */
  71053. scene: Scene;
  71054. /**
  71055. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71056. */
  71057. zOffset: number;
  71058. private _engine;
  71059. private _effect;
  71060. private _cachedDefines;
  71061. private _savedDepthWrite;
  71062. /**
  71063. * Instantiates a new outline renderer. (There could be only one per scene).
  71064. * @param scene Defines the scene it belongs to
  71065. */
  71066. constructor(scene: Scene);
  71067. /**
  71068. * Register the component to one instance of a scene.
  71069. */
  71070. register(): void;
  71071. /**
  71072. * Rebuilds the elements related to this component in case of
  71073. * context lost for instance.
  71074. */
  71075. rebuild(): void;
  71076. /**
  71077. * Disposes the component and the associated ressources.
  71078. */
  71079. dispose(): void;
  71080. /**
  71081. * Renders the outline in the canvas.
  71082. * @param subMesh Defines the sumesh to render
  71083. * @param batch Defines the batch of meshes in case of instances
  71084. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71085. */
  71086. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71087. /**
  71088. * Returns whether or not the outline renderer is ready for a given submesh.
  71089. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71090. * @param subMesh Defines the submesh to check readyness for
  71091. * @param useInstances Defines wheter wee are trying to render instances or not
  71092. * @returns true if ready otherwise false
  71093. */
  71094. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71095. private _beforeRenderingMesh;
  71096. private _afterRenderingMesh;
  71097. }
  71098. }
  71099. declare module "babylonjs/Rendering/index" {
  71100. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71101. export * from "babylonjs/Rendering/depthRenderer";
  71102. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71103. export * from "babylonjs/Rendering/edgesRenderer";
  71104. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71105. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71106. export * from "babylonjs/Rendering/outlineRenderer";
  71107. export * from "babylonjs/Rendering/renderingGroup";
  71108. export * from "babylonjs/Rendering/renderingManager";
  71109. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71110. }
  71111. declare module "babylonjs/Sprites/ISprites" {
  71112. /**
  71113. * Defines the basic options interface of a Sprite Frame Source Size.
  71114. */
  71115. export interface ISpriteJSONSpriteSourceSize {
  71116. /**
  71117. * number of the original width of the Frame
  71118. */
  71119. w: number;
  71120. /**
  71121. * number of the original height of the Frame
  71122. */
  71123. h: number;
  71124. }
  71125. /**
  71126. * Defines the basic options interface of a Sprite Frame Data.
  71127. */
  71128. export interface ISpriteJSONSpriteFrameData {
  71129. /**
  71130. * number of the x offset of the Frame
  71131. */
  71132. x: number;
  71133. /**
  71134. * number of the y offset of the Frame
  71135. */
  71136. y: number;
  71137. /**
  71138. * number of the width of the Frame
  71139. */
  71140. w: number;
  71141. /**
  71142. * number of the height of the Frame
  71143. */
  71144. h: number;
  71145. }
  71146. /**
  71147. * Defines the basic options interface of a JSON Sprite.
  71148. */
  71149. export interface ISpriteJSONSprite {
  71150. /**
  71151. * string name of the Frame
  71152. */
  71153. filename: string;
  71154. /**
  71155. * ISpriteJSONSpriteFrame basic object of the frame data
  71156. */
  71157. frame: ISpriteJSONSpriteFrameData;
  71158. /**
  71159. * boolean to flag is the frame was rotated.
  71160. */
  71161. rotated: boolean;
  71162. /**
  71163. * boolean to flag is the frame was trimmed.
  71164. */
  71165. trimmed: boolean;
  71166. /**
  71167. * ISpriteJSONSpriteFrame basic object of the source data
  71168. */
  71169. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71170. /**
  71171. * ISpriteJSONSpriteFrame basic object of the source data
  71172. */
  71173. sourceSize: ISpriteJSONSpriteSourceSize;
  71174. }
  71175. /**
  71176. * Defines the basic options interface of a JSON atlas.
  71177. */
  71178. export interface ISpriteJSONAtlas {
  71179. /**
  71180. * Array of objects that contain the frame data.
  71181. */
  71182. frames: Array<ISpriteJSONSprite>;
  71183. /**
  71184. * object basic object containing the sprite meta data.
  71185. */
  71186. meta?: object;
  71187. }
  71188. }
  71189. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71190. /** @hidden */
  71191. export var spriteMapPixelShader: {
  71192. name: string;
  71193. shader: string;
  71194. };
  71195. }
  71196. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71197. /** @hidden */
  71198. export var spriteMapVertexShader: {
  71199. name: string;
  71200. shader: string;
  71201. };
  71202. }
  71203. declare module "babylonjs/Sprites/spriteMap" {
  71204. import { IDisposable, Scene } from "babylonjs/scene";
  71205. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71206. import { Texture } from "babylonjs/Materials/Textures/texture";
  71207. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71208. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71209. import "babylonjs/Meshes/Builders/planeBuilder";
  71210. import "babylonjs/Shaders/spriteMap.fragment";
  71211. import "babylonjs/Shaders/spriteMap.vertex";
  71212. /**
  71213. * Defines the basic options interface of a SpriteMap
  71214. */
  71215. export interface ISpriteMapOptions {
  71216. /**
  71217. * Vector2 of the number of cells in the grid.
  71218. */
  71219. stageSize?: Vector2;
  71220. /**
  71221. * Vector2 of the size of the output plane in World Units.
  71222. */
  71223. outputSize?: Vector2;
  71224. /**
  71225. * Vector3 of the position of the output plane in World Units.
  71226. */
  71227. outputPosition?: Vector3;
  71228. /**
  71229. * Vector3 of the rotation of the output plane.
  71230. */
  71231. outputRotation?: Vector3;
  71232. /**
  71233. * number of layers that the system will reserve in resources.
  71234. */
  71235. layerCount?: number;
  71236. /**
  71237. * number of max animation frames a single cell will reserve in resources.
  71238. */
  71239. maxAnimationFrames?: number;
  71240. /**
  71241. * number cell index of the base tile when the system compiles.
  71242. */
  71243. baseTile?: number;
  71244. /**
  71245. * boolean flip the sprite after its been repositioned by the framing data.
  71246. */
  71247. flipU?: boolean;
  71248. /**
  71249. * Vector3 scalar of the global RGB values of the SpriteMap.
  71250. */
  71251. colorMultiply?: Vector3;
  71252. }
  71253. /**
  71254. * Defines the IDisposable interface in order to be cleanable from resources.
  71255. */
  71256. export interface ISpriteMap extends IDisposable {
  71257. /**
  71258. * String name of the SpriteMap.
  71259. */
  71260. name: string;
  71261. /**
  71262. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71263. */
  71264. atlasJSON: ISpriteJSONAtlas;
  71265. /**
  71266. * Texture of the SpriteMap.
  71267. */
  71268. spriteSheet: Texture;
  71269. /**
  71270. * The parameters to initialize the SpriteMap with.
  71271. */
  71272. options: ISpriteMapOptions;
  71273. }
  71274. /**
  71275. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71276. */
  71277. export class SpriteMap implements ISpriteMap {
  71278. /** The Name of the spriteMap */
  71279. name: string;
  71280. /** The JSON file with the frame and meta data */
  71281. atlasJSON: ISpriteJSONAtlas;
  71282. /** The systems Sprite Sheet Texture */
  71283. spriteSheet: Texture;
  71284. /** Arguments passed with the Constructor */
  71285. options: ISpriteMapOptions;
  71286. /** Public Sprite Storage array, parsed from atlasJSON */
  71287. sprites: Array<ISpriteJSONSprite>;
  71288. /** Returns the Number of Sprites in the System */
  71289. get spriteCount(): number;
  71290. /** Returns the Position of Output Plane*/
  71291. get position(): Vector3;
  71292. /** Returns the Position of Output Plane*/
  71293. set position(v: Vector3);
  71294. /** Returns the Rotation of Output Plane*/
  71295. get rotation(): Vector3;
  71296. /** Returns the Rotation of Output Plane*/
  71297. set rotation(v: Vector3);
  71298. /** Sets the AnimationMap*/
  71299. get animationMap(): RawTexture;
  71300. /** Sets the AnimationMap*/
  71301. set animationMap(v: RawTexture);
  71302. /** Scene that the SpriteMap was created in */
  71303. private _scene;
  71304. /** Texture Buffer of Float32 that holds tile frame data*/
  71305. private _frameMap;
  71306. /** Texture Buffers of Float32 that holds tileMap data*/
  71307. private _tileMaps;
  71308. /** Texture Buffer of Float32 that holds Animation Data*/
  71309. private _animationMap;
  71310. /** Custom ShaderMaterial Central to the System*/
  71311. private _material;
  71312. /** Custom ShaderMaterial Central to the System*/
  71313. private _output;
  71314. /** Systems Time Ticker*/
  71315. private _time;
  71316. /**
  71317. * Creates a new SpriteMap
  71318. * @param name defines the SpriteMaps Name
  71319. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71320. * @param spriteSheet is the Texture that the Sprites are on.
  71321. * @param options a basic deployment configuration
  71322. * @param scene The Scene that the map is deployed on
  71323. */
  71324. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71325. /**
  71326. * Returns tileID location
  71327. * @returns Vector2 the cell position ID
  71328. */
  71329. getTileID(): Vector2;
  71330. /**
  71331. * Gets the UV location of the mouse over the SpriteMap.
  71332. * @returns Vector2 the UV position of the mouse interaction
  71333. */
  71334. getMousePosition(): Vector2;
  71335. /**
  71336. * Creates the "frame" texture Buffer
  71337. * -------------------------------------
  71338. * Structure of frames
  71339. * "filename": "Falling-Water-2.png",
  71340. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71341. * "rotated": true,
  71342. * "trimmed": true,
  71343. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71344. * "sourceSize": {"w":32,"h":32}
  71345. * @returns RawTexture of the frameMap
  71346. */
  71347. private _createFrameBuffer;
  71348. /**
  71349. * Creates the tileMap texture Buffer
  71350. * @param buffer normally and array of numbers, or a false to generate from scratch
  71351. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71352. * @returns RawTexture of the tileMap
  71353. */
  71354. private _createTileBuffer;
  71355. /**
  71356. * Modifies the data of the tileMaps
  71357. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71358. * @param pos is the iVector2 Coordinates of the Tile
  71359. * @param tile The SpriteIndex of the new Tile
  71360. */
  71361. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71362. /**
  71363. * Creates the animationMap texture Buffer
  71364. * @param buffer normally and array of numbers, or a false to generate from scratch
  71365. * @returns RawTexture of the animationMap
  71366. */
  71367. private _createTileAnimationBuffer;
  71368. /**
  71369. * Modifies the data of the animationMap
  71370. * @param cellID is the Index of the Sprite
  71371. * @param _frame is the target Animation frame
  71372. * @param toCell is the Target Index of the next frame of the animation
  71373. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71374. * @param speed is a global scalar of the time variable on the map.
  71375. */
  71376. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71377. /**
  71378. * Exports the .tilemaps file
  71379. */
  71380. saveTileMaps(): void;
  71381. /**
  71382. * Imports the .tilemaps file
  71383. * @param url of the .tilemaps file
  71384. */
  71385. loadTileMaps(url: string): void;
  71386. /**
  71387. * Release associated resources
  71388. */
  71389. dispose(): void;
  71390. }
  71391. }
  71392. declare module "babylonjs/Sprites/spritePackedManager" {
  71393. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71394. import { Scene } from "babylonjs/scene";
  71395. /**
  71396. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71397. * @see http://doc.babylonjs.com/babylon101/sprites
  71398. */
  71399. export class SpritePackedManager extends SpriteManager {
  71400. /** defines the packed manager's name */
  71401. name: string;
  71402. /**
  71403. * Creates a new sprite manager from a packed sprite sheet
  71404. * @param name defines the manager's name
  71405. * @param imgUrl defines the sprite sheet url
  71406. * @param capacity defines the maximum allowed number of sprites
  71407. * @param scene defines the hosting scene
  71408. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71409. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71410. * @param samplingMode defines the smapling mode to use with spritesheet
  71411. * @param fromPacked set to true; do not alter
  71412. */
  71413. constructor(
  71414. /** defines the packed manager's name */
  71415. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71416. }
  71417. }
  71418. declare module "babylonjs/Sprites/index" {
  71419. export * from "babylonjs/Sprites/sprite";
  71420. export * from "babylonjs/Sprites/ISprites";
  71421. export * from "babylonjs/Sprites/spriteManager";
  71422. export * from "babylonjs/Sprites/spriteMap";
  71423. export * from "babylonjs/Sprites/spritePackedManager";
  71424. export * from "babylonjs/Sprites/spriteSceneComponent";
  71425. }
  71426. declare module "babylonjs/States/index" {
  71427. export * from "babylonjs/States/alphaCullingState";
  71428. export * from "babylonjs/States/depthCullingState";
  71429. export * from "babylonjs/States/stencilState";
  71430. }
  71431. declare module "babylonjs/Misc/assetsManager" {
  71432. import { Scene } from "babylonjs/scene";
  71433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71434. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71435. import { Skeleton } from "babylonjs/Bones/skeleton";
  71436. import { Observable } from "babylonjs/Misc/observable";
  71437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71438. import { Texture } from "babylonjs/Materials/Textures/texture";
  71439. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71440. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71441. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71442. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71443. /**
  71444. * Defines the list of states available for a task inside a AssetsManager
  71445. */
  71446. export enum AssetTaskState {
  71447. /**
  71448. * Initialization
  71449. */
  71450. INIT = 0,
  71451. /**
  71452. * Running
  71453. */
  71454. RUNNING = 1,
  71455. /**
  71456. * Done
  71457. */
  71458. DONE = 2,
  71459. /**
  71460. * Error
  71461. */
  71462. ERROR = 3
  71463. }
  71464. /**
  71465. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71466. */
  71467. export abstract class AbstractAssetTask {
  71468. /**
  71469. * Task name
  71470. */ name: string;
  71471. /**
  71472. * Callback called when the task is successful
  71473. */
  71474. onSuccess: (task: any) => void;
  71475. /**
  71476. * Callback called when the task is not successful
  71477. */
  71478. onError: (task: any, message?: string, exception?: any) => void;
  71479. /**
  71480. * Creates a new AssetsManager
  71481. * @param name defines the name of the task
  71482. */
  71483. constructor(
  71484. /**
  71485. * Task name
  71486. */ name: string);
  71487. private _isCompleted;
  71488. private _taskState;
  71489. private _errorObject;
  71490. /**
  71491. * Get if the task is completed
  71492. */
  71493. get isCompleted(): boolean;
  71494. /**
  71495. * Gets the current state of the task
  71496. */
  71497. get taskState(): AssetTaskState;
  71498. /**
  71499. * Gets the current error object (if task is in error)
  71500. */
  71501. get errorObject(): {
  71502. message?: string;
  71503. exception?: any;
  71504. };
  71505. /**
  71506. * Internal only
  71507. * @hidden
  71508. */
  71509. _setErrorObject(message?: string, exception?: any): void;
  71510. /**
  71511. * Execute the current task
  71512. * @param scene defines the scene where you want your assets to be loaded
  71513. * @param onSuccess is a callback called when the task is successfully executed
  71514. * @param onError is a callback called if an error occurs
  71515. */
  71516. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71517. /**
  71518. * Execute the current task
  71519. * @param scene defines the scene where you want your assets to be loaded
  71520. * @param onSuccess is a callback called when the task is successfully executed
  71521. * @param onError is a callback called if an error occurs
  71522. */
  71523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71524. /**
  71525. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71526. * This can be used with failed tasks that have the reason for failure fixed.
  71527. */
  71528. reset(): void;
  71529. private onErrorCallback;
  71530. private onDoneCallback;
  71531. }
  71532. /**
  71533. * Define the interface used by progress events raised during assets loading
  71534. */
  71535. export interface IAssetsProgressEvent {
  71536. /**
  71537. * Defines the number of remaining tasks to process
  71538. */
  71539. remainingCount: number;
  71540. /**
  71541. * Defines the total number of tasks
  71542. */
  71543. totalCount: number;
  71544. /**
  71545. * Defines the task that was just processed
  71546. */
  71547. task: AbstractAssetTask;
  71548. }
  71549. /**
  71550. * Class used to share progress information about assets loading
  71551. */
  71552. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71553. /**
  71554. * Defines the number of remaining tasks to process
  71555. */
  71556. remainingCount: number;
  71557. /**
  71558. * Defines the total number of tasks
  71559. */
  71560. totalCount: number;
  71561. /**
  71562. * Defines the task that was just processed
  71563. */
  71564. task: AbstractAssetTask;
  71565. /**
  71566. * Creates a AssetsProgressEvent
  71567. * @param remainingCount defines the number of remaining tasks to process
  71568. * @param totalCount defines the total number of tasks
  71569. * @param task defines the task that was just processed
  71570. */
  71571. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71572. }
  71573. /**
  71574. * Define a task used by AssetsManager to load meshes
  71575. */
  71576. export class MeshAssetTask extends AbstractAssetTask {
  71577. /**
  71578. * Defines the name of the task
  71579. */
  71580. name: string;
  71581. /**
  71582. * Defines the list of mesh's names you want to load
  71583. */
  71584. meshesNames: any;
  71585. /**
  71586. * Defines the root url to use as a base to load your meshes and associated resources
  71587. */
  71588. rootUrl: string;
  71589. /**
  71590. * Defines the filename of the scene to load from
  71591. */
  71592. sceneFilename: string;
  71593. /**
  71594. * Gets the list of loaded meshes
  71595. */
  71596. loadedMeshes: Array<AbstractMesh>;
  71597. /**
  71598. * Gets the list of loaded particle systems
  71599. */
  71600. loadedParticleSystems: Array<IParticleSystem>;
  71601. /**
  71602. * Gets the list of loaded skeletons
  71603. */
  71604. loadedSkeletons: Array<Skeleton>;
  71605. /**
  71606. * Gets the list of loaded animation groups
  71607. */
  71608. loadedAnimationGroups: Array<AnimationGroup>;
  71609. /**
  71610. * Callback called when the task is successful
  71611. */
  71612. onSuccess: (task: MeshAssetTask) => void;
  71613. /**
  71614. * Callback called when the task is successful
  71615. */
  71616. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71617. /**
  71618. * Creates a new MeshAssetTask
  71619. * @param name defines the name of the task
  71620. * @param meshesNames defines the list of mesh's names you want to load
  71621. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71622. * @param sceneFilename defines the filename of the scene to load from
  71623. */
  71624. constructor(
  71625. /**
  71626. * Defines the name of the task
  71627. */
  71628. name: string,
  71629. /**
  71630. * Defines the list of mesh's names you want to load
  71631. */
  71632. meshesNames: any,
  71633. /**
  71634. * Defines the root url to use as a base to load your meshes and associated resources
  71635. */
  71636. rootUrl: string,
  71637. /**
  71638. * Defines the filename of the scene to load from
  71639. */
  71640. sceneFilename: string);
  71641. /**
  71642. * Execute the current task
  71643. * @param scene defines the scene where you want your assets to be loaded
  71644. * @param onSuccess is a callback called when the task is successfully executed
  71645. * @param onError is a callback called if an error occurs
  71646. */
  71647. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71648. }
  71649. /**
  71650. * Define a task used by AssetsManager to load text content
  71651. */
  71652. export class TextFileAssetTask extends AbstractAssetTask {
  71653. /**
  71654. * Defines the name of the task
  71655. */
  71656. name: string;
  71657. /**
  71658. * Defines the location of the file to load
  71659. */
  71660. url: string;
  71661. /**
  71662. * Gets the loaded text string
  71663. */
  71664. text: string;
  71665. /**
  71666. * Callback called when the task is successful
  71667. */
  71668. onSuccess: (task: TextFileAssetTask) => void;
  71669. /**
  71670. * Callback called when the task is successful
  71671. */
  71672. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71673. /**
  71674. * Creates a new TextFileAssetTask object
  71675. * @param name defines the name of the task
  71676. * @param url defines the location of the file to load
  71677. */
  71678. constructor(
  71679. /**
  71680. * Defines the name of the task
  71681. */
  71682. name: string,
  71683. /**
  71684. * Defines the location of the file to load
  71685. */
  71686. url: string);
  71687. /**
  71688. * Execute the current task
  71689. * @param scene defines the scene where you want your assets to be loaded
  71690. * @param onSuccess is a callback called when the task is successfully executed
  71691. * @param onError is a callback called if an error occurs
  71692. */
  71693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71694. }
  71695. /**
  71696. * Define a task used by AssetsManager to load binary data
  71697. */
  71698. export class BinaryFileAssetTask extends AbstractAssetTask {
  71699. /**
  71700. * Defines the name of the task
  71701. */
  71702. name: string;
  71703. /**
  71704. * Defines the location of the file to load
  71705. */
  71706. url: string;
  71707. /**
  71708. * Gets the lodaded data (as an array buffer)
  71709. */
  71710. data: ArrayBuffer;
  71711. /**
  71712. * Callback called when the task is successful
  71713. */
  71714. onSuccess: (task: BinaryFileAssetTask) => void;
  71715. /**
  71716. * Callback called when the task is successful
  71717. */
  71718. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71719. /**
  71720. * Creates a new BinaryFileAssetTask object
  71721. * @param name defines the name of the new task
  71722. * @param url defines the location of the file to load
  71723. */
  71724. constructor(
  71725. /**
  71726. * Defines the name of the task
  71727. */
  71728. name: string,
  71729. /**
  71730. * Defines the location of the file to load
  71731. */
  71732. url: string);
  71733. /**
  71734. * Execute the current task
  71735. * @param scene defines the scene where you want your assets to be loaded
  71736. * @param onSuccess is a callback called when the task is successfully executed
  71737. * @param onError is a callback called if an error occurs
  71738. */
  71739. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71740. }
  71741. /**
  71742. * Define a task used by AssetsManager to load images
  71743. */
  71744. export class ImageAssetTask extends AbstractAssetTask {
  71745. /**
  71746. * Defines the name of the task
  71747. */
  71748. name: string;
  71749. /**
  71750. * Defines the location of the image to load
  71751. */
  71752. url: string;
  71753. /**
  71754. * Gets the loaded images
  71755. */
  71756. image: HTMLImageElement;
  71757. /**
  71758. * Callback called when the task is successful
  71759. */
  71760. onSuccess: (task: ImageAssetTask) => void;
  71761. /**
  71762. * Callback called when the task is successful
  71763. */
  71764. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71765. /**
  71766. * Creates a new ImageAssetTask
  71767. * @param name defines the name of the task
  71768. * @param url defines the location of the image to load
  71769. */
  71770. constructor(
  71771. /**
  71772. * Defines the name of the task
  71773. */
  71774. name: string,
  71775. /**
  71776. * Defines the location of the image to load
  71777. */
  71778. url: string);
  71779. /**
  71780. * Execute the current task
  71781. * @param scene defines the scene where you want your assets to be loaded
  71782. * @param onSuccess is a callback called when the task is successfully executed
  71783. * @param onError is a callback called if an error occurs
  71784. */
  71785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71786. }
  71787. /**
  71788. * Defines the interface used by texture loading tasks
  71789. */
  71790. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71791. /**
  71792. * Gets the loaded texture
  71793. */
  71794. texture: TEX;
  71795. }
  71796. /**
  71797. * Define a task used by AssetsManager to load 2D textures
  71798. */
  71799. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71800. /**
  71801. * Defines the name of the task
  71802. */
  71803. name: string;
  71804. /**
  71805. * Defines the location of the file to load
  71806. */
  71807. url: string;
  71808. /**
  71809. * Defines if mipmap should not be generated (default is false)
  71810. */
  71811. noMipmap?: boolean | undefined;
  71812. /**
  71813. * Defines if texture must be inverted on Y axis (default is true)
  71814. */
  71815. invertY: boolean;
  71816. /**
  71817. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71818. */
  71819. samplingMode: number;
  71820. /**
  71821. * Gets the loaded texture
  71822. */
  71823. texture: Texture;
  71824. /**
  71825. * Callback called when the task is successful
  71826. */
  71827. onSuccess: (task: TextureAssetTask) => void;
  71828. /**
  71829. * Callback called when the task is successful
  71830. */
  71831. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71832. /**
  71833. * Creates a new TextureAssetTask object
  71834. * @param name defines the name of the task
  71835. * @param url defines the location of the file to load
  71836. * @param noMipmap defines if mipmap should not be generated (default is false)
  71837. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71838. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71839. */
  71840. constructor(
  71841. /**
  71842. * Defines the name of the task
  71843. */
  71844. name: string,
  71845. /**
  71846. * Defines the location of the file to load
  71847. */
  71848. url: string,
  71849. /**
  71850. * Defines if mipmap should not be generated (default is false)
  71851. */
  71852. noMipmap?: boolean | undefined,
  71853. /**
  71854. * Defines if texture must be inverted on Y axis (default is true)
  71855. */
  71856. invertY?: boolean,
  71857. /**
  71858. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71859. */
  71860. samplingMode?: number);
  71861. /**
  71862. * Execute the current task
  71863. * @param scene defines the scene where you want your assets to be loaded
  71864. * @param onSuccess is a callback called when the task is successfully executed
  71865. * @param onError is a callback called if an error occurs
  71866. */
  71867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71868. }
  71869. /**
  71870. * Define a task used by AssetsManager to load cube textures
  71871. */
  71872. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71873. /**
  71874. * Defines the name of the task
  71875. */
  71876. name: string;
  71877. /**
  71878. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71879. */
  71880. url: string;
  71881. /**
  71882. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71883. */
  71884. extensions?: string[] | undefined;
  71885. /**
  71886. * Defines if mipmaps should not be generated (default is false)
  71887. */
  71888. noMipmap?: boolean | undefined;
  71889. /**
  71890. * Defines the explicit list of files (undefined by default)
  71891. */
  71892. files?: string[] | undefined;
  71893. /**
  71894. * Gets the loaded texture
  71895. */
  71896. texture: CubeTexture;
  71897. /**
  71898. * Callback called when the task is successful
  71899. */
  71900. onSuccess: (task: CubeTextureAssetTask) => void;
  71901. /**
  71902. * Callback called when the task is successful
  71903. */
  71904. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71905. /**
  71906. * Creates a new CubeTextureAssetTask
  71907. * @param name defines the name of the task
  71908. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71909. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71910. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71911. * @param files defines the explicit list of files (undefined by default)
  71912. */
  71913. constructor(
  71914. /**
  71915. * Defines the name of the task
  71916. */
  71917. name: string,
  71918. /**
  71919. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71920. */
  71921. url: string,
  71922. /**
  71923. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71924. */
  71925. extensions?: string[] | undefined,
  71926. /**
  71927. * Defines if mipmaps should not be generated (default is false)
  71928. */
  71929. noMipmap?: boolean | undefined,
  71930. /**
  71931. * Defines the explicit list of files (undefined by default)
  71932. */
  71933. files?: string[] | undefined);
  71934. /**
  71935. * Execute the current task
  71936. * @param scene defines the scene where you want your assets to be loaded
  71937. * @param onSuccess is a callback called when the task is successfully executed
  71938. * @param onError is a callback called if an error occurs
  71939. */
  71940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71941. }
  71942. /**
  71943. * Define a task used by AssetsManager to load HDR cube textures
  71944. */
  71945. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71946. /**
  71947. * Defines the name of the task
  71948. */
  71949. name: string;
  71950. /**
  71951. * Defines the location of the file to load
  71952. */
  71953. url: string;
  71954. /**
  71955. * Defines the desired size (the more it increases the longer the generation will be)
  71956. */
  71957. size: number;
  71958. /**
  71959. * Defines if mipmaps should not be generated (default is false)
  71960. */
  71961. noMipmap: boolean;
  71962. /**
  71963. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71964. */
  71965. generateHarmonics: boolean;
  71966. /**
  71967. * 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)
  71968. */
  71969. gammaSpace: boolean;
  71970. /**
  71971. * Internal Use Only
  71972. */
  71973. reserved: boolean;
  71974. /**
  71975. * Gets the loaded texture
  71976. */
  71977. texture: HDRCubeTexture;
  71978. /**
  71979. * Callback called when the task is successful
  71980. */
  71981. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71982. /**
  71983. * Callback called when the task is successful
  71984. */
  71985. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71986. /**
  71987. * Creates a new HDRCubeTextureAssetTask object
  71988. * @param name defines the name of the task
  71989. * @param url defines the location of the file to load
  71990. * @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.
  71991. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71992. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71993. * @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)
  71994. * @param reserved Internal use only
  71995. */
  71996. constructor(
  71997. /**
  71998. * Defines the name of the task
  71999. */
  72000. name: string,
  72001. /**
  72002. * Defines the location of the file to load
  72003. */
  72004. url: string,
  72005. /**
  72006. * Defines the desired size (the more it increases the longer the generation will be)
  72007. */
  72008. size: number,
  72009. /**
  72010. * Defines if mipmaps should not be generated (default is false)
  72011. */
  72012. noMipmap?: boolean,
  72013. /**
  72014. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72015. */
  72016. generateHarmonics?: boolean,
  72017. /**
  72018. * 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)
  72019. */
  72020. gammaSpace?: boolean,
  72021. /**
  72022. * Internal Use Only
  72023. */
  72024. reserved?: boolean);
  72025. /**
  72026. * Execute the current task
  72027. * @param scene defines the scene where you want your assets to be loaded
  72028. * @param onSuccess is a callback called when the task is successfully executed
  72029. * @param onError is a callback called if an error occurs
  72030. */
  72031. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72032. }
  72033. /**
  72034. * Define a task used by AssetsManager to load Equirectangular cube textures
  72035. */
  72036. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72037. /**
  72038. * Defines the name of the task
  72039. */
  72040. name: string;
  72041. /**
  72042. * Defines the location of the file to load
  72043. */
  72044. url: string;
  72045. /**
  72046. * Defines the desired size (the more it increases the longer the generation will be)
  72047. */
  72048. size: number;
  72049. /**
  72050. * Defines if mipmaps should not be generated (default is false)
  72051. */
  72052. noMipmap: boolean;
  72053. /**
  72054. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72055. * but the standard material would require them in Gamma space) (default is true)
  72056. */
  72057. gammaSpace: boolean;
  72058. /**
  72059. * Gets the loaded texture
  72060. */
  72061. texture: EquiRectangularCubeTexture;
  72062. /**
  72063. * Callback called when the task is successful
  72064. */
  72065. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72066. /**
  72067. * Callback called when the task is successful
  72068. */
  72069. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72070. /**
  72071. * Creates a new EquiRectangularCubeTextureAssetTask object
  72072. * @param name defines the name of the task
  72073. * @param url defines the location of the file to load
  72074. * @param size defines the desired size (the more it increases the longer the generation will be)
  72075. * If the size is omitted this implies you are using a preprocessed cubemap.
  72076. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72077. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72078. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72079. * (default is true)
  72080. */
  72081. constructor(
  72082. /**
  72083. * Defines the name of the task
  72084. */
  72085. name: string,
  72086. /**
  72087. * Defines the location of the file to load
  72088. */
  72089. url: string,
  72090. /**
  72091. * Defines the desired size (the more it increases the longer the generation will be)
  72092. */
  72093. size: number,
  72094. /**
  72095. * Defines if mipmaps should not be generated (default is false)
  72096. */
  72097. noMipmap?: boolean,
  72098. /**
  72099. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72100. * but the standard material would require them in Gamma space) (default is true)
  72101. */
  72102. gammaSpace?: boolean);
  72103. /**
  72104. * Execute the current task
  72105. * @param scene defines the scene where you want your assets to be loaded
  72106. * @param onSuccess is a callback called when the task is successfully executed
  72107. * @param onError is a callback called if an error occurs
  72108. */
  72109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72110. }
  72111. /**
  72112. * This class can be used to easily import assets into a scene
  72113. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72114. */
  72115. export class AssetsManager {
  72116. private _scene;
  72117. private _isLoading;
  72118. protected _tasks: AbstractAssetTask[];
  72119. protected _waitingTasksCount: number;
  72120. protected _totalTasksCount: number;
  72121. /**
  72122. * Callback called when all tasks are processed
  72123. */
  72124. onFinish: (tasks: AbstractAssetTask[]) => void;
  72125. /**
  72126. * Callback called when a task is successful
  72127. */
  72128. onTaskSuccess: (task: AbstractAssetTask) => void;
  72129. /**
  72130. * Callback called when a task had an error
  72131. */
  72132. onTaskError: (task: AbstractAssetTask) => void;
  72133. /**
  72134. * Callback called when a task is done (whatever the result is)
  72135. */
  72136. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72137. /**
  72138. * Observable called when all tasks are processed
  72139. */
  72140. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72141. /**
  72142. * Observable called when a task had an error
  72143. */
  72144. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72145. /**
  72146. * Observable called when all tasks were executed
  72147. */
  72148. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72149. /**
  72150. * Observable called when a task is done (whatever the result is)
  72151. */
  72152. onProgressObservable: Observable<IAssetsProgressEvent>;
  72153. /**
  72154. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72156. */
  72157. useDefaultLoadingScreen: boolean;
  72158. /**
  72159. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72160. * when all assets have been downloaded.
  72161. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72162. */
  72163. autoHideLoadingUI: boolean;
  72164. /**
  72165. * Creates a new AssetsManager
  72166. * @param scene defines the scene to work on
  72167. */
  72168. constructor(scene: Scene);
  72169. /**
  72170. * Add a MeshAssetTask to the list of active tasks
  72171. * @param taskName defines the name of the new task
  72172. * @param meshesNames defines the name of meshes to load
  72173. * @param rootUrl defines the root url to use to locate files
  72174. * @param sceneFilename defines the filename of the scene file
  72175. * @returns a new MeshAssetTask object
  72176. */
  72177. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72178. /**
  72179. * Add a TextFileAssetTask to the list of active tasks
  72180. * @param taskName defines the name of the new task
  72181. * @param url defines the url of the file to load
  72182. * @returns a new TextFileAssetTask object
  72183. */
  72184. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72185. /**
  72186. * Add a BinaryFileAssetTask to the list of active tasks
  72187. * @param taskName defines the name of the new task
  72188. * @param url defines the url of the file to load
  72189. * @returns a new BinaryFileAssetTask object
  72190. */
  72191. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72192. /**
  72193. * Add a ImageAssetTask to the list of active tasks
  72194. * @param taskName defines the name of the new task
  72195. * @param url defines the url of the file to load
  72196. * @returns a new ImageAssetTask object
  72197. */
  72198. addImageTask(taskName: string, url: string): ImageAssetTask;
  72199. /**
  72200. * Add a TextureAssetTask to the list of active tasks
  72201. * @param taskName defines the name of the new task
  72202. * @param url defines the url of the file to load
  72203. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72204. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72205. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72206. * @returns a new TextureAssetTask object
  72207. */
  72208. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72209. /**
  72210. * Add a CubeTextureAssetTask to the list of active tasks
  72211. * @param taskName defines the name of the new task
  72212. * @param url defines the url of the file to load
  72213. * @param extensions defines the extension to use to load the cube map (can be null)
  72214. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72215. * @param files defines the list of files to load (can be null)
  72216. * @returns a new CubeTextureAssetTask object
  72217. */
  72218. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72219. /**
  72220. *
  72221. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72222. * @param taskName defines the name of the new task
  72223. * @param url defines the url of the file to load
  72224. * @param size defines the size you want for the cubemap (can be null)
  72225. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72226. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72227. * @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)
  72228. * @param reserved Internal use only
  72229. * @returns a new HDRCubeTextureAssetTask object
  72230. */
  72231. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72232. /**
  72233. *
  72234. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72235. * @param taskName defines the name of the new task
  72236. * @param url defines the url of the file to load
  72237. * @param size defines the size you want for the cubemap (can be null)
  72238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72239. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72240. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72241. * @returns a new EquiRectangularCubeTextureAssetTask object
  72242. */
  72243. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72244. /**
  72245. * Remove a task from the assets manager.
  72246. * @param task the task to remove
  72247. */
  72248. removeTask(task: AbstractAssetTask): void;
  72249. private _decreaseWaitingTasksCount;
  72250. private _runTask;
  72251. /**
  72252. * Reset the AssetsManager and remove all tasks
  72253. * @return the current instance of the AssetsManager
  72254. */
  72255. reset(): AssetsManager;
  72256. /**
  72257. * Start the loading process
  72258. * @return the current instance of the AssetsManager
  72259. */
  72260. load(): AssetsManager;
  72261. /**
  72262. * Start the loading process as an async operation
  72263. * @return a promise returning the list of failed tasks
  72264. */
  72265. loadAsync(): Promise<void>;
  72266. }
  72267. }
  72268. declare module "babylonjs/Misc/deferred" {
  72269. /**
  72270. * Wrapper class for promise with external resolve and reject.
  72271. */
  72272. export class Deferred<T> {
  72273. /**
  72274. * The promise associated with this deferred object.
  72275. */
  72276. readonly promise: Promise<T>;
  72277. private _resolve;
  72278. private _reject;
  72279. /**
  72280. * The resolve method of the promise associated with this deferred object.
  72281. */
  72282. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72283. /**
  72284. * The reject method of the promise associated with this deferred object.
  72285. */
  72286. get reject(): (reason?: any) => void;
  72287. /**
  72288. * Constructor for this deferred object.
  72289. */
  72290. constructor();
  72291. }
  72292. }
  72293. declare module "babylonjs/Misc/meshExploder" {
  72294. import { Mesh } from "babylonjs/Meshes/mesh";
  72295. /**
  72296. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72297. */
  72298. export class MeshExploder {
  72299. private _centerMesh;
  72300. private _meshes;
  72301. private _meshesOrigins;
  72302. private _toCenterVectors;
  72303. private _scaledDirection;
  72304. private _newPosition;
  72305. private _centerPosition;
  72306. /**
  72307. * Explodes meshes from a center mesh.
  72308. * @param meshes The meshes to explode.
  72309. * @param centerMesh The mesh to be center of explosion.
  72310. */
  72311. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72312. private _setCenterMesh;
  72313. /**
  72314. * Get class name
  72315. * @returns "MeshExploder"
  72316. */
  72317. getClassName(): string;
  72318. /**
  72319. * "Exploded meshes"
  72320. * @returns Array of meshes with the centerMesh at index 0.
  72321. */
  72322. getMeshes(): Array<Mesh>;
  72323. /**
  72324. * Explodes meshes giving a specific direction
  72325. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72326. */
  72327. explode(direction?: number): void;
  72328. }
  72329. }
  72330. declare module "babylonjs/Misc/filesInput" {
  72331. import { Engine } from "babylonjs/Engines/engine";
  72332. import { Scene } from "babylonjs/scene";
  72333. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72334. /**
  72335. * Class used to help managing file picking and drag'n'drop
  72336. */
  72337. export class FilesInput {
  72338. /**
  72339. * List of files ready to be loaded
  72340. */
  72341. static get FilesToLoad(): {
  72342. [key: string]: File;
  72343. };
  72344. /**
  72345. * Callback called when a file is processed
  72346. */
  72347. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72348. private _engine;
  72349. private _currentScene;
  72350. private _sceneLoadedCallback;
  72351. private _progressCallback;
  72352. private _additionalRenderLoopLogicCallback;
  72353. private _textureLoadingCallback;
  72354. private _startingProcessingFilesCallback;
  72355. private _onReloadCallback;
  72356. private _errorCallback;
  72357. private _elementToMonitor;
  72358. private _sceneFileToLoad;
  72359. private _filesToLoad;
  72360. /**
  72361. * Creates a new FilesInput
  72362. * @param engine defines the rendering engine
  72363. * @param scene defines the hosting scene
  72364. * @param sceneLoadedCallback callback called when scene is loaded
  72365. * @param progressCallback callback called to track progress
  72366. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72367. * @param textureLoadingCallback callback called when a texture is loading
  72368. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72369. * @param onReloadCallback callback called when a reload is requested
  72370. * @param errorCallback callback call if an error occurs
  72371. */
  72372. 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);
  72373. private _dragEnterHandler;
  72374. private _dragOverHandler;
  72375. private _dropHandler;
  72376. /**
  72377. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72378. * @param elementToMonitor defines the DOM element to track
  72379. */
  72380. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72381. /**
  72382. * Release all associated resources
  72383. */
  72384. dispose(): void;
  72385. private renderFunction;
  72386. private drag;
  72387. private drop;
  72388. private _traverseFolder;
  72389. private _processFiles;
  72390. /**
  72391. * Load files from a drop event
  72392. * @param event defines the drop event to use as source
  72393. */
  72394. loadFiles(event: any): void;
  72395. private _processReload;
  72396. /**
  72397. * Reload the current scene from the loaded files
  72398. */
  72399. reload(): void;
  72400. }
  72401. }
  72402. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72403. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72404. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72405. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72406. }
  72407. declare module "babylonjs/Misc/sceneOptimizer" {
  72408. import { Scene, IDisposable } from "babylonjs/scene";
  72409. import { Observable } from "babylonjs/Misc/observable";
  72410. /**
  72411. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72413. */
  72414. export class SceneOptimization {
  72415. /**
  72416. * Defines the priority of this optimization (0 by default which means first in the list)
  72417. */
  72418. priority: number;
  72419. /**
  72420. * Gets a string describing the action executed by the current optimization
  72421. * @returns description string
  72422. */
  72423. getDescription(): string;
  72424. /**
  72425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72426. * @param scene defines the current scene where to apply this optimization
  72427. * @param optimizer defines the current optimizer
  72428. * @returns true if everything that can be done was applied
  72429. */
  72430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72431. /**
  72432. * Creates the SceneOptimization object
  72433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72434. * @param desc defines the description associated with the optimization
  72435. */
  72436. constructor(
  72437. /**
  72438. * Defines the priority of this optimization (0 by default which means first in the list)
  72439. */
  72440. priority?: number);
  72441. }
  72442. /**
  72443. * Defines an optimization used to reduce the size of render target textures
  72444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72445. */
  72446. export class TextureOptimization extends SceneOptimization {
  72447. /**
  72448. * Defines the priority of this optimization (0 by default which means first in the list)
  72449. */
  72450. priority: number;
  72451. /**
  72452. * 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
  72453. */
  72454. maximumSize: number;
  72455. /**
  72456. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72457. */
  72458. step: number;
  72459. /**
  72460. * Gets a string describing the action executed by the current optimization
  72461. * @returns description string
  72462. */
  72463. getDescription(): string;
  72464. /**
  72465. * Creates the TextureOptimization object
  72466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72467. * @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
  72468. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72469. */
  72470. constructor(
  72471. /**
  72472. * Defines the priority of this optimization (0 by default which means first in the list)
  72473. */
  72474. priority?: number,
  72475. /**
  72476. * 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
  72477. */
  72478. maximumSize?: number,
  72479. /**
  72480. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72481. */
  72482. step?: number);
  72483. /**
  72484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72485. * @param scene defines the current scene where to apply this optimization
  72486. * @param optimizer defines the current optimizer
  72487. * @returns true if everything that can be done was applied
  72488. */
  72489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72490. }
  72491. /**
  72492. * Defines an optimization used to increase or decrease the rendering resolution
  72493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72494. */
  72495. export class HardwareScalingOptimization extends SceneOptimization {
  72496. /**
  72497. * Defines the priority of this optimization (0 by default which means first in the list)
  72498. */
  72499. priority: number;
  72500. /**
  72501. * Defines the maximum scale to use (2 by default)
  72502. */
  72503. maximumScale: number;
  72504. /**
  72505. * Defines the step to use between two passes (0.5 by default)
  72506. */
  72507. step: number;
  72508. private _currentScale;
  72509. private _directionOffset;
  72510. /**
  72511. * Gets a string describing the action executed by the current optimization
  72512. * @return description string
  72513. */
  72514. getDescription(): string;
  72515. /**
  72516. * Creates the HardwareScalingOptimization object
  72517. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72518. * @param maximumScale defines the maximum scale to use (2 by default)
  72519. * @param step defines the step to use between two passes (0.5 by default)
  72520. */
  72521. constructor(
  72522. /**
  72523. * Defines the priority of this optimization (0 by default which means first in the list)
  72524. */
  72525. priority?: number,
  72526. /**
  72527. * Defines the maximum scale to use (2 by default)
  72528. */
  72529. maximumScale?: number,
  72530. /**
  72531. * Defines the step to use between two passes (0.5 by default)
  72532. */
  72533. step?: number);
  72534. /**
  72535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72536. * @param scene defines the current scene where to apply this optimization
  72537. * @param optimizer defines the current optimizer
  72538. * @returns true if everything that can be done was applied
  72539. */
  72540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72541. }
  72542. /**
  72543. * Defines an optimization used to remove shadows
  72544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72545. */
  72546. export class ShadowsOptimization extends SceneOptimization {
  72547. /**
  72548. * Gets a string describing the action executed by the current optimization
  72549. * @return description string
  72550. */
  72551. getDescription(): string;
  72552. /**
  72553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72554. * @param scene defines the current scene where to apply this optimization
  72555. * @param optimizer defines the current optimizer
  72556. * @returns true if everything that can be done was applied
  72557. */
  72558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72559. }
  72560. /**
  72561. * Defines an optimization used to turn post-processes off
  72562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72563. */
  72564. export class PostProcessesOptimization extends SceneOptimization {
  72565. /**
  72566. * Gets a string describing the action executed by the current optimization
  72567. * @return description string
  72568. */
  72569. getDescription(): string;
  72570. /**
  72571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72572. * @param scene defines the current scene where to apply this optimization
  72573. * @param optimizer defines the current optimizer
  72574. * @returns true if everything that can be done was applied
  72575. */
  72576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72577. }
  72578. /**
  72579. * Defines an optimization used to turn lens flares off
  72580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72581. */
  72582. export class LensFlaresOptimization extends SceneOptimization {
  72583. /**
  72584. * Gets a string describing the action executed by the current optimization
  72585. * @return description string
  72586. */
  72587. getDescription(): string;
  72588. /**
  72589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72590. * @param scene defines the current scene where to apply this optimization
  72591. * @param optimizer defines the current optimizer
  72592. * @returns true if everything that can be done was applied
  72593. */
  72594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72595. }
  72596. /**
  72597. * Defines an optimization based on user defined callback.
  72598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72599. */
  72600. export class CustomOptimization extends SceneOptimization {
  72601. /**
  72602. * Callback called to apply the custom optimization.
  72603. */
  72604. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72605. /**
  72606. * Callback called to get custom description
  72607. */
  72608. onGetDescription: () => string;
  72609. /**
  72610. * Gets a string describing the action executed by the current optimization
  72611. * @returns description string
  72612. */
  72613. getDescription(): string;
  72614. /**
  72615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72616. * @param scene defines the current scene where to apply this optimization
  72617. * @param optimizer defines the current optimizer
  72618. * @returns true if everything that can be done was applied
  72619. */
  72620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72621. }
  72622. /**
  72623. * Defines an optimization used to turn particles off
  72624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72625. */
  72626. export class ParticlesOptimization extends SceneOptimization {
  72627. /**
  72628. * Gets a string describing the action executed by the current optimization
  72629. * @return description string
  72630. */
  72631. getDescription(): string;
  72632. /**
  72633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72634. * @param scene defines the current scene where to apply this optimization
  72635. * @param optimizer defines the current optimizer
  72636. * @returns true if everything that can be done was applied
  72637. */
  72638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72639. }
  72640. /**
  72641. * Defines an optimization used to turn render targets off
  72642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72643. */
  72644. export class RenderTargetsOptimization extends SceneOptimization {
  72645. /**
  72646. * Gets a string describing the action executed by the current optimization
  72647. * @return description string
  72648. */
  72649. getDescription(): string;
  72650. /**
  72651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72652. * @param scene defines the current scene where to apply this optimization
  72653. * @param optimizer defines the current optimizer
  72654. * @returns true if everything that can be done was applied
  72655. */
  72656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72657. }
  72658. /**
  72659. * Defines an optimization used to merge meshes with compatible materials
  72660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72661. */
  72662. export class MergeMeshesOptimization extends SceneOptimization {
  72663. private static _UpdateSelectionTree;
  72664. /**
  72665. * Gets or sets a boolean which defines if optimization octree has to be updated
  72666. */
  72667. static get UpdateSelectionTree(): boolean;
  72668. /**
  72669. * Gets or sets a boolean which defines if optimization octree has to be updated
  72670. */
  72671. static set UpdateSelectionTree(value: boolean);
  72672. /**
  72673. * Gets a string describing the action executed by the current optimization
  72674. * @return description string
  72675. */
  72676. getDescription(): string;
  72677. private _canBeMerged;
  72678. /**
  72679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72680. * @param scene defines the current scene where to apply this optimization
  72681. * @param optimizer defines the current optimizer
  72682. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72683. * @returns true if everything that can be done was applied
  72684. */
  72685. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72686. }
  72687. /**
  72688. * Defines a list of options used by SceneOptimizer
  72689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72690. */
  72691. export class SceneOptimizerOptions {
  72692. /**
  72693. * Defines the target frame rate to reach (60 by default)
  72694. */
  72695. targetFrameRate: number;
  72696. /**
  72697. * Defines the interval between two checkes (2000ms by default)
  72698. */
  72699. trackerDuration: number;
  72700. /**
  72701. * Gets the list of optimizations to apply
  72702. */
  72703. optimizations: SceneOptimization[];
  72704. /**
  72705. * Creates a new list of options used by SceneOptimizer
  72706. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72707. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72708. */
  72709. constructor(
  72710. /**
  72711. * Defines the target frame rate to reach (60 by default)
  72712. */
  72713. targetFrameRate?: number,
  72714. /**
  72715. * Defines the interval between two checkes (2000ms by default)
  72716. */
  72717. trackerDuration?: number);
  72718. /**
  72719. * Add a new optimization
  72720. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72721. * @returns the current SceneOptimizerOptions
  72722. */
  72723. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72724. /**
  72725. * Add a new custom optimization
  72726. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72727. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72729. * @returns the current SceneOptimizerOptions
  72730. */
  72731. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72732. /**
  72733. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72734. * @param targetFrameRate defines the target frame rate (60 by default)
  72735. * @returns a SceneOptimizerOptions object
  72736. */
  72737. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72738. /**
  72739. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72740. * @param targetFrameRate defines the target frame rate (60 by default)
  72741. * @returns a SceneOptimizerOptions object
  72742. */
  72743. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72744. /**
  72745. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72746. * @param targetFrameRate defines the target frame rate (60 by default)
  72747. * @returns a SceneOptimizerOptions object
  72748. */
  72749. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72750. }
  72751. /**
  72752. * Class used to run optimizations in order to reach a target frame rate
  72753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72754. */
  72755. export class SceneOptimizer implements IDisposable {
  72756. private _isRunning;
  72757. private _options;
  72758. private _scene;
  72759. private _currentPriorityLevel;
  72760. private _targetFrameRate;
  72761. private _trackerDuration;
  72762. private _currentFrameRate;
  72763. private _sceneDisposeObserver;
  72764. private _improvementMode;
  72765. /**
  72766. * Defines an observable called when the optimizer reaches the target frame rate
  72767. */
  72768. onSuccessObservable: Observable<SceneOptimizer>;
  72769. /**
  72770. * Defines an observable called when the optimizer enables an optimization
  72771. */
  72772. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72773. /**
  72774. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72775. */
  72776. onFailureObservable: Observable<SceneOptimizer>;
  72777. /**
  72778. * Gets a boolean indicating if the optimizer is in improvement mode
  72779. */
  72780. get isInImprovementMode(): boolean;
  72781. /**
  72782. * Gets the current priority level (0 at start)
  72783. */
  72784. get currentPriorityLevel(): number;
  72785. /**
  72786. * Gets the current frame rate checked by the SceneOptimizer
  72787. */
  72788. get currentFrameRate(): number;
  72789. /**
  72790. * Gets or sets the current target frame rate (60 by default)
  72791. */
  72792. get targetFrameRate(): number;
  72793. /**
  72794. * Gets or sets the current target frame rate (60 by default)
  72795. */
  72796. set targetFrameRate(value: number);
  72797. /**
  72798. * Gets or sets the current interval between two checks (every 2000ms by default)
  72799. */
  72800. get trackerDuration(): number;
  72801. /**
  72802. * Gets or sets the current interval between two checks (every 2000ms by default)
  72803. */
  72804. set trackerDuration(value: number);
  72805. /**
  72806. * Gets the list of active optimizations
  72807. */
  72808. get optimizations(): SceneOptimization[];
  72809. /**
  72810. * Creates a new SceneOptimizer
  72811. * @param scene defines the scene to work on
  72812. * @param options defines the options to use with the SceneOptimizer
  72813. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72814. * @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)
  72815. */
  72816. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72817. /**
  72818. * Stops the current optimizer
  72819. */
  72820. stop(): void;
  72821. /**
  72822. * Reset the optimizer to initial step (current priority level = 0)
  72823. */
  72824. reset(): void;
  72825. /**
  72826. * Start the optimizer. By default it will try to reach a specific framerate
  72827. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72828. */
  72829. start(): void;
  72830. private _checkCurrentState;
  72831. /**
  72832. * Release all resources
  72833. */
  72834. dispose(): void;
  72835. /**
  72836. * Helper function to create a SceneOptimizer with one single line of code
  72837. * @param scene defines the scene to work on
  72838. * @param options defines the options to use with the SceneOptimizer
  72839. * @param onSuccess defines a callback to call on success
  72840. * @param onFailure defines a callback to call on failure
  72841. * @returns the new SceneOptimizer object
  72842. */
  72843. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72844. }
  72845. }
  72846. declare module "babylonjs/Misc/sceneSerializer" {
  72847. import { Scene } from "babylonjs/scene";
  72848. /**
  72849. * Class used to serialize a scene into a string
  72850. */
  72851. export class SceneSerializer {
  72852. /**
  72853. * Clear cache used by a previous serialization
  72854. */
  72855. static ClearCache(): void;
  72856. /**
  72857. * Serialize a scene into a JSON compatible object
  72858. * @param scene defines the scene to serialize
  72859. * @returns a JSON compatible object
  72860. */
  72861. static Serialize(scene: Scene): any;
  72862. /**
  72863. * Serialize a mesh into a JSON compatible object
  72864. * @param toSerialize defines the mesh to serialize
  72865. * @param withParents defines if parents must be serialized as well
  72866. * @param withChildren defines if children must be serialized as well
  72867. * @returns a JSON compatible object
  72868. */
  72869. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72870. }
  72871. }
  72872. declare module "babylonjs/Misc/textureTools" {
  72873. import { Texture } from "babylonjs/Materials/Textures/texture";
  72874. /**
  72875. * Class used to host texture specific utilities
  72876. */
  72877. export class TextureTools {
  72878. /**
  72879. * Uses the GPU to create a copy texture rescaled at a given size
  72880. * @param texture Texture to copy from
  72881. * @param width defines the desired width
  72882. * @param height defines the desired height
  72883. * @param useBilinearMode defines if bilinear mode has to be used
  72884. * @return the generated texture
  72885. */
  72886. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72887. }
  72888. }
  72889. declare module "babylonjs/Misc/videoRecorder" {
  72890. import { Nullable } from "babylonjs/types";
  72891. import { Engine } from "babylonjs/Engines/engine";
  72892. /**
  72893. * This represents the different options available for the video capture.
  72894. */
  72895. export interface VideoRecorderOptions {
  72896. /** Defines the mime type of the video. */
  72897. mimeType: string;
  72898. /** Defines the FPS the video should be recorded at. */
  72899. fps: number;
  72900. /** Defines the chunk size for the recording data. */
  72901. recordChunckSize: number;
  72902. /** The audio tracks to attach to the recording. */
  72903. audioTracks?: MediaStreamTrack[];
  72904. }
  72905. /**
  72906. * This can help with recording videos from BabylonJS.
  72907. * This is based on the available WebRTC functionalities of the browser.
  72908. *
  72909. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72910. */
  72911. export class VideoRecorder {
  72912. private static readonly _defaultOptions;
  72913. /**
  72914. * Returns whether or not the VideoRecorder is available in your browser.
  72915. * @param engine Defines the Babylon Engine.
  72916. * @returns true if supported otherwise false.
  72917. */
  72918. static IsSupported(engine: Engine): boolean;
  72919. private readonly _options;
  72920. private _canvas;
  72921. private _mediaRecorder;
  72922. private _recordedChunks;
  72923. private _fileName;
  72924. private _resolve;
  72925. private _reject;
  72926. /**
  72927. * True when a recording is already in progress.
  72928. */
  72929. get isRecording(): boolean;
  72930. /**
  72931. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72932. * @param engine Defines the BabylonJS Engine you wish to record.
  72933. * @param options Defines options that can be used to customize the capture.
  72934. */
  72935. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72936. /**
  72937. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72938. */
  72939. stopRecording(): void;
  72940. /**
  72941. * Starts recording the canvas for a max duration specified in parameters.
  72942. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72943. * If null no automatic download will start and you can rely on the promise to get the data back.
  72944. * @param maxDuration Defines the maximum recording time in seconds.
  72945. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72946. * @return A promise callback at the end of the recording with the video data in Blob.
  72947. */
  72948. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72949. /**
  72950. * Releases internal resources used during the recording.
  72951. */
  72952. dispose(): void;
  72953. private _handleDataAvailable;
  72954. private _handleError;
  72955. private _handleStop;
  72956. }
  72957. }
  72958. declare module "babylonjs/Misc/screenshotTools" {
  72959. import { Camera } from "babylonjs/Cameras/camera";
  72960. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72961. import { Engine } from "babylonjs/Engines/engine";
  72962. /**
  72963. * Class containing a set of static utilities functions for screenshots
  72964. */
  72965. export class ScreenshotTools {
  72966. /**
  72967. * Captures a screenshot of the current rendering
  72968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72969. * @param engine defines the rendering engine
  72970. * @param camera defines the source camera
  72971. * @param size This parameter can be set to a single number or to an object with the
  72972. * following (optional) properties: precision, width, height. If a single number is passed,
  72973. * it will be used for both width and height. If an object is passed, the screenshot size
  72974. * will be derived from the parameters. The precision property is a multiplier allowing
  72975. * rendering at a higher or lower resolution
  72976. * @param successCallback defines the callback receives a single parameter which contains the
  72977. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72978. * src parameter of an <img> to display it
  72979. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72980. * Check your browser for supported MIME types
  72981. */
  72982. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72983. /**
  72984. * Captures a screenshot of the current rendering
  72985. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72986. * @param engine defines the rendering engine
  72987. * @param camera defines the source camera
  72988. * @param size This parameter can be set to a single number or to an object with the
  72989. * following (optional) properties: precision, width, height. If a single number is passed,
  72990. * it will be used for both width and height. If an object is passed, the screenshot size
  72991. * will be derived from the parameters. The precision property is a multiplier allowing
  72992. * rendering at a higher or lower resolution
  72993. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72994. * Check your browser for supported MIME types
  72995. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72996. * to the src parameter of an <img> to display it
  72997. */
  72998. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72999. /**
  73000. * Generates an image screenshot from the specified camera.
  73001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73002. * @param engine The engine to use for rendering
  73003. * @param camera The camera to use for rendering
  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 successCallback The callback receives a single parameter which contains the
  73010. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73011. * src parameter of an <img> to display it
  73012. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73013. * Check your browser for supported MIME types
  73014. * @param samples Texture samples (default: 1)
  73015. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73016. * @param fileName A name for for the downloaded file.
  73017. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73018. */
  73019. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73020. /**
  73021. * Generates an image screenshot from the specified camera.
  73022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73023. * @param engine The engine to use for rendering
  73024. * @param camera The camera to use for rendering
  73025. * @param size This parameter can be set to a single number or to an object with the
  73026. * following (optional) properties: precision, width, height. If a single number is passed,
  73027. * it will be used for both width and height. If an object is passed, the screenshot size
  73028. * will be derived from the parameters. The precision property is a multiplier allowing
  73029. * rendering at a higher or lower resolution
  73030. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73031. * Check your browser for supported MIME types
  73032. * @param samples Texture samples (default: 1)
  73033. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73034. * @param fileName A name for for the downloaded file.
  73035. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73036. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73037. * to the src parameter of an <img> to display it
  73038. */
  73039. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73040. /**
  73041. * Gets height and width for screenshot size
  73042. * @private
  73043. */
  73044. private static _getScreenshotSize;
  73045. }
  73046. }
  73047. declare module "babylonjs/Misc/dataReader" {
  73048. /**
  73049. * Interface for a data buffer
  73050. */
  73051. export interface IDataBuffer {
  73052. /**
  73053. * Reads bytes from the data buffer.
  73054. * @param byteOffset The byte offset to read
  73055. * @param byteLength The byte length to read
  73056. * @returns A promise that resolves when the bytes are read
  73057. */
  73058. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73059. /**
  73060. * The byte length of the buffer.
  73061. */
  73062. readonly byteLength: number;
  73063. }
  73064. /**
  73065. * Utility class for reading from a data buffer
  73066. */
  73067. export class DataReader {
  73068. /**
  73069. * The data buffer associated with this data reader.
  73070. */
  73071. readonly buffer: IDataBuffer;
  73072. /**
  73073. * The current byte offset from the beginning of the data buffer.
  73074. */
  73075. byteOffset: number;
  73076. private _dataView;
  73077. private _dataByteOffset;
  73078. /**
  73079. * Constructor
  73080. * @param buffer The buffer to read
  73081. */
  73082. constructor(buffer: IDataBuffer);
  73083. /**
  73084. * Loads the given byte length.
  73085. * @param byteLength The byte length to load
  73086. * @returns A promise that resolves when the load is complete
  73087. */
  73088. loadAsync(byteLength: number): Promise<void>;
  73089. /**
  73090. * Read a unsigned 32-bit integer from the currently loaded data range.
  73091. * @returns The 32-bit integer read
  73092. */
  73093. readUint32(): number;
  73094. /**
  73095. * Read a byte array from the currently loaded data range.
  73096. * @param byteLength The byte length to read
  73097. * @returns The byte array read
  73098. */
  73099. readUint8Array(byteLength: number): Uint8Array;
  73100. /**
  73101. * Read a string from the currently loaded data range.
  73102. * @param byteLength The byte length to read
  73103. * @returns The string read
  73104. */
  73105. readString(byteLength: number): string;
  73106. /**
  73107. * Skips the given byte length the currently loaded data range.
  73108. * @param byteLength The byte length to skip
  73109. */
  73110. skipBytes(byteLength: number): void;
  73111. }
  73112. }
  73113. declare module "babylonjs/Misc/dataStorage" {
  73114. /**
  73115. * Class for storing data to local storage if available or in-memory storage otherwise
  73116. */
  73117. export class DataStorage {
  73118. private static _Storage;
  73119. private static _GetStorage;
  73120. /**
  73121. * Reads a string from the data storage
  73122. * @param key The key to read
  73123. * @param defaultValue The value if the key doesn't exist
  73124. * @returns The string value
  73125. */
  73126. static ReadString(key: string, defaultValue: string): string;
  73127. /**
  73128. * Writes a string to the data storage
  73129. * @param key The key to write
  73130. * @param value The value to write
  73131. */
  73132. static WriteString(key: string, value: string): void;
  73133. /**
  73134. * Reads a boolean from the data storage
  73135. * @param key The key to read
  73136. * @param defaultValue The value if the key doesn't exist
  73137. * @returns The boolean value
  73138. */
  73139. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73140. /**
  73141. * Writes a boolean to the data storage
  73142. * @param key The key to write
  73143. * @param value The value to write
  73144. */
  73145. static WriteBoolean(key: string, value: boolean): void;
  73146. /**
  73147. * Reads a number from the data storage
  73148. * @param key The key to read
  73149. * @param defaultValue The value if the key doesn't exist
  73150. * @returns The number value
  73151. */
  73152. static ReadNumber(key: string, defaultValue: number): number;
  73153. /**
  73154. * Writes a number to the data storage
  73155. * @param key The key to write
  73156. * @param value The value to write
  73157. */
  73158. static WriteNumber(key: string, value: number): void;
  73159. }
  73160. }
  73161. declare module "babylonjs/Misc/index" {
  73162. export * from "babylonjs/Misc/andOrNotEvaluator";
  73163. export * from "babylonjs/Misc/assetsManager";
  73164. export * from "babylonjs/Misc/basis";
  73165. export * from "babylonjs/Misc/dds";
  73166. export * from "babylonjs/Misc/decorators";
  73167. export * from "babylonjs/Misc/deferred";
  73168. export * from "babylonjs/Misc/environmentTextureTools";
  73169. export * from "babylonjs/Misc/meshExploder";
  73170. export * from "babylonjs/Misc/filesInput";
  73171. export * from "babylonjs/Misc/HighDynamicRange/index";
  73172. export * from "babylonjs/Misc/khronosTextureContainer";
  73173. export * from "babylonjs/Misc/observable";
  73174. export * from "babylonjs/Misc/performanceMonitor";
  73175. export * from "babylonjs/Misc/promise";
  73176. export * from "babylonjs/Misc/sceneOptimizer";
  73177. export * from "babylonjs/Misc/sceneSerializer";
  73178. export * from "babylonjs/Misc/smartArray";
  73179. export * from "babylonjs/Misc/stringDictionary";
  73180. export * from "babylonjs/Misc/tags";
  73181. export * from "babylonjs/Misc/textureTools";
  73182. export * from "babylonjs/Misc/tga";
  73183. export * from "babylonjs/Misc/tools";
  73184. export * from "babylonjs/Misc/videoRecorder";
  73185. export * from "babylonjs/Misc/virtualJoystick";
  73186. export * from "babylonjs/Misc/workerPool";
  73187. export * from "babylonjs/Misc/logger";
  73188. export * from "babylonjs/Misc/typeStore";
  73189. export * from "babylonjs/Misc/filesInputStore";
  73190. export * from "babylonjs/Misc/deepCopier";
  73191. export * from "babylonjs/Misc/pivotTools";
  73192. export * from "babylonjs/Misc/precisionDate";
  73193. export * from "babylonjs/Misc/screenshotTools";
  73194. export * from "babylonjs/Misc/typeStore";
  73195. export * from "babylonjs/Misc/webRequest";
  73196. export * from "babylonjs/Misc/iInspectable";
  73197. export * from "babylonjs/Misc/brdfTextureTools";
  73198. export * from "babylonjs/Misc/rgbdTextureTools";
  73199. export * from "babylonjs/Misc/gradients";
  73200. export * from "babylonjs/Misc/perfCounter";
  73201. export * from "babylonjs/Misc/fileRequest";
  73202. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73203. export * from "babylonjs/Misc/retryStrategy";
  73204. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73205. export * from "babylonjs/Misc/canvasGenerator";
  73206. export * from "babylonjs/Misc/fileTools";
  73207. export * from "babylonjs/Misc/stringTools";
  73208. export * from "babylonjs/Misc/dataReader";
  73209. export * from "babylonjs/Misc/minMaxReducer";
  73210. export * from "babylonjs/Misc/depthReducer";
  73211. export * from "babylonjs/Misc/dataStorage";
  73212. }
  73213. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73214. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73215. import { Observable } from "babylonjs/Misc/observable";
  73216. import { Matrix } from "babylonjs/Maths/math.vector";
  73217. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73218. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73219. /**
  73220. * Options used for hit testing
  73221. */
  73222. export interface IWebXRLegacyHitTestOptions {
  73223. /**
  73224. * Only test when user interacted with the scene. Default - hit test every frame
  73225. */
  73226. testOnPointerDownOnly?: boolean;
  73227. /**
  73228. * The node to use to transform the local results to world coordinates
  73229. */
  73230. worldParentNode?: TransformNode;
  73231. }
  73232. /**
  73233. * Interface defining the babylon result of raycasting/hit-test
  73234. */
  73235. export interface IWebXRLegacyHitResult {
  73236. /**
  73237. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73238. */
  73239. transformationMatrix: Matrix;
  73240. /**
  73241. * The native hit test result
  73242. */
  73243. xrHitResult: XRHitResult | XRHitTestResult;
  73244. }
  73245. /**
  73246. * The currently-working hit-test module.
  73247. * Hit test (or Ray-casting) is used to interact with the real world.
  73248. * For further information read here - https://github.com/immersive-web/hit-test
  73249. */
  73250. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73251. /**
  73252. * options to use when constructing this feature
  73253. */
  73254. readonly options: IWebXRLegacyHitTestOptions;
  73255. private _direction;
  73256. private _mat;
  73257. private _onSelectEnabled;
  73258. private _origin;
  73259. /**
  73260. * The module's name
  73261. */
  73262. static readonly Name: string;
  73263. /**
  73264. * The (Babylon) version of this module.
  73265. * This is an integer representing the implementation version.
  73266. * This number does not correspond to the WebXR specs version
  73267. */
  73268. static readonly Version: number;
  73269. /**
  73270. * Populated with the last native XR Hit Results
  73271. */
  73272. lastNativeXRHitResults: XRHitResult[];
  73273. /**
  73274. * Triggered when new babylon (transformed) hit test results are available
  73275. */
  73276. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73277. /**
  73278. * Creates a new instance of the (legacy version) hit test feature
  73279. * @param _xrSessionManager an instance of WebXRSessionManager
  73280. * @param options options to use when constructing this feature
  73281. */
  73282. constructor(_xrSessionManager: WebXRSessionManager,
  73283. /**
  73284. * options to use when constructing this feature
  73285. */
  73286. options?: IWebXRLegacyHitTestOptions);
  73287. /**
  73288. * execute a hit test with an XR Ray
  73289. *
  73290. * @param xrSession a native xrSession that will execute this hit test
  73291. * @param xrRay the ray (position and direction) to use for ray-casting
  73292. * @param referenceSpace native XR reference space to use for the hit-test
  73293. * @param filter filter function that will filter the results
  73294. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73295. */
  73296. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73297. /**
  73298. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73299. * @param event the (select) event to use to select with
  73300. * @param referenceSpace the reference space to use for this hit test
  73301. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73302. */
  73303. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73304. /**
  73305. * attach this feature
  73306. * Will usually be called by the features manager
  73307. *
  73308. * @returns true if successful.
  73309. */
  73310. attach(): boolean;
  73311. /**
  73312. * detach this feature.
  73313. * Will usually be called by the features manager
  73314. *
  73315. * @returns true if successful.
  73316. */
  73317. detach(): boolean;
  73318. /**
  73319. * Dispose this feature and all of the resources attached
  73320. */
  73321. dispose(): void;
  73322. protected _onXRFrame(frame: XRFrame): void;
  73323. private _onHitTestResults;
  73324. private _onSelect;
  73325. }
  73326. }
  73327. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73328. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73329. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73330. import { Observable } from "babylonjs/Misc/observable";
  73331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73332. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73333. /**
  73334. * Options used in the plane detector module
  73335. */
  73336. export interface IWebXRPlaneDetectorOptions {
  73337. /**
  73338. * The node to use to transform the local results to world coordinates
  73339. */
  73340. worldParentNode?: TransformNode;
  73341. }
  73342. /**
  73343. * A babylon interface for a WebXR plane.
  73344. * A Plane is actually a polygon, built from N points in space
  73345. *
  73346. * Supported in chrome 79, not supported in canary 81 ATM
  73347. */
  73348. export interface IWebXRPlane {
  73349. /**
  73350. * a babylon-assigned ID for this polygon
  73351. */
  73352. id: number;
  73353. /**
  73354. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73355. */
  73356. polygonDefinition: Array<Vector3>;
  73357. /**
  73358. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73359. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73360. */
  73361. transformationMatrix: Matrix;
  73362. /**
  73363. * the native xr-plane object
  73364. */
  73365. xrPlane: XRPlane;
  73366. }
  73367. /**
  73368. * The plane detector is used to detect planes in the real world when in AR
  73369. * For more information see https://github.com/immersive-web/real-world-geometry/
  73370. */
  73371. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73372. private _options;
  73373. private _detectedPlanes;
  73374. private _enabled;
  73375. private _lastFrameDetected;
  73376. /**
  73377. * The module's name
  73378. */
  73379. static readonly Name: string;
  73380. /**
  73381. * The (Babylon) version of this module.
  73382. * This is an integer representing the implementation version.
  73383. * This number does not correspond to the WebXR specs version
  73384. */
  73385. static readonly Version: number;
  73386. /**
  73387. * Observers registered here will be executed when a new plane was added to the session
  73388. */
  73389. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73390. /**
  73391. * Observers registered here will be executed when a plane is no longer detected in the session
  73392. */
  73393. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73394. /**
  73395. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73396. * This can execute N times every frame
  73397. */
  73398. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73399. /**
  73400. * construct a new Plane Detector
  73401. * @param _xrSessionManager an instance of xr Session manager
  73402. * @param _options configuration to use when constructing this feature
  73403. */
  73404. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73405. /**
  73406. * Dispose this feature and all of the resources attached
  73407. */
  73408. dispose(): void;
  73409. protected _onXRFrame(frame: XRFrame): void;
  73410. private _init;
  73411. private _updatePlaneWithXRPlane;
  73412. /**
  73413. * avoiding using Array.find for global support.
  73414. * @param xrPlane the plane to find in the array
  73415. */
  73416. private findIndexInPlaneArray;
  73417. }
  73418. }
  73419. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73420. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73421. import { Observable } from "babylonjs/Misc/observable";
  73422. import { Matrix } from "babylonjs/Maths/math.vector";
  73423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73424. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73425. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73426. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73427. /**
  73428. * Configuration options of the anchor system
  73429. */
  73430. export interface IWebXRAnchorSystemOptions {
  73431. /**
  73432. * Should a new anchor be added every time a select event is triggered
  73433. */
  73434. addAnchorOnSelect?: boolean;
  73435. /**
  73436. * should the anchor system use plane detection.
  73437. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73438. */
  73439. usePlaneDetection?: boolean;
  73440. /**
  73441. * a node that will be used to convert local to world coordinates
  73442. */
  73443. worldParentNode?: TransformNode;
  73444. }
  73445. /**
  73446. * A babylon container for an XR Anchor
  73447. */
  73448. export interface IWebXRAnchor {
  73449. /**
  73450. * A babylon-assigned ID for this anchor
  73451. */
  73452. id: number;
  73453. /**
  73454. * Transformation matrix to apply to an object attached to this anchor
  73455. */
  73456. transformationMatrix: Matrix;
  73457. /**
  73458. * The native anchor object
  73459. */
  73460. xrAnchor: XRAnchor;
  73461. }
  73462. /**
  73463. * An implementation of the anchor system of WebXR.
  73464. * Note that the current documented implementation is not available in any browser. Future implementations
  73465. * will use the frame to create an anchor and not the session or a detected plane
  73466. * For further information see https://github.com/immersive-web/anchors/
  73467. */
  73468. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73469. private _options;
  73470. private _enabled;
  73471. private _hitTestModule;
  73472. private _lastFrameDetected;
  73473. private _onSelect;
  73474. private _planeDetector;
  73475. private _trackedAnchors;
  73476. /**
  73477. * The module's name
  73478. */
  73479. static readonly Name: string;
  73480. /**
  73481. * The (Babylon) version of this module.
  73482. * This is an integer representing the implementation version.
  73483. * This number does not correspond to the WebXR specs version
  73484. */
  73485. static readonly Version: number;
  73486. /**
  73487. * Observers registered here will be executed when a new anchor was added to the session
  73488. */
  73489. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73490. /**
  73491. * Observers registered here will be executed when an anchor was removed from the session
  73492. */
  73493. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73494. /**
  73495. * Observers registered here will be executed when an existing anchor updates
  73496. * This can execute N times every frame
  73497. */
  73498. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73499. /**
  73500. * constructs a new anchor system
  73501. * @param _xrSessionManager an instance of WebXRSessionManager
  73502. * @param _options configuration object for this feature
  73503. */
  73504. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73505. /**
  73506. * Add anchor at a specific XR point.
  73507. *
  73508. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73509. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73510. * @returns a promise the fulfills when the anchor was created
  73511. */
  73512. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73513. /**
  73514. * attach this feature
  73515. * Will usually be called by the features manager
  73516. *
  73517. * @returns true if successful.
  73518. */
  73519. attach(): boolean;
  73520. /**
  73521. * detach this feature.
  73522. * Will usually be called by the features manager
  73523. *
  73524. * @returns true if successful.
  73525. */
  73526. detach(): boolean;
  73527. /**
  73528. * Dispose this feature and all of the resources attached
  73529. */
  73530. dispose(): void;
  73531. /**
  73532. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73533. * @param hitTestModule the hit-test module to use.
  73534. */
  73535. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73536. /**
  73537. * set the plane detector to use in order to create anchors from frames
  73538. * @param planeDetector the plane-detector module to use
  73539. * @param enable enable plane-anchors. default is true
  73540. */
  73541. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73542. protected _onXRFrame(frame: XRFrame): void;
  73543. /**
  73544. * avoiding using Array.find for global support.
  73545. * @param xrAnchor the plane to find in the array
  73546. */
  73547. private _findIndexInAnchorArray;
  73548. private _updateAnchorWithXRFrame;
  73549. }
  73550. }
  73551. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73552. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73554. import { Observable } from "babylonjs/Misc/observable";
  73555. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73556. /**
  73557. * Options interface for the background remover plugin
  73558. */
  73559. export interface IWebXRBackgroundRemoverOptions {
  73560. /**
  73561. * Further background meshes to disable when entering AR
  73562. */
  73563. backgroundMeshes?: AbstractMesh[];
  73564. /**
  73565. * flags to configure the removal of the environment helper.
  73566. * If not set, the entire background will be removed. If set, flags should be set as well.
  73567. */
  73568. environmentHelperRemovalFlags?: {
  73569. /**
  73570. * Should the skybox be removed (default false)
  73571. */
  73572. skyBox?: boolean;
  73573. /**
  73574. * Should the ground be removed (default false)
  73575. */
  73576. ground?: boolean;
  73577. };
  73578. /**
  73579. * don't disable the environment helper
  73580. */
  73581. ignoreEnvironmentHelper?: boolean;
  73582. }
  73583. /**
  73584. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73585. */
  73586. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73587. /**
  73588. * read-only options to be used in this module
  73589. */
  73590. readonly options: IWebXRBackgroundRemoverOptions;
  73591. /**
  73592. * The module's name
  73593. */
  73594. static readonly Name: string;
  73595. /**
  73596. * The (Babylon) version of this module.
  73597. * This is an integer representing the implementation version.
  73598. * This number does not correspond to the WebXR specs version
  73599. */
  73600. static readonly Version: number;
  73601. /**
  73602. * registered observers will be triggered when the background state changes
  73603. */
  73604. onBackgroundStateChangedObservable: Observable<boolean>;
  73605. /**
  73606. * constructs a new background remover module
  73607. * @param _xrSessionManager the session manager for this module
  73608. * @param options read-only options to be used in this module
  73609. */
  73610. constructor(_xrSessionManager: WebXRSessionManager,
  73611. /**
  73612. * read-only options to be used in this module
  73613. */
  73614. options?: IWebXRBackgroundRemoverOptions);
  73615. /**
  73616. * attach this feature
  73617. * Will usually be called by the features manager
  73618. *
  73619. * @returns true if successful.
  73620. */
  73621. attach(): boolean;
  73622. /**
  73623. * detach this feature.
  73624. * Will usually be called by the features manager
  73625. *
  73626. * @returns true if successful.
  73627. */
  73628. detach(): boolean;
  73629. /**
  73630. * Dispose this feature and all of the resources attached
  73631. */
  73632. dispose(): void;
  73633. protected _onXRFrame(_xrFrame: XRFrame): void;
  73634. private _setBackgroundState;
  73635. }
  73636. }
  73637. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73638. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73639. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73640. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73641. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73642. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73643. import { Nullable } from "babylonjs/types";
  73644. /**
  73645. * Options for the controller physics feature
  73646. */
  73647. export class IWebXRControllerPhysicsOptions {
  73648. /**
  73649. * Should the headset get its own impostor
  73650. */
  73651. enableHeadsetImpostor?: boolean;
  73652. /**
  73653. * Optional parameters for the headset impostor
  73654. */
  73655. headsetImpostorParams?: {
  73656. /**
  73657. * The type of impostor to create. Default is sphere
  73658. */
  73659. impostorType: number;
  73660. /**
  73661. * the size of the impostor. Defaults to 10cm
  73662. */
  73663. impostorSize?: number | {
  73664. width: number;
  73665. height: number;
  73666. depth: number;
  73667. };
  73668. /**
  73669. * Friction definitions
  73670. */
  73671. friction?: number;
  73672. /**
  73673. * Restitution
  73674. */
  73675. restitution?: number;
  73676. };
  73677. /**
  73678. * The physics properties of the future impostors
  73679. */
  73680. physicsProperties?: {
  73681. /**
  73682. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73683. * Note that this requires a physics engine that supports mesh impostors!
  73684. */
  73685. useControllerMesh?: boolean;
  73686. /**
  73687. * The type of impostor to create. Default is sphere
  73688. */
  73689. impostorType?: number;
  73690. /**
  73691. * the size of the impostor. Defaults to 10cm
  73692. */
  73693. impostorSize?: number | {
  73694. width: number;
  73695. height: number;
  73696. depth: number;
  73697. };
  73698. /**
  73699. * Friction definitions
  73700. */
  73701. friction?: number;
  73702. /**
  73703. * Restitution
  73704. */
  73705. restitution?: number;
  73706. };
  73707. /**
  73708. * the xr input to use with this pointer selection
  73709. */
  73710. xrInput: WebXRInput;
  73711. }
  73712. /**
  73713. * Add physics impostor to your webxr controllers,
  73714. * including naive calculation of their linear and angular velocity
  73715. */
  73716. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73717. private readonly _options;
  73718. private _attachController;
  73719. private _controllers;
  73720. private _debugMode;
  73721. private _delta;
  73722. private _headsetImpostor?;
  73723. private _headsetMesh?;
  73724. private _lastTimestamp;
  73725. private _tmpQuaternion;
  73726. private _tmpVector;
  73727. /**
  73728. * The module's name
  73729. */
  73730. static readonly Name: string;
  73731. /**
  73732. * The (Babylon) version of this module.
  73733. * This is an integer representing the implementation version.
  73734. * This number does not correspond to the webxr specs version
  73735. */
  73736. static readonly Version: number;
  73737. /**
  73738. * Construct a new Controller Physics Feature
  73739. * @param _xrSessionManager the corresponding xr session manager
  73740. * @param _options options to create this feature with
  73741. */
  73742. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73743. /**
  73744. * @hidden
  73745. * enable debugging - will show console outputs and the impostor mesh
  73746. */
  73747. _enablePhysicsDebug(): void;
  73748. /**
  73749. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73750. * @param xrController the controller to add
  73751. */
  73752. addController(xrController: WebXRInputSource): void;
  73753. /**
  73754. * attach this feature
  73755. * Will usually be called by the features manager
  73756. *
  73757. * @returns true if successful.
  73758. */
  73759. attach(): boolean;
  73760. /**
  73761. * detach this feature.
  73762. * Will usually be called by the features manager
  73763. *
  73764. * @returns true if successful.
  73765. */
  73766. detach(): boolean;
  73767. /**
  73768. * Get the headset impostor, if enabled
  73769. * @returns the impostor
  73770. */
  73771. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73772. /**
  73773. * Get the physics impostor of a specific controller.
  73774. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73775. * @param controller the controller or the controller id of which to get the impostor
  73776. * @returns the impostor or null
  73777. */
  73778. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73779. /**
  73780. * Update the physics properties provided in the constructor
  73781. * @param newProperties the new properties object
  73782. */
  73783. setPhysicsProperties(newProperties: {
  73784. impostorType?: number;
  73785. impostorSize?: number | {
  73786. width: number;
  73787. height: number;
  73788. depth: number;
  73789. };
  73790. friction?: number;
  73791. restitution?: number;
  73792. }): void;
  73793. protected _onXRFrame(_xrFrame: any): void;
  73794. private _detachController;
  73795. }
  73796. }
  73797. declare module "babylonjs/XR/features/WebXRHitTest" {
  73798. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73799. import { Observable } from "babylonjs/Misc/observable";
  73800. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73801. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73802. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73803. /**
  73804. * Options used for hit testing (version 2)
  73805. */
  73806. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73807. /**
  73808. * Do not create a permanent hit test. Will usually be used when only
  73809. * transient inputs are needed.
  73810. */
  73811. disablePermanentHitTest?: boolean;
  73812. /**
  73813. * Enable transient (for example touch-based) hit test inspections
  73814. */
  73815. enableTransientHitTest?: boolean;
  73816. /**
  73817. * Offset ray for the permanent hit test
  73818. */
  73819. offsetRay?: Vector3;
  73820. /**
  73821. * Offset ray for the transient hit test
  73822. */
  73823. transientOffsetRay?: Vector3;
  73824. /**
  73825. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73826. */
  73827. useReferenceSpace?: boolean;
  73828. }
  73829. /**
  73830. * Interface defining the babylon result of hit-test
  73831. */
  73832. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73833. /**
  73834. * The input source that generated this hit test (if transient)
  73835. */
  73836. inputSource?: XRInputSource;
  73837. /**
  73838. * Is this a transient hit test
  73839. */
  73840. isTransient?: boolean;
  73841. /**
  73842. * Position of the hit test result
  73843. */
  73844. position: Vector3;
  73845. /**
  73846. * Rotation of the hit test result
  73847. */
  73848. rotationQuaternion: Quaternion;
  73849. }
  73850. /**
  73851. * The currently-working hit-test module.
  73852. * Hit test (or Ray-casting) is used to interact with the real world.
  73853. * For further information read here - https://github.com/immersive-web/hit-test
  73854. *
  73855. * Tested on chrome (mobile) 80.
  73856. */
  73857. export class WebXRHitTest extends WebXRAbstractFeature {
  73858. /**
  73859. * options to use when constructing this feature
  73860. */
  73861. readonly options: IWebXRHitTestOptions;
  73862. private _tmpMat;
  73863. private _tmpPos;
  73864. private _tmpQuat;
  73865. private _transientXrHitTestSource;
  73866. private _xrHitTestSource;
  73867. private initHitTestSource;
  73868. /**
  73869. * The module's name
  73870. */
  73871. static readonly Name: string;
  73872. /**
  73873. * The (Babylon) version of this module.
  73874. * This is an integer representing the implementation version.
  73875. * This number does not correspond to the WebXR specs version
  73876. */
  73877. static readonly Version: number;
  73878. /**
  73879. * When set to true, each hit test will have its own position/rotation objects
  73880. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73881. * the developers will clone them or copy them as they see fit.
  73882. */
  73883. autoCloneTransformation: boolean;
  73884. /**
  73885. * Populated with the last native XR Hit Results
  73886. */
  73887. lastNativeXRHitResults: XRHitResult[];
  73888. /**
  73889. * Triggered when new babylon (transformed) hit test results are available
  73890. */
  73891. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73892. /**
  73893. * Use this to temporarily pause hit test checks.
  73894. */
  73895. paused: boolean;
  73896. /**
  73897. * Creates a new instance of the hit test feature
  73898. * @param _xrSessionManager an instance of WebXRSessionManager
  73899. * @param options options to use when constructing this feature
  73900. */
  73901. constructor(_xrSessionManager: WebXRSessionManager,
  73902. /**
  73903. * options to use when constructing this feature
  73904. */
  73905. options?: IWebXRHitTestOptions);
  73906. /**
  73907. * attach this feature
  73908. * Will usually be called by the features manager
  73909. *
  73910. * @returns true if successful.
  73911. */
  73912. attach(): boolean;
  73913. /**
  73914. * detach this feature.
  73915. * Will usually be called by the features manager
  73916. *
  73917. * @returns true if successful.
  73918. */
  73919. detach(): boolean;
  73920. /**
  73921. * Dispose this feature and all of the resources attached
  73922. */
  73923. dispose(): void;
  73924. protected _onXRFrame(frame: XRFrame): void;
  73925. private _processWebXRHitTestResult;
  73926. }
  73927. }
  73928. declare module "babylonjs/XR/features/index" {
  73929. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73930. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73931. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73932. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73933. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73934. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73935. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73936. export * from "babylonjs/XR/features/WebXRHitTest";
  73937. }
  73938. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73939. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73941. import { Scene } from "babylonjs/scene";
  73942. /**
  73943. * The motion controller class for all microsoft mixed reality controllers
  73944. */
  73945. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73946. protected readonly _mapping: {
  73947. defaultButton: {
  73948. valueNodeName: string;
  73949. unpressedNodeName: string;
  73950. pressedNodeName: string;
  73951. };
  73952. defaultAxis: {
  73953. valueNodeName: string;
  73954. minNodeName: string;
  73955. maxNodeName: string;
  73956. };
  73957. buttons: {
  73958. "xr-standard-trigger": {
  73959. rootNodeName: string;
  73960. componentProperty: string;
  73961. states: string[];
  73962. };
  73963. "xr-standard-squeeze": {
  73964. rootNodeName: string;
  73965. componentProperty: string;
  73966. states: string[];
  73967. };
  73968. "xr-standard-touchpad": {
  73969. rootNodeName: string;
  73970. labelAnchorNodeName: string;
  73971. touchPointNodeName: string;
  73972. };
  73973. "xr-standard-thumbstick": {
  73974. rootNodeName: string;
  73975. componentProperty: string;
  73976. states: string[];
  73977. };
  73978. };
  73979. axes: {
  73980. "xr-standard-touchpad": {
  73981. "x-axis": {
  73982. rootNodeName: string;
  73983. };
  73984. "y-axis": {
  73985. rootNodeName: string;
  73986. };
  73987. };
  73988. "xr-standard-thumbstick": {
  73989. "x-axis": {
  73990. rootNodeName: string;
  73991. };
  73992. "y-axis": {
  73993. rootNodeName: string;
  73994. };
  73995. };
  73996. };
  73997. };
  73998. /**
  73999. * The base url used to load the left and right controller models
  74000. */
  74001. static MODEL_BASE_URL: string;
  74002. /**
  74003. * The name of the left controller model file
  74004. */
  74005. static MODEL_LEFT_FILENAME: string;
  74006. /**
  74007. * The name of the right controller model file
  74008. */
  74009. static MODEL_RIGHT_FILENAME: string;
  74010. profileId: string;
  74011. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74012. protected _getFilenameAndPath(): {
  74013. filename: string;
  74014. path: string;
  74015. };
  74016. protected _getModelLoadingConstraints(): boolean;
  74017. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74018. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74019. protected _updateModel(): void;
  74020. }
  74021. }
  74022. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74023. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74025. import { Scene } from "babylonjs/scene";
  74026. /**
  74027. * The motion controller class for oculus touch (quest, rift).
  74028. * This class supports legacy mapping as well the standard xr mapping
  74029. */
  74030. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74031. private _forceLegacyControllers;
  74032. private _modelRootNode;
  74033. /**
  74034. * The base url used to load the left and right controller models
  74035. */
  74036. static MODEL_BASE_URL: string;
  74037. /**
  74038. * The name of the left controller model file
  74039. */
  74040. static MODEL_LEFT_FILENAME: string;
  74041. /**
  74042. * The name of the right controller model file
  74043. */
  74044. static MODEL_RIGHT_FILENAME: string;
  74045. /**
  74046. * Base Url for the Quest controller model.
  74047. */
  74048. static QUEST_MODEL_BASE_URL: string;
  74049. profileId: string;
  74050. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74051. protected _getFilenameAndPath(): {
  74052. filename: string;
  74053. path: string;
  74054. };
  74055. protected _getModelLoadingConstraints(): boolean;
  74056. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74058. protected _updateModel(): void;
  74059. /**
  74060. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74061. * between the touch and touch 2.
  74062. */
  74063. private _isQuest;
  74064. }
  74065. }
  74066. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74067. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74068. import { Scene } from "babylonjs/scene";
  74069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74070. /**
  74071. * The motion controller class for the standard HTC-Vive controllers
  74072. */
  74073. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74074. private _modelRootNode;
  74075. /**
  74076. * The base url used to load the left and right controller models
  74077. */
  74078. static MODEL_BASE_URL: string;
  74079. /**
  74080. * File name for the controller model.
  74081. */
  74082. static MODEL_FILENAME: string;
  74083. profileId: string;
  74084. /**
  74085. * Create a new Vive motion controller object
  74086. * @param scene the scene to use to create this controller
  74087. * @param gamepadObject the corresponding gamepad object
  74088. * @param handness the handness of the controller
  74089. */
  74090. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74091. protected _getFilenameAndPath(): {
  74092. filename: string;
  74093. path: string;
  74094. };
  74095. protected _getModelLoadingConstraints(): boolean;
  74096. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74097. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74098. protected _updateModel(): void;
  74099. }
  74100. }
  74101. declare module "babylonjs/XR/motionController/index" {
  74102. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74103. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74104. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74105. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74106. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74107. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74108. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74109. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74110. }
  74111. declare module "babylonjs/XR/index" {
  74112. export * from "babylonjs/XR/webXRCamera";
  74113. export * from "babylonjs/XR/webXREnterExitUI";
  74114. export * from "babylonjs/XR/webXRExperienceHelper";
  74115. export * from "babylonjs/XR/webXRInput";
  74116. export * from "babylonjs/XR/webXRInputSource";
  74117. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74118. export * from "babylonjs/XR/webXRTypes";
  74119. export * from "babylonjs/XR/webXRSessionManager";
  74120. export * from "babylonjs/XR/webXRDefaultExperience";
  74121. export * from "babylonjs/XR/webXRFeaturesManager";
  74122. export * from "babylonjs/XR/features/index";
  74123. export * from "babylonjs/XR/motionController/index";
  74124. }
  74125. declare module "babylonjs/index" {
  74126. export * from "babylonjs/abstractScene";
  74127. export * from "babylonjs/Actions/index";
  74128. export * from "babylonjs/Animations/index";
  74129. export * from "babylonjs/assetContainer";
  74130. export * from "babylonjs/Audio/index";
  74131. export * from "babylonjs/Behaviors/index";
  74132. export * from "babylonjs/Bones/index";
  74133. export * from "babylonjs/Cameras/index";
  74134. export * from "babylonjs/Collisions/index";
  74135. export * from "babylonjs/Culling/index";
  74136. export * from "babylonjs/Debug/index";
  74137. export * from "babylonjs/Engines/index";
  74138. export * from "babylonjs/Events/index";
  74139. export * from "babylonjs/Gamepads/index";
  74140. export * from "babylonjs/Gizmos/index";
  74141. export * from "babylonjs/Helpers/index";
  74142. export * from "babylonjs/Instrumentation/index";
  74143. export * from "babylonjs/Layers/index";
  74144. export * from "babylonjs/LensFlares/index";
  74145. export * from "babylonjs/Lights/index";
  74146. export * from "babylonjs/Loading/index";
  74147. export * from "babylonjs/Materials/index";
  74148. export * from "babylonjs/Maths/index";
  74149. export * from "babylonjs/Meshes/index";
  74150. export * from "babylonjs/Morph/index";
  74151. export * from "babylonjs/Navigation/index";
  74152. export * from "babylonjs/node";
  74153. export * from "babylonjs/Offline/index";
  74154. export * from "babylonjs/Particles/index";
  74155. export * from "babylonjs/Physics/index";
  74156. export * from "babylonjs/PostProcesses/index";
  74157. export * from "babylonjs/Probes/index";
  74158. export * from "babylonjs/Rendering/index";
  74159. export * from "babylonjs/scene";
  74160. export * from "babylonjs/sceneComponent";
  74161. export * from "babylonjs/Sprites/index";
  74162. export * from "babylonjs/States/index";
  74163. export * from "babylonjs/Misc/index";
  74164. export * from "babylonjs/XR/index";
  74165. export * from "babylonjs/types";
  74166. }
  74167. declare module "babylonjs/Animations/pathCursor" {
  74168. import { Vector3 } from "babylonjs/Maths/math.vector";
  74169. import { Path2 } from "babylonjs/Maths/math.path";
  74170. /**
  74171. * A cursor which tracks a point on a path
  74172. */
  74173. export class PathCursor {
  74174. private path;
  74175. /**
  74176. * Stores path cursor callbacks for when an onchange event is triggered
  74177. */
  74178. private _onchange;
  74179. /**
  74180. * The value of the path cursor
  74181. */
  74182. value: number;
  74183. /**
  74184. * The animation array of the path cursor
  74185. */
  74186. animations: Animation[];
  74187. /**
  74188. * Initializes the path cursor
  74189. * @param path The path to track
  74190. */
  74191. constructor(path: Path2);
  74192. /**
  74193. * Gets the cursor point on the path
  74194. * @returns A point on the path cursor at the cursor location
  74195. */
  74196. getPoint(): Vector3;
  74197. /**
  74198. * Moves the cursor ahead by the step amount
  74199. * @param step The amount to move the cursor forward
  74200. * @returns This path cursor
  74201. */
  74202. moveAhead(step?: number): PathCursor;
  74203. /**
  74204. * Moves the cursor behind by the step amount
  74205. * @param step The amount to move the cursor back
  74206. * @returns This path cursor
  74207. */
  74208. moveBack(step?: number): PathCursor;
  74209. /**
  74210. * Moves the cursor by the step amount
  74211. * If the step amount is greater than one, an exception is thrown
  74212. * @param step The amount to move the cursor
  74213. * @returns This path cursor
  74214. */
  74215. move(step: number): PathCursor;
  74216. /**
  74217. * Ensures that the value is limited between zero and one
  74218. * @returns This path cursor
  74219. */
  74220. private ensureLimits;
  74221. /**
  74222. * Runs onchange callbacks on change (used by the animation engine)
  74223. * @returns This path cursor
  74224. */
  74225. private raiseOnChange;
  74226. /**
  74227. * Executes a function on change
  74228. * @param f A path cursor onchange callback
  74229. * @returns This path cursor
  74230. */
  74231. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74232. }
  74233. }
  74234. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74235. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74236. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74237. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74238. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74239. }
  74240. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74241. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74242. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74243. }
  74244. declare module "babylonjs/Engines/Processors/index" {
  74245. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74246. export * from "babylonjs/Engines/Processors/Expressions/index";
  74247. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74248. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74249. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74250. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74251. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74252. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74253. }
  74254. declare module "babylonjs/Legacy/legacy" {
  74255. import * as Babylon from "babylonjs/index";
  74256. export * from "babylonjs/index";
  74257. }
  74258. declare module "babylonjs/Shaders/blur.fragment" {
  74259. /** @hidden */
  74260. export var blurPixelShader: {
  74261. name: string;
  74262. shader: string;
  74263. };
  74264. }
  74265. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74266. /** @hidden */
  74267. export var pointCloudVertexDeclaration: {
  74268. name: string;
  74269. shader: string;
  74270. };
  74271. }
  74272. declare module "babylonjs" {
  74273. export * from "babylonjs/Legacy/legacy";
  74274. }
  74275. declare module BABYLON {
  74276. /** Alias type for value that can be null */
  74277. export type Nullable<T> = T | null;
  74278. /**
  74279. * Alias type for number that are floats
  74280. * @ignorenaming
  74281. */
  74282. export type float = number;
  74283. /**
  74284. * Alias type for number that are doubles.
  74285. * @ignorenaming
  74286. */
  74287. export type double = number;
  74288. /**
  74289. * Alias type for number that are integer
  74290. * @ignorenaming
  74291. */
  74292. export type int = number;
  74293. /** Alias type for number array or Float32Array */
  74294. export type FloatArray = number[] | Float32Array;
  74295. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74296. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74297. /**
  74298. * Alias for types that can be used by a Buffer or VertexBuffer.
  74299. */
  74300. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74301. /**
  74302. * Alias type for primitive types
  74303. * @ignorenaming
  74304. */
  74305. type Primitive = undefined | null | boolean | string | number | Function;
  74306. /**
  74307. * Type modifier to make all the properties of an object Readonly
  74308. */
  74309. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74310. /**
  74311. * Type modifier to make all the properties of an object Readonly recursively
  74312. */
  74313. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74314. /**
  74315. * Type modifier to make object properties readonly.
  74316. */
  74317. export type DeepImmutableObject<T> = {
  74318. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74319. };
  74320. /** @hidden */
  74321. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74322. }
  74323. }
  74324. declare module BABYLON {
  74325. /**
  74326. * A class serves as a medium between the observable and its observers
  74327. */
  74328. export class EventState {
  74329. /**
  74330. * Create a new EventState
  74331. * @param mask defines the mask associated with this state
  74332. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74333. * @param target defines the original target of the state
  74334. * @param currentTarget defines the current target of the state
  74335. */
  74336. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74337. /**
  74338. * Initialize the current event state
  74339. * @param mask defines the mask associated with this state
  74340. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74341. * @param target defines the original target of the state
  74342. * @param currentTarget defines the current target of the state
  74343. * @returns the current event state
  74344. */
  74345. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74346. /**
  74347. * An Observer can set this property to true to prevent subsequent observers of being notified
  74348. */
  74349. skipNextObservers: boolean;
  74350. /**
  74351. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74352. */
  74353. mask: number;
  74354. /**
  74355. * The object that originally notified the event
  74356. */
  74357. target?: any;
  74358. /**
  74359. * The current object in the bubbling phase
  74360. */
  74361. currentTarget?: any;
  74362. /**
  74363. * This will be populated with the return value of the last function that was executed.
  74364. * If it is the first function in the callback chain it will be the event data.
  74365. */
  74366. lastReturnValue?: any;
  74367. }
  74368. /**
  74369. * Represent an Observer registered to a given Observable object.
  74370. */
  74371. export class Observer<T> {
  74372. /**
  74373. * Defines the callback to call when the observer is notified
  74374. */
  74375. callback: (eventData: T, eventState: EventState) => void;
  74376. /**
  74377. * Defines the mask of the observer (used to filter notifications)
  74378. */
  74379. mask: number;
  74380. /**
  74381. * Defines the current scope used to restore the JS context
  74382. */
  74383. scope: any;
  74384. /** @hidden */
  74385. _willBeUnregistered: boolean;
  74386. /**
  74387. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74388. */
  74389. unregisterOnNextCall: boolean;
  74390. /**
  74391. * Creates a new observer
  74392. * @param callback defines the callback to call when the observer is notified
  74393. * @param mask defines the mask of the observer (used to filter notifications)
  74394. * @param scope defines the current scope used to restore the JS context
  74395. */
  74396. constructor(
  74397. /**
  74398. * Defines the callback to call when the observer is notified
  74399. */
  74400. callback: (eventData: T, eventState: EventState) => void,
  74401. /**
  74402. * Defines the mask of the observer (used to filter notifications)
  74403. */
  74404. mask: number,
  74405. /**
  74406. * Defines the current scope used to restore the JS context
  74407. */
  74408. scope?: any);
  74409. }
  74410. /**
  74411. * Represent a list of observers registered to multiple Observables object.
  74412. */
  74413. export class MultiObserver<T> {
  74414. private _observers;
  74415. private _observables;
  74416. /**
  74417. * Release associated resources
  74418. */
  74419. dispose(): void;
  74420. /**
  74421. * Raise a callback when one of the observable will notify
  74422. * @param observables defines a list of observables to watch
  74423. * @param callback defines the callback to call on notification
  74424. * @param mask defines the mask used to filter notifications
  74425. * @param scope defines the current scope used to restore the JS context
  74426. * @returns the new MultiObserver
  74427. */
  74428. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74429. }
  74430. /**
  74431. * The Observable class is a simple implementation of the Observable pattern.
  74432. *
  74433. * 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.
  74434. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74435. * 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).
  74436. * 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.
  74437. */
  74438. export class Observable<T> {
  74439. private _observers;
  74440. private _eventState;
  74441. private _onObserverAdded;
  74442. /**
  74443. * Gets the list of observers
  74444. */
  74445. get observers(): Array<Observer<T>>;
  74446. /**
  74447. * Creates a new observable
  74448. * @param onObserverAdded defines a callback to call when a new observer is added
  74449. */
  74450. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74451. /**
  74452. * Create a new Observer with the specified callback
  74453. * @param callback the callback that will be executed for that Observer
  74454. * @param mask the mask used to filter observers
  74455. * @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.
  74456. * @param scope optional scope for the callback to be called from
  74457. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74458. * @returns the new observer created for the callback
  74459. */
  74460. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74461. /**
  74462. * Create a new Observer with the specified callback and unregisters after the next notification
  74463. * @param callback the callback that will be executed for that Observer
  74464. * @returns the new observer created for the callback
  74465. */
  74466. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74467. /**
  74468. * Remove an Observer from the Observable object
  74469. * @param observer the instance of the Observer to remove
  74470. * @returns false if it doesn't belong to this Observable
  74471. */
  74472. remove(observer: Nullable<Observer<T>>): boolean;
  74473. /**
  74474. * Remove a callback from the Observable object
  74475. * @param callback the callback to remove
  74476. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74477. * @returns false if it doesn't belong to this Observable
  74478. */
  74479. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74480. private _deferUnregister;
  74481. private _remove;
  74482. /**
  74483. * Moves the observable to the top of the observer list making it get called first when notified
  74484. * @param observer the observer to move
  74485. */
  74486. makeObserverTopPriority(observer: Observer<T>): void;
  74487. /**
  74488. * Moves the observable to the bottom of the observer list making it get called last when notified
  74489. * @param observer the observer to move
  74490. */
  74491. makeObserverBottomPriority(observer: Observer<T>): void;
  74492. /**
  74493. * Notify all Observers by calling their respective callback with the given data
  74494. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74495. * @param eventData defines the data to send to all observers
  74496. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74497. * @param target defines the original target of the state
  74498. * @param currentTarget defines the current target of the state
  74499. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74500. */
  74501. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74502. /**
  74503. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74504. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74505. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74506. * and it is crucial that all callbacks will be executed.
  74507. * The order of the callbacks is kept, callbacks are not executed parallel.
  74508. *
  74509. * @param eventData The data to be sent to each callback
  74510. * @param mask is used to filter observers defaults to -1
  74511. * @param target defines the callback target (see EventState)
  74512. * @param currentTarget defines he current object in the bubbling phase
  74513. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74514. */
  74515. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74516. /**
  74517. * Notify a specific observer
  74518. * @param observer defines the observer to notify
  74519. * @param eventData defines the data to be sent to each callback
  74520. * @param mask is used to filter observers defaults to -1
  74521. */
  74522. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74523. /**
  74524. * Gets a boolean indicating if the observable has at least one observer
  74525. * @returns true is the Observable has at least one Observer registered
  74526. */
  74527. hasObservers(): boolean;
  74528. /**
  74529. * Clear the list of observers
  74530. */
  74531. clear(): void;
  74532. /**
  74533. * Clone the current observable
  74534. * @returns a new observable
  74535. */
  74536. clone(): Observable<T>;
  74537. /**
  74538. * Does this observable handles observer registered with a given mask
  74539. * @param mask defines the mask to be tested
  74540. * @return whether or not one observer registered with the given mask is handeled
  74541. **/
  74542. hasSpecificMask(mask?: number): boolean;
  74543. }
  74544. }
  74545. declare module BABYLON {
  74546. /**
  74547. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74548. * Babylon.js
  74549. */
  74550. export class DomManagement {
  74551. /**
  74552. * Checks if the window object exists
  74553. * @returns true if the window object exists
  74554. */
  74555. static IsWindowObjectExist(): boolean;
  74556. /**
  74557. * Checks if the navigator object exists
  74558. * @returns true if the navigator object exists
  74559. */
  74560. static IsNavigatorAvailable(): boolean;
  74561. /**
  74562. * Extracts text content from a DOM element hierarchy
  74563. * @param element defines the root element
  74564. * @returns a string
  74565. */
  74566. static GetDOMTextContent(element: HTMLElement): string;
  74567. }
  74568. }
  74569. declare module BABYLON {
  74570. /**
  74571. * Logger used througouht the application to allow configuration of
  74572. * the log level required for the messages.
  74573. */
  74574. export class Logger {
  74575. /**
  74576. * No log
  74577. */
  74578. static readonly NoneLogLevel: number;
  74579. /**
  74580. * Only message logs
  74581. */
  74582. static readonly MessageLogLevel: number;
  74583. /**
  74584. * Only warning logs
  74585. */
  74586. static readonly WarningLogLevel: number;
  74587. /**
  74588. * Only error logs
  74589. */
  74590. static readonly ErrorLogLevel: number;
  74591. /**
  74592. * All logs
  74593. */
  74594. static readonly AllLogLevel: number;
  74595. private static _LogCache;
  74596. /**
  74597. * Gets a value indicating the number of loading errors
  74598. * @ignorenaming
  74599. */
  74600. static errorsCount: number;
  74601. /**
  74602. * Callback called when a new log is added
  74603. */
  74604. static OnNewCacheEntry: (entry: string) => void;
  74605. private static _AddLogEntry;
  74606. private static _FormatMessage;
  74607. private static _LogDisabled;
  74608. private static _LogEnabled;
  74609. private static _WarnDisabled;
  74610. private static _WarnEnabled;
  74611. private static _ErrorDisabled;
  74612. private static _ErrorEnabled;
  74613. /**
  74614. * Log a message to the console
  74615. */
  74616. static Log: (message: string) => void;
  74617. /**
  74618. * Write a warning message to the console
  74619. */
  74620. static Warn: (message: string) => void;
  74621. /**
  74622. * Write an error message to the console
  74623. */
  74624. static Error: (message: string) => void;
  74625. /**
  74626. * Gets current log cache (list of logs)
  74627. */
  74628. static get LogCache(): string;
  74629. /**
  74630. * Clears the log cache
  74631. */
  74632. static ClearLogCache(): void;
  74633. /**
  74634. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74635. */
  74636. static set LogLevels(level: number);
  74637. }
  74638. }
  74639. declare module BABYLON {
  74640. /** @hidden */
  74641. export class _TypeStore {
  74642. /** @hidden */
  74643. static RegisteredTypes: {
  74644. [key: string]: Object;
  74645. };
  74646. /** @hidden */
  74647. static GetClass(fqdn: string): any;
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. /**
  74652. * Helper to manipulate strings
  74653. */
  74654. export class StringTools {
  74655. /**
  74656. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74657. * @param str Source string
  74658. * @param suffix Suffix to search for in the source string
  74659. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74660. */
  74661. static EndsWith(str: string, suffix: string): boolean;
  74662. /**
  74663. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74664. * @param str Source string
  74665. * @param suffix Suffix to search for in the source string
  74666. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74667. */
  74668. static StartsWith(str: string, suffix: string): boolean;
  74669. /**
  74670. * Decodes a buffer into a string
  74671. * @param buffer The buffer to decode
  74672. * @returns The decoded string
  74673. */
  74674. static Decode(buffer: Uint8Array | Uint16Array): string;
  74675. /**
  74676. * Encode a buffer to a base64 string
  74677. * @param buffer defines the buffer to encode
  74678. * @returns the encoded string
  74679. */
  74680. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74681. /**
  74682. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74683. * @param num the number to convert and pad
  74684. * @param length the expected length of the string
  74685. * @returns the padded string
  74686. */
  74687. static PadNumber(num: number, length: number): string;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /**
  74692. * Class containing a set of static utilities functions for deep copy.
  74693. */
  74694. export class DeepCopier {
  74695. /**
  74696. * Tries to copy an object by duplicating every property
  74697. * @param source defines the source object
  74698. * @param destination defines the target object
  74699. * @param doNotCopyList defines a list of properties to avoid
  74700. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74701. */
  74702. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74703. }
  74704. }
  74705. declare module BABYLON {
  74706. /**
  74707. * Class containing a set of static utilities functions for precision date
  74708. */
  74709. export class PrecisionDate {
  74710. /**
  74711. * Gets either window.performance.now() if supported or Date.now() else
  74712. */
  74713. static get Now(): number;
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /** @hidden */
  74718. export class _DevTools {
  74719. static WarnImport(name: string): string;
  74720. }
  74721. }
  74722. declare module BABYLON {
  74723. /**
  74724. * Interface used to define the mechanism to get data from the network
  74725. */
  74726. export interface IWebRequest {
  74727. /**
  74728. * Returns client's response url
  74729. */
  74730. responseURL: string;
  74731. /**
  74732. * Returns client's status
  74733. */
  74734. status: number;
  74735. /**
  74736. * Returns client's status as a text
  74737. */
  74738. statusText: string;
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74744. */
  74745. export class WebRequest implements IWebRequest {
  74746. private _xhr;
  74747. /**
  74748. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74749. * i.e. when loading files, where the server/service expects an Authorization header
  74750. */
  74751. static CustomRequestHeaders: {
  74752. [key: string]: string;
  74753. };
  74754. /**
  74755. * Add callback functions in this array to update all the requests before they get sent to the network
  74756. */
  74757. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74758. private _injectCustomRequestHeaders;
  74759. /**
  74760. * Gets or sets a function to be called when loading progress changes
  74761. */
  74762. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74763. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74764. /**
  74765. * Returns client's state
  74766. */
  74767. get readyState(): number;
  74768. /**
  74769. * Returns client's status
  74770. */
  74771. get status(): number;
  74772. /**
  74773. * Returns client's status as a text
  74774. */
  74775. get statusText(): string;
  74776. /**
  74777. * Returns client's response
  74778. */
  74779. get response(): any;
  74780. /**
  74781. * Returns client's response url
  74782. */
  74783. get responseURL(): string;
  74784. /**
  74785. * Returns client's response as text
  74786. */
  74787. get responseText(): string;
  74788. /**
  74789. * Gets or sets the expected response type
  74790. */
  74791. get responseType(): XMLHttpRequestResponseType;
  74792. set responseType(value: XMLHttpRequestResponseType);
  74793. /** @hidden */
  74794. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74795. /** @hidden */
  74796. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74797. /**
  74798. * Cancels any network activity
  74799. */
  74800. abort(): void;
  74801. /**
  74802. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74803. * @param body defines an optional request body
  74804. */
  74805. send(body?: Document | BodyInit | null): void;
  74806. /**
  74807. * Sets the request method, request URL
  74808. * @param method defines the method to use (GET, POST, etc..)
  74809. * @param url defines the url to connect with
  74810. */
  74811. open(method: string, url: string): void;
  74812. /**
  74813. * Sets the value of a request header.
  74814. * @param name The name of the header whose value is to be set
  74815. * @param value The value to set as the body of the header
  74816. */
  74817. setRequestHeader(name: string, value: string): void;
  74818. /**
  74819. * Get the string containing the text of a particular header's value.
  74820. * @param name The name of the header
  74821. * @returns The string containing the text of the given header name
  74822. */
  74823. getResponseHeader(name: string): Nullable<string>;
  74824. }
  74825. }
  74826. declare module BABYLON {
  74827. /**
  74828. * File request interface
  74829. */
  74830. export interface IFileRequest {
  74831. /**
  74832. * Raised when the request is complete (success or error).
  74833. */
  74834. onCompleteObservable: Observable<IFileRequest>;
  74835. /**
  74836. * Aborts the request for a file.
  74837. */
  74838. abort: () => void;
  74839. }
  74840. }
  74841. declare module BABYLON {
  74842. /**
  74843. * Define options used to create a render target texture
  74844. */
  74845. export class RenderTargetCreationOptions {
  74846. /**
  74847. * Specifies is mipmaps must be generated
  74848. */
  74849. generateMipMaps?: boolean;
  74850. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74851. generateDepthBuffer?: boolean;
  74852. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74853. generateStencilBuffer?: boolean;
  74854. /** Defines texture type (int by default) */
  74855. type?: number;
  74856. /** Defines sampling mode (trilinear by default) */
  74857. samplingMode?: number;
  74858. /** Defines format (RGBA by default) */
  74859. format?: number;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /** Defines the cross module used constants to avoid circular dependncies */
  74864. export class Constants {
  74865. /** Defines that alpha blending is disabled */
  74866. static readonly ALPHA_DISABLE: number;
  74867. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74868. static readonly ALPHA_ADD: number;
  74869. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74870. static readonly ALPHA_COMBINE: number;
  74871. /** Defines that alpha blending is DEST - SRC * DEST */
  74872. static readonly ALPHA_SUBTRACT: number;
  74873. /** Defines that alpha blending is SRC * DEST */
  74874. static readonly ALPHA_MULTIPLY: number;
  74875. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74876. static readonly ALPHA_MAXIMIZED: number;
  74877. /** Defines that alpha blending is SRC + DEST */
  74878. static readonly ALPHA_ONEONE: number;
  74879. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74880. static readonly ALPHA_PREMULTIPLIED: number;
  74881. /**
  74882. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74883. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74884. */
  74885. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74886. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74887. static readonly ALPHA_INTERPOLATE: number;
  74888. /**
  74889. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74890. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74891. */
  74892. static readonly ALPHA_SCREENMODE: number;
  74893. /**
  74894. * Defines that alpha blending is SRC + DST
  74895. * Alpha will be set to SRC ALPHA + DST ALPHA
  74896. */
  74897. static readonly ALPHA_ONEONE_ONEONE: number;
  74898. /**
  74899. * Defines that alpha blending is SRC * DST ALPHA + DST
  74900. * Alpha will be set to 0
  74901. */
  74902. static readonly ALPHA_ALPHATOCOLOR: number;
  74903. /**
  74904. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74905. */
  74906. static readonly ALPHA_REVERSEONEMINUS: number;
  74907. /**
  74908. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74909. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74910. */
  74911. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74912. /**
  74913. * Defines that alpha blending is SRC + DST
  74914. * Alpha will be set to SRC ALPHA
  74915. */
  74916. static readonly ALPHA_ONEONE_ONEZERO: number;
  74917. /**
  74918. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74919. * Alpha will be set to DST ALPHA
  74920. */
  74921. static readonly ALPHA_EXCLUSION: number;
  74922. /** Defines that alpha blending equation a SUM */
  74923. static readonly ALPHA_EQUATION_ADD: number;
  74924. /** Defines that alpha blending equation a SUBSTRACTION */
  74925. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74926. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74927. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74928. /** Defines that alpha blending equation a MAX operation */
  74929. static readonly ALPHA_EQUATION_MAX: number;
  74930. /** Defines that alpha blending equation a MIN operation */
  74931. static readonly ALPHA_EQUATION_MIN: number;
  74932. /**
  74933. * Defines that alpha blending equation a DARKEN operation:
  74934. * It takes the min of the src and sums the alpha channels.
  74935. */
  74936. static readonly ALPHA_EQUATION_DARKEN: number;
  74937. /** Defines that the ressource is not delayed*/
  74938. static readonly DELAYLOADSTATE_NONE: number;
  74939. /** Defines that the ressource was successfully delay loaded */
  74940. static readonly DELAYLOADSTATE_LOADED: number;
  74941. /** Defines that the ressource is currently delay loading */
  74942. static readonly DELAYLOADSTATE_LOADING: number;
  74943. /** Defines that the ressource is delayed and has not started loading */
  74944. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74946. static readonly NEVER: number;
  74947. /** 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 */
  74948. static readonly ALWAYS: number;
  74949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74950. static readonly LESS: number;
  74951. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74952. static readonly EQUAL: number;
  74953. /** 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 */
  74954. static readonly LEQUAL: number;
  74955. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74956. static readonly GREATER: number;
  74957. /** 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 */
  74958. static readonly GEQUAL: number;
  74959. /** 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 */
  74960. static readonly NOTEQUAL: number;
  74961. /** Passed to stencilOperation to specify that stencil value must be kept */
  74962. static readonly KEEP: number;
  74963. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74964. static readonly REPLACE: number;
  74965. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74966. static readonly INCR: number;
  74967. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74968. static readonly DECR: number;
  74969. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74970. static readonly INVERT: number;
  74971. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74972. static readonly INCR_WRAP: number;
  74973. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74974. static readonly DECR_WRAP: number;
  74975. /** Texture is not repeating outside of 0..1 UVs */
  74976. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74977. /** Texture is repeating outside of 0..1 UVs */
  74978. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74979. /** Texture is repeating and mirrored */
  74980. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74981. /** ALPHA */
  74982. static readonly TEXTUREFORMAT_ALPHA: number;
  74983. /** LUMINANCE */
  74984. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74985. /** LUMINANCE_ALPHA */
  74986. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74987. /** RGB */
  74988. static readonly TEXTUREFORMAT_RGB: number;
  74989. /** RGBA */
  74990. static readonly TEXTUREFORMAT_RGBA: number;
  74991. /** RED */
  74992. static readonly TEXTUREFORMAT_RED: number;
  74993. /** RED (2nd reference) */
  74994. static readonly TEXTUREFORMAT_R: number;
  74995. /** RG */
  74996. static readonly TEXTUREFORMAT_RG: number;
  74997. /** RED_INTEGER */
  74998. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74999. /** RED_INTEGER (2nd reference) */
  75000. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75001. /** RG_INTEGER */
  75002. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75003. /** RGB_INTEGER */
  75004. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75005. /** RGBA_INTEGER */
  75006. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75007. /** UNSIGNED_BYTE */
  75008. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75009. /** UNSIGNED_BYTE (2nd reference) */
  75010. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75011. /** FLOAT */
  75012. static readonly TEXTURETYPE_FLOAT: number;
  75013. /** HALF_FLOAT */
  75014. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75015. /** BYTE */
  75016. static readonly TEXTURETYPE_BYTE: number;
  75017. /** SHORT */
  75018. static readonly TEXTURETYPE_SHORT: number;
  75019. /** UNSIGNED_SHORT */
  75020. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75021. /** INT */
  75022. static readonly TEXTURETYPE_INT: number;
  75023. /** UNSIGNED_INT */
  75024. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75025. /** UNSIGNED_SHORT_4_4_4_4 */
  75026. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75027. /** UNSIGNED_SHORT_5_5_5_1 */
  75028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75029. /** UNSIGNED_SHORT_5_6_5 */
  75030. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75031. /** UNSIGNED_INT_2_10_10_10_REV */
  75032. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75033. /** UNSIGNED_INT_24_8 */
  75034. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75035. /** UNSIGNED_INT_10F_11F_11F_REV */
  75036. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75037. /** UNSIGNED_INT_5_9_9_9_REV */
  75038. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75039. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75040. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75041. /** nearest is mag = nearest and min = nearest and no mip */
  75042. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75043. /** mag = nearest and min = nearest and mip = none */
  75044. static readonly TEXTURE_NEAREST_NEAREST: number;
  75045. /** Bilinear is mag = linear and min = linear and no mip */
  75046. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75047. /** mag = linear and min = linear and mip = none */
  75048. static readonly TEXTURE_LINEAR_LINEAR: number;
  75049. /** Trilinear is mag = linear and min = linear and mip = linear */
  75050. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75051. /** Trilinear is mag = linear and min = linear and mip = linear */
  75052. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75053. /** mag = nearest and min = nearest and mip = nearest */
  75054. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75055. /** mag = nearest and min = linear and mip = nearest */
  75056. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75057. /** mag = nearest and min = linear and mip = linear */
  75058. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75059. /** mag = nearest and min = linear and mip = none */
  75060. static readonly TEXTURE_NEAREST_LINEAR: number;
  75061. /** nearest is mag = nearest and min = nearest and mip = linear */
  75062. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75063. /** mag = linear and min = nearest and mip = nearest */
  75064. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75065. /** mag = linear and min = nearest and mip = linear */
  75066. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75068. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75069. /** mag = linear and min = nearest and mip = none */
  75070. static readonly TEXTURE_LINEAR_NEAREST: number;
  75071. /** Explicit coordinates mode */
  75072. static readonly TEXTURE_EXPLICIT_MODE: number;
  75073. /** Spherical coordinates mode */
  75074. static readonly TEXTURE_SPHERICAL_MODE: number;
  75075. /** Planar coordinates mode */
  75076. static readonly TEXTURE_PLANAR_MODE: number;
  75077. /** Cubic coordinates mode */
  75078. static readonly TEXTURE_CUBIC_MODE: number;
  75079. /** Projection coordinates mode */
  75080. static readonly TEXTURE_PROJECTION_MODE: number;
  75081. /** Skybox coordinates mode */
  75082. static readonly TEXTURE_SKYBOX_MODE: number;
  75083. /** Inverse Cubic coordinates mode */
  75084. static readonly TEXTURE_INVCUBIC_MODE: number;
  75085. /** Equirectangular coordinates mode */
  75086. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75087. /** Equirectangular Fixed coordinates mode */
  75088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75089. /** Equirectangular Fixed Mirrored coordinates mode */
  75090. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75091. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75092. static readonly SCALEMODE_FLOOR: number;
  75093. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75094. static readonly SCALEMODE_NEAREST: number;
  75095. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75096. static readonly SCALEMODE_CEILING: number;
  75097. /**
  75098. * The dirty texture flag value
  75099. */
  75100. static readonly MATERIAL_TextureDirtyFlag: number;
  75101. /**
  75102. * The dirty light flag value
  75103. */
  75104. static readonly MATERIAL_LightDirtyFlag: number;
  75105. /**
  75106. * The dirty fresnel flag value
  75107. */
  75108. static readonly MATERIAL_FresnelDirtyFlag: number;
  75109. /**
  75110. * The dirty attribute flag value
  75111. */
  75112. static readonly MATERIAL_AttributesDirtyFlag: number;
  75113. /**
  75114. * The dirty misc flag value
  75115. */
  75116. static readonly MATERIAL_MiscDirtyFlag: number;
  75117. /**
  75118. * The all dirty flag value
  75119. */
  75120. static readonly MATERIAL_AllDirtyFlag: number;
  75121. /**
  75122. * Returns the triangle fill mode
  75123. */
  75124. static readonly MATERIAL_TriangleFillMode: number;
  75125. /**
  75126. * Returns the wireframe mode
  75127. */
  75128. static readonly MATERIAL_WireFrameFillMode: number;
  75129. /**
  75130. * Returns the point fill mode
  75131. */
  75132. static readonly MATERIAL_PointFillMode: number;
  75133. /**
  75134. * Returns the point list draw mode
  75135. */
  75136. static readonly MATERIAL_PointListDrawMode: number;
  75137. /**
  75138. * Returns the line list draw mode
  75139. */
  75140. static readonly MATERIAL_LineListDrawMode: number;
  75141. /**
  75142. * Returns the line loop draw mode
  75143. */
  75144. static readonly MATERIAL_LineLoopDrawMode: number;
  75145. /**
  75146. * Returns the line strip draw mode
  75147. */
  75148. static readonly MATERIAL_LineStripDrawMode: number;
  75149. /**
  75150. * Returns the triangle strip draw mode
  75151. */
  75152. static readonly MATERIAL_TriangleStripDrawMode: number;
  75153. /**
  75154. * Returns the triangle fan draw mode
  75155. */
  75156. static readonly MATERIAL_TriangleFanDrawMode: number;
  75157. /**
  75158. * Stores the clock-wise side orientation
  75159. */
  75160. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75161. /**
  75162. * Stores the counter clock-wise side orientation
  75163. */
  75164. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75165. /**
  75166. * Nothing
  75167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75168. */
  75169. static readonly ACTION_NothingTrigger: number;
  75170. /**
  75171. * On pick
  75172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75173. */
  75174. static readonly ACTION_OnPickTrigger: number;
  75175. /**
  75176. * On left pick
  75177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75178. */
  75179. static readonly ACTION_OnLeftPickTrigger: number;
  75180. /**
  75181. * On right pick
  75182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75183. */
  75184. static readonly ACTION_OnRightPickTrigger: number;
  75185. /**
  75186. * On center pick
  75187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75188. */
  75189. static readonly ACTION_OnCenterPickTrigger: number;
  75190. /**
  75191. * On pick down
  75192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75193. */
  75194. static readonly ACTION_OnPickDownTrigger: number;
  75195. /**
  75196. * On double pick
  75197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75198. */
  75199. static readonly ACTION_OnDoublePickTrigger: number;
  75200. /**
  75201. * On pick up
  75202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75203. */
  75204. static readonly ACTION_OnPickUpTrigger: number;
  75205. /**
  75206. * On pick out.
  75207. * This trigger will only be raised if you also declared a OnPickDown
  75208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75209. */
  75210. static readonly ACTION_OnPickOutTrigger: number;
  75211. /**
  75212. * On long press
  75213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75214. */
  75215. static readonly ACTION_OnLongPressTrigger: number;
  75216. /**
  75217. * On pointer over
  75218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75219. */
  75220. static readonly ACTION_OnPointerOverTrigger: number;
  75221. /**
  75222. * On pointer out
  75223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75224. */
  75225. static readonly ACTION_OnPointerOutTrigger: number;
  75226. /**
  75227. * On every frame
  75228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75229. */
  75230. static readonly ACTION_OnEveryFrameTrigger: number;
  75231. /**
  75232. * On intersection enter
  75233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75234. */
  75235. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75236. /**
  75237. * On intersection exit
  75238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75239. */
  75240. static readonly ACTION_OnIntersectionExitTrigger: number;
  75241. /**
  75242. * On key down
  75243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75244. */
  75245. static readonly ACTION_OnKeyDownTrigger: number;
  75246. /**
  75247. * On key up
  75248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75249. */
  75250. static readonly ACTION_OnKeyUpTrigger: number;
  75251. /**
  75252. * Billboard mode will only apply to Y axis
  75253. */
  75254. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75255. /**
  75256. * Billboard mode will apply to all axes
  75257. */
  75258. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75259. /**
  75260. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75261. */
  75262. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75263. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75264. * Test order :
  75265. * Is the bounding sphere outside the frustum ?
  75266. * If not, are the bounding box vertices outside the frustum ?
  75267. * It not, then the cullable object is in the frustum.
  75268. */
  75269. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75270. /** Culling strategy : Bounding Sphere Only.
  75271. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75272. * It's also less accurate than the standard because some not visible objects can still be selected.
  75273. * Test : is the bounding sphere outside the frustum ?
  75274. * If not, then the cullable object is in the frustum.
  75275. */
  75276. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75277. /** Culling strategy : Optimistic Inclusion.
  75278. * This in an inclusion test first, then the standard exclusion test.
  75279. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75280. * 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.
  75281. * Anyway, it's as accurate as the standard strategy.
  75282. * Test :
  75283. * Is the cullable object bounding sphere center in the frustum ?
  75284. * If not, apply the default culling strategy.
  75285. */
  75286. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75287. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75288. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75289. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75290. * 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.
  75291. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75292. * Test :
  75293. * Is the cullable object bounding sphere center in the frustum ?
  75294. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75295. */
  75296. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75297. /**
  75298. * No logging while loading
  75299. */
  75300. static readonly SCENELOADER_NO_LOGGING: number;
  75301. /**
  75302. * Minimal logging while loading
  75303. */
  75304. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75305. /**
  75306. * Summary logging while loading
  75307. */
  75308. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75309. /**
  75310. * Detailled logging while loading
  75311. */
  75312. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75313. }
  75314. }
  75315. declare module BABYLON {
  75316. /**
  75317. * This represents the required contract to create a new type of texture loader.
  75318. */
  75319. export interface IInternalTextureLoader {
  75320. /**
  75321. * Defines wether the loader supports cascade loading the different faces.
  75322. */
  75323. supportCascades: boolean;
  75324. /**
  75325. * This returns if the loader support the current file information.
  75326. * @param extension defines the file extension of the file being loaded
  75327. * @returns true if the loader can load the specified file
  75328. */
  75329. canLoad(extension: string): boolean;
  75330. /**
  75331. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75332. * @param data contains the texture data
  75333. * @param texture defines the BabylonJS internal texture
  75334. * @param createPolynomials will be true if polynomials have been requested
  75335. * @param onLoad defines the callback to trigger once the texture is ready
  75336. * @param onError defines the callback to trigger in case of error
  75337. */
  75338. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75339. /**
  75340. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75341. * @param data contains the texture data
  75342. * @param texture defines the BabylonJS internal texture
  75343. * @param callback defines the method to call once ready to upload
  75344. */
  75345. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75346. }
  75347. }
  75348. declare module BABYLON {
  75349. /**
  75350. * Class used to store and describe the pipeline context associated with an effect
  75351. */
  75352. export interface IPipelineContext {
  75353. /**
  75354. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75355. */
  75356. isAsync: boolean;
  75357. /**
  75358. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75359. */
  75360. isReady: boolean;
  75361. /** @hidden */
  75362. _getVertexShaderCode(): string | null;
  75363. /** @hidden */
  75364. _getFragmentShaderCode(): string | null;
  75365. /** @hidden */
  75366. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75367. }
  75368. }
  75369. declare module BABYLON {
  75370. /**
  75371. * Class used to store gfx data (like WebGLBuffer)
  75372. */
  75373. export class DataBuffer {
  75374. /**
  75375. * Gets or sets the number of objects referencing this buffer
  75376. */
  75377. references: number;
  75378. /** Gets or sets the size of the underlying buffer */
  75379. capacity: number;
  75380. /**
  75381. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75382. */
  75383. is32Bits: boolean;
  75384. /**
  75385. * Gets the underlying buffer
  75386. */
  75387. get underlyingResource(): any;
  75388. }
  75389. }
  75390. declare module BABYLON {
  75391. /** @hidden */
  75392. export interface IShaderProcessor {
  75393. attributeProcessor?: (attribute: string) => string;
  75394. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75395. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75396. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75397. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75398. lineProcessor?: (line: string, isFragment: boolean) => string;
  75399. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75400. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75401. }
  75402. }
  75403. declare module BABYLON {
  75404. /** @hidden */
  75405. export interface ProcessingOptions {
  75406. defines: string[];
  75407. indexParameters: any;
  75408. isFragment: boolean;
  75409. shouldUseHighPrecisionShader: boolean;
  75410. supportsUniformBuffers: boolean;
  75411. shadersRepository: string;
  75412. includesShadersStore: {
  75413. [key: string]: string;
  75414. };
  75415. processor?: IShaderProcessor;
  75416. version: string;
  75417. platformName: string;
  75418. lookForClosingBracketForUniformBuffer?: boolean;
  75419. }
  75420. }
  75421. declare module BABYLON {
  75422. /** @hidden */
  75423. export class ShaderCodeNode {
  75424. line: string;
  75425. children: ShaderCodeNode[];
  75426. additionalDefineKey?: string;
  75427. additionalDefineValue?: string;
  75428. isValid(preprocessors: {
  75429. [key: string]: string;
  75430. }): boolean;
  75431. process(preprocessors: {
  75432. [key: string]: string;
  75433. }, options: ProcessingOptions): string;
  75434. }
  75435. }
  75436. declare module BABYLON {
  75437. /** @hidden */
  75438. export class ShaderCodeCursor {
  75439. private _lines;
  75440. lineIndex: number;
  75441. get currentLine(): string;
  75442. get canRead(): boolean;
  75443. set lines(value: string[]);
  75444. }
  75445. }
  75446. declare module BABYLON {
  75447. /** @hidden */
  75448. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75449. process(preprocessors: {
  75450. [key: string]: string;
  75451. }, options: ProcessingOptions): string;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /** @hidden */
  75456. export class ShaderDefineExpression {
  75457. isTrue(preprocessors: {
  75458. [key: string]: string;
  75459. }): boolean;
  75460. private static OperatorPriority;
  75461. private static Stack;
  75462. static postfixToInfix(postfix: string[]): string;
  75463. static infixToPostfix(infix: string): string[];
  75464. }
  75465. }
  75466. declare module BABYLON {
  75467. /** @hidden */
  75468. export class ShaderCodeTestNode extends ShaderCodeNode {
  75469. testExpression: ShaderDefineExpression;
  75470. isValid(preprocessors: {
  75471. [key: string]: string;
  75472. }): boolean;
  75473. }
  75474. }
  75475. declare module BABYLON {
  75476. /** @hidden */
  75477. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75478. define: string;
  75479. not: boolean;
  75480. constructor(define: string, not?: boolean);
  75481. isTrue(preprocessors: {
  75482. [key: string]: string;
  75483. }): boolean;
  75484. }
  75485. }
  75486. declare module BABYLON {
  75487. /** @hidden */
  75488. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75489. leftOperand: ShaderDefineExpression;
  75490. rightOperand: ShaderDefineExpression;
  75491. isTrue(preprocessors: {
  75492. [key: string]: string;
  75493. }): boolean;
  75494. }
  75495. }
  75496. declare module BABYLON {
  75497. /** @hidden */
  75498. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75499. leftOperand: ShaderDefineExpression;
  75500. rightOperand: ShaderDefineExpression;
  75501. isTrue(preprocessors: {
  75502. [key: string]: string;
  75503. }): boolean;
  75504. }
  75505. }
  75506. declare module BABYLON {
  75507. /** @hidden */
  75508. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75509. define: string;
  75510. operand: string;
  75511. testValue: string;
  75512. constructor(define: string, operand: string, testValue: string);
  75513. isTrue(preprocessors: {
  75514. [key: string]: string;
  75515. }): boolean;
  75516. }
  75517. }
  75518. declare module BABYLON {
  75519. /**
  75520. * Class used to enable access to offline support
  75521. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75522. */
  75523. export interface IOfflineProvider {
  75524. /**
  75525. * Gets a boolean indicating if scene must be saved in the database
  75526. */
  75527. enableSceneOffline: boolean;
  75528. /**
  75529. * Gets a boolean indicating if textures must be saved in the database
  75530. */
  75531. enableTexturesOffline: boolean;
  75532. /**
  75533. * Open the offline support and make it available
  75534. * @param successCallback defines the callback to call on success
  75535. * @param errorCallback defines the callback to call on error
  75536. */
  75537. open(successCallback: () => void, errorCallback: () => void): void;
  75538. /**
  75539. * Loads an image from the offline support
  75540. * @param url defines the url to load from
  75541. * @param image defines the target DOM image
  75542. */
  75543. loadImage(url: string, image: HTMLImageElement): void;
  75544. /**
  75545. * Loads a file from offline support
  75546. * @param url defines the URL to load from
  75547. * @param sceneLoaded defines a callback to call on success
  75548. * @param progressCallBack defines a callback to call when progress changed
  75549. * @param errorCallback defines a callback to call on error
  75550. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75551. */
  75552. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75553. }
  75554. }
  75555. declare module BABYLON {
  75556. /**
  75557. * Class used to help managing file picking and drag'n'drop
  75558. * File Storage
  75559. */
  75560. export class FilesInputStore {
  75561. /**
  75562. * List of files ready to be loaded
  75563. */
  75564. static FilesToLoad: {
  75565. [key: string]: File;
  75566. };
  75567. }
  75568. }
  75569. declare module BABYLON {
  75570. /**
  75571. * Class used to define a retry strategy when error happens while loading assets
  75572. */
  75573. export class RetryStrategy {
  75574. /**
  75575. * Function used to defines an exponential back off strategy
  75576. * @param maxRetries defines the maximum number of retries (3 by default)
  75577. * @param baseInterval defines the interval between retries
  75578. * @returns the strategy function to use
  75579. */
  75580. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75581. }
  75582. }
  75583. declare module BABYLON {
  75584. /**
  75585. * @ignore
  75586. * Application error to support additional information when loading a file
  75587. */
  75588. export abstract class BaseError extends Error {
  75589. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75590. }
  75591. }
  75592. declare module BABYLON {
  75593. /** @ignore */
  75594. export class LoadFileError extends BaseError {
  75595. request?: WebRequest;
  75596. file?: File;
  75597. /**
  75598. * Creates a new LoadFileError
  75599. * @param message defines the message of the error
  75600. * @param request defines the optional web request
  75601. * @param file defines the optional file
  75602. */
  75603. constructor(message: string, object?: WebRequest | File);
  75604. }
  75605. /** @ignore */
  75606. export class RequestFileError extends BaseError {
  75607. request: WebRequest;
  75608. /**
  75609. * Creates a new LoadFileError
  75610. * @param message defines the message of the error
  75611. * @param request defines the optional web request
  75612. */
  75613. constructor(message: string, request: WebRequest);
  75614. }
  75615. /** @ignore */
  75616. export class ReadFileError extends BaseError {
  75617. file: File;
  75618. /**
  75619. * Creates a new ReadFileError
  75620. * @param message defines the message of the error
  75621. * @param file defines the optional file
  75622. */
  75623. constructor(message: string, file: File);
  75624. }
  75625. /**
  75626. * @hidden
  75627. */
  75628. export class FileTools {
  75629. /**
  75630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75631. */
  75632. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75633. /**
  75634. * Gets or sets the base URL to use to load assets
  75635. */
  75636. static BaseUrl: string;
  75637. /**
  75638. * Default behaviour for cors in the application.
  75639. * It can be a string if the expected behavior is identical in the entire app.
  75640. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75641. */
  75642. static CorsBehavior: string | ((url: string | string[]) => string);
  75643. /**
  75644. * Gets or sets a function used to pre-process url before using them to load assets
  75645. */
  75646. static PreprocessUrl: (url: string) => string;
  75647. /**
  75648. * Removes unwanted characters from an url
  75649. * @param url defines the url to clean
  75650. * @returns the cleaned url
  75651. */
  75652. private static _CleanUrl;
  75653. /**
  75654. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75655. * @param url define the url we are trying
  75656. * @param element define the dom element where to configure the cors policy
  75657. */
  75658. static SetCorsBehavior(url: string | string[], element: {
  75659. crossOrigin: string | null;
  75660. }): void;
  75661. /**
  75662. * Loads an image as an HTMLImageElement.
  75663. * @param input url string, ArrayBuffer, or Blob to load
  75664. * @param onLoad callback called when the image successfully loads
  75665. * @param onError callback called when the image fails to load
  75666. * @param offlineProvider offline provider for caching
  75667. * @param mimeType optional mime type
  75668. * @returns the HTMLImageElement of the loaded image
  75669. */
  75670. 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>;
  75671. /**
  75672. * Reads a file from a File object
  75673. * @param file defines the file to load
  75674. * @param onSuccess defines the callback to call when data is loaded
  75675. * @param onProgress defines the callback to call during loading process
  75676. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75677. * @param onError defines the callback to call when an error occurs
  75678. * @returns a file request object
  75679. */
  75680. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75681. /**
  75682. * Loads a file from a url
  75683. * @param url url to load
  75684. * @param onSuccess callback called when the file successfully loads
  75685. * @param onProgress callback called while file is loading (if the server supports this mode)
  75686. * @param offlineProvider defines the offline provider for caching
  75687. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75688. * @param onError callback called when the file fails to load
  75689. * @returns a file request object
  75690. */
  75691. 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;
  75692. /**
  75693. * Loads a file
  75694. * @param url url to load
  75695. * @param onSuccess callback called when the file successfully loads
  75696. * @param onProgress callback called while file is loading (if the server supports this mode)
  75697. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75698. * @param onError callback called when the file fails to load
  75699. * @param onOpened callback called when the web request is opened
  75700. * @returns a file request object
  75701. */
  75702. 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;
  75703. /**
  75704. * Checks if the loaded document was accessed via `file:`-Protocol.
  75705. * @returns boolean
  75706. */
  75707. static IsFileURL(): boolean;
  75708. }
  75709. }
  75710. declare module BABYLON {
  75711. /** @hidden */
  75712. export class ShaderProcessor {
  75713. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75714. private static _ProcessPrecision;
  75715. private static _ExtractOperation;
  75716. private static _BuildSubExpression;
  75717. private static _BuildExpression;
  75718. private static _MoveCursorWithinIf;
  75719. private static _MoveCursor;
  75720. private static _EvaluatePreProcessors;
  75721. private static _PreparePreProcessors;
  75722. private static _ProcessShaderConversion;
  75723. private static _ProcessIncludes;
  75724. /**
  75725. * Loads a file from a url
  75726. * @param url url to load
  75727. * @param onSuccess callback called when the file successfully loads
  75728. * @param onProgress callback called while file is loading (if the server supports this mode)
  75729. * @param offlineProvider defines the offline provider for caching
  75730. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75731. * @param onError callback called when the file fails to load
  75732. * @returns a file request object
  75733. * @hidden
  75734. */
  75735. 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;
  75736. }
  75737. }
  75738. declare module BABYLON {
  75739. /**
  75740. * @hidden
  75741. */
  75742. export interface IColor4Like {
  75743. r: float;
  75744. g: float;
  75745. b: float;
  75746. a: float;
  75747. }
  75748. /**
  75749. * @hidden
  75750. */
  75751. export interface IColor3Like {
  75752. r: float;
  75753. g: float;
  75754. b: float;
  75755. }
  75756. /**
  75757. * @hidden
  75758. */
  75759. export interface IVector4Like {
  75760. x: float;
  75761. y: float;
  75762. z: float;
  75763. w: float;
  75764. }
  75765. /**
  75766. * @hidden
  75767. */
  75768. export interface IVector3Like {
  75769. x: float;
  75770. y: float;
  75771. z: float;
  75772. }
  75773. /**
  75774. * @hidden
  75775. */
  75776. export interface IVector2Like {
  75777. x: float;
  75778. y: float;
  75779. }
  75780. /**
  75781. * @hidden
  75782. */
  75783. export interface IMatrixLike {
  75784. toArray(): DeepImmutable<Float32Array>;
  75785. updateFlag: int;
  75786. }
  75787. /**
  75788. * @hidden
  75789. */
  75790. export interface IViewportLike {
  75791. x: float;
  75792. y: float;
  75793. width: float;
  75794. height: float;
  75795. }
  75796. /**
  75797. * @hidden
  75798. */
  75799. export interface IPlaneLike {
  75800. normal: IVector3Like;
  75801. d: float;
  75802. normalize(): void;
  75803. }
  75804. }
  75805. declare module BABYLON {
  75806. /**
  75807. * Interface used to define common properties for effect fallbacks
  75808. */
  75809. export interface IEffectFallbacks {
  75810. /**
  75811. * Removes the defines that should be removed when falling back.
  75812. * @param currentDefines defines the current define statements for the shader.
  75813. * @param effect defines the current effect we try to compile
  75814. * @returns The resulting defines with defines of the current rank removed.
  75815. */
  75816. reduce(currentDefines: string, effect: Effect): string;
  75817. /**
  75818. * Removes the fallback from the bound mesh.
  75819. */
  75820. unBindMesh(): void;
  75821. /**
  75822. * Checks to see if more fallbacks are still availible.
  75823. */
  75824. hasMoreFallbacks: boolean;
  75825. }
  75826. }
  75827. declare module BABYLON {
  75828. /**
  75829. * Class used to evalaute queries containing `and` and `or` operators
  75830. */
  75831. export class AndOrNotEvaluator {
  75832. /**
  75833. * Evaluate a query
  75834. * @param query defines the query to evaluate
  75835. * @param evaluateCallback defines the callback used to filter result
  75836. * @returns true if the query matches
  75837. */
  75838. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75839. private static _HandleParenthesisContent;
  75840. private static _SimplifyNegation;
  75841. }
  75842. }
  75843. declare module BABYLON {
  75844. /**
  75845. * Class used to store custom tags
  75846. */
  75847. export class Tags {
  75848. /**
  75849. * Adds support for tags on the given object
  75850. * @param obj defines the object to use
  75851. */
  75852. static EnableFor(obj: any): void;
  75853. /**
  75854. * Removes tags support
  75855. * @param obj defines the object to use
  75856. */
  75857. static DisableFor(obj: any): void;
  75858. /**
  75859. * Gets a boolean indicating if the given object has tags
  75860. * @param obj defines the object to use
  75861. * @returns a boolean
  75862. */
  75863. static HasTags(obj: any): boolean;
  75864. /**
  75865. * Gets the tags available on a given object
  75866. * @param obj defines the object to use
  75867. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75868. * @returns the tags
  75869. */
  75870. static GetTags(obj: any, asString?: boolean): any;
  75871. /**
  75872. * Adds tags to an object
  75873. * @param obj defines the object to use
  75874. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75875. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75876. */
  75877. static AddTagsTo(obj: any, tagsString: string): void;
  75878. /**
  75879. * @hidden
  75880. */
  75881. static _AddTagTo(obj: any, tag: string): void;
  75882. /**
  75883. * Removes specific tags from a specific object
  75884. * @param obj defines the object to use
  75885. * @param tagsString defines the tags to remove
  75886. */
  75887. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75888. /**
  75889. * @hidden
  75890. */
  75891. static _RemoveTagFrom(obj: any, tag: string): void;
  75892. /**
  75893. * Defines if tags hosted on an object match a given query
  75894. * @param obj defines the object to use
  75895. * @param tagsQuery defines the tag query
  75896. * @returns a boolean
  75897. */
  75898. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75899. }
  75900. }
  75901. declare module BABYLON {
  75902. /**
  75903. * Scalar computation library
  75904. */
  75905. export class Scalar {
  75906. /**
  75907. * Two pi constants convenient for computation.
  75908. */
  75909. static TwoPi: number;
  75910. /**
  75911. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75912. * @param a number
  75913. * @param b number
  75914. * @param epsilon (default = 1.401298E-45)
  75915. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75916. */
  75917. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75918. /**
  75919. * Returns a string : the upper case translation of the number i to hexadecimal.
  75920. * @param i number
  75921. * @returns the upper case translation of the number i to hexadecimal.
  75922. */
  75923. static ToHex(i: number): string;
  75924. /**
  75925. * Returns -1 if value is negative and +1 is value is positive.
  75926. * @param value the value
  75927. * @returns the value itself if it's equal to zero.
  75928. */
  75929. static Sign(value: number): number;
  75930. /**
  75931. * Returns the value itself if it's between min and max.
  75932. * Returns min if the value is lower than min.
  75933. * Returns max if the value is greater than max.
  75934. * @param value the value to clmap
  75935. * @param min the min value to clamp to (default: 0)
  75936. * @param max the max value to clamp to (default: 1)
  75937. * @returns the clamped value
  75938. */
  75939. static Clamp(value: number, min?: number, max?: number): number;
  75940. /**
  75941. * the log2 of value.
  75942. * @param value the value to compute log2 of
  75943. * @returns the log2 of value.
  75944. */
  75945. static Log2(value: number): number;
  75946. /**
  75947. * Loops the value, so that it is never larger than length and never smaller than 0.
  75948. *
  75949. * This is similar to the modulo operator but it works with floating point numbers.
  75950. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75951. * With t = 5 and length = 2.5, the result would be 0.0.
  75952. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75953. * @param value the value
  75954. * @param length the length
  75955. * @returns the looped value
  75956. */
  75957. static Repeat(value: number, length: number): number;
  75958. /**
  75959. * Normalize the value between 0.0 and 1.0 using min and max values
  75960. * @param value value to normalize
  75961. * @param min max to normalize between
  75962. * @param max min to normalize between
  75963. * @returns the normalized value
  75964. */
  75965. static Normalize(value: number, min: number, max: number): number;
  75966. /**
  75967. * Denormalize the value from 0.0 and 1.0 using min and max values
  75968. * @param normalized value to denormalize
  75969. * @param min max to denormalize between
  75970. * @param max min to denormalize between
  75971. * @returns the denormalized value
  75972. */
  75973. static Denormalize(normalized: number, min: number, max: number): number;
  75974. /**
  75975. * Calculates the shortest difference between two given angles given in degrees.
  75976. * @param current current angle in degrees
  75977. * @param target target angle in degrees
  75978. * @returns the delta
  75979. */
  75980. static DeltaAngle(current: number, target: number): number;
  75981. /**
  75982. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75983. * @param tx value
  75984. * @param length length
  75985. * @returns The returned value will move back and forth between 0 and length
  75986. */
  75987. static PingPong(tx: number, length: number): number;
  75988. /**
  75989. * Interpolates between min and max with smoothing at the limits.
  75990. *
  75991. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75992. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75993. * @param from from
  75994. * @param to to
  75995. * @param tx value
  75996. * @returns the smooth stepped value
  75997. */
  75998. static SmoothStep(from: number, to: number, tx: number): number;
  75999. /**
  76000. * Moves a value current towards target.
  76001. *
  76002. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76003. * Negative values of maxDelta pushes the value away from target.
  76004. * @param current current value
  76005. * @param target target value
  76006. * @param maxDelta max distance to move
  76007. * @returns resulting value
  76008. */
  76009. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76010. /**
  76011. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76012. *
  76013. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76014. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76015. * @param current current value
  76016. * @param target target value
  76017. * @param maxDelta max distance to move
  76018. * @returns resulting angle
  76019. */
  76020. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76021. /**
  76022. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76023. * @param start start value
  76024. * @param end target value
  76025. * @param amount amount to lerp between
  76026. * @returns the lerped value
  76027. */
  76028. static Lerp(start: number, end: number, amount: number): number;
  76029. /**
  76030. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76031. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76032. * @param start start value
  76033. * @param end target value
  76034. * @param amount amount to lerp between
  76035. * @returns the lerped value
  76036. */
  76037. static LerpAngle(start: number, end: number, amount: number): number;
  76038. /**
  76039. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76040. * @param a start value
  76041. * @param b target value
  76042. * @param value value between a and b
  76043. * @returns the inverseLerp value
  76044. */
  76045. static InverseLerp(a: number, b: number, value: number): number;
  76046. /**
  76047. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76048. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76049. * @param value1 spline value
  76050. * @param tangent1 spline value
  76051. * @param value2 spline value
  76052. * @param tangent2 spline value
  76053. * @param amount input value
  76054. * @returns hermite result
  76055. */
  76056. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76057. /**
  76058. * Returns a random float number between and min and max values
  76059. * @param min min value of random
  76060. * @param max max value of random
  76061. * @returns random value
  76062. */
  76063. static RandomRange(min: number, max: number): number;
  76064. /**
  76065. * This function returns percentage of a number in a given range.
  76066. *
  76067. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76068. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76069. * @param number to convert to percentage
  76070. * @param min min range
  76071. * @param max max range
  76072. * @returns the percentage
  76073. */
  76074. static RangeToPercent(number: number, min: number, max: number): number;
  76075. /**
  76076. * This function returns number that corresponds to the percentage in a given range.
  76077. *
  76078. * PercentToRange(0.34,0,100) will return 34.
  76079. * @param percent to convert to number
  76080. * @param min min range
  76081. * @param max max range
  76082. * @returns the number
  76083. */
  76084. static PercentToRange(percent: number, min: number, max: number): number;
  76085. /**
  76086. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76087. * @param angle The angle to normalize in radian.
  76088. * @return The converted angle.
  76089. */
  76090. static NormalizeRadians(angle: number): number;
  76091. }
  76092. }
  76093. declare module BABYLON {
  76094. /**
  76095. * Constant used to convert a value to gamma space
  76096. * @ignorenaming
  76097. */
  76098. export const ToGammaSpace: number;
  76099. /**
  76100. * Constant used to convert a value to linear space
  76101. * @ignorenaming
  76102. */
  76103. export const ToLinearSpace = 2.2;
  76104. /**
  76105. * Constant used to define the minimal number value in Babylon.js
  76106. * @ignorenaming
  76107. */
  76108. let Epsilon: number;
  76109. }
  76110. declare module BABYLON {
  76111. /**
  76112. * Class used to represent a viewport on screen
  76113. */
  76114. export class Viewport {
  76115. /** viewport left coordinate */
  76116. x: number;
  76117. /** viewport top coordinate */
  76118. y: number;
  76119. /**viewport width */
  76120. width: number;
  76121. /** viewport height */
  76122. height: number;
  76123. /**
  76124. * Creates a Viewport object located at (x, y) and sized (width, height)
  76125. * @param x defines viewport left coordinate
  76126. * @param y defines viewport top coordinate
  76127. * @param width defines the viewport width
  76128. * @param height defines the viewport height
  76129. */
  76130. constructor(
  76131. /** viewport left coordinate */
  76132. x: number,
  76133. /** viewport top coordinate */
  76134. y: number,
  76135. /**viewport width */
  76136. width: number,
  76137. /** viewport height */
  76138. height: number);
  76139. /**
  76140. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76141. * @param renderWidth defines the rendering width
  76142. * @param renderHeight defines the rendering height
  76143. * @returns a new Viewport
  76144. */
  76145. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76146. /**
  76147. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76148. * @param renderWidth defines the rendering width
  76149. * @param renderHeight defines the rendering height
  76150. * @param ref defines the target viewport
  76151. * @returns the current viewport
  76152. */
  76153. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76154. /**
  76155. * Returns a new Viewport copied from the current one
  76156. * @returns a new Viewport
  76157. */
  76158. clone(): Viewport;
  76159. }
  76160. }
  76161. declare module BABYLON {
  76162. /**
  76163. * Class containing a set of static utilities functions for arrays.
  76164. */
  76165. export class ArrayTools {
  76166. /**
  76167. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76168. * @param size the number of element to construct and put in the array
  76169. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76170. * @returns a new array filled with new objects
  76171. */
  76172. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76173. }
  76174. }
  76175. declare module BABYLON {
  76176. /**
  76177. * Class representing a vector containing 2 coordinates
  76178. */
  76179. export class Vector2 {
  76180. /** defines the first coordinate */
  76181. x: number;
  76182. /** defines the second coordinate */
  76183. y: number;
  76184. /**
  76185. * Creates a new Vector2 from the given x and y coordinates
  76186. * @param x defines the first coordinate
  76187. * @param y defines the second coordinate
  76188. */
  76189. constructor(
  76190. /** defines the first coordinate */
  76191. x?: number,
  76192. /** defines the second coordinate */
  76193. y?: number);
  76194. /**
  76195. * Gets a string with the Vector2 coordinates
  76196. * @returns a string with the Vector2 coordinates
  76197. */
  76198. toString(): string;
  76199. /**
  76200. * Gets class name
  76201. * @returns the string "Vector2"
  76202. */
  76203. getClassName(): string;
  76204. /**
  76205. * Gets current vector hash code
  76206. * @returns the Vector2 hash code as a number
  76207. */
  76208. getHashCode(): number;
  76209. /**
  76210. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76211. * @param array defines the source array
  76212. * @param index defines the offset in source array
  76213. * @returns the current Vector2
  76214. */
  76215. toArray(array: FloatArray, index?: number): Vector2;
  76216. /**
  76217. * Copy the current vector to an array
  76218. * @returns a new array with 2 elements: the Vector2 coordinates.
  76219. */
  76220. asArray(): number[];
  76221. /**
  76222. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76223. * @param source defines the source Vector2
  76224. * @returns the current updated Vector2
  76225. */
  76226. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76227. /**
  76228. * Sets the Vector2 coordinates with the given floats
  76229. * @param x defines the first coordinate
  76230. * @param y defines the second coordinate
  76231. * @returns the current updated Vector2
  76232. */
  76233. copyFromFloats(x: number, y: number): Vector2;
  76234. /**
  76235. * Sets the Vector2 coordinates with the given floats
  76236. * @param x defines the first coordinate
  76237. * @param y defines the second coordinate
  76238. * @returns the current updated Vector2
  76239. */
  76240. set(x: number, y: number): Vector2;
  76241. /**
  76242. * Add another vector with the current one
  76243. * @param otherVector defines the other vector
  76244. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76245. */
  76246. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76247. /**
  76248. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76249. * @param otherVector defines the other vector
  76250. * @param result defines the target vector
  76251. * @returns the unmodified current Vector2
  76252. */
  76253. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76254. /**
  76255. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76256. * @param otherVector defines the other vector
  76257. * @returns the current updated Vector2
  76258. */
  76259. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76260. /**
  76261. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76262. * @param otherVector defines the other vector
  76263. * @returns a new Vector2
  76264. */
  76265. addVector3(otherVector: Vector3): Vector2;
  76266. /**
  76267. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76268. * @param otherVector defines the other vector
  76269. * @returns a new Vector2
  76270. */
  76271. subtract(otherVector: Vector2): Vector2;
  76272. /**
  76273. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76274. * @param otherVector defines the other vector
  76275. * @param result defines the target vector
  76276. * @returns the unmodified current Vector2
  76277. */
  76278. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76279. /**
  76280. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76281. * @param otherVector defines the other vector
  76282. * @returns the current updated Vector2
  76283. */
  76284. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76285. /**
  76286. * Multiplies in place the current Vector2 coordinates by the given ones
  76287. * @param otherVector defines the other vector
  76288. * @returns the current updated Vector2
  76289. */
  76290. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76291. /**
  76292. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76293. * @param otherVector defines the other vector
  76294. * @returns a new Vector2
  76295. */
  76296. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76297. /**
  76298. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76299. * @param otherVector defines the other vector
  76300. * @param result defines the target vector
  76301. * @returns the unmodified current Vector2
  76302. */
  76303. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76304. /**
  76305. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76306. * @param x defines the first coordinate
  76307. * @param y defines the second coordinate
  76308. * @returns a new Vector2
  76309. */
  76310. multiplyByFloats(x: number, y: number): Vector2;
  76311. /**
  76312. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76313. * @param otherVector defines the other vector
  76314. * @returns a new Vector2
  76315. */
  76316. divide(otherVector: Vector2): Vector2;
  76317. /**
  76318. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76319. * @param otherVector defines the other vector
  76320. * @param result defines the target vector
  76321. * @returns the unmodified current Vector2
  76322. */
  76323. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76324. /**
  76325. * Divides the current Vector2 coordinates by the given ones
  76326. * @param otherVector defines the other vector
  76327. * @returns the current updated Vector2
  76328. */
  76329. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76330. /**
  76331. * Gets a new Vector2 with current Vector2 negated coordinates
  76332. * @returns a new Vector2
  76333. */
  76334. negate(): Vector2;
  76335. /**
  76336. * Negate this vector in place
  76337. * @returns this
  76338. */
  76339. negateInPlace(): Vector2;
  76340. /**
  76341. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76342. * @param result defines the Vector3 object where to store the result
  76343. * @returns the current Vector2
  76344. */
  76345. negateToRef(result: Vector2): Vector2;
  76346. /**
  76347. * Multiply the Vector2 coordinates by scale
  76348. * @param scale defines the scaling factor
  76349. * @returns the current updated Vector2
  76350. */
  76351. scaleInPlace(scale: number): Vector2;
  76352. /**
  76353. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76354. * @param scale defines the scaling factor
  76355. * @returns a new Vector2
  76356. */
  76357. scale(scale: number): Vector2;
  76358. /**
  76359. * Scale the current Vector2 values by a factor to a given Vector2
  76360. * @param scale defines the scale factor
  76361. * @param result defines the Vector2 object where to store the result
  76362. * @returns the unmodified current Vector2
  76363. */
  76364. scaleToRef(scale: number, result: Vector2): Vector2;
  76365. /**
  76366. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76367. * @param scale defines the scale factor
  76368. * @param result defines the Vector2 object where to store the result
  76369. * @returns the unmodified current Vector2
  76370. */
  76371. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76372. /**
  76373. * Gets a boolean if two vectors are equals
  76374. * @param otherVector defines the other vector
  76375. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76376. */
  76377. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76378. /**
  76379. * Gets a boolean if two vectors are equals (using an epsilon value)
  76380. * @param otherVector defines the other vector
  76381. * @param epsilon defines the minimal distance to consider equality
  76382. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76383. */
  76384. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76385. /**
  76386. * Gets a new Vector2 from current Vector2 floored values
  76387. * @returns a new Vector2
  76388. */
  76389. floor(): Vector2;
  76390. /**
  76391. * Gets a new Vector2 from current Vector2 floored values
  76392. * @returns a new Vector2
  76393. */
  76394. fract(): Vector2;
  76395. /**
  76396. * Gets the length of the vector
  76397. * @returns the vector length (float)
  76398. */
  76399. length(): number;
  76400. /**
  76401. * Gets the vector squared length
  76402. * @returns the vector squared length (float)
  76403. */
  76404. lengthSquared(): number;
  76405. /**
  76406. * Normalize the vector
  76407. * @returns the current updated Vector2
  76408. */
  76409. normalize(): Vector2;
  76410. /**
  76411. * Gets a new Vector2 copied from the Vector2
  76412. * @returns a new Vector2
  76413. */
  76414. clone(): Vector2;
  76415. /**
  76416. * Gets a new Vector2(0, 0)
  76417. * @returns a new Vector2
  76418. */
  76419. static Zero(): Vector2;
  76420. /**
  76421. * Gets a new Vector2(1, 1)
  76422. * @returns a new Vector2
  76423. */
  76424. static One(): Vector2;
  76425. /**
  76426. * Gets a new Vector2 set from the given index element of the given array
  76427. * @param array defines the data source
  76428. * @param offset defines the offset in the data source
  76429. * @returns a new Vector2
  76430. */
  76431. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76432. /**
  76433. * Sets "result" from the given index element of the given array
  76434. * @param array defines the data source
  76435. * @param offset defines the offset in the data source
  76436. * @param result defines the target vector
  76437. */
  76438. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76439. /**
  76440. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76441. * @param value1 defines 1st point of control
  76442. * @param value2 defines 2nd point of control
  76443. * @param value3 defines 3rd point of control
  76444. * @param value4 defines 4th point of control
  76445. * @param amount defines the interpolation factor
  76446. * @returns a new Vector2
  76447. */
  76448. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76449. /**
  76450. * 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".
  76451. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76452. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76453. * @param value defines the value to clamp
  76454. * @param min defines the lower limit
  76455. * @param max defines the upper limit
  76456. * @returns a new Vector2
  76457. */
  76458. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76459. /**
  76460. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76461. * @param value1 defines the 1st control point
  76462. * @param tangent1 defines the outgoing tangent
  76463. * @param value2 defines the 2nd control point
  76464. * @param tangent2 defines the incoming tangent
  76465. * @param amount defines the interpolation factor
  76466. * @returns a new Vector2
  76467. */
  76468. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76469. /**
  76470. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76471. * @param start defines the start vector
  76472. * @param end defines the end vector
  76473. * @param amount defines the interpolation factor
  76474. * @returns a new Vector2
  76475. */
  76476. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76477. /**
  76478. * Gets the dot product of the vector "left" and the vector "right"
  76479. * @param left defines first vector
  76480. * @param right defines second vector
  76481. * @returns the dot product (float)
  76482. */
  76483. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76484. /**
  76485. * Returns a new Vector2 equal to the normalized given vector
  76486. * @param vector defines the vector to normalize
  76487. * @returns a new Vector2
  76488. */
  76489. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76490. /**
  76491. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76492. * @param left defines 1st vector
  76493. * @param right defines 2nd vector
  76494. * @returns a new Vector2
  76495. */
  76496. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76497. /**
  76498. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76499. * @param left defines 1st vector
  76500. * @param right defines 2nd vector
  76501. * @returns a new Vector2
  76502. */
  76503. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76504. /**
  76505. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76506. * @param vector defines the vector to transform
  76507. * @param transformation defines the matrix to apply
  76508. * @returns a new Vector2
  76509. */
  76510. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76511. /**
  76512. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76513. * @param vector defines the vector to transform
  76514. * @param transformation defines the matrix to apply
  76515. * @param result defines the target vector
  76516. */
  76517. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76518. /**
  76519. * Determines if a given vector is included in a triangle
  76520. * @param p defines the vector to test
  76521. * @param p0 defines 1st triangle point
  76522. * @param p1 defines 2nd triangle point
  76523. * @param p2 defines 3rd triangle point
  76524. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76525. */
  76526. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76527. /**
  76528. * Gets the distance between the vectors "value1" and "value2"
  76529. * @param value1 defines first vector
  76530. * @param value2 defines second vector
  76531. * @returns the distance between vectors
  76532. */
  76533. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76534. /**
  76535. * Returns the squared distance between the vectors "value1" and "value2"
  76536. * @param value1 defines first vector
  76537. * @param value2 defines second vector
  76538. * @returns the squared distance between vectors
  76539. */
  76540. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76541. /**
  76542. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76543. * @param value1 defines first vector
  76544. * @param value2 defines second vector
  76545. * @returns a new Vector2
  76546. */
  76547. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76548. /**
  76549. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76550. * @param p defines the middle point
  76551. * @param segA defines one point of the segment
  76552. * @param segB defines the other point of the segment
  76553. * @returns the shortest distance
  76554. */
  76555. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76556. }
  76557. /**
  76558. * Class used to store (x,y,z) vector representation
  76559. * A Vector3 is the main object used in 3D geometry
  76560. * It can represent etiher the coordinates of a point the space, either a direction
  76561. * Reminder: js uses a left handed forward facing system
  76562. */
  76563. export class Vector3 {
  76564. /**
  76565. * Defines the first coordinates (on X axis)
  76566. */
  76567. x: number;
  76568. /**
  76569. * Defines the second coordinates (on Y axis)
  76570. */
  76571. y: number;
  76572. /**
  76573. * Defines the third coordinates (on Z axis)
  76574. */
  76575. z: number;
  76576. private static _UpReadOnly;
  76577. private static _ZeroReadOnly;
  76578. /**
  76579. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76580. * @param x defines the first coordinates (on X axis)
  76581. * @param y defines the second coordinates (on Y axis)
  76582. * @param z defines the third coordinates (on Z axis)
  76583. */
  76584. constructor(
  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. /**
  76598. * Creates a string representation of the Vector3
  76599. * @returns a string with the Vector3 coordinates.
  76600. */
  76601. toString(): string;
  76602. /**
  76603. * Gets the class name
  76604. * @returns the string "Vector3"
  76605. */
  76606. getClassName(): string;
  76607. /**
  76608. * Creates the Vector3 hash code
  76609. * @returns a number which tends to be unique between Vector3 instances
  76610. */
  76611. getHashCode(): number;
  76612. /**
  76613. * Creates an array containing three elements : the coordinates of the Vector3
  76614. * @returns a new array of numbers
  76615. */
  76616. asArray(): number[];
  76617. /**
  76618. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76619. * @param array defines the destination array
  76620. * @param index defines the offset in the destination array
  76621. * @returns the current Vector3
  76622. */
  76623. toArray(array: FloatArray, index?: number): Vector3;
  76624. /**
  76625. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76626. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76627. */
  76628. toQuaternion(): Quaternion;
  76629. /**
  76630. * Adds the given vector to the current Vector3
  76631. * @param otherVector defines the second operand
  76632. * @returns the current updated Vector3
  76633. */
  76634. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76635. /**
  76636. * Adds the given coordinates to the current Vector3
  76637. * @param x defines the x coordinate of the operand
  76638. * @param y defines the y coordinate of the operand
  76639. * @param z defines the z coordinate of the operand
  76640. * @returns the current updated Vector3
  76641. */
  76642. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76643. /**
  76644. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76645. * @param otherVector defines the second operand
  76646. * @returns the resulting Vector3
  76647. */
  76648. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76649. /**
  76650. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76651. * @param otherVector defines the second operand
  76652. * @param result defines the Vector3 object where to store the result
  76653. * @returns the current Vector3
  76654. */
  76655. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76656. /**
  76657. * Subtract the given vector from the current Vector3
  76658. * @param otherVector defines the second operand
  76659. * @returns the current updated Vector3
  76660. */
  76661. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76662. /**
  76663. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76664. * @param otherVector defines the second operand
  76665. * @returns the resulting Vector3
  76666. */
  76667. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76668. /**
  76669. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76670. * @param otherVector defines the second operand
  76671. * @param result defines the Vector3 object where to store the result
  76672. * @returns the current Vector3
  76673. */
  76674. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76675. /**
  76676. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76677. * @param x defines the x coordinate of the operand
  76678. * @param y defines the y coordinate of the operand
  76679. * @param z defines the z coordinate of the operand
  76680. * @returns the resulting Vector3
  76681. */
  76682. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76683. /**
  76684. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76685. * @param x defines the x coordinate of the operand
  76686. * @param y defines the y coordinate of the operand
  76687. * @param z defines the z coordinate of the operand
  76688. * @param result defines the Vector3 object where to store the result
  76689. * @returns the current Vector3
  76690. */
  76691. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76692. /**
  76693. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76694. * @returns a new Vector3
  76695. */
  76696. negate(): Vector3;
  76697. /**
  76698. * Negate this vector in place
  76699. * @returns this
  76700. */
  76701. negateInPlace(): Vector3;
  76702. /**
  76703. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76704. * @param result defines the Vector3 object where to store the result
  76705. * @returns the current Vector3
  76706. */
  76707. negateToRef(result: Vector3): Vector3;
  76708. /**
  76709. * Multiplies the Vector3 coordinates by the float "scale"
  76710. * @param scale defines the multiplier factor
  76711. * @returns the current updated Vector3
  76712. */
  76713. scaleInPlace(scale: number): Vector3;
  76714. /**
  76715. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76716. * @param scale defines the multiplier factor
  76717. * @returns a new Vector3
  76718. */
  76719. scale(scale: number): Vector3;
  76720. /**
  76721. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76722. * @param scale defines the multiplier factor
  76723. * @param result defines the Vector3 object where to store the result
  76724. * @returns the current Vector3
  76725. */
  76726. scaleToRef(scale: number, result: Vector3): Vector3;
  76727. /**
  76728. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76729. * @param scale defines the scale factor
  76730. * @param result defines the Vector3 object where to store the result
  76731. * @returns the unmodified current Vector3
  76732. */
  76733. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76734. /**
  76735. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76736. * @param otherVector defines the second operand
  76737. * @returns true if both vectors are equals
  76738. */
  76739. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76740. /**
  76741. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76742. * @param otherVector defines the second operand
  76743. * @param epsilon defines the minimal distance to define values as equals
  76744. * @returns true if both vectors are distant less than epsilon
  76745. */
  76746. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76747. /**
  76748. * Returns true if the current Vector3 coordinates equals the given floats
  76749. * @param x defines the x coordinate of the operand
  76750. * @param y defines the y coordinate of the operand
  76751. * @param z defines the z coordinate of the operand
  76752. * @returns true if both vectors are equals
  76753. */
  76754. equalsToFloats(x: number, y: number, z: number): boolean;
  76755. /**
  76756. * Multiplies the current Vector3 coordinates by the given ones
  76757. * @param otherVector defines the second operand
  76758. * @returns the current updated Vector3
  76759. */
  76760. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76761. /**
  76762. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76763. * @param otherVector defines the second operand
  76764. * @returns the new Vector3
  76765. */
  76766. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76767. /**
  76768. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76769. * @param otherVector defines the second operand
  76770. * @param result defines the Vector3 object where to store the result
  76771. * @returns the current Vector3
  76772. */
  76773. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76774. /**
  76775. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76776. * @param x defines the x coordinate of the operand
  76777. * @param y defines the y coordinate of the operand
  76778. * @param z defines the z coordinate of the operand
  76779. * @returns the new Vector3
  76780. */
  76781. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76782. /**
  76783. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76784. * @param otherVector defines the second operand
  76785. * @returns the new Vector3
  76786. */
  76787. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76788. /**
  76789. * Divides the current Vector3 coordinates by the given ones 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. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76795. /**
  76796. * Divides the current Vector3 coordinates by the given ones.
  76797. * @param otherVector defines the second operand
  76798. * @returns the current updated Vector3
  76799. */
  76800. divideInPlace(otherVector: Vector3): Vector3;
  76801. /**
  76802. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76803. * @param other defines the second operand
  76804. * @returns the current updated Vector3
  76805. */
  76806. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76807. /**
  76808. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76809. * @param other defines the second operand
  76810. * @returns the current updated Vector3
  76811. */
  76812. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76813. /**
  76814. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76815. * @param x defines the x coordinate of the operand
  76816. * @param y defines the y coordinate of the operand
  76817. * @param z defines the z coordinate of the operand
  76818. * @returns the current updated Vector3
  76819. */
  76820. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76821. /**
  76822. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76823. * @param x defines the x coordinate of the operand
  76824. * @param y defines the y coordinate of the operand
  76825. * @param z defines the z coordinate of the operand
  76826. * @returns the current updated Vector3
  76827. */
  76828. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76829. /**
  76830. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76831. * Check if is non uniform within a certain amount of decimal places to account for this
  76832. * @param epsilon the amount the values can differ
  76833. * @returns if the the vector is non uniform to a certain number of decimal places
  76834. */
  76835. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76836. /**
  76837. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76838. */
  76839. get isNonUniform(): boolean;
  76840. /**
  76841. * Gets a new Vector3 from current Vector3 floored values
  76842. * @returns a new Vector3
  76843. */
  76844. floor(): Vector3;
  76845. /**
  76846. * Gets a new Vector3 from current Vector3 floored values
  76847. * @returns a new Vector3
  76848. */
  76849. fract(): Vector3;
  76850. /**
  76851. * Gets the length of the Vector3
  76852. * @returns the length of the Vector3
  76853. */
  76854. length(): number;
  76855. /**
  76856. * Gets the squared length of the Vector3
  76857. * @returns squared length of the Vector3
  76858. */
  76859. lengthSquared(): number;
  76860. /**
  76861. * Normalize the current Vector3.
  76862. * Please note that this is an in place operation.
  76863. * @returns the current updated Vector3
  76864. */
  76865. normalize(): Vector3;
  76866. /**
  76867. * Reorders the x y z properties of the vector in place
  76868. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76869. * @returns the current updated vector
  76870. */
  76871. reorderInPlace(order: string): this;
  76872. /**
  76873. * Rotates the vector around 0,0,0 by a quaternion
  76874. * @param quaternion the rotation quaternion
  76875. * @param result vector to store the result
  76876. * @returns the resulting vector
  76877. */
  76878. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76879. /**
  76880. * Rotates a vector around a given point
  76881. * @param quaternion the rotation quaternion
  76882. * @param point the point to rotate around
  76883. * @param result vector to store the result
  76884. * @returns the resulting vector
  76885. */
  76886. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76887. /**
  76888. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76889. * The cross product is then orthogonal to both current and "other"
  76890. * @param other defines the right operand
  76891. * @returns the cross product
  76892. */
  76893. cross(other: Vector3): Vector3;
  76894. /**
  76895. * Normalize the current Vector3 with the given input length.
  76896. * Please note that this is an in place operation.
  76897. * @param len the length of the vector
  76898. * @returns the current updated Vector3
  76899. */
  76900. normalizeFromLength(len: number): Vector3;
  76901. /**
  76902. * Normalize the current Vector3 to a new vector
  76903. * @returns the new Vector3
  76904. */
  76905. normalizeToNew(): Vector3;
  76906. /**
  76907. * Normalize the current Vector3 to the reference
  76908. * @param reference define the Vector3 to update
  76909. * @returns the updated Vector3
  76910. */
  76911. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76912. /**
  76913. * Creates a new Vector3 copied from the current Vector3
  76914. * @returns the new Vector3
  76915. */
  76916. clone(): Vector3;
  76917. /**
  76918. * Copies the given vector coordinates to the current Vector3 ones
  76919. * @param source defines the source Vector3
  76920. * @returns the current updated Vector3
  76921. */
  76922. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76923. /**
  76924. * Copies the given floats to the current Vector3 coordinates
  76925. * @param x defines the x coordinate of the operand
  76926. * @param y defines the y coordinate of the operand
  76927. * @param z defines the z coordinate of the operand
  76928. * @returns the current updated Vector3
  76929. */
  76930. copyFromFloats(x: number, y: number, z: number): Vector3;
  76931. /**
  76932. * Copies the given floats to the current Vector3 coordinates
  76933. * @param x defines the x coordinate of the operand
  76934. * @param y defines the y coordinate of the operand
  76935. * @param z defines the z coordinate of the operand
  76936. * @returns the current updated Vector3
  76937. */
  76938. set(x: number, y: number, z: number): Vector3;
  76939. /**
  76940. * Copies the given float to the current Vector3 coordinates
  76941. * @param v defines the x, y and z coordinates of the operand
  76942. * @returns the current updated Vector3
  76943. */
  76944. setAll(v: number): Vector3;
  76945. /**
  76946. * Get the clip factor between two vectors
  76947. * @param vector0 defines the first operand
  76948. * @param vector1 defines the second operand
  76949. * @param axis defines the axis to use
  76950. * @param size defines the size along the axis
  76951. * @returns the clip factor
  76952. */
  76953. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76954. /**
  76955. * Get angle between two vectors
  76956. * @param vector0 angle between vector0 and vector1
  76957. * @param vector1 angle between vector0 and vector1
  76958. * @param normal direction of the normal
  76959. * @return the angle between vector0 and vector1
  76960. */
  76961. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76962. /**
  76963. * Returns a new Vector3 set from the index "offset" of the given array
  76964. * @param array defines the source array
  76965. * @param offset defines the offset in the source array
  76966. * @returns the new Vector3
  76967. */
  76968. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76969. /**
  76970. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76971. * @param array defines the source array
  76972. * @param offset defines the offset in the source array
  76973. * @returns the new Vector3
  76974. * @deprecated Please use FromArray instead.
  76975. */
  76976. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76977. /**
  76978. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76979. * @param array defines the source array
  76980. * @param offset defines the offset in the source array
  76981. * @param result defines the Vector3 where to store the result
  76982. */
  76983. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76984. /**
  76985. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76986. * @param array defines the source array
  76987. * @param offset defines the offset in the source array
  76988. * @param result defines the Vector3 where to store the result
  76989. * @deprecated Please use FromArrayToRef instead.
  76990. */
  76991. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76992. /**
  76993. * Sets the given vector "result" with the given floats.
  76994. * @param x defines the x coordinate of the source
  76995. * @param y defines the y coordinate of the source
  76996. * @param z defines the z coordinate of the source
  76997. * @param result defines the Vector3 where to store the result
  76998. */
  76999. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77000. /**
  77001. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77002. * @returns a new empty Vector3
  77003. */
  77004. static Zero(): Vector3;
  77005. /**
  77006. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77007. * @returns a new unit Vector3
  77008. */
  77009. static One(): Vector3;
  77010. /**
  77011. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77012. * @returns a new up Vector3
  77013. */
  77014. static Up(): Vector3;
  77015. /**
  77016. * Gets a up Vector3 that must not be updated
  77017. */
  77018. static get UpReadOnly(): DeepImmutable<Vector3>;
  77019. /**
  77020. * Gets a zero Vector3 that must not be updated
  77021. */
  77022. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77023. /**
  77024. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77025. * @returns a new down Vector3
  77026. */
  77027. static Down(): Vector3;
  77028. /**
  77029. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77030. * @returns a new forward Vector3
  77031. */
  77032. static Forward(): Vector3;
  77033. /**
  77034. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77035. * @returns a new forward Vector3
  77036. */
  77037. static Backward(): Vector3;
  77038. /**
  77039. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77040. * @returns a new right Vector3
  77041. */
  77042. static Right(): Vector3;
  77043. /**
  77044. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77045. * @returns a new left Vector3
  77046. */
  77047. static Left(): Vector3;
  77048. /**
  77049. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77050. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77051. * @param vector defines the Vector3 to transform
  77052. * @param transformation defines the transformation matrix
  77053. * @returns the transformed Vector3
  77054. */
  77055. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77056. /**
  77057. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77058. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77059. * @param vector defines the Vector3 to transform
  77060. * @param transformation defines the transformation matrix
  77061. * @param result defines the Vector3 where to store the result
  77062. */
  77063. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77064. /**
  77065. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77066. * This method computes tranformed coordinates only, not transformed direction vectors
  77067. * @param x define the x coordinate of the source vector
  77068. * @param y define the y coordinate of the source vector
  77069. * @param z define the z coordinate of the source vector
  77070. * @param transformation defines the transformation matrix
  77071. * @param result defines the Vector3 where to store the result
  77072. */
  77073. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77074. /**
  77075. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77076. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77077. * @param vector defines the Vector3 to transform
  77078. * @param transformation defines the transformation matrix
  77079. * @returns the new Vector3
  77080. */
  77081. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77082. /**
  77083. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77084. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77085. * @param vector defines the Vector3 to transform
  77086. * @param transformation defines the transformation matrix
  77087. * @param result defines the Vector3 where to store the result
  77088. */
  77089. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77090. /**
  77091. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77092. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77093. * @param x define the x coordinate of the source vector
  77094. * @param y define the y coordinate of the source vector
  77095. * @param z define the z coordinate of the source vector
  77096. * @param transformation defines the transformation matrix
  77097. * @param result defines the Vector3 where to store the result
  77098. */
  77099. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77100. /**
  77101. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77102. * @param value1 defines the first control point
  77103. * @param value2 defines the second control point
  77104. * @param value3 defines the third control point
  77105. * @param value4 defines the fourth control point
  77106. * @param amount defines the amount on the spline to use
  77107. * @returns the new Vector3
  77108. */
  77109. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77110. /**
  77111. * 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"
  77112. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77113. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77114. * @param value defines the current value
  77115. * @param min defines the lower range value
  77116. * @param max defines the upper range value
  77117. * @returns the new Vector3
  77118. */
  77119. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77120. /**
  77121. * 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"
  77122. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77123. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77124. * @param value defines the current value
  77125. * @param min defines the lower range value
  77126. * @param max defines the upper range value
  77127. * @param result defines the Vector3 where to store the result
  77128. */
  77129. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77130. /**
  77131. * Checks if a given vector is inside a specific range
  77132. * @param v defines the vector to test
  77133. * @param min defines the minimum range
  77134. * @param max defines the maximum range
  77135. */
  77136. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77137. /**
  77138. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77139. * @param value1 defines the first control point
  77140. * @param tangent1 defines the first tangent vector
  77141. * @param value2 defines the second control point
  77142. * @param tangent2 defines the second tangent vector
  77143. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77144. * @returns the new Vector3
  77145. */
  77146. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77147. /**
  77148. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77149. * @param start defines the start value
  77150. * @param end defines the end value
  77151. * @param amount max defines amount between both (between 0 and 1)
  77152. * @returns the new Vector3
  77153. */
  77154. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77155. /**
  77156. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77157. * @param start defines the start value
  77158. * @param end defines the end value
  77159. * @param amount max defines amount between both (between 0 and 1)
  77160. * @param result defines the Vector3 where to store the result
  77161. */
  77162. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77163. /**
  77164. * Returns the dot product (float) between the vectors "left" and "right"
  77165. * @param left defines the left operand
  77166. * @param right defines the right operand
  77167. * @returns the dot product
  77168. */
  77169. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77170. /**
  77171. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77172. * The cross product is then orthogonal to both "left" and "right"
  77173. * @param left defines the left operand
  77174. * @param right defines the right operand
  77175. * @returns the cross product
  77176. */
  77177. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77178. /**
  77179. * Sets the given vector "result" with the cross product of "left" and "right"
  77180. * The cross product is then orthogonal to both "left" and "right"
  77181. * @param left defines the left operand
  77182. * @param right defines the right operand
  77183. * @param result defines the Vector3 where to store the result
  77184. */
  77185. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77186. /**
  77187. * Returns a new Vector3 as the normalization of the given vector
  77188. * @param vector defines the Vector3 to normalize
  77189. * @returns the new Vector3
  77190. */
  77191. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77192. /**
  77193. * Sets the given vector "result" with the normalization of the given first vector
  77194. * @param vector defines the Vector3 to normalize
  77195. * @param result defines the Vector3 where to store the result
  77196. */
  77197. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77198. /**
  77199. * Project a Vector3 onto screen space
  77200. * @param vector defines the Vector3 to project
  77201. * @param world defines the world matrix to use
  77202. * @param transform defines the transform (view x projection) matrix to use
  77203. * @param viewport defines the screen viewport to use
  77204. * @returns the new Vector3
  77205. */
  77206. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77207. /** @hidden */
  77208. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77209. /**
  77210. * Unproject from screen space to object space
  77211. * @param source defines the screen space Vector3 to use
  77212. * @param viewportWidth defines the current width of the viewport
  77213. * @param viewportHeight defines the current height of the viewport
  77214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77215. * @param transform defines the transform (view x projection) matrix to use
  77216. * @returns the new Vector3
  77217. */
  77218. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77219. /**
  77220. * Unproject from screen space to object space
  77221. * @param source defines the screen space Vector3 to use
  77222. * @param viewportWidth defines the current width of the viewport
  77223. * @param viewportHeight defines the current height of the viewport
  77224. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77225. * @param view defines the view matrix to use
  77226. * @param projection defines the projection matrix to use
  77227. * @returns the new Vector3
  77228. */
  77229. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77230. /**
  77231. * Unproject from screen space to object space
  77232. * @param source defines the screen space Vector3 to use
  77233. * @param viewportWidth defines the current width of the viewport
  77234. * @param viewportHeight defines the current height of the viewport
  77235. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77236. * @param view defines the view matrix to use
  77237. * @param projection defines the projection matrix to use
  77238. * @param result defines the Vector3 where to store the result
  77239. */
  77240. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77241. /**
  77242. * Unproject from screen space to object space
  77243. * @param sourceX defines the screen space x coordinate to use
  77244. * @param sourceY defines the screen space y coordinate to use
  77245. * @param sourceZ defines the screen space z coordinate to use
  77246. * @param viewportWidth defines the current width of the viewport
  77247. * @param viewportHeight defines the current height of the viewport
  77248. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77249. * @param view defines the view matrix to use
  77250. * @param projection defines the projection matrix to use
  77251. * @param result defines the Vector3 where to store the result
  77252. */
  77253. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77254. /**
  77255. * Gets the minimal coordinate values between two Vector3
  77256. * @param left defines the first operand
  77257. * @param right defines the second operand
  77258. * @returns the new Vector3
  77259. */
  77260. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77261. /**
  77262. * Gets the maximal coordinate values between two Vector3
  77263. * @param left defines the first operand
  77264. * @param right defines the second operand
  77265. * @returns the new Vector3
  77266. */
  77267. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77268. /**
  77269. * Returns the distance between the vectors "value1" and "value2"
  77270. * @param value1 defines the first operand
  77271. * @param value2 defines the second operand
  77272. * @returns the distance
  77273. */
  77274. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77275. /**
  77276. * Returns the squared distance between the vectors "value1" and "value2"
  77277. * @param value1 defines the first operand
  77278. * @param value2 defines the second operand
  77279. * @returns the squared distance
  77280. */
  77281. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77282. /**
  77283. * Returns a new Vector3 located at the center between "value1" and "value2"
  77284. * @param value1 defines the first operand
  77285. * @param value2 defines the second operand
  77286. * @returns the new Vector3
  77287. */
  77288. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77289. /**
  77290. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77291. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77292. * to something in order to rotate it from its local system to the given target system
  77293. * Note: axis1, axis2 and axis3 are normalized during this operation
  77294. * @param axis1 defines the first axis
  77295. * @param axis2 defines the second axis
  77296. * @param axis3 defines the third axis
  77297. * @returns a new Vector3
  77298. */
  77299. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77300. /**
  77301. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77302. * @param axis1 defines the first axis
  77303. * @param axis2 defines the second axis
  77304. * @param axis3 defines the third axis
  77305. * @param ref defines the Vector3 where to store the result
  77306. */
  77307. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77308. }
  77309. /**
  77310. * Vector4 class created for EulerAngle class conversion to Quaternion
  77311. */
  77312. export class Vector4 {
  77313. /** x value of the vector */
  77314. x: number;
  77315. /** y value of the vector */
  77316. y: number;
  77317. /** z value of the vector */
  77318. z: number;
  77319. /** w value of the vector */
  77320. w: number;
  77321. /**
  77322. * Creates a Vector4 object from the given floats.
  77323. * @param x x value of the vector
  77324. * @param y y value of the vector
  77325. * @param z z value of the vector
  77326. * @param w w value of the vector
  77327. */
  77328. constructor(
  77329. /** x value of the vector */
  77330. x: number,
  77331. /** y value of the vector */
  77332. y: number,
  77333. /** z value of the vector */
  77334. z: number,
  77335. /** w value of the vector */
  77336. w: number);
  77337. /**
  77338. * Returns the string with the Vector4 coordinates.
  77339. * @returns a string containing all the vector values
  77340. */
  77341. toString(): string;
  77342. /**
  77343. * Returns the string "Vector4".
  77344. * @returns "Vector4"
  77345. */
  77346. getClassName(): string;
  77347. /**
  77348. * Returns the Vector4 hash code.
  77349. * @returns a unique hash code
  77350. */
  77351. getHashCode(): number;
  77352. /**
  77353. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77354. * @returns the resulting array
  77355. */
  77356. asArray(): number[];
  77357. /**
  77358. * Populates the given array from the given index with the Vector4 coordinates.
  77359. * @param array array to populate
  77360. * @param index index of the array to start at (default: 0)
  77361. * @returns the Vector4.
  77362. */
  77363. toArray(array: FloatArray, index?: number): Vector4;
  77364. /**
  77365. * Adds the given vector to the current Vector4.
  77366. * @param otherVector the vector to add
  77367. * @returns the updated Vector4.
  77368. */
  77369. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77370. /**
  77371. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77372. * @param otherVector the vector to add
  77373. * @returns the resulting vector
  77374. */
  77375. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77376. /**
  77377. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77378. * @param otherVector the vector to add
  77379. * @param result the vector to store the result
  77380. * @returns the current Vector4.
  77381. */
  77382. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77383. /**
  77384. * Subtract in place the given vector from the current Vector4.
  77385. * @param otherVector the vector to subtract
  77386. * @returns the updated Vector4.
  77387. */
  77388. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77389. /**
  77390. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77391. * @param otherVector the vector to add
  77392. * @returns the new vector with the result
  77393. */
  77394. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77395. /**
  77396. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77397. * @param otherVector the vector to subtract
  77398. * @param result the vector to store the result
  77399. * @returns the current Vector4.
  77400. */
  77401. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77402. /**
  77403. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77404. */
  77405. /**
  77406. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77407. * @param x value to subtract
  77408. * @param y value to subtract
  77409. * @param z value to subtract
  77410. * @param w value to subtract
  77411. * @returns new vector containing the result
  77412. */
  77413. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77414. /**
  77415. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77416. * @param x value to subtract
  77417. * @param y value to subtract
  77418. * @param z value to subtract
  77419. * @param w value to subtract
  77420. * @param result the vector to store the result in
  77421. * @returns the current Vector4.
  77422. */
  77423. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77424. /**
  77425. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77426. * @returns a new vector with the negated values
  77427. */
  77428. negate(): Vector4;
  77429. /**
  77430. * Negate this vector in place
  77431. * @returns this
  77432. */
  77433. negateInPlace(): Vector4;
  77434. /**
  77435. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77436. * @param result defines the Vector3 object where to store the result
  77437. * @returns the current Vector4
  77438. */
  77439. negateToRef(result: Vector4): Vector4;
  77440. /**
  77441. * Multiplies the current Vector4 coordinates by scale (float).
  77442. * @param scale the number to scale with
  77443. * @returns the updated Vector4.
  77444. */
  77445. scaleInPlace(scale: number): Vector4;
  77446. /**
  77447. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77448. * @param scale the number to scale with
  77449. * @returns a new vector with the result
  77450. */
  77451. scale(scale: number): Vector4;
  77452. /**
  77453. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77454. * @param scale the number to scale with
  77455. * @param result a vector to store the result in
  77456. * @returns the current Vector4.
  77457. */
  77458. scaleToRef(scale: number, result: Vector4): Vector4;
  77459. /**
  77460. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77461. * @param scale defines the scale factor
  77462. * @param result defines the Vector4 object where to store the result
  77463. * @returns the unmodified current Vector4
  77464. */
  77465. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77466. /**
  77467. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77468. * @param otherVector the vector to compare against
  77469. * @returns true if they are equal
  77470. */
  77471. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77472. /**
  77473. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77474. * @param otherVector vector to compare against
  77475. * @param epsilon (Default: very small number)
  77476. * @returns true if they are equal
  77477. */
  77478. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77479. /**
  77480. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77481. * @param x x value to compare against
  77482. * @param y y value to compare against
  77483. * @param z z value to compare against
  77484. * @param w w value to compare against
  77485. * @returns true if equal
  77486. */
  77487. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77488. /**
  77489. * Multiplies in place the current Vector4 by the given one.
  77490. * @param otherVector vector to multiple with
  77491. * @returns the updated Vector4.
  77492. */
  77493. multiplyInPlace(otherVector: Vector4): Vector4;
  77494. /**
  77495. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77496. * @param otherVector vector to multiple with
  77497. * @returns resulting new vector
  77498. */
  77499. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77500. /**
  77501. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77502. * @param otherVector vector to multiple with
  77503. * @param result vector to store the result
  77504. * @returns the current Vector4.
  77505. */
  77506. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77507. /**
  77508. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77509. * @param x x value multiply with
  77510. * @param y y value multiply with
  77511. * @param z z value multiply with
  77512. * @param w w value multiply with
  77513. * @returns resulting new vector
  77514. */
  77515. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77516. /**
  77517. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77518. * @param otherVector vector to devide with
  77519. * @returns resulting new vector
  77520. */
  77521. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77522. /**
  77523. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77524. * @param otherVector vector to devide with
  77525. * @param result vector to store the result
  77526. * @returns the current Vector4.
  77527. */
  77528. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77529. /**
  77530. * Divides the current Vector3 coordinates by the given ones.
  77531. * @param otherVector vector to devide with
  77532. * @returns the updated Vector3.
  77533. */
  77534. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77535. /**
  77536. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77537. * @param other defines the second operand
  77538. * @returns the current updated Vector4
  77539. */
  77540. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77541. /**
  77542. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77543. * @param other defines the second operand
  77544. * @returns the current updated Vector4
  77545. */
  77546. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77547. /**
  77548. * Gets a new Vector4 from current Vector4 floored values
  77549. * @returns a new Vector4
  77550. */
  77551. floor(): Vector4;
  77552. /**
  77553. * Gets a new Vector4 from current Vector3 floored values
  77554. * @returns a new Vector4
  77555. */
  77556. fract(): Vector4;
  77557. /**
  77558. * Returns the Vector4 length (float).
  77559. * @returns the length
  77560. */
  77561. length(): number;
  77562. /**
  77563. * Returns the Vector4 squared length (float).
  77564. * @returns the length squared
  77565. */
  77566. lengthSquared(): number;
  77567. /**
  77568. * Normalizes in place the Vector4.
  77569. * @returns the updated Vector4.
  77570. */
  77571. normalize(): Vector4;
  77572. /**
  77573. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77574. * @returns this converted to a new vector3
  77575. */
  77576. toVector3(): Vector3;
  77577. /**
  77578. * Returns a new Vector4 copied from the current one.
  77579. * @returns the new cloned vector
  77580. */
  77581. clone(): Vector4;
  77582. /**
  77583. * Updates the current Vector4 with the given one coordinates.
  77584. * @param source the source vector to copy from
  77585. * @returns the updated Vector4.
  77586. */
  77587. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77588. /**
  77589. * Updates the current Vector4 coordinates with the given floats.
  77590. * @param x float to copy from
  77591. * @param y float to copy from
  77592. * @param z float to copy from
  77593. * @param w float to copy from
  77594. * @returns the updated Vector4.
  77595. */
  77596. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77597. /**
  77598. * Updates the current Vector4 coordinates with the given floats.
  77599. * @param x float to set from
  77600. * @param y float to set from
  77601. * @param z float to set from
  77602. * @param w float to set from
  77603. * @returns the updated Vector4.
  77604. */
  77605. set(x: number, y: number, z: number, w: number): Vector4;
  77606. /**
  77607. * Copies the given float to the current Vector3 coordinates
  77608. * @param v defines the x, y, z and w coordinates of the operand
  77609. * @returns the current updated Vector3
  77610. */
  77611. setAll(v: number): Vector4;
  77612. /**
  77613. * Returns a new Vector4 set from the starting index of the given array.
  77614. * @param array the array to pull values from
  77615. * @param offset the offset into the array to start at
  77616. * @returns the new vector
  77617. */
  77618. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77619. /**
  77620. * Updates the given vector "result" from the starting index of the given array.
  77621. * @param array the array to pull values from
  77622. * @param offset the offset into the array to start at
  77623. * @param result the vector to store the result in
  77624. */
  77625. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77626. /**
  77627. * Updates the given vector "result" from the starting index of the given Float32Array.
  77628. * @param array the array to pull values from
  77629. * @param offset the offset into the array to start at
  77630. * @param result the vector to store the result in
  77631. */
  77632. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77633. /**
  77634. * Updates the given vector "result" coordinates from the given floats.
  77635. * @param x float to set from
  77636. * @param y float to set from
  77637. * @param z float to set from
  77638. * @param w float to set from
  77639. * @param result the vector to the floats in
  77640. */
  77641. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77642. /**
  77643. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77644. * @returns the new vector
  77645. */
  77646. static Zero(): Vector4;
  77647. /**
  77648. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77649. * @returns the new vector
  77650. */
  77651. static One(): Vector4;
  77652. /**
  77653. * Returns a new normalized Vector4 from the given one.
  77654. * @param vector the vector to normalize
  77655. * @returns the vector
  77656. */
  77657. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77658. /**
  77659. * Updates the given vector "result" from the normalization of the given one.
  77660. * @param vector the vector to normalize
  77661. * @param result the vector to store the result in
  77662. */
  77663. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77664. /**
  77665. * Returns a vector with the minimum values from the left and right vectors
  77666. * @param left left vector to minimize
  77667. * @param right right vector to minimize
  77668. * @returns a new vector with the minimum of the left and right vector values
  77669. */
  77670. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77671. /**
  77672. * Returns a vector with the maximum values from the left and right vectors
  77673. * @param left left vector to maximize
  77674. * @param right right vector to maximize
  77675. * @returns a new vector with the maximum of the left and right vector values
  77676. */
  77677. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77678. /**
  77679. * Returns the distance (float) between the vectors "value1" and "value2".
  77680. * @param value1 value to calulate the distance between
  77681. * @param value2 value to calulate the distance between
  77682. * @return the distance between the two vectors
  77683. */
  77684. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77685. /**
  77686. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77687. * @param value1 value to calulate the distance between
  77688. * @param value2 value to calulate the distance between
  77689. * @return the distance between the two vectors squared
  77690. */
  77691. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77692. /**
  77693. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77694. * @param value1 value to calulate the center between
  77695. * @param value2 value to calulate the center between
  77696. * @return the center between the two vectors
  77697. */
  77698. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77699. /**
  77700. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77701. * This methods computes transformed normalized direction vectors only.
  77702. * @param vector the vector to transform
  77703. * @param transformation the transformation matrix to apply
  77704. * @returns the new vector
  77705. */
  77706. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77707. /**
  77708. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77709. * This methods computes transformed normalized direction vectors only.
  77710. * @param vector the vector to transform
  77711. * @param transformation the transformation matrix to apply
  77712. * @param result the vector to store the result in
  77713. */
  77714. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77715. /**
  77716. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77717. * This methods computes transformed normalized direction vectors only.
  77718. * @param x value to transform
  77719. * @param y value to transform
  77720. * @param z value to transform
  77721. * @param w value to transform
  77722. * @param transformation the transformation matrix to apply
  77723. * @param result the vector to store the results in
  77724. */
  77725. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77726. /**
  77727. * Creates a new Vector4 from a Vector3
  77728. * @param source defines the source data
  77729. * @param w defines the 4th component (default is 0)
  77730. * @returns a new Vector4
  77731. */
  77732. static FromVector3(source: Vector3, w?: number): Vector4;
  77733. }
  77734. /**
  77735. * Class used to store quaternion data
  77736. * @see https://en.wikipedia.org/wiki/Quaternion
  77737. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77738. */
  77739. export class Quaternion {
  77740. /** defines the first component (0 by default) */
  77741. x: number;
  77742. /** defines the second component (0 by default) */
  77743. y: number;
  77744. /** defines the third component (0 by default) */
  77745. z: number;
  77746. /** defines the fourth component (1.0 by default) */
  77747. w: number;
  77748. /**
  77749. * Creates a new Quaternion from the given floats
  77750. * @param x defines the first component (0 by default)
  77751. * @param y defines the second component (0 by default)
  77752. * @param z defines the third component (0 by default)
  77753. * @param w defines the fourth component (1.0 by default)
  77754. */
  77755. constructor(
  77756. /** defines the first component (0 by default) */
  77757. x?: number,
  77758. /** defines the second component (0 by default) */
  77759. y?: number,
  77760. /** defines the third component (0 by default) */
  77761. z?: number,
  77762. /** defines the fourth component (1.0 by default) */
  77763. w?: number);
  77764. /**
  77765. * Gets a string representation for the current quaternion
  77766. * @returns a string with the Quaternion coordinates
  77767. */
  77768. toString(): string;
  77769. /**
  77770. * Gets the class name of the quaternion
  77771. * @returns the string "Quaternion"
  77772. */
  77773. getClassName(): string;
  77774. /**
  77775. * Gets a hash code for this quaternion
  77776. * @returns the quaternion hash code
  77777. */
  77778. getHashCode(): number;
  77779. /**
  77780. * Copy the quaternion to an array
  77781. * @returns a new array populated with 4 elements from the quaternion coordinates
  77782. */
  77783. asArray(): number[];
  77784. /**
  77785. * Check if two quaternions are equals
  77786. * @param otherQuaternion defines the second operand
  77787. * @return true if the current quaternion and the given one coordinates are strictly equals
  77788. */
  77789. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77790. /**
  77791. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77792. * @param otherQuaternion defines the other quaternion
  77793. * @param epsilon defines the minimal distance to consider equality
  77794. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77795. */
  77796. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77797. /**
  77798. * Clone the current quaternion
  77799. * @returns a new quaternion copied from the current one
  77800. */
  77801. clone(): Quaternion;
  77802. /**
  77803. * Copy a quaternion to the current one
  77804. * @param other defines the other quaternion
  77805. * @returns the updated current quaternion
  77806. */
  77807. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77808. /**
  77809. * Updates the current quaternion with the given float coordinates
  77810. * @param x defines the x coordinate
  77811. * @param y defines the y coordinate
  77812. * @param z defines the z coordinate
  77813. * @param w defines the w coordinate
  77814. * @returns the updated current quaternion
  77815. */
  77816. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77817. /**
  77818. * Updates the current quaternion from the given float coordinates
  77819. * @param x defines the x coordinate
  77820. * @param y defines the y coordinate
  77821. * @param z defines the z coordinate
  77822. * @param w defines the w coordinate
  77823. * @returns the updated current quaternion
  77824. */
  77825. set(x: number, y: number, z: number, w: number): Quaternion;
  77826. /**
  77827. * Adds two quaternions
  77828. * @param other defines the second operand
  77829. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77830. */
  77831. add(other: DeepImmutable<Quaternion>): Quaternion;
  77832. /**
  77833. * Add a quaternion to the current one
  77834. * @param other defines the quaternion to add
  77835. * @returns the current quaternion
  77836. */
  77837. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77838. /**
  77839. * Subtract two quaternions
  77840. * @param other defines the second operand
  77841. * @returns a new quaternion as the subtraction result of the given one from the current one
  77842. */
  77843. subtract(other: Quaternion): Quaternion;
  77844. /**
  77845. * Multiplies the current quaternion by a scale factor
  77846. * @param value defines the scale factor
  77847. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77848. */
  77849. scale(value: number): Quaternion;
  77850. /**
  77851. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77852. * @param scale defines the scale factor
  77853. * @param result defines the Quaternion object where to store the result
  77854. * @returns the unmodified current quaternion
  77855. */
  77856. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77857. /**
  77858. * Multiplies in place the current quaternion by a scale factor
  77859. * @param value defines the scale factor
  77860. * @returns the current modified quaternion
  77861. */
  77862. scaleInPlace(value: number): Quaternion;
  77863. /**
  77864. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77865. * @param scale defines the scale factor
  77866. * @param result defines the Quaternion object where to store the result
  77867. * @returns the unmodified current quaternion
  77868. */
  77869. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77870. /**
  77871. * Multiplies two quaternions
  77872. * @param q1 defines the second operand
  77873. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77874. */
  77875. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77876. /**
  77877. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77878. * @param q1 defines the second operand
  77879. * @param result defines the target quaternion
  77880. * @returns the current quaternion
  77881. */
  77882. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77883. /**
  77884. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77885. * @param q1 defines the second operand
  77886. * @returns the currentupdated quaternion
  77887. */
  77888. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77889. /**
  77890. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77891. * @param ref defines the target quaternion
  77892. * @returns the current quaternion
  77893. */
  77894. conjugateToRef(ref: Quaternion): Quaternion;
  77895. /**
  77896. * Conjugates in place (1-q) the current quaternion
  77897. * @returns the current updated quaternion
  77898. */
  77899. conjugateInPlace(): Quaternion;
  77900. /**
  77901. * Conjugates in place (1-q) the current quaternion
  77902. * @returns a new quaternion
  77903. */
  77904. conjugate(): Quaternion;
  77905. /**
  77906. * Gets length of current quaternion
  77907. * @returns the quaternion length (float)
  77908. */
  77909. length(): number;
  77910. /**
  77911. * Normalize in place the current quaternion
  77912. * @returns the current updated quaternion
  77913. */
  77914. normalize(): Quaternion;
  77915. /**
  77916. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77917. * @param order is a reserved parameter and is ignore for now
  77918. * @returns a new Vector3 containing the Euler angles
  77919. */
  77920. toEulerAngles(order?: string): Vector3;
  77921. /**
  77922. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77923. * @param result defines the vector which will be filled with the Euler angles
  77924. * @param order is a reserved parameter and is ignore for now
  77925. * @returns the current unchanged quaternion
  77926. */
  77927. toEulerAnglesToRef(result: Vector3): Quaternion;
  77928. /**
  77929. * Updates the given rotation matrix with the current quaternion values
  77930. * @param result defines the target matrix
  77931. * @returns the current unchanged quaternion
  77932. */
  77933. toRotationMatrix(result: Matrix): Quaternion;
  77934. /**
  77935. * Updates the current quaternion from the given rotation matrix values
  77936. * @param matrix defines the source matrix
  77937. * @returns the current updated quaternion
  77938. */
  77939. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77940. /**
  77941. * Creates a new quaternion from a rotation matrix
  77942. * @param matrix defines the source matrix
  77943. * @returns a new quaternion created from the given rotation matrix values
  77944. */
  77945. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77946. /**
  77947. * Updates the given quaternion with the given rotation matrix values
  77948. * @param matrix defines the source matrix
  77949. * @param result defines the target quaternion
  77950. */
  77951. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77952. /**
  77953. * Returns the dot product (float) between the quaternions "left" and "right"
  77954. * @param left defines the left operand
  77955. * @param right defines the right operand
  77956. * @returns the dot product
  77957. */
  77958. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77959. /**
  77960. * Checks if the two quaternions are close to each other
  77961. * @param quat0 defines the first quaternion to check
  77962. * @param quat1 defines the second quaternion to check
  77963. * @returns true if the two quaternions are close to each other
  77964. */
  77965. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77966. /**
  77967. * Creates an empty quaternion
  77968. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77969. */
  77970. static Zero(): Quaternion;
  77971. /**
  77972. * Inverse a given quaternion
  77973. * @param q defines the source quaternion
  77974. * @returns a new quaternion as the inverted current quaternion
  77975. */
  77976. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77977. /**
  77978. * Inverse a given quaternion
  77979. * @param q defines the source quaternion
  77980. * @param result the quaternion the result will be stored in
  77981. * @returns the result quaternion
  77982. */
  77983. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77984. /**
  77985. * Creates an identity quaternion
  77986. * @returns the identity quaternion
  77987. */
  77988. static Identity(): Quaternion;
  77989. /**
  77990. * Gets a boolean indicating if the given quaternion is identity
  77991. * @param quaternion defines the quaternion to check
  77992. * @returns true if the quaternion is identity
  77993. */
  77994. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77995. /**
  77996. * Creates a quaternion from a rotation around an axis
  77997. * @param axis defines the axis to use
  77998. * @param angle defines the angle to use
  77999. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78000. */
  78001. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78002. /**
  78003. * Creates a rotation around an axis and stores it into the given quaternion
  78004. * @param axis defines the axis to use
  78005. * @param angle defines the angle to use
  78006. * @param result defines the target quaternion
  78007. * @returns the target quaternion
  78008. */
  78009. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78010. /**
  78011. * Creates a new quaternion from data stored into an array
  78012. * @param array defines the data source
  78013. * @param offset defines the offset in the source array where the data starts
  78014. * @returns a new quaternion
  78015. */
  78016. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78017. /**
  78018. * Updates the given quaternion "result" from the starting index of the given array.
  78019. * @param array the array to pull values from
  78020. * @param offset the offset into the array to start at
  78021. * @param result the quaternion to store the result in
  78022. */
  78023. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78024. /**
  78025. * Create a quaternion from Euler rotation angles
  78026. * @param x Pitch
  78027. * @param y Yaw
  78028. * @param z Roll
  78029. * @returns the new Quaternion
  78030. */
  78031. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78032. /**
  78033. * Updates a quaternion from Euler rotation angles
  78034. * @param x Pitch
  78035. * @param y Yaw
  78036. * @param z Roll
  78037. * @param result the quaternion to store the result
  78038. * @returns the updated quaternion
  78039. */
  78040. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78041. /**
  78042. * Create a quaternion from Euler rotation vector
  78043. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78044. * @returns the new Quaternion
  78045. */
  78046. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78047. /**
  78048. * Updates a quaternion from Euler rotation vector
  78049. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78050. * @param result the quaternion to store the result
  78051. * @returns the updated quaternion
  78052. */
  78053. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78054. /**
  78055. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78056. * @param yaw defines the rotation around Y axis
  78057. * @param pitch defines the rotation around X axis
  78058. * @param roll defines the rotation around Z axis
  78059. * @returns the new quaternion
  78060. */
  78061. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78062. /**
  78063. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78064. * @param yaw defines the rotation around Y axis
  78065. * @param pitch defines the rotation around X axis
  78066. * @param roll defines the rotation around Z axis
  78067. * @param result defines the target quaternion
  78068. */
  78069. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78070. /**
  78071. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78072. * @param alpha defines the rotation around first axis
  78073. * @param beta defines the rotation around second axis
  78074. * @param gamma defines the rotation around third axis
  78075. * @returns the new quaternion
  78076. */
  78077. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78078. /**
  78079. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78080. * @param alpha defines the rotation around first axis
  78081. * @param beta defines the rotation around second axis
  78082. * @param gamma defines the rotation around third axis
  78083. * @param result defines the target quaternion
  78084. */
  78085. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78086. /**
  78087. * 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)
  78088. * @param axis1 defines the first axis
  78089. * @param axis2 defines the second axis
  78090. * @param axis3 defines the third axis
  78091. * @returns the new quaternion
  78092. */
  78093. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78094. /**
  78095. * 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
  78096. * @param axis1 defines the first axis
  78097. * @param axis2 defines the second axis
  78098. * @param axis3 defines the third axis
  78099. * @param ref defines the target quaternion
  78100. */
  78101. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78102. /**
  78103. * Interpolates between two quaternions
  78104. * @param left defines first quaternion
  78105. * @param right defines second quaternion
  78106. * @param amount defines the gradient to use
  78107. * @returns the new interpolated quaternion
  78108. */
  78109. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78110. /**
  78111. * Interpolates between two quaternions and stores it into a target quaternion
  78112. * @param left defines first quaternion
  78113. * @param right defines second quaternion
  78114. * @param amount defines the gradient to use
  78115. * @param result defines the target quaternion
  78116. */
  78117. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78118. /**
  78119. * Interpolate between two quaternions using Hermite interpolation
  78120. * @param value1 defines first quaternion
  78121. * @param tangent1 defines the incoming tangent
  78122. * @param value2 defines second quaternion
  78123. * @param tangent2 defines the outgoing tangent
  78124. * @param amount defines the target quaternion
  78125. * @returns the new interpolated quaternion
  78126. */
  78127. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78128. }
  78129. /**
  78130. * Class used to store matrix data (4x4)
  78131. */
  78132. export class Matrix {
  78133. private static _updateFlagSeed;
  78134. private static _identityReadOnly;
  78135. private _isIdentity;
  78136. private _isIdentityDirty;
  78137. private _isIdentity3x2;
  78138. private _isIdentity3x2Dirty;
  78139. /**
  78140. * Gets the update flag of the matrix which is an unique number for the matrix.
  78141. * It will be incremented every time the matrix data change.
  78142. * You can use it to speed the comparison between two versions of the same matrix.
  78143. */
  78144. updateFlag: number;
  78145. private readonly _m;
  78146. /**
  78147. * Gets the internal data of the matrix
  78148. */
  78149. get m(): DeepImmutable<Float32Array>;
  78150. /** @hidden */
  78151. _markAsUpdated(): void;
  78152. /** @hidden */
  78153. private _updateIdentityStatus;
  78154. /**
  78155. * Creates an empty matrix (filled with zeros)
  78156. */
  78157. constructor();
  78158. /**
  78159. * Check if the current matrix is identity
  78160. * @returns true is the matrix is the identity matrix
  78161. */
  78162. isIdentity(): boolean;
  78163. /**
  78164. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78165. * @returns true is the matrix is the identity matrix
  78166. */
  78167. isIdentityAs3x2(): boolean;
  78168. /**
  78169. * Gets the determinant of the matrix
  78170. * @returns the matrix determinant
  78171. */
  78172. determinant(): number;
  78173. /**
  78174. * Returns the matrix as a Float32Array
  78175. * @returns the matrix underlying array
  78176. */
  78177. toArray(): DeepImmutable<Float32Array>;
  78178. /**
  78179. * Returns the matrix as a Float32Array
  78180. * @returns the matrix underlying array.
  78181. */
  78182. asArray(): DeepImmutable<Float32Array>;
  78183. /**
  78184. * Inverts the current matrix in place
  78185. * @returns the current inverted matrix
  78186. */
  78187. invert(): Matrix;
  78188. /**
  78189. * Sets all the matrix elements to zero
  78190. * @returns the current matrix
  78191. */
  78192. reset(): Matrix;
  78193. /**
  78194. * Adds the current matrix with a second one
  78195. * @param other defines the matrix to add
  78196. * @returns a new matrix as the addition of the current matrix and the given one
  78197. */
  78198. add(other: DeepImmutable<Matrix>): Matrix;
  78199. /**
  78200. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78201. * @param other defines the matrix to add
  78202. * @param result defines the target matrix
  78203. * @returns the current matrix
  78204. */
  78205. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78206. /**
  78207. * Adds in place the given matrix to the current matrix
  78208. * @param other defines the second operand
  78209. * @returns the current updated matrix
  78210. */
  78211. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78212. /**
  78213. * Sets the given matrix to the current inverted Matrix
  78214. * @param other defines the target matrix
  78215. * @returns the unmodified current matrix
  78216. */
  78217. invertToRef(other: Matrix): Matrix;
  78218. /**
  78219. * add a value at the specified position in the current Matrix
  78220. * @param index the index of the value within the matrix. between 0 and 15.
  78221. * @param value the value to be added
  78222. * @returns the current updated matrix
  78223. */
  78224. addAtIndex(index: number, value: number): Matrix;
  78225. /**
  78226. * mutiply the specified position in the current Matrix by a value
  78227. * @param index the index of the value within the matrix. between 0 and 15.
  78228. * @param value the value to be added
  78229. * @returns the current updated matrix
  78230. */
  78231. multiplyAtIndex(index: number, value: number): Matrix;
  78232. /**
  78233. * Inserts the translation vector (using 3 floats) in the current matrix
  78234. * @param x defines the 1st component of the translation
  78235. * @param y defines the 2nd component of the translation
  78236. * @param z defines the 3rd component of the translation
  78237. * @returns the current updated matrix
  78238. */
  78239. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78240. /**
  78241. * Adds the translation vector (using 3 floats) in the current matrix
  78242. * @param x defines the 1st component of the translation
  78243. * @param y defines the 2nd component of the translation
  78244. * @param z defines the 3rd component of the translation
  78245. * @returns the current updated matrix
  78246. */
  78247. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78248. /**
  78249. * Inserts the translation vector in the current matrix
  78250. * @param vector3 defines the translation to insert
  78251. * @returns the current updated matrix
  78252. */
  78253. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78254. /**
  78255. * Gets the translation value of the current matrix
  78256. * @returns a new Vector3 as the extracted translation from the matrix
  78257. */
  78258. getTranslation(): Vector3;
  78259. /**
  78260. * Fill a Vector3 with the extracted translation from the matrix
  78261. * @param result defines the Vector3 where to store the translation
  78262. * @returns the current matrix
  78263. */
  78264. getTranslationToRef(result: Vector3): Matrix;
  78265. /**
  78266. * Remove rotation and scaling part from the matrix
  78267. * @returns the updated matrix
  78268. */
  78269. removeRotationAndScaling(): Matrix;
  78270. /**
  78271. * Multiply two matrices
  78272. * @param other defines the second operand
  78273. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78274. */
  78275. multiply(other: DeepImmutable<Matrix>): Matrix;
  78276. /**
  78277. * Copy the current matrix from the given one
  78278. * @param other defines the source matrix
  78279. * @returns the current updated matrix
  78280. */
  78281. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78282. /**
  78283. * Populates the given array from the starting index with the current matrix values
  78284. * @param array defines the target array
  78285. * @param offset defines the offset in the target array where to start storing values
  78286. * @returns the current matrix
  78287. */
  78288. copyToArray(array: Float32Array, offset?: number): Matrix;
  78289. /**
  78290. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78291. * @param other defines the second operand
  78292. * @param result defines the matrix where to store the multiplication
  78293. * @returns the current matrix
  78294. */
  78295. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78296. /**
  78297. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78298. * @param other defines the second operand
  78299. * @param result defines the array where to store the multiplication
  78300. * @param offset defines the offset in the target array where to start storing values
  78301. * @returns the current matrix
  78302. */
  78303. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78304. /**
  78305. * Check equality between this matrix and a second one
  78306. * @param value defines the second matrix to compare
  78307. * @returns true is the current matrix and the given one values are strictly equal
  78308. */
  78309. equals(value: DeepImmutable<Matrix>): boolean;
  78310. /**
  78311. * Clone the current matrix
  78312. * @returns a new matrix from the current matrix
  78313. */
  78314. clone(): Matrix;
  78315. /**
  78316. * Returns the name of the current matrix class
  78317. * @returns the string "Matrix"
  78318. */
  78319. getClassName(): string;
  78320. /**
  78321. * Gets the hash code of the current matrix
  78322. * @returns the hash code
  78323. */
  78324. getHashCode(): number;
  78325. /**
  78326. * Decomposes the current Matrix into a translation, rotation and scaling components
  78327. * @param scale defines the scale vector3 given as a reference to update
  78328. * @param rotation defines the rotation quaternion given as a reference to update
  78329. * @param translation defines the translation vector3 given as a reference to update
  78330. * @returns true if operation was successful
  78331. */
  78332. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78333. /**
  78334. * Gets specific row of the matrix
  78335. * @param index defines the number of the row to get
  78336. * @returns the index-th row of the current matrix as a new Vector4
  78337. */
  78338. getRow(index: number): Nullable<Vector4>;
  78339. /**
  78340. * Sets the index-th row of the current matrix to the vector4 values
  78341. * @param index defines the number of the row to set
  78342. * @param row defines the target vector4
  78343. * @returns the updated current matrix
  78344. */
  78345. setRow(index: number, row: Vector4): Matrix;
  78346. /**
  78347. * Compute the transpose of the matrix
  78348. * @returns the new transposed matrix
  78349. */
  78350. transpose(): Matrix;
  78351. /**
  78352. * Compute the transpose of the matrix and store it in a given matrix
  78353. * @param result defines the target matrix
  78354. * @returns the current matrix
  78355. */
  78356. transposeToRef(result: Matrix): Matrix;
  78357. /**
  78358. * Sets the index-th row of the current matrix with the given 4 x float values
  78359. * @param index defines the row index
  78360. * @param x defines the x component to set
  78361. * @param y defines the y component to set
  78362. * @param z defines the z component to set
  78363. * @param w defines the w component to set
  78364. * @returns the updated current matrix
  78365. */
  78366. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78367. /**
  78368. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78369. * @param scale defines the scale factor
  78370. * @returns a new matrix
  78371. */
  78372. scale(scale: number): Matrix;
  78373. /**
  78374. * Scale the current matrix values by a factor to a given result matrix
  78375. * @param scale defines the scale factor
  78376. * @param result defines the matrix to store the result
  78377. * @returns the current matrix
  78378. */
  78379. scaleToRef(scale: number, result: Matrix): Matrix;
  78380. /**
  78381. * Scale the current matrix values by a factor and add the result to a given matrix
  78382. * @param scale defines the scale factor
  78383. * @param result defines the Matrix to store the result
  78384. * @returns the current matrix
  78385. */
  78386. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78387. /**
  78388. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78389. * @param ref matrix to store the result
  78390. */
  78391. toNormalMatrix(ref: Matrix): void;
  78392. /**
  78393. * Gets only rotation part of the current matrix
  78394. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78395. */
  78396. getRotationMatrix(): Matrix;
  78397. /**
  78398. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78399. * @param result defines the target matrix to store data to
  78400. * @returns the current matrix
  78401. */
  78402. getRotationMatrixToRef(result: Matrix): Matrix;
  78403. /**
  78404. * Toggles model matrix from being right handed to left handed in place and vice versa
  78405. */
  78406. toggleModelMatrixHandInPlace(): void;
  78407. /**
  78408. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78409. */
  78410. toggleProjectionMatrixHandInPlace(): void;
  78411. /**
  78412. * Creates a matrix from an array
  78413. * @param array defines the source array
  78414. * @param offset defines an offset in the source array
  78415. * @returns a new Matrix set from the starting index of the given array
  78416. */
  78417. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78418. /**
  78419. * Copy the content of an array into a given matrix
  78420. * @param array defines the source array
  78421. * @param offset defines an offset in the source array
  78422. * @param result defines the target matrix
  78423. */
  78424. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78425. /**
  78426. * Stores an array into a matrix after having multiplied each component by a given factor
  78427. * @param array defines the source array
  78428. * @param offset defines the offset in the source array
  78429. * @param scale defines the scaling factor
  78430. * @param result defines the target matrix
  78431. */
  78432. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78433. /**
  78434. * Gets an identity matrix that must not be updated
  78435. */
  78436. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78437. /**
  78438. * Stores a list of values (16) inside a given matrix
  78439. * @param initialM11 defines 1st value of 1st row
  78440. * @param initialM12 defines 2nd value of 1st row
  78441. * @param initialM13 defines 3rd value of 1st row
  78442. * @param initialM14 defines 4th value of 1st row
  78443. * @param initialM21 defines 1st value of 2nd row
  78444. * @param initialM22 defines 2nd value of 2nd row
  78445. * @param initialM23 defines 3rd value of 2nd row
  78446. * @param initialM24 defines 4th value of 2nd row
  78447. * @param initialM31 defines 1st value of 3rd row
  78448. * @param initialM32 defines 2nd value of 3rd row
  78449. * @param initialM33 defines 3rd value of 3rd row
  78450. * @param initialM34 defines 4th value of 3rd row
  78451. * @param initialM41 defines 1st value of 4th row
  78452. * @param initialM42 defines 2nd value of 4th row
  78453. * @param initialM43 defines 3rd value of 4th row
  78454. * @param initialM44 defines 4th value of 4th row
  78455. * @param result defines the target matrix
  78456. */
  78457. 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;
  78458. /**
  78459. * Creates new matrix from a list of values (16)
  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. * @returns the new matrix
  78477. */
  78478. 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;
  78479. /**
  78480. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78481. * @param scale defines the scale vector3
  78482. * @param rotation defines the rotation quaternion
  78483. * @param translation defines the translation vector3
  78484. * @returns a new matrix
  78485. */
  78486. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78487. /**
  78488. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78489. * @param scale defines the scale vector3
  78490. * @param rotation defines the rotation quaternion
  78491. * @param translation defines the translation vector3
  78492. * @param result defines the target matrix
  78493. */
  78494. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78495. /**
  78496. * Creates a new identity matrix
  78497. * @returns a new identity matrix
  78498. */
  78499. static Identity(): Matrix;
  78500. /**
  78501. * Creates a new identity matrix and stores the result in a given matrix
  78502. * @param result defines the target matrix
  78503. */
  78504. static IdentityToRef(result: Matrix): void;
  78505. /**
  78506. * Creates a new zero matrix
  78507. * @returns a new zero matrix
  78508. */
  78509. static Zero(): Matrix;
  78510. /**
  78511. * Creates a new rotation matrix for "angle" radians around the X axis
  78512. * @param angle defines the angle (in radians) to use
  78513. * @return the new matrix
  78514. */
  78515. static RotationX(angle: number): Matrix;
  78516. /**
  78517. * Creates a new matrix as the invert of a given matrix
  78518. * @param source defines the source matrix
  78519. * @returns the new matrix
  78520. */
  78521. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78522. /**
  78523. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78524. * @param angle defines the angle (in radians) to use
  78525. * @param result defines the target matrix
  78526. */
  78527. static RotationXToRef(angle: number, result: Matrix): void;
  78528. /**
  78529. * Creates a new rotation matrix for "angle" radians around the Y axis
  78530. * @param angle defines the angle (in radians) to use
  78531. * @return the new matrix
  78532. */
  78533. static RotationY(angle: number): Matrix;
  78534. /**
  78535. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78536. * @param angle defines the angle (in radians) to use
  78537. * @param result defines the target matrix
  78538. */
  78539. static RotationYToRef(angle: number, result: Matrix): void;
  78540. /**
  78541. * Creates a new rotation matrix for "angle" radians around the Z axis
  78542. * @param angle defines the angle (in radians) to use
  78543. * @return the new matrix
  78544. */
  78545. static RotationZ(angle: number): Matrix;
  78546. /**
  78547. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78548. * @param angle defines the angle (in radians) to use
  78549. * @param result defines the target matrix
  78550. */
  78551. static RotationZToRef(angle: number, result: Matrix): void;
  78552. /**
  78553. * Creates a new rotation matrix for "angle" radians around the given axis
  78554. * @param axis defines the axis to use
  78555. * @param angle defines the angle (in radians) to use
  78556. * @return the new matrix
  78557. */
  78558. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78559. /**
  78560. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78561. * @param axis defines the axis to use
  78562. * @param angle defines the angle (in radians) to use
  78563. * @param result defines the target matrix
  78564. */
  78565. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78566. /**
  78567. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78568. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78569. * @param from defines the vector to align
  78570. * @param to defines the vector to align to
  78571. * @param result defines the target matrix
  78572. */
  78573. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78574. /**
  78575. * Creates a rotation matrix
  78576. * @param yaw defines the yaw angle in radians (Y axis)
  78577. * @param pitch defines the pitch angle in radians (X axis)
  78578. * @param roll defines the roll angle in radians (X axis)
  78579. * @returns the new rotation matrix
  78580. */
  78581. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78582. /**
  78583. * Creates a rotation matrix and stores it in a given matrix
  78584. * @param yaw defines the yaw angle in radians (Y axis)
  78585. * @param pitch defines the pitch angle in radians (X axis)
  78586. * @param roll defines the roll angle in radians (X axis)
  78587. * @param result defines the target matrix
  78588. */
  78589. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78590. /**
  78591. * Creates a scaling matrix
  78592. * @param x defines the scale factor on X axis
  78593. * @param y defines the scale factor on Y axis
  78594. * @param z defines the scale factor on Z axis
  78595. * @returns the new matrix
  78596. */
  78597. static Scaling(x: number, y: number, z: number): Matrix;
  78598. /**
  78599. * Creates a scaling matrix and stores it in a given matrix
  78600. * @param x defines the scale factor on X axis
  78601. * @param y defines the scale factor on Y axis
  78602. * @param z defines the scale factor on Z axis
  78603. * @param result defines the target matrix
  78604. */
  78605. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78606. /**
  78607. * Creates a translation matrix
  78608. * @param x defines the translation on X axis
  78609. * @param y defines the translation on Y axis
  78610. * @param z defines the translationon Z axis
  78611. * @returns the new matrix
  78612. */
  78613. static Translation(x: number, y: number, z: number): Matrix;
  78614. /**
  78615. * Creates a translation matrix and stores it in a given matrix
  78616. * @param x defines the translation on X axis
  78617. * @param y defines the translation on Y axis
  78618. * @param z defines the translationon Z axis
  78619. * @param result defines the target matrix
  78620. */
  78621. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78622. /**
  78623. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78624. * @param startValue defines the start value
  78625. * @param endValue defines the end value
  78626. * @param gradient defines the gradient factor
  78627. * @returns the new matrix
  78628. */
  78629. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78630. /**
  78631. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78632. * @param startValue defines the start value
  78633. * @param endValue defines the end value
  78634. * @param gradient defines the gradient factor
  78635. * @param result defines the Matrix object where to store data
  78636. */
  78637. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78638. /**
  78639. * Builds a new matrix whose values are computed by:
  78640. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78641. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78642. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78643. * @param startValue defines the first matrix
  78644. * @param endValue defines the second matrix
  78645. * @param gradient defines the gradient between the two matrices
  78646. * @returns the new matrix
  78647. */
  78648. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78649. /**
  78650. * Update a matrix to values which are computed by:
  78651. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78652. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78653. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78654. * @param startValue defines the first matrix
  78655. * @param endValue defines the second matrix
  78656. * @param gradient defines the gradient between the two matrices
  78657. * @param result defines the target matrix
  78658. */
  78659. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78660. /**
  78661. * 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"
  78662. * This function works in left handed mode
  78663. * @param eye defines the final position of the entity
  78664. * @param target defines where the entity should look at
  78665. * @param up defines the up vector for the entity
  78666. * @returns the new matrix
  78667. */
  78668. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78669. /**
  78670. * 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".
  78671. * This function works in left handed mode
  78672. * @param eye defines the final position of the entity
  78673. * @param target defines where the entity should look at
  78674. * @param up defines the up vector for the entity
  78675. * @param result defines the target matrix
  78676. */
  78677. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78678. /**
  78679. * 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"
  78680. * This function works in right handed mode
  78681. * @param eye defines the final position of the entity
  78682. * @param target defines where the entity should look at
  78683. * @param up defines the up vector for the entity
  78684. * @returns the new matrix
  78685. */
  78686. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78687. /**
  78688. * 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".
  78689. * This function works in right handed mode
  78690. * @param eye defines the final position of the entity
  78691. * @param target defines where the entity should look at
  78692. * @param up defines the up vector for the entity
  78693. * @param result defines the target matrix
  78694. */
  78695. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78696. /**
  78697. * Create a left-handed orthographic projection matrix
  78698. * @param width defines the viewport width
  78699. * @param height defines the viewport height
  78700. * @param znear defines the near clip plane
  78701. * @param zfar defines the far clip plane
  78702. * @returns a new matrix as a left-handed orthographic projection matrix
  78703. */
  78704. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78705. /**
  78706. * Store a left-handed orthographic projection to a given matrix
  78707. * @param width defines the viewport width
  78708. * @param height defines the viewport height
  78709. * @param znear defines the near clip plane
  78710. * @param zfar defines the far clip plane
  78711. * @param result defines the target matrix
  78712. */
  78713. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78714. /**
  78715. * Create a left-handed orthographic projection matrix
  78716. * @param left defines the viewport left coordinate
  78717. * @param right defines the viewport right coordinate
  78718. * @param bottom defines the viewport bottom coordinate
  78719. * @param top defines the viewport top coordinate
  78720. * @param znear defines the near clip plane
  78721. * @param zfar defines the far clip plane
  78722. * @returns a new matrix as a left-handed orthographic projection matrix
  78723. */
  78724. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78725. /**
  78726. * Stores a left-handed orthographic projection into a given matrix
  78727. * @param left defines the viewport left coordinate
  78728. * @param right defines the viewport right coordinate
  78729. * @param bottom defines the viewport bottom coordinate
  78730. * @param top defines the viewport top coordinate
  78731. * @param znear defines the near clip plane
  78732. * @param zfar defines the far clip plane
  78733. * @param result defines the target matrix
  78734. */
  78735. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78736. /**
  78737. * Creates a right-handed orthographic projection matrix
  78738. * @param left defines the viewport left coordinate
  78739. * @param right defines the viewport right coordinate
  78740. * @param bottom defines the viewport bottom coordinate
  78741. * @param top defines the viewport top coordinate
  78742. * @param znear defines the near clip plane
  78743. * @param zfar defines the far clip plane
  78744. * @returns a new matrix as a right-handed orthographic projection matrix
  78745. */
  78746. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78747. /**
  78748. * Stores a right-handed orthographic projection into a given matrix
  78749. * @param left defines the viewport left coordinate
  78750. * @param right defines the viewport right coordinate
  78751. * @param bottom defines the viewport bottom coordinate
  78752. * @param top defines the viewport top coordinate
  78753. * @param znear defines the near clip plane
  78754. * @param zfar defines the far clip plane
  78755. * @param result defines the target matrix
  78756. */
  78757. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78758. /**
  78759. * Creates a left-handed perspective projection matrix
  78760. * @param width defines the viewport width
  78761. * @param height defines the viewport height
  78762. * @param znear defines the near clip plane
  78763. * @param zfar defines the far clip plane
  78764. * @returns a new matrix as a left-handed perspective projection matrix
  78765. */
  78766. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78767. /**
  78768. * Creates a left-handed perspective projection matrix
  78769. * @param fov defines the horizontal field of view
  78770. * @param aspect defines the aspect ratio
  78771. * @param znear defines the near clip plane
  78772. * @param zfar defines the far clip plane
  78773. * @returns a new matrix as a left-handed perspective projection matrix
  78774. */
  78775. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78776. /**
  78777. * Stores a left-handed perspective projection into a given matrix
  78778. * @param fov defines the horizontal field of view
  78779. * @param aspect defines the aspect ratio
  78780. * @param znear defines the near clip plane
  78781. * @param zfar defines the far clip plane
  78782. * @param result defines the target matrix
  78783. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78784. */
  78785. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78786. /**
  78787. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78788. * @param fov defines the horizontal field of view
  78789. * @param aspect defines the aspect ratio
  78790. * @param znear defines the near clip plane
  78791. * @param zfar not used as infinity is used as far clip
  78792. * @param result defines the target matrix
  78793. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78794. */
  78795. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78796. /**
  78797. * Creates a right-handed perspective projection matrix
  78798. * @param fov defines the horizontal field of view
  78799. * @param aspect defines the aspect ratio
  78800. * @param znear defines the near clip plane
  78801. * @param zfar defines the far clip plane
  78802. * @returns a new matrix as a right-handed perspective projection matrix
  78803. */
  78804. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78805. /**
  78806. * Stores a right-handed perspective projection into a given matrix
  78807. * @param fov defines the horizontal field of view
  78808. * @param aspect defines the aspect ratio
  78809. * @param znear defines the near clip plane
  78810. * @param zfar defines the far clip plane
  78811. * @param result defines the target matrix
  78812. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78813. */
  78814. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78815. /**
  78816. * Stores a right-handed perspective projection into a given matrix
  78817. * @param fov defines the horizontal field of view
  78818. * @param aspect defines the aspect ratio
  78819. * @param znear defines the near clip plane
  78820. * @param zfar not used as infinity is used as far clip
  78821. * @param result defines the target matrix
  78822. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78823. */
  78824. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78825. /**
  78826. * Stores a perspective projection for WebVR info a given matrix
  78827. * @param fov defines the field of view
  78828. * @param znear defines the near clip plane
  78829. * @param zfar defines the far clip plane
  78830. * @param result defines the target matrix
  78831. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78832. */
  78833. static PerspectiveFovWebVRToRef(fov: {
  78834. upDegrees: number;
  78835. downDegrees: number;
  78836. leftDegrees: number;
  78837. rightDegrees: number;
  78838. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78839. /**
  78840. * Computes a complete transformation matrix
  78841. * @param viewport defines the viewport to use
  78842. * @param world defines the world matrix
  78843. * @param view defines the view matrix
  78844. * @param projection defines the projection matrix
  78845. * @param zmin defines the near clip plane
  78846. * @param zmax defines the far clip plane
  78847. * @returns the transformation matrix
  78848. */
  78849. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78850. /**
  78851. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78852. * @param matrix defines the matrix to use
  78853. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78854. */
  78855. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78856. /**
  78857. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78858. * @param matrix defines the matrix to use
  78859. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78860. */
  78861. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78862. /**
  78863. * Compute the transpose of a given matrix
  78864. * @param matrix defines the matrix to transpose
  78865. * @returns the new matrix
  78866. */
  78867. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78868. /**
  78869. * Compute the transpose of a matrix and store it in a target matrix
  78870. * @param matrix defines the matrix to transpose
  78871. * @param result defines the target matrix
  78872. */
  78873. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78874. /**
  78875. * Computes a reflection matrix from a plane
  78876. * @param plane defines the reflection plane
  78877. * @returns a new matrix
  78878. */
  78879. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78880. /**
  78881. * Computes a reflection matrix from a plane
  78882. * @param plane defines the reflection plane
  78883. * @param result defines the target matrix
  78884. */
  78885. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78886. /**
  78887. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78888. * @param xaxis defines the value of the 1st axis
  78889. * @param yaxis defines the value of the 2nd axis
  78890. * @param zaxis defines the value of the 3rd axis
  78891. * @param result defines the target matrix
  78892. */
  78893. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78894. /**
  78895. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78896. * @param quat defines the quaternion to use
  78897. * @param result defines the target matrix
  78898. */
  78899. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78900. }
  78901. /**
  78902. * @hidden
  78903. */
  78904. export class TmpVectors {
  78905. static Vector2: Vector2[];
  78906. static Vector3: Vector3[];
  78907. static Vector4: Vector4[];
  78908. static Quaternion: Quaternion[];
  78909. static Matrix: Matrix[];
  78910. }
  78911. }
  78912. declare module BABYLON {
  78913. /**
  78914. * Defines potential orientation for back face culling
  78915. */
  78916. export enum Orientation {
  78917. /**
  78918. * Clockwise
  78919. */
  78920. CW = 0,
  78921. /** Counter clockwise */
  78922. CCW = 1
  78923. }
  78924. /** Class used to represent a Bezier curve */
  78925. export class BezierCurve {
  78926. /**
  78927. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78928. * @param t defines the time
  78929. * @param x1 defines the left coordinate on X axis
  78930. * @param y1 defines the left coordinate on Y axis
  78931. * @param x2 defines the right coordinate on X axis
  78932. * @param y2 defines the right coordinate on Y axis
  78933. * @returns the interpolated value
  78934. */
  78935. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78936. }
  78937. /**
  78938. * Defines angle representation
  78939. */
  78940. export class Angle {
  78941. private _radians;
  78942. /**
  78943. * Creates an Angle object of "radians" radians (float).
  78944. * @param radians the angle in radians
  78945. */
  78946. constructor(radians: number);
  78947. /**
  78948. * Get value in degrees
  78949. * @returns the Angle value in degrees (float)
  78950. */
  78951. degrees(): number;
  78952. /**
  78953. * Get value in radians
  78954. * @returns the Angle value in radians (float)
  78955. */
  78956. radians(): number;
  78957. /**
  78958. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78959. * @param a defines first vector
  78960. * @param b defines second vector
  78961. * @returns a new Angle
  78962. */
  78963. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78964. /**
  78965. * Gets a new Angle object from the given float in radians
  78966. * @param radians defines the angle value in radians
  78967. * @returns a new Angle
  78968. */
  78969. static FromRadians(radians: number): Angle;
  78970. /**
  78971. * Gets a new Angle object from the given float in degrees
  78972. * @param degrees defines the angle value in degrees
  78973. * @returns a new Angle
  78974. */
  78975. static FromDegrees(degrees: number): Angle;
  78976. }
  78977. /**
  78978. * This represents an arc in a 2d space.
  78979. */
  78980. export class Arc2 {
  78981. /** Defines the start point of the arc */
  78982. startPoint: Vector2;
  78983. /** Defines the mid point of the arc */
  78984. midPoint: Vector2;
  78985. /** Defines the end point of the arc */
  78986. endPoint: Vector2;
  78987. /**
  78988. * Defines the center point of the arc.
  78989. */
  78990. centerPoint: Vector2;
  78991. /**
  78992. * Defines the radius of the arc.
  78993. */
  78994. radius: number;
  78995. /**
  78996. * Defines the angle of the arc (from mid point to end point).
  78997. */
  78998. angle: Angle;
  78999. /**
  79000. * Defines the start angle of the arc (from start point to middle point).
  79001. */
  79002. startAngle: Angle;
  79003. /**
  79004. * Defines the orientation of the arc (clock wise/counter clock wise).
  79005. */
  79006. orientation: Orientation;
  79007. /**
  79008. * Creates an Arc object from the three given points : start, middle and end.
  79009. * @param startPoint Defines the start point of the arc
  79010. * @param midPoint Defines the midlle point of the arc
  79011. * @param endPoint Defines the end point of the arc
  79012. */
  79013. constructor(
  79014. /** Defines the start point of the arc */
  79015. startPoint: Vector2,
  79016. /** Defines the mid point of the arc */
  79017. midPoint: Vector2,
  79018. /** Defines the end point of the arc */
  79019. endPoint: Vector2);
  79020. }
  79021. /**
  79022. * Represents a 2D path made up of multiple 2D points
  79023. */
  79024. export class Path2 {
  79025. private _points;
  79026. private _length;
  79027. /**
  79028. * If the path start and end point are the same
  79029. */
  79030. closed: boolean;
  79031. /**
  79032. * Creates a Path2 object from the starting 2D coordinates x and y.
  79033. * @param x the starting points x value
  79034. * @param y the starting points y value
  79035. */
  79036. constructor(x: number, y: number);
  79037. /**
  79038. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79039. * @param x the added points x value
  79040. * @param y the added points y value
  79041. * @returns the updated Path2.
  79042. */
  79043. addLineTo(x: number, y: number): Path2;
  79044. /**
  79045. * 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.
  79046. * @param midX middle point x value
  79047. * @param midY middle point y value
  79048. * @param endX end point x value
  79049. * @param endY end point y value
  79050. * @param numberOfSegments (default: 36)
  79051. * @returns the updated Path2.
  79052. */
  79053. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79054. /**
  79055. * Closes the Path2.
  79056. * @returns the Path2.
  79057. */
  79058. close(): Path2;
  79059. /**
  79060. * Gets the sum of the distance between each sequential point in the path
  79061. * @returns the Path2 total length (float).
  79062. */
  79063. length(): number;
  79064. /**
  79065. * Gets the points which construct the path
  79066. * @returns the Path2 internal array of points.
  79067. */
  79068. getPoints(): Vector2[];
  79069. /**
  79070. * Retreives the point at the distance aways from the starting point
  79071. * @param normalizedLengthPosition the length along the path to retreive the point from
  79072. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79073. */
  79074. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79075. /**
  79076. * Creates a new path starting from an x and y position
  79077. * @param x starting x value
  79078. * @param y starting y value
  79079. * @returns a new Path2 starting at the coordinates (x, y).
  79080. */
  79081. static StartingAt(x: number, y: number): Path2;
  79082. }
  79083. /**
  79084. * Represents a 3D path made up of multiple 3D points
  79085. */
  79086. export class Path3D {
  79087. /**
  79088. * an array of Vector3, the curve axis of the Path3D
  79089. */
  79090. path: Vector3[];
  79091. private _curve;
  79092. private _distances;
  79093. private _tangents;
  79094. private _normals;
  79095. private _binormals;
  79096. private _raw;
  79097. private _alignTangentsWithPath;
  79098. private readonly _pointAtData;
  79099. /**
  79100. * new Path3D(path, normal, raw)
  79101. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79102. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79103. * @param path an array of Vector3, the curve axis of the Path3D
  79104. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79105. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79106. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79107. */
  79108. constructor(
  79109. /**
  79110. * an array of Vector3, the curve axis of the Path3D
  79111. */
  79112. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79113. /**
  79114. * Returns the Path3D array of successive Vector3 designing its curve.
  79115. * @returns the Path3D array of successive Vector3 designing its curve.
  79116. */
  79117. getCurve(): Vector3[];
  79118. /**
  79119. * Returns the Path3D array of successive Vector3 designing its curve.
  79120. * @returns the Path3D array of successive Vector3 designing its curve.
  79121. */
  79122. getPoints(): Vector3[];
  79123. /**
  79124. * @returns the computed length (float) of the path.
  79125. */
  79126. length(): number;
  79127. /**
  79128. * Returns an array populated with tangent vectors on each Path3D curve point.
  79129. * @returns an array populated with tangent vectors on each Path3D curve point.
  79130. */
  79131. getTangents(): Vector3[];
  79132. /**
  79133. * Returns an array populated with normal vectors on each Path3D curve point.
  79134. * @returns an array populated with normal vectors on each Path3D curve point.
  79135. */
  79136. getNormals(): Vector3[];
  79137. /**
  79138. * Returns an array populated with binormal vectors on each Path3D curve point.
  79139. * @returns an array populated with binormal vectors on each Path3D curve point.
  79140. */
  79141. getBinormals(): Vector3[];
  79142. /**
  79143. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79144. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79145. */
  79146. getDistances(): number[];
  79147. /**
  79148. * Returns an interpolated point along this path
  79149. * @param position the position of the point along this path, from 0.0 to 1.0
  79150. * @returns a new Vector3 as the point
  79151. */
  79152. getPointAt(position: number): Vector3;
  79153. /**
  79154. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79155. * @param position the position of the point along this path, from 0.0 to 1.0
  79156. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79157. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79158. */
  79159. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79160. /**
  79161. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79162. * @param position the position of the point along this path, from 0.0 to 1.0
  79163. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79164. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79165. */
  79166. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79167. /**
  79168. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79169. * @param position the position of the point along this path, from 0.0 to 1.0
  79170. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79171. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79172. */
  79173. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79174. /**
  79175. * Returns the distance (float) 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. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79178. */
  79179. getDistanceAt(position: number): number;
  79180. /**
  79181. * Returns the array index of the previous point of an interpolated point along this path
  79182. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79183. * @returns the array index
  79184. */
  79185. getPreviousPointIndexAt(position: number): number;
  79186. /**
  79187. * 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)
  79188. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79189. * @returns the sub position
  79190. */
  79191. getSubPositionAt(position: number): number;
  79192. /**
  79193. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79194. * @param target the vector of which to get the closest position to
  79195. * @returns the position of the closest virtual point on this path to the target vector
  79196. */
  79197. getClosestPositionTo(target: Vector3): number;
  79198. /**
  79199. * Returns a sub path (slice) of this path
  79200. * @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
  79201. * @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
  79202. * @returns a sub path (slice) of this path
  79203. */
  79204. slice(start?: number, end?: number): Path3D;
  79205. /**
  79206. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79207. * @param path path which all values are copied into the curves points
  79208. * @param firstNormal which should be projected onto the curve
  79209. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79210. * @returns the same object updated.
  79211. */
  79212. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79213. private _compute;
  79214. private _getFirstNonNullVector;
  79215. private _getLastNonNullVector;
  79216. private _normalVector;
  79217. /**
  79218. * Updates the point at data for an interpolated point along this curve
  79219. * @param position the position of the point along this curve, from 0.0 to 1.0
  79220. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79221. * @returns the (updated) point at data
  79222. */
  79223. private _updatePointAtData;
  79224. /**
  79225. * Updates the point at data from the specified parameters
  79226. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79227. * @param point the interpolated point
  79228. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79229. */
  79230. private _setPointAtData;
  79231. /**
  79232. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79233. */
  79234. private _updateInterpolationMatrix;
  79235. }
  79236. /**
  79237. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79238. * A Curve3 is designed from a series of successive Vector3.
  79239. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79240. */
  79241. export class Curve3 {
  79242. private _points;
  79243. private _length;
  79244. /**
  79245. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79246. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79247. * @param v1 (Vector3) the control point
  79248. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79249. * @param nbPoints (integer) the wanted number of points in the curve
  79250. * @returns the created Curve3
  79251. */
  79252. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79253. /**
  79254. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79255. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79256. * @param v1 (Vector3) the first control point
  79257. * @param v2 (Vector3) the second control point
  79258. * @param v3 (Vector3) the end point of the Cubic Bezier
  79259. * @param nbPoints (integer) the wanted number of points in the curve
  79260. * @returns the created Curve3
  79261. */
  79262. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79263. /**
  79264. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79265. * @param p1 (Vector3) the origin point of the Hermite Spline
  79266. * @param t1 (Vector3) the tangent vector at the origin point
  79267. * @param p2 (Vector3) the end point of the Hermite Spline
  79268. * @param t2 (Vector3) the tangent vector at the end point
  79269. * @param nbPoints (integer) the wanted number of points in the curve
  79270. * @returns the created Curve3
  79271. */
  79272. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79273. /**
  79274. * Returns a Curve3 object along a CatmullRom Spline curve :
  79275. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79276. * @param nbPoints (integer) the wanted number of points between each curve control points
  79277. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79278. * @returns the created Curve3
  79279. */
  79280. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79281. /**
  79282. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79283. * A Curve3 is designed from a series of successive Vector3.
  79284. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79285. * @param points points which make up the curve
  79286. */
  79287. constructor(points: Vector3[]);
  79288. /**
  79289. * @returns the Curve3 stored array of successive Vector3
  79290. */
  79291. getPoints(): Vector3[];
  79292. /**
  79293. * @returns the computed length (float) of the curve.
  79294. */
  79295. length(): number;
  79296. /**
  79297. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79298. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79299. * curveA and curveB keep unchanged.
  79300. * @param curve the curve to continue from this curve
  79301. * @returns the newly constructed curve
  79302. */
  79303. continue(curve: DeepImmutable<Curve3>): Curve3;
  79304. private _computeLength;
  79305. }
  79306. }
  79307. declare module BABYLON {
  79308. /**
  79309. * This represents the main contract an easing function should follow.
  79310. * Easing functions are used throughout the animation system.
  79311. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79312. */
  79313. export interface IEasingFunction {
  79314. /**
  79315. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79316. * of the easing function.
  79317. * The link below provides some of the most common examples of easing functions.
  79318. * @see https://easings.net/
  79319. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79320. * @returns the corresponding value on the curve defined by the easing function
  79321. */
  79322. ease(gradient: number): number;
  79323. }
  79324. /**
  79325. * Base class used for every default easing function.
  79326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79327. */
  79328. export class EasingFunction implements IEasingFunction {
  79329. /**
  79330. * Interpolation follows the mathematical formula associated with the easing function.
  79331. */
  79332. static readonly EASINGMODE_EASEIN: number;
  79333. /**
  79334. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79335. */
  79336. static readonly EASINGMODE_EASEOUT: number;
  79337. /**
  79338. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79339. */
  79340. static readonly EASINGMODE_EASEINOUT: number;
  79341. private _easingMode;
  79342. /**
  79343. * Sets the easing mode of the current function.
  79344. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79345. */
  79346. setEasingMode(easingMode: number): void;
  79347. /**
  79348. * Gets the current easing mode.
  79349. * @returns the easing mode
  79350. */
  79351. getEasingMode(): number;
  79352. /**
  79353. * @hidden
  79354. */
  79355. easeInCore(gradient: number): number;
  79356. /**
  79357. * Given an input gradient between 0 and 1, this returns the corresponding value
  79358. * of the easing function.
  79359. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79360. * @returns the corresponding value on the curve defined by the easing function
  79361. */
  79362. ease(gradient: number): number;
  79363. }
  79364. /**
  79365. * Easing function with a circle shape (see link below).
  79366. * @see https://easings.net/#easeInCirc
  79367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79368. */
  79369. export class CircleEase extends EasingFunction implements IEasingFunction {
  79370. /** @hidden */
  79371. easeInCore(gradient: number): number;
  79372. }
  79373. /**
  79374. * Easing function with a ease back shape (see link below).
  79375. * @see https://easings.net/#easeInBack
  79376. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79377. */
  79378. export class BackEase extends EasingFunction implements IEasingFunction {
  79379. /** Defines the amplitude of the function */
  79380. amplitude: number;
  79381. /**
  79382. * Instantiates a back ease easing
  79383. * @see https://easings.net/#easeInBack
  79384. * @param amplitude Defines the amplitude of the function
  79385. */
  79386. constructor(
  79387. /** Defines the amplitude of the function */
  79388. amplitude?: number);
  79389. /** @hidden */
  79390. easeInCore(gradient: number): number;
  79391. }
  79392. /**
  79393. * Easing function with a bouncing shape (see link below).
  79394. * @see https://easings.net/#easeInBounce
  79395. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79396. */
  79397. export class BounceEase extends EasingFunction implements IEasingFunction {
  79398. /** Defines the number of bounces */
  79399. bounces: number;
  79400. /** Defines the amplitude of the bounce */
  79401. bounciness: number;
  79402. /**
  79403. * Instantiates a bounce easing
  79404. * @see https://easings.net/#easeInBounce
  79405. * @param bounces Defines the number of bounces
  79406. * @param bounciness Defines the amplitude of the bounce
  79407. */
  79408. constructor(
  79409. /** Defines the number of bounces */
  79410. bounces?: number,
  79411. /** Defines the amplitude of the bounce */
  79412. bounciness?: number);
  79413. /** @hidden */
  79414. easeInCore(gradient: number): number;
  79415. }
  79416. /**
  79417. * Easing function with a power of 3 shape (see link below).
  79418. * @see https://easings.net/#easeInCubic
  79419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79420. */
  79421. export class CubicEase extends EasingFunction implements IEasingFunction {
  79422. /** @hidden */
  79423. easeInCore(gradient: number): number;
  79424. }
  79425. /**
  79426. * Easing function with an elastic shape (see link below).
  79427. * @see https://easings.net/#easeInElastic
  79428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79429. */
  79430. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79431. /** Defines the number of oscillations*/
  79432. oscillations: number;
  79433. /** Defines the amplitude of the oscillations*/
  79434. springiness: number;
  79435. /**
  79436. * Instantiates an elastic easing function
  79437. * @see https://easings.net/#easeInElastic
  79438. * @param oscillations Defines the number of oscillations
  79439. * @param springiness Defines the amplitude of the oscillations
  79440. */
  79441. constructor(
  79442. /** Defines the number of oscillations*/
  79443. oscillations?: number,
  79444. /** Defines the amplitude of the oscillations*/
  79445. springiness?: number);
  79446. /** @hidden */
  79447. easeInCore(gradient: number): number;
  79448. }
  79449. /**
  79450. * Easing function with an exponential shape (see link below).
  79451. * @see https://easings.net/#easeInExpo
  79452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79453. */
  79454. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79455. /** Defines the exponent of the function */
  79456. exponent: number;
  79457. /**
  79458. * Instantiates an exponential easing function
  79459. * @see https://easings.net/#easeInExpo
  79460. * @param exponent Defines the exponent of the function
  79461. */
  79462. constructor(
  79463. /** Defines the exponent of the function */
  79464. exponent?: number);
  79465. /** @hidden */
  79466. easeInCore(gradient: number): number;
  79467. }
  79468. /**
  79469. * Easing function with a power shape (see link below).
  79470. * @see https://easings.net/#easeInQuad
  79471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79472. */
  79473. export class PowerEase extends EasingFunction implements IEasingFunction {
  79474. /** Defines the power of the function */
  79475. power: number;
  79476. /**
  79477. * Instantiates an power base easing function
  79478. * @see https://easings.net/#easeInQuad
  79479. * @param power Defines the power of the function
  79480. */
  79481. constructor(
  79482. /** Defines the power of the function */
  79483. power?: number);
  79484. /** @hidden */
  79485. easeInCore(gradient: number): number;
  79486. }
  79487. /**
  79488. * Easing function with a power of 2 shape (see link below).
  79489. * @see https://easings.net/#easeInQuad
  79490. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79491. */
  79492. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79493. /** @hidden */
  79494. easeInCore(gradient: number): number;
  79495. }
  79496. /**
  79497. * Easing function with a power of 4 shape (see link below).
  79498. * @see https://easings.net/#easeInQuart
  79499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79500. */
  79501. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79502. /** @hidden */
  79503. easeInCore(gradient: number): number;
  79504. }
  79505. /**
  79506. * Easing function with a power of 5 shape (see link below).
  79507. * @see https://easings.net/#easeInQuint
  79508. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79509. */
  79510. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79511. /** @hidden */
  79512. easeInCore(gradient: number): number;
  79513. }
  79514. /**
  79515. * Easing function with a sin shape (see link below).
  79516. * @see https://easings.net/#easeInSine
  79517. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79518. */
  79519. export class SineEase extends EasingFunction implements IEasingFunction {
  79520. /** @hidden */
  79521. easeInCore(gradient: number): number;
  79522. }
  79523. /**
  79524. * Easing function with a bezier shape (see link below).
  79525. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79527. */
  79528. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79529. /** Defines the x component of the start tangent in the bezier curve */
  79530. x1: number;
  79531. /** Defines the y component of the start tangent in the bezier curve */
  79532. y1: number;
  79533. /** Defines the x component of the end tangent in the bezier curve */
  79534. x2: number;
  79535. /** Defines the y component of the end tangent in the bezier curve */
  79536. y2: number;
  79537. /**
  79538. * Instantiates a bezier function
  79539. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79540. * @param x1 Defines the x component of the start tangent in the bezier curve
  79541. * @param y1 Defines the y component of the start tangent in the bezier curve
  79542. * @param x2 Defines the x component of the end tangent in the bezier curve
  79543. * @param y2 Defines the y component of the end tangent in the bezier curve
  79544. */
  79545. constructor(
  79546. /** Defines the x component of the start tangent in the bezier curve */
  79547. x1?: number,
  79548. /** Defines the y component of the start tangent in the bezier curve */
  79549. y1?: number,
  79550. /** Defines the x component of the end tangent in the bezier curve */
  79551. x2?: number,
  79552. /** Defines the y component of the end tangent in the bezier curve */
  79553. y2?: number);
  79554. /** @hidden */
  79555. easeInCore(gradient: number): number;
  79556. }
  79557. }
  79558. declare module BABYLON {
  79559. /**
  79560. * Class used to hold a RBG color
  79561. */
  79562. export class Color3 {
  79563. /**
  79564. * Defines the red component (between 0 and 1, default is 0)
  79565. */
  79566. r: number;
  79567. /**
  79568. * Defines the green component (between 0 and 1, default is 0)
  79569. */
  79570. g: number;
  79571. /**
  79572. * Defines the blue component (between 0 and 1, default is 0)
  79573. */
  79574. b: number;
  79575. /**
  79576. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79577. * @param r defines the red component (between 0 and 1, default is 0)
  79578. * @param g defines the green component (between 0 and 1, default is 0)
  79579. * @param b defines the blue component (between 0 and 1, default is 0)
  79580. */
  79581. constructor(
  79582. /**
  79583. * Defines the red component (between 0 and 1, default is 0)
  79584. */
  79585. r?: number,
  79586. /**
  79587. * Defines the green component (between 0 and 1, default is 0)
  79588. */
  79589. g?: number,
  79590. /**
  79591. * Defines the blue component (between 0 and 1, default is 0)
  79592. */
  79593. b?: number);
  79594. /**
  79595. * Creates a string with the Color3 current values
  79596. * @returns the string representation of the Color3 object
  79597. */
  79598. toString(): string;
  79599. /**
  79600. * Returns the string "Color3"
  79601. * @returns "Color3"
  79602. */
  79603. getClassName(): string;
  79604. /**
  79605. * Compute the Color3 hash code
  79606. * @returns an unique number that can be used to hash Color3 objects
  79607. */
  79608. getHashCode(): number;
  79609. /**
  79610. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79611. * @param array defines the array where to store the r,g,b components
  79612. * @param index defines an optional index in the target array to define where to start storing values
  79613. * @returns the current Color3 object
  79614. */
  79615. toArray(array: FloatArray, index?: number): Color3;
  79616. /**
  79617. * Returns a new Color4 object from the current Color3 and the given alpha
  79618. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79619. * @returns a new Color4 object
  79620. */
  79621. toColor4(alpha?: number): Color4;
  79622. /**
  79623. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79624. * @returns the new array
  79625. */
  79626. asArray(): number[];
  79627. /**
  79628. * Returns the luminance value
  79629. * @returns a float value
  79630. */
  79631. toLuminance(): number;
  79632. /**
  79633. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79634. * @param otherColor defines the second operand
  79635. * @returns the new Color3 object
  79636. */
  79637. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79638. /**
  79639. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79640. * @param otherColor defines the second operand
  79641. * @param result defines the Color3 object where to store the result
  79642. * @returns the current Color3
  79643. */
  79644. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79645. /**
  79646. * Determines equality between Color3 objects
  79647. * @param otherColor defines the second operand
  79648. * @returns true if the rgb values are equal to the given ones
  79649. */
  79650. equals(otherColor: DeepImmutable<Color3>): boolean;
  79651. /**
  79652. * Determines equality between the current Color3 object and a set of r,b,g values
  79653. * @param r defines the red component to check
  79654. * @param g defines the green component to check
  79655. * @param b defines the blue component to check
  79656. * @returns true if the rgb values are equal to the given ones
  79657. */
  79658. equalsFloats(r: number, g: number, b: number): boolean;
  79659. /**
  79660. * Multiplies in place each rgb value by scale
  79661. * @param scale defines the scaling factor
  79662. * @returns the updated Color3
  79663. */
  79664. scale(scale: number): Color3;
  79665. /**
  79666. * Multiplies the rgb values by scale and stores the result into "result"
  79667. * @param scale defines the scaling factor
  79668. * @param result defines the Color3 object where to store the result
  79669. * @returns the unmodified current Color3
  79670. */
  79671. scaleToRef(scale: number, result: Color3): Color3;
  79672. /**
  79673. * Scale the current Color3 values by a factor and add the result to a given Color3
  79674. * @param scale defines the scale factor
  79675. * @param result defines color to store the result into
  79676. * @returns the unmodified current Color3
  79677. */
  79678. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79679. /**
  79680. * Clamps the rgb values by the min and max values and stores the result into "result"
  79681. * @param min defines minimum clamping value (default is 0)
  79682. * @param max defines maximum clamping value (default is 1)
  79683. * @param result defines color to store the result into
  79684. * @returns the original Color3
  79685. */
  79686. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79687. /**
  79688. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79689. * @param otherColor defines the second operand
  79690. * @returns the new Color3
  79691. */
  79692. add(otherColor: DeepImmutable<Color3>): Color3;
  79693. /**
  79694. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79695. * @param otherColor defines the second operand
  79696. * @param result defines Color3 object to store the result into
  79697. * @returns the unmodified current Color3
  79698. */
  79699. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79700. /**
  79701. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79702. * @param otherColor defines the second operand
  79703. * @returns the new Color3
  79704. */
  79705. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79706. /**
  79707. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79708. * @param otherColor defines the second operand
  79709. * @param result defines Color3 object to store the result into
  79710. * @returns the unmodified current Color3
  79711. */
  79712. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79713. /**
  79714. * Copy the current object
  79715. * @returns a new Color3 copied the current one
  79716. */
  79717. clone(): Color3;
  79718. /**
  79719. * Copies the rgb values from the source in the current Color3
  79720. * @param source defines the source Color3 object
  79721. * @returns the updated Color3 object
  79722. */
  79723. copyFrom(source: DeepImmutable<Color3>): Color3;
  79724. /**
  79725. * Updates the Color3 rgb values from the given floats
  79726. * @param r defines the red component to read from
  79727. * @param g defines the green component to read from
  79728. * @param b defines the blue component to read from
  79729. * @returns the current Color3 object
  79730. */
  79731. copyFromFloats(r: number, g: number, b: number): Color3;
  79732. /**
  79733. * Updates the Color3 rgb values from the given floats
  79734. * @param r defines the red component to read from
  79735. * @param g defines the green component to read from
  79736. * @param b defines the blue component to read from
  79737. * @returns the current Color3 object
  79738. */
  79739. set(r: number, g: number, b: number): Color3;
  79740. /**
  79741. * Compute the Color3 hexadecimal code as a string
  79742. * @returns a string containing the hexadecimal representation of the Color3 object
  79743. */
  79744. toHexString(): string;
  79745. /**
  79746. * Computes a new Color3 converted from the current one to linear space
  79747. * @returns a new Color3 object
  79748. */
  79749. toLinearSpace(): Color3;
  79750. /**
  79751. * Converts current color in rgb space to HSV values
  79752. * @returns a new color3 representing the HSV values
  79753. */
  79754. toHSV(): Color3;
  79755. /**
  79756. * Converts current color in rgb space to HSV values
  79757. * @param result defines the Color3 where to store the HSV values
  79758. */
  79759. toHSVToRef(result: Color3): void;
  79760. /**
  79761. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79762. * @param convertedColor defines the Color3 object where to store the linear space version
  79763. * @returns the unmodified Color3
  79764. */
  79765. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79766. /**
  79767. * Computes a new Color3 converted from the current one to gamma space
  79768. * @returns a new Color3 object
  79769. */
  79770. toGammaSpace(): Color3;
  79771. /**
  79772. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79773. * @param convertedColor defines the Color3 object where to store the gamma space version
  79774. * @returns the unmodified Color3
  79775. */
  79776. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79777. private static _BlackReadOnly;
  79778. /**
  79779. * Convert Hue, saturation and value to a Color3 (RGB)
  79780. * @param hue defines the hue
  79781. * @param saturation defines the saturation
  79782. * @param value defines the value
  79783. * @param result defines the Color3 where to store the RGB values
  79784. */
  79785. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79786. /**
  79787. * Creates a new Color3 from the string containing valid hexadecimal values
  79788. * @param hex defines a string containing valid hexadecimal values
  79789. * @returns a new Color3 object
  79790. */
  79791. static FromHexString(hex: string): Color3;
  79792. /**
  79793. * Creates a new Color3 from the starting index of the given array
  79794. * @param array defines the source array
  79795. * @param offset defines an offset in the source array
  79796. * @returns a new Color3 object
  79797. */
  79798. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79799. /**
  79800. * Creates a new Color3 from integer values (< 256)
  79801. * @param r defines the red component to read from (value between 0 and 255)
  79802. * @param g defines the green component to read from (value between 0 and 255)
  79803. * @param b defines the blue component to read from (value between 0 and 255)
  79804. * @returns a new Color3 object
  79805. */
  79806. static FromInts(r: number, g: number, b: number): Color3;
  79807. /**
  79808. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79809. * @param start defines the start Color3 value
  79810. * @param end defines the end Color3 value
  79811. * @param amount defines the gradient value between start and end
  79812. * @returns a new Color3 object
  79813. */
  79814. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79815. /**
  79816. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79817. * @param left defines the start value
  79818. * @param right defines the end value
  79819. * @param amount defines the gradient factor
  79820. * @param result defines the Color3 object where to store the result
  79821. */
  79822. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79823. /**
  79824. * Returns a Color3 value containing a red color
  79825. * @returns a new Color3 object
  79826. */
  79827. static Red(): Color3;
  79828. /**
  79829. * Returns a Color3 value containing a green color
  79830. * @returns a new Color3 object
  79831. */
  79832. static Green(): Color3;
  79833. /**
  79834. * Returns a Color3 value containing a blue color
  79835. * @returns a new Color3 object
  79836. */
  79837. static Blue(): Color3;
  79838. /**
  79839. * Returns a Color3 value containing a black color
  79840. * @returns a new Color3 object
  79841. */
  79842. static Black(): Color3;
  79843. /**
  79844. * Gets a Color3 value containing a black color that must not be updated
  79845. */
  79846. static get BlackReadOnly(): DeepImmutable<Color3>;
  79847. /**
  79848. * Returns a Color3 value containing a white color
  79849. * @returns a new Color3 object
  79850. */
  79851. static White(): Color3;
  79852. /**
  79853. * Returns a Color3 value containing a purple color
  79854. * @returns a new Color3 object
  79855. */
  79856. static Purple(): Color3;
  79857. /**
  79858. * Returns a Color3 value containing a magenta color
  79859. * @returns a new Color3 object
  79860. */
  79861. static Magenta(): Color3;
  79862. /**
  79863. * Returns a Color3 value containing a yellow color
  79864. * @returns a new Color3 object
  79865. */
  79866. static Yellow(): Color3;
  79867. /**
  79868. * Returns a Color3 value containing a gray color
  79869. * @returns a new Color3 object
  79870. */
  79871. static Gray(): Color3;
  79872. /**
  79873. * Returns a Color3 value containing a teal color
  79874. * @returns a new Color3 object
  79875. */
  79876. static Teal(): Color3;
  79877. /**
  79878. * Returns a Color3 value containing a random color
  79879. * @returns a new Color3 object
  79880. */
  79881. static Random(): Color3;
  79882. }
  79883. /**
  79884. * Class used to hold a RBGA color
  79885. */
  79886. export class Color4 {
  79887. /**
  79888. * Defines the red component (between 0 and 1, default is 0)
  79889. */
  79890. r: number;
  79891. /**
  79892. * Defines the green component (between 0 and 1, default is 0)
  79893. */
  79894. g: number;
  79895. /**
  79896. * Defines the blue component (between 0 and 1, default is 0)
  79897. */
  79898. b: number;
  79899. /**
  79900. * Defines the alpha component (between 0 and 1, default is 1)
  79901. */
  79902. a: number;
  79903. /**
  79904. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79905. * @param r defines the red component (between 0 and 1, default is 0)
  79906. * @param g defines the green component (between 0 and 1, default is 0)
  79907. * @param b defines the blue component (between 0 and 1, default is 0)
  79908. * @param a defines the alpha component (between 0 and 1, default is 1)
  79909. */
  79910. constructor(
  79911. /**
  79912. * Defines the red component (between 0 and 1, default is 0)
  79913. */
  79914. r?: number,
  79915. /**
  79916. * Defines the green component (between 0 and 1, default is 0)
  79917. */
  79918. g?: number,
  79919. /**
  79920. * Defines the blue component (between 0 and 1, default is 0)
  79921. */
  79922. b?: number,
  79923. /**
  79924. * Defines the alpha component (between 0 and 1, default is 1)
  79925. */
  79926. a?: number);
  79927. /**
  79928. * Adds in place the given Color4 values to the current Color4 object
  79929. * @param right defines the second operand
  79930. * @returns the current updated Color4 object
  79931. */
  79932. addInPlace(right: DeepImmutable<Color4>): Color4;
  79933. /**
  79934. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79935. * @returns the new array
  79936. */
  79937. asArray(): number[];
  79938. /**
  79939. * Stores from the starting index in the given array the Color4 successive values
  79940. * @param array defines the array where to store the r,g,b components
  79941. * @param index defines an optional index in the target array to define where to start storing values
  79942. * @returns the current Color4 object
  79943. */
  79944. toArray(array: number[], index?: number): Color4;
  79945. /**
  79946. * Determines equality between Color4 objects
  79947. * @param otherColor defines the second operand
  79948. * @returns true if the rgba values are equal to the given ones
  79949. */
  79950. equals(otherColor: DeepImmutable<Color4>): boolean;
  79951. /**
  79952. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79953. * @param right defines the second operand
  79954. * @returns a new Color4 object
  79955. */
  79956. add(right: DeepImmutable<Color4>): Color4;
  79957. /**
  79958. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79959. * @param right defines the second operand
  79960. * @returns a new Color4 object
  79961. */
  79962. subtract(right: DeepImmutable<Color4>): Color4;
  79963. /**
  79964. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79965. * @param right defines the second operand
  79966. * @param result defines the Color4 object where to store the result
  79967. * @returns the current Color4 object
  79968. */
  79969. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79970. /**
  79971. * Creates a new Color4 with the current Color4 values multiplied by scale
  79972. * @param scale defines the scaling factor to apply
  79973. * @returns a new Color4 object
  79974. */
  79975. scale(scale: number): Color4;
  79976. /**
  79977. * Multiplies the current Color4 values by scale and stores the result in "result"
  79978. * @param scale defines the scaling factor to apply
  79979. * @param result defines the Color4 object where to store the result
  79980. * @returns the current unmodified Color4
  79981. */
  79982. scaleToRef(scale: number, result: Color4): Color4;
  79983. /**
  79984. * Scale the current Color4 values by a factor and add the result to a given Color4
  79985. * @param scale defines the scale factor
  79986. * @param result defines the Color4 object where to store the result
  79987. * @returns the unmodified current Color4
  79988. */
  79989. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79990. /**
  79991. * Clamps the rgb values by the min and max values and stores the result into "result"
  79992. * @param min defines minimum clamping value (default is 0)
  79993. * @param max defines maximum clamping value (default is 1)
  79994. * @param result defines color to store the result into.
  79995. * @returns the cuurent Color4
  79996. */
  79997. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79998. /**
  79999. * Multipy an Color4 value by another and return a new Color4 object
  80000. * @param color defines the Color4 value to multiply by
  80001. * @returns a new Color4 object
  80002. */
  80003. multiply(color: Color4): Color4;
  80004. /**
  80005. * Multipy a Color4 value by another and push the result in a reference value
  80006. * @param color defines the Color4 value to multiply by
  80007. * @param result defines the Color4 to fill the result in
  80008. * @returns the result Color4
  80009. */
  80010. multiplyToRef(color: Color4, result: Color4): Color4;
  80011. /**
  80012. * Creates a string with the Color4 current values
  80013. * @returns the string representation of the Color4 object
  80014. */
  80015. toString(): string;
  80016. /**
  80017. * Returns the string "Color4"
  80018. * @returns "Color4"
  80019. */
  80020. getClassName(): string;
  80021. /**
  80022. * Compute the Color4 hash code
  80023. * @returns an unique number that can be used to hash Color4 objects
  80024. */
  80025. getHashCode(): number;
  80026. /**
  80027. * Creates a new Color4 copied from the current one
  80028. * @returns a new Color4 object
  80029. */
  80030. clone(): Color4;
  80031. /**
  80032. * Copies the given Color4 values into the current one
  80033. * @param source defines the source Color4 object
  80034. * @returns the current updated Color4 object
  80035. */
  80036. copyFrom(source: Color4): Color4;
  80037. /**
  80038. * Copies the given float values into the current one
  80039. * @param r defines the red component to read from
  80040. * @param g defines the green component to read from
  80041. * @param b defines the blue component to read from
  80042. * @param a defines the alpha component to read from
  80043. * @returns the current updated Color4 object
  80044. */
  80045. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80046. /**
  80047. * Copies the given float values into the current one
  80048. * @param r defines the red component to read from
  80049. * @param g defines the green component to read from
  80050. * @param b defines the blue component to read from
  80051. * @param a defines the alpha component to read from
  80052. * @returns the current updated Color4 object
  80053. */
  80054. set(r: number, g: number, b: number, a: number): Color4;
  80055. /**
  80056. * Compute the Color4 hexadecimal code as a string
  80057. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80058. * @returns a string containing the hexadecimal representation of the Color4 object
  80059. */
  80060. toHexString(returnAsColor3?: boolean): string;
  80061. /**
  80062. * Computes a new Color4 converted from the current one to linear space
  80063. * @returns a new Color4 object
  80064. */
  80065. toLinearSpace(): Color4;
  80066. /**
  80067. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80068. * @param convertedColor defines the Color4 object where to store the linear space version
  80069. * @returns the unmodified Color4
  80070. */
  80071. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80072. /**
  80073. * Computes a new Color4 converted from the current one to gamma space
  80074. * @returns a new Color4 object
  80075. */
  80076. toGammaSpace(): Color4;
  80077. /**
  80078. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80079. * @param convertedColor defines the Color4 object where to store the gamma space version
  80080. * @returns the unmodified Color4
  80081. */
  80082. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80083. /**
  80084. * Creates a new Color4 from the string containing valid hexadecimal values
  80085. * @param hex defines a string containing valid hexadecimal values
  80086. * @returns a new Color4 object
  80087. */
  80088. static FromHexString(hex: string): Color4;
  80089. /**
  80090. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80091. * @param left defines the start value
  80092. * @param right defines the end value
  80093. * @param amount defines the gradient factor
  80094. * @returns a new Color4 object
  80095. */
  80096. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80097. /**
  80098. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80099. * @param left defines the start value
  80100. * @param right defines the end value
  80101. * @param amount defines the gradient factor
  80102. * @param result defines the Color4 object where to store data
  80103. */
  80104. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80105. /**
  80106. * Creates a new Color4 from a Color3 and an alpha value
  80107. * @param color3 defines the source Color3 to read from
  80108. * @param alpha defines the alpha component (1.0 by default)
  80109. * @returns a new Color4 object
  80110. */
  80111. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80112. /**
  80113. * Creates a new Color4 from the starting index element of the given array
  80114. * @param array defines the source array to read from
  80115. * @param offset defines the offset in the source array
  80116. * @returns a new Color4 object
  80117. */
  80118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80119. /**
  80120. * Creates a new Color3 from integer values (< 256)
  80121. * @param r defines the red component to read from (value between 0 and 255)
  80122. * @param g defines the green component to read from (value between 0 and 255)
  80123. * @param b defines the blue component to read from (value between 0 and 255)
  80124. * @param a defines the alpha component to read from (value between 0 and 255)
  80125. * @returns a new Color3 object
  80126. */
  80127. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80128. /**
  80129. * Check the content of a given array and convert it to an array containing RGBA data
  80130. * If the original array was already containing count * 4 values then it is returned directly
  80131. * @param colors defines the array to check
  80132. * @param count defines the number of RGBA data to expect
  80133. * @returns an array containing count * 4 values (RGBA)
  80134. */
  80135. static CheckColors4(colors: number[], count: number): number[];
  80136. }
  80137. /**
  80138. * @hidden
  80139. */
  80140. export class TmpColors {
  80141. static Color3: Color3[];
  80142. static Color4: Color4[];
  80143. }
  80144. }
  80145. declare module BABYLON {
  80146. /**
  80147. * Defines an interface which represents an animation key frame
  80148. */
  80149. export interface IAnimationKey {
  80150. /**
  80151. * Frame of the key frame
  80152. */
  80153. frame: number;
  80154. /**
  80155. * Value at the specifies key frame
  80156. */
  80157. value: any;
  80158. /**
  80159. * The input tangent for the cubic hermite spline
  80160. */
  80161. inTangent?: any;
  80162. /**
  80163. * The output tangent for the cubic hermite spline
  80164. */
  80165. outTangent?: any;
  80166. /**
  80167. * The animation interpolation type
  80168. */
  80169. interpolation?: AnimationKeyInterpolation;
  80170. }
  80171. /**
  80172. * Enum for the animation key frame interpolation type
  80173. */
  80174. export enum AnimationKeyInterpolation {
  80175. /**
  80176. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80177. */
  80178. STEP = 1
  80179. }
  80180. }
  80181. declare module BABYLON {
  80182. /**
  80183. * Represents the range of an animation
  80184. */
  80185. export class AnimationRange {
  80186. /**The name of the animation range**/
  80187. name: string;
  80188. /**The starting frame of the animation */
  80189. from: number;
  80190. /**The ending frame of the animation*/
  80191. to: number;
  80192. /**
  80193. * Initializes the range of an animation
  80194. * @param name The name of the animation range
  80195. * @param from The starting frame of the animation
  80196. * @param to The ending frame of the animation
  80197. */
  80198. constructor(
  80199. /**The name of the animation range**/
  80200. name: string,
  80201. /**The starting frame of the animation */
  80202. from: number,
  80203. /**The ending frame of the animation*/
  80204. to: number);
  80205. /**
  80206. * Makes a copy of the animation range
  80207. * @returns A copy of the animation range
  80208. */
  80209. clone(): AnimationRange;
  80210. }
  80211. }
  80212. declare module BABYLON {
  80213. /**
  80214. * Composed of a frame, and an action function
  80215. */
  80216. export class AnimationEvent {
  80217. /** The frame for which the event is triggered **/
  80218. frame: number;
  80219. /** The event to perform when triggered **/
  80220. action: (currentFrame: number) => void;
  80221. /** Specifies if the event should be triggered only once**/
  80222. onlyOnce?: boolean | undefined;
  80223. /**
  80224. * Specifies if the animation event is done
  80225. */
  80226. isDone: boolean;
  80227. /**
  80228. * Initializes the animation event
  80229. * @param frame The frame for which the event is triggered
  80230. * @param action The event to perform when triggered
  80231. * @param onlyOnce Specifies if the event should be triggered only once
  80232. */
  80233. constructor(
  80234. /** The frame for which the event is triggered **/
  80235. frame: number,
  80236. /** The event to perform when triggered **/
  80237. action: (currentFrame: number) => void,
  80238. /** Specifies if the event should be triggered only once**/
  80239. onlyOnce?: boolean | undefined);
  80240. /** @hidden */
  80241. _clone(): AnimationEvent;
  80242. }
  80243. }
  80244. declare module BABYLON {
  80245. /**
  80246. * Interface used to define a behavior
  80247. */
  80248. export interface Behavior<T> {
  80249. /** gets or sets behavior's name */
  80250. name: string;
  80251. /**
  80252. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80253. */
  80254. init(): void;
  80255. /**
  80256. * Called when the behavior is attached to a target
  80257. * @param target defines the target where the behavior is attached to
  80258. */
  80259. attach(target: T): void;
  80260. /**
  80261. * Called when the behavior is detached from its target
  80262. */
  80263. detach(): void;
  80264. }
  80265. /**
  80266. * Interface implemented by classes supporting behaviors
  80267. */
  80268. export interface IBehaviorAware<T> {
  80269. /**
  80270. * Attach a behavior
  80271. * @param behavior defines the behavior to attach
  80272. * @returns the current host
  80273. */
  80274. addBehavior(behavior: Behavior<T>): T;
  80275. /**
  80276. * Remove a behavior from the current object
  80277. * @param behavior defines the behavior to detach
  80278. * @returns the current host
  80279. */
  80280. removeBehavior(behavior: Behavior<T>): T;
  80281. /**
  80282. * Gets a behavior using its name to search
  80283. * @param name defines the name to search
  80284. * @returns the behavior or null if not found
  80285. */
  80286. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80287. }
  80288. }
  80289. declare module BABYLON {
  80290. /**
  80291. * Defines an array and its length.
  80292. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80293. */
  80294. export interface ISmartArrayLike<T> {
  80295. /**
  80296. * The data of the array.
  80297. */
  80298. data: Array<T>;
  80299. /**
  80300. * The active length of the array.
  80301. */
  80302. length: number;
  80303. }
  80304. /**
  80305. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80306. */
  80307. export class SmartArray<T> implements ISmartArrayLike<T> {
  80308. /**
  80309. * The full set of data from the array.
  80310. */
  80311. data: Array<T>;
  80312. /**
  80313. * The active length of the array.
  80314. */
  80315. length: number;
  80316. protected _id: number;
  80317. /**
  80318. * Instantiates a Smart Array.
  80319. * @param capacity defines the default capacity of the array.
  80320. */
  80321. constructor(capacity: number);
  80322. /**
  80323. * Pushes a value at the end of the active data.
  80324. * @param value defines the object to push in the array.
  80325. */
  80326. push(value: T): void;
  80327. /**
  80328. * Iterates over the active data and apply the lambda to them.
  80329. * @param func defines the action to apply on each value.
  80330. */
  80331. forEach(func: (content: T) => void): void;
  80332. /**
  80333. * Sorts the full sets of data.
  80334. * @param compareFn defines the comparison function to apply.
  80335. */
  80336. sort(compareFn: (a: T, b: T) => number): void;
  80337. /**
  80338. * Resets the active data to an empty array.
  80339. */
  80340. reset(): void;
  80341. /**
  80342. * Releases all the data from the array as well as the array.
  80343. */
  80344. dispose(): void;
  80345. /**
  80346. * Concats the active data with a given array.
  80347. * @param array defines the data to concatenate with.
  80348. */
  80349. concat(array: any): void;
  80350. /**
  80351. * Returns the position of a value in the active data.
  80352. * @param value defines the value to find the index for
  80353. * @returns the index if found in the active data otherwise -1
  80354. */
  80355. indexOf(value: T): number;
  80356. /**
  80357. * Returns whether an element is part of the active data.
  80358. * @param value defines the value to look for
  80359. * @returns true if found in the active data otherwise false
  80360. */
  80361. contains(value: T): boolean;
  80362. private static _GlobalId;
  80363. }
  80364. /**
  80365. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80366. * The data in this array can only be present once
  80367. */
  80368. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80369. private _duplicateId;
  80370. /**
  80371. * Pushes a value at the end of the active data.
  80372. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80373. * @param value defines the object to push in the array.
  80374. */
  80375. push(value: T): void;
  80376. /**
  80377. * Pushes a value at the end of the active data.
  80378. * If the data is already present, it won t be added again
  80379. * @param value defines the object to push in the array.
  80380. * @returns true if added false if it was already present
  80381. */
  80382. pushNoDuplicate(value: T): boolean;
  80383. /**
  80384. * Resets the active data to an empty array.
  80385. */
  80386. reset(): void;
  80387. /**
  80388. * Concats the active data with a given array.
  80389. * This ensures no dupplicate will be present in the result.
  80390. * @param array defines the data to concatenate with.
  80391. */
  80392. concatWithNoDuplicate(array: any): void;
  80393. }
  80394. }
  80395. declare module BABYLON {
  80396. /**
  80397. * @ignore
  80398. * This is a list of all the different input types that are available in the application.
  80399. * Fo instance: ArcRotateCameraGamepadInput...
  80400. */
  80401. export var CameraInputTypes: {};
  80402. /**
  80403. * This is the contract to implement in order to create a new input class.
  80404. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80405. */
  80406. export interface ICameraInput<TCamera extends Camera> {
  80407. /**
  80408. * Defines the camera the input is attached to.
  80409. */
  80410. camera: Nullable<TCamera>;
  80411. /**
  80412. * Gets the class name of the current intput.
  80413. * @returns the class name
  80414. */
  80415. getClassName(): string;
  80416. /**
  80417. * Get the friendly name associated with the input class.
  80418. * @returns the input friendly name
  80419. */
  80420. getSimpleName(): string;
  80421. /**
  80422. * Attach the input controls to a specific dom element to get the input from.
  80423. * @param element Defines the element the controls should be listened from
  80424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80425. */
  80426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80427. /**
  80428. * Detach the current controls from the specified dom element.
  80429. * @param element Defines the element to stop listening the inputs from
  80430. */
  80431. detachControl(element: Nullable<HTMLElement>): void;
  80432. /**
  80433. * Update the current camera state depending on the inputs that have been used this frame.
  80434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80435. */
  80436. checkInputs?: () => void;
  80437. }
  80438. /**
  80439. * Represents a map of input types to input instance or input index to input instance.
  80440. */
  80441. export interface CameraInputsMap<TCamera extends Camera> {
  80442. /**
  80443. * Accessor to the input by input type.
  80444. */
  80445. [name: string]: ICameraInput<TCamera>;
  80446. /**
  80447. * Accessor to the input by input index.
  80448. */
  80449. [idx: number]: ICameraInput<TCamera>;
  80450. }
  80451. /**
  80452. * This represents the input manager used within a camera.
  80453. * It helps dealing with all the different kind of input attached to a camera.
  80454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80455. */
  80456. export class CameraInputsManager<TCamera extends Camera> {
  80457. /**
  80458. * Defines the list of inputs attahed to the camera.
  80459. */
  80460. attached: CameraInputsMap<TCamera>;
  80461. /**
  80462. * Defines the dom element the camera is collecting inputs from.
  80463. * This is null if the controls have not been attached.
  80464. */
  80465. attachedElement: Nullable<HTMLElement>;
  80466. /**
  80467. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80468. */
  80469. noPreventDefault: boolean;
  80470. /**
  80471. * Defined the camera the input manager belongs to.
  80472. */
  80473. camera: TCamera;
  80474. /**
  80475. * Update the current camera state depending on the inputs that have been used this frame.
  80476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80477. */
  80478. checkInputs: () => void;
  80479. /**
  80480. * Instantiate a new Camera Input Manager.
  80481. * @param camera Defines the camera the input manager blongs to
  80482. */
  80483. constructor(camera: TCamera);
  80484. /**
  80485. * Add an input method to a camera
  80486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80487. * @param input camera input method
  80488. */
  80489. add(input: ICameraInput<TCamera>): void;
  80490. /**
  80491. * Remove a specific input method from a camera
  80492. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80493. * @param inputToRemove camera input method
  80494. */
  80495. remove(inputToRemove: ICameraInput<TCamera>): void;
  80496. /**
  80497. * Remove a specific input type from a camera
  80498. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80499. * @param inputType the type of the input to remove
  80500. */
  80501. removeByType(inputType: string): void;
  80502. private _addCheckInputs;
  80503. /**
  80504. * Attach the input controls to the currently attached dom element to listen the events from.
  80505. * @param input Defines the input to attach
  80506. */
  80507. attachInput(input: ICameraInput<TCamera>): void;
  80508. /**
  80509. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80510. * @param element Defines the dom element to collect the events from
  80511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80512. */
  80513. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80514. /**
  80515. * Detach the current manager inputs controls from a specific dom element.
  80516. * @param element Defines the dom element to collect the events from
  80517. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80518. */
  80519. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80520. /**
  80521. * Rebuild the dynamic inputCheck function from the current list of
  80522. * defined inputs in the manager.
  80523. */
  80524. rebuildInputCheck(): void;
  80525. /**
  80526. * Remove all attached input methods from a camera
  80527. */
  80528. clear(): void;
  80529. /**
  80530. * Serialize the current input manager attached to a camera.
  80531. * This ensures than once parsed,
  80532. * the input associated to the camera will be identical to the current ones
  80533. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80534. */
  80535. serialize(serializedCamera: any): void;
  80536. /**
  80537. * Parses an input manager serialized JSON to restore the previous list of inputs
  80538. * and states associated to a camera.
  80539. * @param parsedCamera Defines the JSON to parse
  80540. */
  80541. parse(parsedCamera: any): void;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. /**
  80546. * Class used to store data that will be store in GPU memory
  80547. */
  80548. export class Buffer {
  80549. private _engine;
  80550. private _buffer;
  80551. /** @hidden */
  80552. _data: Nullable<DataArray>;
  80553. private _updatable;
  80554. private _instanced;
  80555. private _divisor;
  80556. /**
  80557. * Gets the byte stride.
  80558. */
  80559. readonly byteStride: number;
  80560. /**
  80561. * Constructor
  80562. * @param engine the engine
  80563. * @param data the data to use for this buffer
  80564. * @param updatable whether the data is updatable
  80565. * @param stride the stride (optional)
  80566. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80567. * @param instanced whether the buffer is instanced (optional)
  80568. * @param useBytes set to true if the stride in in bytes (optional)
  80569. * @param divisor sets an optional divisor for instances (1 by default)
  80570. */
  80571. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80572. /**
  80573. * Create a new VertexBuffer based on the current buffer
  80574. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80575. * @param offset defines offset in the buffer (0 by default)
  80576. * @param size defines the size in floats of attributes (position is 3 for instance)
  80577. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80578. * @param instanced defines if the vertex buffer contains indexed data
  80579. * @param useBytes defines if the offset and stride are in bytes *
  80580. * @param divisor sets an optional divisor for instances (1 by default)
  80581. * @returns the new vertex buffer
  80582. */
  80583. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80584. /**
  80585. * Gets a boolean indicating if the Buffer is updatable?
  80586. * @returns true if the buffer is updatable
  80587. */
  80588. isUpdatable(): boolean;
  80589. /**
  80590. * Gets current buffer's data
  80591. * @returns a DataArray or null
  80592. */
  80593. getData(): Nullable<DataArray>;
  80594. /**
  80595. * Gets underlying native buffer
  80596. * @returns underlying native buffer
  80597. */
  80598. getBuffer(): Nullable<DataBuffer>;
  80599. /**
  80600. * Gets the stride in float32 units (i.e. byte stride / 4).
  80601. * May not be an integer if the byte stride is not divisible by 4.
  80602. * @returns the stride in float32 units
  80603. * @deprecated Please use byteStride instead.
  80604. */
  80605. getStrideSize(): number;
  80606. /**
  80607. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80608. * @param data defines the data to store
  80609. */
  80610. create(data?: Nullable<DataArray>): void;
  80611. /** @hidden */
  80612. _rebuild(): void;
  80613. /**
  80614. * Update current buffer data
  80615. * @param data defines the data to store
  80616. */
  80617. update(data: DataArray): void;
  80618. /**
  80619. * Updates the data directly.
  80620. * @param data the new data
  80621. * @param offset the new offset
  80622. * @param vertexCount the vertex count (optional)
  80623. * @param useBytes set to true if the offset is in bytes
  80624. */
  80625. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80626. /**
  80627. * Release all resources
  80628. */
  80629. dispose(): void;
  80630. }
  80631. /**
  80632. * Specialized buffer used to store vertex data
  80633. */
  80634. export class VertexBuffer {
  80635. /** @hidden */
  80636. _buffer: Buffer;
  80637. private _kind;
  80638. private _size;
  80639. private _ownsBuffer;
  80640. private _instanced;
  80641. private _instanceDivisor;
  80642. /**
  80643. * The byte type.
  80644. */
  80645. static readonly BYTE: number;
  80646. /**
  80647. * The unsigned byte type.
  80648. */
  80649. static readonly UNSIGNED_BYTE: number;
  80650. /**
  80651. * The short type.
  80652. */
  80653. static readonly SHORT: number;
  80654. /**
  80655. * The unsigned short type.
  80656. */
  80657. static readonly UNSIGNED_SHORT: number;
  80658. /**
  80659. * The integer type.
  80660. */
  80661. static readonly INT: number;
  80662. /**
  80663. * The unsigned integer type.
  80664. */
  80665. static readonly UNSIGNED_INT: number;
  80666. /**
  80667. * The float type.
  80668. */
  80669. static readonly FLOAT: number;
  80670. /**
  80671. * Gets or sets the instance divisor when in instanced mode
  80672. */
  80673. get instanceDivisor(): number;
  80674. set instanceDivisor(value: number);
  80675. /**
  80676. * Gets the byte stride.
  80677. */
  80678. readonly byteStride: number;
  80679. /**
  80680. * Gets the byte offset.
  80681. */
  80682. readonly byteOffset: number;
  80683. /**
  80684. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80685. */
  80686. readonly normalized: boolean;
  80687. /**
  80688. * Gets the data type of each component in the array.
  80689. */
  80690. readonly type: number;
  80691. /**
  80692. * Constructor
  80693. * @param engine the engine
  80694. * @param data the data to use for this vertex buffer
  80695. * @param kind the vertex buffer kind
  80696. * @param updatable whether the data is updatable
  80697. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80698. * @param stride the stride (optional)
  80699. * @param instanced whether the buffer is instanced (optional)
  80700. * @param offset the offset of the data (optional)
  80701. * @param size the number of components (optional)
  80702. * @param type the type of the component (optional)
  80703. * @param normalized whether the data contains normalized data (optional)
  80704. * @param useBytes set to true if stride and offset are in bytes (optional)
  80705. * @param divisor defines the instance divisor to use (1 by default)
  80706. */
  80707. 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);
  80708. /** @hidden */
  80709. _rebuild(): void;
  80710. /**
  80711. * Returns the kind of the VertexBuffer (string)
  80712. * @returns a string
  80713. */
  80714. getKind(): string;
  80715. /**
  80716. * Gets a boolean indicating if the VertexBuffer is updatable?
  80717. * @returns true if the buffer is updatable
  80718. */
  80719. isUpdatable(): boolean;
  80720. /**
  80721. * Gets current buffer's data
  80722. * @returns a DataArray or null
  80723. */
  80724. getData(): Nullable<DataArray>;
  80725. /**
  80726. * Gets underlying native buffer
  80727. * @returns underlying native buffer
  80728. */
  80729. getBuffer(): Nullable<DataBuffer>;
  80730. /**
  80731. * Gets the stride in float32 units (i.e. byte stride / 4).
  80732. * May not be an integer if the byte stride is not divisible by 4.
  80733. * @returns the stride in float32 units
  80734. * @deprecated Please use byteStride instead.
  80735. */
  80736. getStrideSize(): number;
  80737. /**
  80738. * Returns the offset as a multiple of the type byte length.
  80739. * @returns the offset in bytes
  80740. * @deprecated Please use byteOffset instead.
  80741. */
  80742. getOffset(): number;
  80743. /**
  80744. * Returns the number of components per vertex attribute (integer)
  80745. * @returns the size in float
  80746. */
  80747. getSize(): number;
  80748. /**
  80749. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80750. * @returns true if this buffer is instanced
  80751. */
  80752. getIsInstanced(): boolean;
  80753. /**
  80754. * Returns the instancing divisor, zero for non-instanced (integer).
  80755. * @returns a number
  80756. */
  80757. getInstanceDivisor(): number;
  80758. /**
  80759. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80760. * @param data defines the data to store
  80761. */
  80762. create(data?: DataArray): void;
  80763. /**
  80764. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80765. * This function will create a new buffer if the current one is not updatable
  80766. * @param data defines the data to store
  80767. */
  80768. update(data: DataArray): void;
  80769. /**
  80770. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80771. * Returns the directly updated WebGLBuffer.
  80772. * @param data the new data
  80773. * @param offset the new offset
  80774. * @param useBytes set to true if the offset is in bytes
  80775. */
  80776. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80777. /**
  80778. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80779. */
  80780. dispose(): void;
  80781. /**
  80782. * Enumerates each value of this vertex buffer as numbers.
  80783. * @param count the number of values to enumerate
  80784. * @param callback the callback function called for each value
  80785. */
  80786. forEach(count: number, callback: (value: number, index: number) => void): void;
  80787. /**
  80788. * Positions
  80789. */
  80790. static readonly PositionKind: string;
  80791. /**
  80792. * Normals
  80793. */
  80794. static readonly NormalKind: string;
  80795. /**
  80796. * Tangents
  80797. */
  80798. static readonly TangentKind: string;
  80799. /**
  80800. * Texture coordinates
  80801. */
  80802. static readonly UVKind: string;
  80803. /**
  80804. * Texture coordinates 2
  80805. */
  80806. static readonly UV2Kind: string;
  80807. /**
  80808. * Texture coordinates 3
  80809. */
  80810. static readonly UV3Kind: string;
  80811. /**
  80812. * Texture coordinates 4
  80813. */
  80814. static readonly UV4Kind: string;
  80815. /**
  80816. * Texture coordinates 5
  80817. */
  80818. static readonly UV5Kind: string;
  80819. /**
  80820. * Texture coordinates 6
  80821. */
  80822. static readonly UV6Kind: string;
  80823. /**
  80824. * Colors
  80825. */
  80826. static readonly ColorKind: string;
  80827. /**
  80828. * Matrix indices (for bones)
  80829. */
  80830. static readonly MatricesIndicesKind: string;
  80831. /**
  80832. * Matrix weights (for bones)
  80833. */
  80834. static readonly MatricesWeightsKind: string;
  80835. /**
  80836. * Additional matrix indices (for bones)
  80837. */
  80838. static readonly MatricesIndicesExtraKind: string;
  80839. /**
  80840. * Additional matrix weights (for bones)
  80841. */
  80842. static readonly MatricesWeightsExtraKind: string;
  80843. /**
  80844. * Deduces the stride given a kind.
  80845. * @param kind The kind string to deduce
  80846. * @returns The deduced stride
  80847. */
  80848. static DeduceStride(kind: string): number;
  80849. /**
  80850. * Gets the byte length of the given type.
  80851. * @param type the type
  80852. * @returns the number of bytes
  80853. */
  80854. static GetTypeByteLength(type: number): number;
  80855. /**
  80856. * Enumerates each value of the given parameters as numbers.
  80857. * @param data the data to enumerate
  80858. * @param byteOffset the byte offset of the data
  80859. * @param byteStride the byte stride of the data
  80860. * @param componentCount the number of components per element
  80861. * @param componentType the type of the component
  80862. * @param count the number of values to enumerate
  80863. * @param normalized whether the data is normalized
  80864. * @param callback the callback function called for each value
  80865. */
  80866. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80867. private static _GetFloatValue;
  80868. }
  80869. }
  80870. declare module BABYLON {
  80871. /**
  80872. * @hidden
  80873. */
  80874. export class IntersectionInfo {
  80875. bu: Nullable<number>;
  80876. bv: Nullable<number>;
  80877. distance: number;
  80878. faceId: number;
  80879. subMeshId: number;
  80880. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80881. }
  80882. }
  80883. declare module BABYLON {
  80884. /**
  80885. * Represens a plane by the equation ax + by + cz + d = 0
  80886. */
  80887. export class Plane {
  80888. private static _TmpMatrix;
  80889. /**
  80890. * Normal of the plane (a,b,c)
  80891. */
  80892. normal: Vector3;
  80893. /**
  80894. * d component of the plane
  80895. */
  80896. d: number;
  80897. /**
  80898. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80899. * @param a a component of the plane
  80900. * @param b b component of the plane
  80901. * @param c c component of the plane
  80902. * @param d d component of the plane
  80903. */
  80904. constructor(a: number, b: number, c: number, d: number);
  80905. /**
  80906. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80907. */
  80908. asArray(): number[];
  80909. /**
  80910. * @returns a new plane copied from the current Plane.
  80911. */
  80912. clone(): Plane;
  80913. /**
  80914. * @returns the string "Plane".
  80915. */
  80916. getClassName(): string;
  80917. /**
  80918. * @returns the Plane hash code.
  80919. */
  80920. getHashCode(): number;
  80921. /**
  80922. * Normalize the current Plane in place.
  80923. * @returns the updated Plane.
  80924. */
  80925. normalize(): Plane;
  80926. /**
  80927. * Applies a transformation the plane and returns the result
  80928. * @param transformation the transformation matrix to be applied to the plane
  80929. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80930. */
  80931. transform(transformation: DeepImmutable<Matrix>): Plane;
  80932. /**
  80933. * Calcualtte the dot product between the point and the plane normal
  80934. * @param point point to calculate the dot product with
  80935. * @returns the dot product (float) of the point coordinates and the plane normal.
  80936. */
  80937. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80938. /**
  80939. * Updates the current Plane from the plane defined by the three given points.
  80940. * @param point1 one of the points used to contruct the plane
  80941. * @param point2 one of the points used to contruct the plane
  80942. * @param point3 one of the points used to contruct the plane
  80943. * @returns the updated Plane.
  80944. */
  80945. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80946. /**
  80947. * Checks if the plane is facing a given direction
  80948. * @param direction the direction to check if the plane is facing
  80949. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80950. * @returns True is the vector "direction" is the same side than the plane normal.
  80951. */
  80952. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80953. /**
  80954. * Calculates the distance to a point
  80955. * @param point point to calculate distance to
  80956. * @returns the signed distance (float) from the given point to the Plane.
  80957. */
  80958. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80959. /**
  80960. * Creates a plane from an array
  80961. * @param array the array to create a plane from
  80962. * @returns a new Plane from the given array.
  80963. */
  80964. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80965. /**
  80966. * Creates a plane from three points
  80967. * @param point1 point used to create the plane
  80968. * @param point2 point used to create the plane
  80969. * @param point3 point used to create the plane
  80970. * @returns a new Plane defined by the three given points.
  80971. */
  80972. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80973. /**
  80974. * Creates a plane from an origin point and a normal
  80975. * @param origin origin of the plane to be constructed
  80976. * @param normal normal of the plane to be constructed
  80977. * @returns a new Plane the normal vector to this plane at the given origin point.
  80978. * Note : the vector "normal" is updated because normalized.
  80979. */
  80980. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80981. /**
  80982. * Calculates the distance from a plane and a point
  80983. * @param origin origin of the plane to be constructed
  80984. * @param normal normal of the plane to be constructed
  80985. * @param point point to calculate distance to
  80986. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80987. */
  80988. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80989. }
  80990. }
  80991. declare module BABYLON {
  80992. /**
  80993. * Class used to store bounding sphere information
  80994. */
  80995. export class BoundingSphere {
  80996. /**
  80997. * Gets the center of the bounding sphere in local space
  80998. */
  80999. readonly center: Vector3;
  81000. /**
  81001. * Radius of the bounding sphere in local space
  81002. */
  81003. radius: number;
  81004. /**
  81005. * Gets the center of the bounding sphere in world space
  81006. */
  81007. readonly centerWorld: Vector3;
  81008. /**
  81009. * Radius of the bounding sphere in world space
  81010. */
  81011. radiusWorld: number;
  81012. /**
  81013. * Gets the minimum vector in local space
  81014. */
  81015. readonly minimum: Vector3;
  81016. /**
  81017. * Gets the maximum vector in local space
  81018. */
  81019. readonly maximum: Vector3;
  81020. private _worldMatrix;
  81021. private static readonly TmpVector3;
  81022. /**
  81023. * Creates a new bounding sphere
  81024. * @param min defines the minimum vector (in local space)
  81025. * @param max defines the maximum vector (in local space)
  81026. * @param worldMatrix defines the new world matrix
  81027. */
  81028. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81029. /**
  81030. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81031. * @param min defines the new minimum vector (in local space)
  81032. * @param max defines the new maximum vector (in local space)
  81033. * @param worldMatrix defines the new world matrix
  81034. */
  81035. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81036. /**
  81037. * Scale the current bounding sphere by applying a scale factor
  81038. * @param factor defines the scale factor to apply
  81039. * @returns the current bounding box
  81040. */
  81041. scale(factor: number): BoundingSphere;
  81042. /**
  81043. * Gets the world matrix of the bounding box
  81044. * @returns a matrix
  81045. */
  81046. getWorldMatrix(): DeepImmutable<Matrix>;
  81047. /** @hidden */
  81048. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81049. /**
  81050. * Tests if the bounding sphere is intersecting the frustum planes
  81051. * @param frustumPlanes defines the frustum planes to test
  81052. * @returns true if there is an intersection
  81053. */
  81054. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81055. /**
  81056. * Tests if the bounding sphere center is in between the frustum planes.
  81057. * Used for optimistic fast inclusion.
  81058. * @param frustumPlanes defines the frustum planes to test
  81059. * @returns true if the sphere center is in between the frustum planes
  81060. */
  81061. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81062. /**
  81063. * Tests if a point is inside the bounding sphere
  81064. * @param point defines the point to test
  81065. * @returns true if the point is inside the bounding sphere
  81066. */
  81067. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81068. /**
  81069. * Checks if two sphere intersct
  81070. * @param sphere0 sphere 0
  81071. * @param sphere1 sphere 1
  81072. * @returns true if the speres intersect
  81073. */
  81074. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81075. }
  81076. }
  81077. declare module BABYLON {
  81078. /**
  81079. * Class used to store bounding box information
  81080. */
  81081. export class BoundingBox implements ICullable {
  81082. /**
  81083. * Gets the 8 vectors representing the bounding box in local space
  81084. */
  81085. readonly vectors: Vector3[];
  81086. /**
  81087. * Gets the center of the bounding box in local space
  81088. */
  81089. readonly center: Vector3;
  81090. /**
  81091. * Gets the center of the bounding box in world space
  81092. */
  81093. readonly centerWorld: Vector3;
  81094. /**
  81095. * Gets the extend size in local space
  81096. */
  81097. readonly extendSize: Vector3;
  81098. /**
  81099. * Gets the extend size in world space
  81100. */
  81101. readonly extendSizeWorld: Vector3;
  81102. /**
  81103. * Gets the OBB (object bounding box) directions
  81104. */
  81105. readonly directions: Vector3[];
  81106. /**
  81107. * Gets the 8 vectors representing the bounding box in world space
  81108. */
  81109. readonly vectorsWorld: Vector3[];
  81110. /**
  81111. * Gets the minimum vector in world space
  81112. */
  81113. readonly minimumWorld: Vector3;
  81114. /**
  81115. * Gets the maximum vector in world space
  81116. */
  81117. readonly maximumWorld: Vector3;
  81118. /**
  81119. * Gets the minimum vector in local space
  81120. */
  81121. readonly minimum: Vector3;
  81122. /**
  81123. * Gets the maximum vector in local space
  81124. */
  81125. readonly maximum: Vector3;
  81126. private _worldMatrix;
  81127. private static readonly TmpVector3;
  81128. /**
  81129. * @hidden
  81130. */
  81131. _tag: number;
  81132. /**
  81133. * Creates a new bounding box
  81134. * @param min defines the minimum vector (in local space)
  81135. * @param max defines the maximum vector (in local space)
  81136. * @param worldMatrix defines the new world matrix
  81137. */
  81138. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81139. /**
  81140. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81141. * @param min defines the new minimum vector (in local space)
  81142. * @param max defines the new maximum vector (in local space)
  81143. * @param worldMatrix defines the new world matrix
  81144. */
  81145. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81146. /**
  81147. * Scale the current bounding box by applying a scale factor
  81148. * @param factor defines the scale factor to apply
  81149. * @returns the current bounding box
  81150. */
  81151. scale(factor: number): BoundingBox;
  81152. /**
  81153. * Gets the world matrix of the bounding box
  81154. * @returns a matrix
  81155. */
  81156. getWorldMatrix(): DeepImmutable<Matrix>;
  81157. /** @hidden */
  81158. _update(world: DeepImmutable<Matrix>): void;
  81159. /**
  81160. * Tests if the bounding box is intersecting the frustum planes
  81161. * @param frustumPlanes defines the frustum planes to test
  81162. * @returns true if there is an intersection
  81163. */
  81164. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81165. /**
  81166. * Tests if the bounding box is entirely inside the frustum planes
  81167. * @param frustumPlanes defines the frustum planes to test
  81168. * @returns true if there is an inclusion
  81169. */
  81170. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81171. /**
  81172. * Tests if a point is inside the bounding box
  81173. * @param point defines the point to test
  81174. * @returns true if the point is inside the bounding box
  81175. */
  81176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81177. /**
  81178. * Tests if the bounding box intersects with a bounding sphere
  81179. * @param sphere defines the sphere to test
  81180. * @returns true if there is an intersection
  81181. */
  81182. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81183. /**
  81184. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81185. * @param min defines the min vector to use
  81186. * @param max defines the max vector to use
  81187. * @returns true if there is an intersection
  81188. */
  81189. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81190. /**
  81191. * Tests if two bounding boxes are intersections
  81192. * @param box0 defines the first box to test
  81193. * @param box1 defines the second box to test
  81194. * @returns true if there is an intersection
  81195. */
  81196. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81197. /**
  81198. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81199. * @param minPoint defines the minimum vector of the bounding box
  81200. * @param maxPoint defines the maximum vector of the bounding box
  81201. * @param sphereCenter defines the sphere center
  81202. * @param sphereRadius defines the sphere radius
  81203. * @returns true if there is an intersection
  81204. */
  81205. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81206. /**
  81207. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81208. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81209. * @param frustumPlanes defines the frustum planes to test
  81210. * @return true if there is an inclusion
  81211. */
  81212. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81213. /**
  81214. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81215. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81216. * @param frustumPlanes defines the frustum planes to test
  81217. * @return true if there is an intersection
  81218. */
  81219. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81220. }
  81221. }
  81222. declare module BABYLON {
  81223. /** @hidden */
  81224. export class Collider {
  81225. /** Define if a collision was found */
  81226. collisionFound: boolean;
  81227. /**
  81228. * Define last intersection point in local space
  81229. */
  81230. intersectionPoint: Vector3;
  81231. /**
  81232. * Define last collided mesh
  81233. */
  81234. collidedMesh: Nullable<AbstractMesh>;
  81235. private _collisionPoint;
  81236. private _planeIntersectionPoint;
  81237. private _tempVector;
  81238. private _tempVector2;
  81239. private _tempVector3;
  81240. private _tempVector4;
  81241. private _edge;
  81242. private _baseToVertex;
  81243. private _destinationPoint;
  81244. private _slidePlaneNormal;
  81245. private _displacementVector;
  81246. /** @hidden */
  81247. _radius: Vector3;
  81248. /** @hidden */
  81249. _retry: number;
  81250. private _velocity;
  81251. private _basePoint;
  81252. private _epsilon;
  81253. /** @hidden */
  81254. _velocityWorldLength: number;
  81255. /** @hidden */
  81256. _basePointWorld: Vector3;
  81257. private _velocityWorld;
  81258. private _normalizedVelocity;
  81259. /** @hidden */
  81260. _initialVelocity: Vector3;
  81261. /** @hidden */
  81262. _initialPosition: Vector3;
  81263. private _nearestDistance;
  81264. private _collisionMask;
  81265. get collisionMask(): number;
  81266. set collisionMask(mask: number);
  81267. /**
  81268. * Gets the plane normal used to compute the sliding response (in local space)
  81269. */
  81270. get slidePlaneNormal(): Vector3;
  81271. /** @hidden */
  81272. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81273. /** @hidden */
  81274. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81275. /** @hidden */
  81276. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81277. /** @hidden */
  81278. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81279. /** @hidden */
  81280. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81281. /** @hidden */
  81282. _getResponse(pos: Vector3, vel: Vector3): void;
  81283. }
  81284. }
  81285. declare module BABYLON {
  81286. /**
  81287. * Interface for cullable objects
  81288. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81289. */
  81290. export interface ICullable {
  81291. /**
  81292. * Checks if the object or part of the object is in the frustum
  81293. * @param frustumPlanes Camera near/planes
  81294. * @returns true if the object is in frustum otherwise false
  81295. */
  81296. isInFrustum(frustumPlanes: Plane[]): boolean;
  81297. /**
  81298. * Checks if a cullable object (mesh...) is in the camera frustum
  81299. * Unlike isInFrustum this cheks the full bounding box
  81300. * @param frustumPlanes Camera near/planes
  81301. * @returns true if the object is in frustum otherwise false
  81302. */
  81303. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81304. }
  81305. /**
  81306. * Info for a bounding data of a mesh
  81307. */
  81308. export class BoundingInfo implements ICullable {
  81309. /**
  81310. * Bounding box for the mesh
  81311. */
  81312. readonly boundingBox: BoundingBox;
  81313. /**
  81314. * Bounding sphere for the mesh
  81315. */
  81316. readonly boundingSphere: BoundingSphere;
  81317. private _isLocked;
  81318. private static readonly TmpVector3;
  81319. /**
  81320. * Constructs bounding info
  81321. * @param minimum min vector of the bounding box/sphere
  81322. * @param maximum max vector of the bounding box/sphere
  81323. * @param worldMatrix defines the new world matrix
  81324. */
  81325. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81326. /**
  81327. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81328. * @param min defines the new minimum vector (in local space)
  81329. * @param max defines the new maximum vector (in local space)
  81330. * @param worldMatrix defines the new world matrix
  81331. */
  81332. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81333. /**
  81334. * min vector of the bounding box/sphere
  81335. */
  81336. get minimum(): Vector3;
  81337. /**
  81338. * max vector of the bounding box/sphere
  81339. */
  81340. get maximum(): Vector3;
  81341. /**
  81342. * If the info is locked and won't be updated to avoid perf overhead
  81343. */
  81344. get isLocked(): boolean;
  81345. set isLocked(value: boolean);
  81346. /**
  81347. * Updates the bounding sphere and box
  81348. * @param world world matrix to be used to update
  81349. */
  81350. update(world: DeepImmutable<Matrix>): void;
  81351. /**
  81352. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81353. * @param center New center of the bounding info
  81354. * @param extend New extend of the bounding info
  81355. * @returns the current bounding info
  81356. */
  81357. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81358. /**
  81359. * Scale the current bounding info by applying a scale factor
  81360. * @param factor defines the scale factor to apply
  81361. * @returns the current bounding info
  81362. */
  81363. scale(factor: number): BoundingInfo;
  81364. /**
  81365. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81366. * @param frustumPlanes defines the frustum to test
  81367. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81368. * @returns true if the bounding info is in the frustum planes
  81369. */
  81370. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81371. /**
  81372. * Gets the world distance between the min and max points of the bounding box
  81373. */
  81374. get diagonalLength(): number;
  81375. /**
  81376. * Checks if a cullable object (mesh...) is in the camera frustum
  81377. * Unlike isInFrustum this cheks the full bounding box
  81378. * @param frustumPlanes Camera near/planes
  81379. * @returns true if the object is in frustum otherwise false
  81380. */
  81381. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81382. /** @hidden */
  81383. _checkCollision(collider: Collider): boolean;
  81384. /**
  81385. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81387. * @param point the point to check intersection with
  81388. * @returns if the point intersects
  81389. */
  81390. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81391. /**
  81392. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81393. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81394. * @param boundingInfo the bounding info to check intersection with
  81395. * @param precise if the intersection should be done using OBB
  81396. * @returns if the bounding info intersects
  81397. */
  81398. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81399. }
  81400. }
  81401. declare module BABYLON {
  81402. /**
  81403. * Extracts minimum and maximum values from a list of indexed positions
  81404. * @param positions defines the positions to use
  81405. * @param indices defines the indices to the positions
  81406. * @param indexStart defines the start index
  81407. * @param indexCount defines the end index
  81408. * @param bias defines bias value to add to the result
  81409. * @return minimum and maximum values
  81410. */
  81411. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81412. minimum: Vector3;
  81413. maximum: Vector3;
  81414. };
  81415. /**
  81416. * Extracts minimum and maximum values from a list of positions
  81417. * @param positions defines the positions to use
  81418. * @param start defines the start index in the positions array
  81419. * @param count defines the number of positions to handle
  81420. * @param bias defines bias value to add to the result
  81421. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81422. * @return minimum and maximum values
  81423. */
  81424. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81425. minimum: Vector3;
  81426. maximum: Vector3;
  81427. };
  81428. }
  81429. declare module BABYLON {
  81430. /** @hidden */
  81431. export class WebGLDataBuffer extends DataBuffer {
  81432. private _buffer;
  81433. constructor(resource: WebGLBuffer);
  81434. get underlyingResource(): any;
  81435. }
  81436. }
  81437. declare module BABYLON {
  81438. /** @hidden */
  81439. export class WebGLPipelineContext implements IPipelineContext {
  81440. engine: ThinEngine;
  81441. program: Nullable<WebGLProgram>;
  81442. context?: WebGLRenderingContext;
  81443. vertexShader?: WebGLShader;
  81444. fragmentShader?: WebGLShader;
  81445. isParallelCompiled: boolean;
  81446. onCompiled?: () => void;
  81447. transformFeedback?: WebGLTransformFeedback | null;
  81448. vertexCompilationError: Nullable<string>;
  81449. fragmentCompilationError: Nullable<string>;
  81450. programLinkError: Nullable<string>;
  81451. programValidationError: Nullable<string>;
  81452. get isAsync(): boolean;
  81453. get isReady(): boolean;
  81454. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81455. _getVertexShaderCode(): string | null;
  81456. _getFragmentShaderCode(): string | null;
  81457. }
  81458. }
  81459. declare module BABYLON {
  81460. interface ThinEngine {
  81461. /**
  81462. * Create an uniform buffer
  81463. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81464. * @param elements defines the content of the uniform buffer
  81465. * @returns the webGL uniform buffer
  81466. */
  81467. createUniformBuffer(elements: FloatArray): DataBuffer;
  81468. /**
  81469. * Create a dynamic uniform buffer
  81470. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81471. * @param elements defines the content of the uniform buffer
  81472. * @returns the webGL uniform buffer
  81473. */
  81474. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81475. /**
  81476. * Update an existing uniform buffer
  81477. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81478. * @param uniformBuffer defines the target uniform buffer
  81479. * @param elements defines the content to update
  81480. * @param offset defines the offset in the uniform buffer where update should start
  81481. * @param count defines the size of the data to update
  81482. */
  81483. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81484. /**
  81485. * Bind an uniform buffer to the current webGL context
  81486. * @param buffer defines the buffer to bind
  81487. */
  81488. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81489. /**
  81490. * Bind a buffer to the current webGL context at a given location
  81491. * @param buffer defines the buffer to bind
  81492. * @param location defines the index where to bind the buffer
  81493. */
  81494. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81495. /**
  81496. * Bind a specific block at a given index in a specific shader program
  81497. * @param pipelineContext defines the pipeline context to use
  81498. * @param blockName defines the block name
  81499. * @param index defines the index where to bind the block
  81500. */
  81501. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81502. }
  81503. }
  81504. declare module BABYLON {
  81505. /**
  81506. * Uniform buffer objects.
  81507. *
  81508. * Handles blocks of uniform on the GPU.
  81509. *
  81510. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81511. *
  81512. * For more information, please refer to :
  81513. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81514. */
  81515. export class UniformBuffer {
  81516. private _engine;
  81517. private _buffer;
  81518. private _data;
  81519. private _bufferData;
  81520. private _dynamic?;
  81521. private _uniformLocations;
  81522. private _uniformSizes;
  81523. private _uniformLocationPointer;
  81524. private _needSync;
  81525. private _noUBO;
  81526. private _currentEffect;
  81527. /** @hidden */
  81528. _alreadyBound: boolean;
  81529. private static _MAX_UNIFORM_SIZE;
  81530. private static _tempBuffer;
  81531. /**
  81532. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81533. * This is dynamic to allow compat with webgl 1 and 2.
  81534. * You will need to pass the name of the uniform as well as the value.
  81535. */
  81536. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81537. /**
  81538. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81539. * This is dynamic to allow compat with webgl 1 and 2.
  81540. * You will need to pass the name of the uniform as well as the value.
  81541. */
  81542. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81543. /**
  81544. * Lambda to Update a single float in a uniform buffer.
  81545. * This is dynamic to allow compat with webgl 1 and 2.
  81546. * You will need to pass the name of the uniform as well as the value.
  81547. */
  81548. updateFloat: (name: string, x: number) => void;
  81549. /**
  81550. * Lambda to Update a vec2 of float in a uniform buffer.
  81551. * This is dynamic to allow compat with webgl 1 and 2.
  81552. * You will need to pass the name of the uniform as well as the value.
  81553. */
  81554. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81555. /**
  81556. * Lambda to Update a vec3 of float in a uniform buffer.
  81557. * This is dynamic to allow compat with webgl 1 and 2.
  81558. * You will need to pass the name of the uniform as well as the value.
  81559. */
  81560. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81561. /**
  81562. * Lambda to Update a vec4 of float in a uniform buffer.
  81563. * This is dynamic to allow compat with webgl 1 and 2.
  81564. * You will need to pass the name of the uniform as well as the value.
  81565. */
  81566. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81567. /**
  81568. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81569. * This is dynamic to allow compat with webgl 1 and 2.
  81570. * You will need to pass the name of the uniform as well as the value.
  81571. */
  81572. updateMatrix: (name: string, mat: Matrix) => void;
  81573. /**
  81574. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81575. * This is dynamic to allow compat with webgl 1 and 2.
  81576. * You will need to pass the name of the uniform as well as the value.
  81577. */
  81578. updateVector3: (name: string, vector: Vector3) => void;
  81579. /**
  81580. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81581. * This is dynamic to allow compat with webgl 1 and 2.
  81582. * You will need to pass the name of the uniform as well as the value.
  81583. */
  81584. updateVector4: (name: string, vector: Vector4) => void;
  81585. /**
  81586. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81587. * This is dynamic to allow compat with webgl 1 and 2.
  81588. * You will need to pass the name of the uniform as well as the value.
  81589. */
  81590. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81591. /**
  81592. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81593. * This is dynamic to allow compat with webgl 1 and 2.
  81594. * You will need to pass the name of the uniform as well as the value.
  81595. */
  81596. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81597. /**
  81598. * Instantiates a new Uniform buffer objects.
  81599. *
  81600. * Handles blocks of uniform on the GPU.
  81601. *
  81602. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81603. *
  81604. * For more information, please refer to :
  81605. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81606. * @param engine Define the engine the buffer is associated with
  81607. * @param data Define the data contained in the buffer
  81608. * @param dynamic Define if the buffer is updatable
  81609. */
  81610. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81611. /**
  81612. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81613. * or just falling back on setUniformXXX calls.
  81614. */
  81615. get useUbo(): boolean;
  81616. /**
  81617. * Indicates if the WebGL underlying uniform buffer is in sync
  81618. * with the javascript cache data.
  81619. */
  81620. get isSync(): boolean;
  81621. /**
  81622. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81623. * Also, a dynamic UniformBuffer will disable cache verification and always
  81624. * update the underlying WebGL uniform buffer to the GPU.
  81625. * @returns if Dynamic, otherwise false
  81626. */
  81627. isDynamic(): boolean;
  81628. /**
  81629. * The data cache on JS side.
  81630. * @returns the underlying data as a float array
  81631. */
  81632. getData(): Float32Array;
  81633. /**
  81634. * The underlying WebGL Uniform buffer.
  81635. * @returns the webgl buffer
  81636. */
  81637. getBuffer(): Nullable<DataBuffer>;
  81638. /**
  81639. * std140 layout specifies how to align data within an UBO structure.
  81640. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81641. * for specs.
  81642. */
  81643. private _fillAlignment;
  81644. /**
  81645. * Adds an uniform in the buffer.
  81646. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81647. * for the layout to be correct !
  81648. * @param name Name of the uniform, as used in the uniform block in the shader.
  81649. * @param size Data size, or data directly.
  81650. */
  81651. addUniform(name: string, size: number | number[]): void;
  81652. /**
  81653. * Adds a Matrix 4x4 to the uniform buffer.
  81654. * @param name Name of the uniform, as used in the uniform block in the shader.
  81655. * @param mat A 4x4 matrix.
  81656. */
  81657. addMatrix(name: string, mat: Matrix): void;
  81658. /**
  81659. * Adds a vec2 to the uniform buffer.
  81660. * @param name Name of the uniform, as used in the uniform block in the shader.
  81661. * @param x Define the x component value of the vec2
  81662. * @param y Define the y component value of the vec2
  81663. */
  81664. addFloat2(name: string, x: number, y: number): void;
  81665. /**
  81666. * Adds a vec3 to the uniform buffer.
  81667. * @param name Name of the uniform, as used in the uniform block in the shader.
  81668. * @param x Define the x component value of the vec3
  81669. * @param y Define the y component value of the vec3
  81670. * @param z Define the z component value of the vec3
  81671. */
  81672. addFloat3(name: string, x: number, y: number, z: number): void;
  81673. /**
  81674. * Adds a vec3 to the uniform buffer.
  81675. * @param name Name of the uniform, as used in the uniform block in the shader.
  81676. * @param color Define the vec3 from a Color
  81677. */
  81678. addColor3(name: string, color: Color3): void;
  81679. /**
  81680. * Adds a vec4 to the uniform buffer.
  81681. * @param name Name of the uniform, as used in the uniform block in the shader.
  81682. * @param color Define the rgb components from a Color
  81683. * @param alpha Define the a component of the vec4
  81684. */
  81685. addColor4(name: string, color: Color3, alpha: 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 vector Define the vec3 components from a Vector
  81690. */
  81691. addVector3(name: string, vector: Vector3): void;
  81692. /**
  81693. * Adds a Matrix 3x3 to the uniform buffer.
  81694. * @param name Name of the uniform, as used in the uniform block in the shader.
  81695. */
  81696. addMatrix3x3(name: string): void;
  81697. /**
  81698. * Adds a Matrix 2x2 to the uniform buffer.
  81699. * @param name Name of the uniform, as used in the uniform block in the shader.
  81700. */
  81701. addMatrix2x2(name: string): void;
  81702. /**
  81703. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81704. */
  81705. create(): void;
  81706. /** @hidden */
  81707. _rebuild(): void;
  81708. /**
  81709. * Updates the WebGL Uniform Buffer on the GPU.
  81710. * If the `dynamic` flag is set to true, no cache comparison is done.
  81711. * Otherwise, the buffer will be updated only if the cache differs.
  81712. */
  81713. update(): void;
  81714. /**
  81715. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81717. * @param data Define the flattened data
  81718. * @param size Define the size of the data.
  81719. */
  81720. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81721. private _valueCache;
  81722. private _cacheMatrix;
  81723. private _updateMatrix3x3ForUniform;
  81724. private _updateMatrix3x3ForEffect;
  81725. private _updateMatrix2x2ForEffect;
  81726. private _updateMatrix2x2ForUniform;
  81727. private _updateFloatForEffect;
  81728. private _updateFloatForUniform;
  81729. private _updateFloat2ForEffect;
  81730. private _updateFloat2ForUniform;
  81731. private _updateFloat3ForEffect;
  81732. private _updateFloat3ForUniform;
  81733. private _updateFloat4ForEffect;
  81734. private _updateFloat4ForUniform;
  81735. private _updateMatrixForEffect;
  81736. private _updateMatrixForUniform;
  81737. private _updateVector3ForEffect;
  81738. private _updateVector3ForUniform;
  81739. private _updateVector4ForEffect;
  81740. private _updateVector4ForUniform;
  81741. private _updateColor3ForEffect;
  81742. private _updateColor3ForUniform;
  81743. private _updateColor4ForEffect;
  81744. private _updateColor4ForUniform;
  81745. /**
  81746. * Sets a sampler uniform on the effect.
  81747. * @param name Define the name of the sampler.
  81748. * @param texture Define the texture to set in the sampler
  81749. */
  81750. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81751. /**
  81752. * Directly updates the value of the uniform in the cache AND on the GPU.
  81753. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81754. * @param data Define the flattened data
  81755. */
  81756. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81757. /**
  81758. * Binds this uniform buffer to an effect.
  81759. * @param effect Define the effect to bind the buffer to
  81760. * @param name Name of the uniform block in the shader.
  81761. */
  81762. bindToEffect(effect: Effect, name: string): void;
  81763. /**
  81764. * Disposes the uniform buffer.
  81765. */
  81766. dispose(): void;
  81767. }
  81768. }
  81769. declare module BABYLON {
  81770. /**
  81771. * Enum that determines the text-wrapping mode to use.
  81772. */
  81773. export enum InspectableType {
  81774. /**
  81775. * Checkbox for booleans
  81776. */
  81777. Checkbox = 0,
  81778. /**
  81779. * Sliders for numbers
  81780. */
  81781. Slider = 1,
  81782. /**
  81783. * Vector3
  81784. */
  81785. Vector3 = 2,
  81786. /**
  81787. * Quaternions
  81788. */
  81789. Quaternion = 3,
  81790. /**
  81791. * Color3
  81792. */
  81793. Color3 = 4,
  81794. /**
  81795. * String
  81796. */
  81797. String = 5
  81798. }
  81799. /**
  81800. * Interface used to define custom inspectable properties.
  81801. * This interface is used by the inspector to display custom property grids
  81802. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81803. */
  81804. export interface IInspectable {
  81805. /**
  81806. * Gets the label to display
  81807. */
  81808. label: string;
  81809. /**
  81810. * Gets the name of the property to edit
  81811. */
  81812. propertyName: string;
  81813. /**
  81814. * Gets the type of the editor to use
  81815. */
  81816. type: InspectableType;
  81817. /**
  81818. * Gets the minimum value of the property when using in "slider" mode
  81819. */
  81820. min?: number;
  81821. /**
  81822. * Gets the maximum value of the property when using in "slider" mode
  81823. */
  81824. max?: number;
  81825. /**
  81826. * Gets the setp to use when using in "slider" mode
  81827. */
  81828. step?: number;
  81829. }
  81830. }
  81831. declare module BABYLON {
  81832. /**
  81833. * Class used to provide helper for timing
  81834. */
  81835. export class TimingTools {
  81836. /**
  81837. * Polyfill for setImmediate
  81838. * @param action defines the action to execute after the current execution block
  81839. */
  81840. static SetImmediate(action: () => void): void;
  81841. }
  81842. }
  81843. declare module BABYLON {
  81844. /**
  81845. * Class used to enable instatition of objects by class name
  81846. */
  81847. export class InstantiationTools {
  81848. /**
  81849. * Use this object to register external classes like custom textures or material
  81850. * to allow the laoders to instantiate them
  81851. */
  81852. static RegisteredExternalClasses: {
  81853. [key: string]: Object;
  81854. };
  81855. /**
  81856. * Tries to instantiate a new object from a given class name
  81857. * @param className defines the class name to instantiate
  81858. * @returns the new object or null if the system was not able to do the instantiation
  81859. */
  81860. static Instantiate(className: string): any;
  81861. }
  81862. }
  81863. declare module BABYLON {
  81864. /**
  81865. * Define options used to create a depth texture
  81866. */
  81867. export class DepthTextureCreationOptions {
  81868. /** Specifies whether or not a stencil should be allocated in the texture */
  81869. generateStencil?: boolean;
  81870. /** Specifies whether or not bilinear filtering is enable on the texture */
  81871. bilinearFiltering?: boolean;
  81872. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81873. comparisonFunction?: number;
  81874. /** Specifies if the created texture is a cube texture */
  81875. isCube?: boolean;
  81876. }
  81877. }
  81878. declare module BABYLON {
  81879. interface ThinEngine {
  81880. /**
  81881. * Creates a depth stencil cube texture.
  81882. * This is only available in WebGL 2.
  81883. * @param size The size of face edge in the cube texture.
  81884. * @param options The options defining the cube texture.
  81885. * @returns The cube texture
  81886. */
  81887. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81888. /**
  81889. * Creates a cube texture
  81890. * @param rootUrl defines the url where the files to load is located
  81891. * @param scene defines the current scene
  81892. * @param files defines the list of files to load (1 per face)
  81893. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81894. * @param onLoad defines an optional callback raised when the texture is loaded
  81895. * @param onError defines an optional callback raised if there is an issue to load the texture
  81896. * @param format defines the format of the data
  81897. * @param forcedExtension defines the extension to use to pick the right loader
  81898. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81899. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81900. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81901. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81902. * @returns the cube texture as an InternalTexture
  81903. */
  81904. 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;
  81905. /**
  81906. * Creates a cube texture
  81907. * @param rootUrl defines the url where the files to load is located
  81908. * @param scene defines the current scene
  81909. * @param files defines the list of files to load (1 per face)
  81910. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81911. * @param onLoad defines an optional callback raised when the texture is loaded
  81912. * @param onError defines an optional callback raised if there is an issue to load the texture
  81913. * @param format defines the format of the data
  81914. * @param forcedExtension defines the extension to use to pick the right loader
  81915. * @returns the cube texture as an InternalTexture
  81916. */
  81917. 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;
  81918. /**
  81919. * Creates a cube texture
  81920. * @param rootUrl defines the url where the files to load is located
  81921. * @param scene defines the current scene
  81922. * @param files defines the list of files to load (1 per face)
  81923. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81924. * @param onLoad defines an optional callback raised when the texture is loaded
  81925. * @param onError defines an optional callback raised if there is an issue to load the texture
  81926. * @param format defines the format of the data
  81927. * @param forcedExtension defines the extension to use to pick the right loader
  81928. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81929. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81930. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81931. * @returns the cube texture as an InternalTexture
  81932. */
  81933. 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;
  81934. /** @hidden */
  81935. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81936. /** @hidden */
  81937. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81938. /** @hidden */
  81939. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81940. /** @hidden */
  81941. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81942. /**
  81943. * @hidden
  81944. */
  81945. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81946. }
  81947. }
  81948. declare module BABYLON {
  81949. /**
  81950. * Class for creating a cube texture
  81951. */
  81952. export class CubeTexture extends BaseTexture {
  81953. private _delayedOnLoad;
  81954. /**
  81955. * Observable triggered once the texture has been loaded.
  81956. */
  81957. onLoadObservable: Observable<CubeTexture>;
  81958. /**
  81959. * The url of the texture
  81960. */
  81961. url: string;
  81962. /**
  81963. * Gets or sets the center of the bounding box associated with the cube texture.
  81964. * It must define where the camera used to render the texture was set
  81965. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81966. */
  81967. boundingBoxPosition: Vector3;
  81968. private _boundingBoxSize;
  81969. /**
  81970. * Gets or sets the size of the bounding box associated with the cube texture
  81971. * When defined, the cubemap will switch to local mode
  81972. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81973. * @example https://www.babylonjs-playground.com/#RNASML
  81974. */
  81975. set boundingBoxSize(value: Vector3);
  81976. /**
  81977. * Returns the bounding box size
  81978. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81979. */
  81980. get boundingBoxSize(): Vector3;
  81981. protected _rotationY: number;
  81982. /**
  81983. * Sets texture matrix rotation angle around Y axis in radians.
  81984. */
  81985. set rotationY(value: number);
  81986. /**
  81987. * Gets texture matrix rotation angle around Y axis radians.
  81988. */
  81989. get rotationY(): number;
  81990. /**
  81991. * Are mip maps generated for this texture or not.
  81992. */
  81993. get noMipmap(): boolean;
  81994. private _noMipmap;
  81995. private _files;
  81996. protected _forcedExtension: Nullable<string>;
  81997. private _extensions;
  81998. private _textureMatrix;
  81999. private _format;
  82000. private _createPolynomials;
  82001. /** @hidden */
  82002. _prefiltered: boolean;
  82003. /**
  82004. * Creates a cube texture from an array of image urls
  82005. * @param files defines an array of image urls
  82006. * @param scene defines the hosting scene
  82007. * @param noMipmap specifies if mip maps are not used
  82008. * @returns a cube texture
  82009. */
  82010. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82011. /**
  82012. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82013. * @param url defines the url of the prefiltered texture
  82014. * @param scene defines the scene the texture is attached to
  82015. * @param forcedExtension defines the extension of the file if different from the url
  82016. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82017. * @return the prefiltered texture
  82018. */
  82019. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82020. /**
  82021. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82022. * as prefiltered data.
  82023. * @param rootUrl defines the url of the texture or the root name of the six images
  82024. * @param scene defines the scene the texture is attached to
  82025. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82026. * @param noMipmap defines if mipmaps should be created or not
  82027. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82028. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82029. * @param onError defines a callback triggered in case of error during load
  82030. * @param format defines the internal format to use for the texture once loaded
  82031. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82032. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82033. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82034. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82035. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82036. * @return the cube texture
  82037. */
  82038. 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);
  82039. /**
  82040. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82041. */
  82042. get isPrefiltered(): boolean;
  82043. /**
  82044. * Get the current class name of the texture useful for serialization or dynamic coding.
  82045. * @returns "CubeTexture"
  82046. */
  82047. getClassName(): string;
  82048. /**
  82049. * Update the url (and optional buffer) of this texture if url was null during construction.
  82050. * @param url the url of the texture
  82051. * @param forcedExtension defines the extension to use
  82052. * @param onLoad callback called when the texture is loaded (defaults to null)
  82053. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82054. */
  82055. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82056. /**
  82057. * Delays loading of the cube texture
  82058. * @param forcedExtension defines the extension to use
  82059. */
  82060. delayLoad(forcedExtension?: string): void;
  82061. /**
  82062. * Returns the reflection texture matrix
  82063. * @returns the reflection texture matrix
  82064. */
  82065. getReflectionTextureMatrix(): Matrix;
  82066. /**
  82067. * Sets the reflection texture matrix
  82068. * @param value Reflection texture matrix
  82069. */
  82070. setReflectionTextureMatrix(value: Matrix): void;
  82071. /**
  82072. * Parses text to create a cube texture
  82073. * @param parsedTexture define the serialized text to read from
  82074. * @param scene defines the hosting scene
  82075. * @param rootUrl defines the root url of the cube texture
  82076. * @returns a cube texture
  82077. */
  82078. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82079. /**
  82080. * Makes a clone, or deep copy, of the cube texture
  82081. * @returns a new cube texture
  82082. */
  82083. clone(): CubeTexture;
  82084. }
  82085. }
  82086. declare module BABYLON {
  82087. /**
  82088. * Manages the defines for the Material
  82089. */
  82090. export class MaterialDefines {
  82091. /** @hidden */
  82092. protected _keys: string[];
  82093. private _isDirty;
  82094. /** @hidden */
  82095. _renderId: number;
  82096. /** @hidden */
  82097. _areLightsDirty: boolean;
  82098. /** @hidden */
  82099. _areLightsDisposed: boolean;
  82100. /** @hidden */
  82101. _areAttributesDirty: boolean;
  82102. /** @hidden */
  82103. _areTexturesDirty: boolean;
  82104. /** @hidden */
  82105. _areFresnelDirty: boolean;
  82106. /** @hidden */
  82107. _areMiscDirty: boolean;
  82108. /** @hidden */
  82109. _areImageProcessingDirty: boolean;
  82110. /** @hidden */
  82111. _normals: boolean;
  82112. /** @hidden */
  82113. _uvs: boolean;
  82114. /** @hidden */
  82115. _needNormals: boolean;
  82116. /** @hidden */
  82117. _needUVs: boolean;
  82118. [id: string]: any;
  82119. /**
  82120. * Specifies if the material needs to be re-calculated
  82121. */
  82122. get isDirty(): boolean;
  82123. /**
  82124. * Marks the material to indicate that it has been re-calculated
  82125. */
  82126. markAsProcessed(): void;
  82127. /**
  82128. * Marks the material to indicate that it needs to be re-calculated
  82129. */
  82130. markAsUnprocessed(): void;
  82131. /**
  82132. * Marks the material to indicate all of its defines need to be re-calculated
  82133. */
  82134. markAllAsDirty(): void;
  82135. /**
  82136. * Marks the material to indicate that image processing needs to be re-calculated
  82137. */
  82138. markAsImageProcessingDirty(): void;
  82139. /**
  82140. * Marks the material to indicate the lights need to be re-calculated
  82141. * @param disposed Defines whether the light is dirty due to dispose or not
  82142. */
  82143. markAsLightDirty(disposed?: boolean): void;
  82144. /**
  82145. * Marks the attribute state as changed
  82146. */
  82147. markAsAttributesDirty(): void;
  82148. /**
  82149. * Marks the texture state as changed
  82150. */
  82151. markAsTexturesDirty(): void;
  82152. /**
  82153. * Marks the fresnel state as changed
  82154. */
  82155. markAsFresnelDirty(): void;
  82156. /**
  82157. * Marks the misc state as changed
  82158. */
  82159. markAsMiscDirty(): void;
  82160. /**
  82161. * Rebuilds the material defines
  82162. */
  82163. rebuild(): void;
  82164. /**
  82165. * Specifies if two material defines are equal
  82166. * @param other - A material define instance to compare to
  82167. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82168. */
  82169. isEqual(other: MaterialDefines): boolean;
  82170. /**
  82171. * Clones this instance's defines to another instance
  82172. * @param other - material defines to clone values to
  82173. */
  82174. cloneTo(other: MaterialDefines): void;
  82175. /**
  82176. * Resets the material define values
  82177. */
  82178. reset(): void;
  82179. /**
  82180. * Converts the material define values to a string
  82181. * @returns - String of material define information
  82182. */
  82183. toString(): string;
  82184. }
  82185. }
  82186. declare module BABYLON {
  82187. /**
  82188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82190. * 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;
  82191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82192. */
  82193. export class ColorCurves {
  82194. private _dirty;
  82195. private _tempColor;
  82196. private _globalCurve;
  82197. private _highlightsCurve;
  82198. private _midtonesCurve;
  82199. private _shadowsCurve;
  82200. private _positiveCurve;
  82201. private _negativeCurve;
  82202. private _globalHue;
  82203. private _globalDensity;
  82204. private _globalSaturation;
  82205. private _globalExposure;
  82206. /**
  82207. * Gets the global Hue value.
  82208. * 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).
  82209. */
  82210. get globalHue(): number;
  82211. /**
  82212. * Sets the global Hue value.
  82213. * 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).
  82214. */
  82215. set globalHue(value: number);
  82216. /**
  82217. * Gets the global Density value.
  82218. * 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.
  82219. * Values less than zero provide a filter of opposite hue.
  82220. */
  82221. get globalDensity(): number;
  82222. /**
  82223. * Sets the global Density value.
  82224. * 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.
  82225. * Values less than zero provide a filter of opposite hue.
  82226. */
  82227. set globalDensity(value: number);
  82228. /**
  82229. * Gets the global Saturation value.
  82230. * 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.
  82231. */
  82232. get globalSaturation(): number;
  82233. /**
  82234. * Sets the global Saturation value.
  82235. * 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.
  82236. */
  82237. set globalSaturation(value: number);
  82238. /**
  82239. * Gets the global Exposure value.
  82240. * 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.
  82241. */
  82242. get globalExposure(): number;
  82243. /**
  82244. * Sets the global Exposure value.
  82245. * 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.
  82246. */
  82247. set globalExposure(value: number);
  82248. private _highlightsHue;
  82249. private _highlightsDensity;
  82250. private _highlightsSaturation;
  82251. private _highlightsExposure;
  82252. /**
  82253. * Gets the highlights Hue value.
  82254. * 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).
  82255. */
  82256. get highlightsHue(): number;
  82257. /**
  82258. * Sets the highlights Hue value.
  82259. * 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).
  82260. */
  82261. set highlightsHue(value: number);
  82262. /**
  82263. * Gets the highlights Density value.
  82264. * 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.
  82265. * Values less than zero provide a filter of opposite hue.
  82266. */
  82267. get highlightsDensity(): number;
  82268. /**
  82269. * Sets the highlights Density value.
  82270. * 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.
  82271. * Values less than zero provide a filter of opposite hue.
  82272. */
  82273. set highlightsDensity(value: number);
  82274. /**
  82275. * Gets the highlights Saturation value.
  82276. * 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.
  82277. */
  82278. get highlightsSaturation(): number;
  82279. /**
  82280. * Sets the highlights Saturation value.
  82281. * 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.
  82282. */
  82283. set highlightsSaturation(value: number);
  82284. /**
  82285. * Gets the highlights Exposure value.
  82286. * 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.
  82287. */
  82288. get highlightsExposure(): number;
  82289. /**
  82290. * Sets the highlights Exposure value.
  82291. * 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.
  82292. */
  82293. set highlightsExposure(value: number);
  82294. private _midtonesHue;
  82295. private _midtonesDensity;
  82296. private _midtonesSaturation;
  82297. private _midtonesExposure;
  82298. /**
  82299. * Gets the midtones Hue value.
  82300. * 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).
  82301. */
  82302. get midtonesHue(): number;
  82303. /**
  82304. * Sets the midtones Hue value.
  82305. * 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).
  82306. */
  82307. set midtonesHue(value: number);
  82308. /**
  82309. * Gets the midtones Density value.
  82310. * 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.
  82311. * Values less than zero provide a filter of opposite hue.
  82312. */
  82313. get midtonesDensity(): number;
  82314. /**
  82315. * Sets the midtones Density value.
  82316. * 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.
  82317. * Values less than zero provide a filter of opposite hue.
  82318. */
  82319. set midtonesDensity(value: number);
  82320. /**
  82321. * Gets the midtones Saturation value.
  82322. * 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.
  82323. */
  82324. get midtonesSaturation(): number;
  82325. /**
  82326. * Sets the midtones Saturation value.
  82327. * 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.
  82328. */
  82329. set midtonesSaturation(value: number);
  82330. /**
  82331. * Gets the midtones Exposure value.
  82332. * 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.
  82333. */
  82334. get midtonesExposure(): number;
  82335. /**
  82336. * Sets the midtones Exposure value.
  82337. * 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.
  82338. */
  82339. set midtonesExposure(value: number);
  82340. private _shadowsHue;
  82341. private _shadowsDensity;
  82342. private _shadowsSaturation;
  82343. private _shadowsExposure;
  82344. /**
  82345. * Gets the shadows Hue value.
  82346. * 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).
  82347. */
  82348. get shadowsHue(): number;
  82349. /**
  82350. * Sets the shadows Hue value.
  82351. * 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).
  82352. */
  82353. set shadowsHue(value: number);
  82354. /**
  82355. * Gets the shadows Density value.
  82356. * 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.
  82357. * Values less than zero provide a filter of opposite hue.
  82358. */
  82359. get shadowsDensity(): number;
  82360. /**
  82361. * Sets the shadows Density value.
  82362. * 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.
  82363. * Values less than zero provide a filter of opposite hue.
  82364. */
  82365. set shadowsDensity(value: number);
  82366. /**
  82367. * Gets the shadows Saturation value.
  82368. * 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.
  82369. */
  82370. get shadowsSaturation(): number;
  82371. /**
  82372. * Sets the shadows Saturation value.
  82373. * 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.
  82374. */
  82375. set shadowsSaturation(value: number);
  82376. /**
  82377. * Gets the shadows Exposure value.
  82378. * 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.
  82379. */
  82380. get shadowsExposure(): number;
  82381. /**
  82382. * Sets the shadows Exposure value.
  82383. * 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.
  82384. */
  82385. set shadowsExposure(value: number);
  82386. /**
  82387. * Returns the class name
  82388. * @returns The class name
  82389. */
  82390. getClassName(): string;
  82391. /**
  82392. * Binds the color curves to the shader.
  82393. * @param colorCurves The color curve to bind
  82394. * @param effect The effect to bind to
  82395. * @param positiveUniform The positive uniform shader parameter
  82396. * @param neutralUniform The neutral uniform shader parameter
  82397. * @param negativeUniform The negative uniform shader parameter
  82398. */
  82399. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82400. /**
  82401. * Prepare the list of uniforms associated with the ColorCurves effects.
  82402. * @param uniformsList The list of uniforms used in the effect
  82403. */
  82404. static PrepareUniforms(uniformsList: string[]): void;
  82405. /**
  82406. * Returns color grading data based on a hue, density, saturation and exposure value.
  82407. * @param filterHue The hue of the color filter.
  82408. * @param filterDensity The density of the color filter.
  82409. * @param saturation The saturation.
  82410. * @param exposure The exposure.
  82411. * @param result The result data container.
  82412. */
  82413. private getColorGradingDataToRef;
  82414. /**
  82415. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82416. * @param value The input slider value in range [-100,100].
  82417. * @returns Adjusted value.
  82418. */
  82419. private static applyColorGradingSliderNonlinear;
  82420. /**
  82421. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82422. * @param hue The hue (H) input.
  82423. * @param saturation The saturation (S) input.
  82424. * @param brightness The brightness (B) input.
  82425. * @result An RGBA color represented as Vector4.
  82426. */
  82427. private static fromHSBToRef;
  82428. /**
  82429. * Returns a value clamped between min and max
  82430. * @param value The value to clamp
  82431. * @param min The minimum of value
  82432. * @param max The maximum of value
  82433. * @returns The clamped value.
  82434. */
  82435. private static clamp;
  82436. /**
  82437. * Clones the current color curve instance.
  82438. * @return The cloned curves
  82439. */
  82440. clone(): ColorCurves;
  82441. /**
  82442. * Serializes the current color curve instance to a json representation.
  82443. * @return a JSON representation
  82444. */
  82445. serialize(): any;
  82446. /**
  82447. * Parses the color curve from a json representation.
  82448. * @param source the JSON source to parse
  82449. * @return The parsed curves
  82450. */
  82451. static Parse(source: any): ColorCurves;
  82452. }
  82453. }
  82454. declare module BABYLON {
  82455. /**
  82456. * Interface to follow in your material defines to integrate easily the
  82457. * Image proccessing functions.
  82458. * @hidden
  82459. */
  82460. export interface IImageProcessingConfigurationDefines {
  82461. IMAGEPROCESSING: boolean;
  82462. VIGNETTE: boolean;
  82463. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82464. VIGNETTEBLENDMODEOPAQUE: boolean;
  82465. TONEMAPPING: boolean;
  82466. TONEMAPPING_ACES: boolean;
  82467. CONTRAST: boolean;
  82468. EXPOSURE: boolean;
  82469. COLORCURVES: boolean;
  82470. COLORGRADING: boolean;
  82471. COLORGRADING3D: boolean;
  82472. SAMPLER3DGREENDEPTH: boolean;
  82473. SAMPLER3DBGRMAP: boolean;
  82474. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82475. }
  82476. /**
  82477. * @hidden
  82478. */
  82479. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82480. IMAGEPROCESSING: boolean;
  82481. VIGNETTE: boolean;
  82482. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82483. VIGNETTEBLENDMODEOPAQUE: boolean;
  82484. TONEMAPPING: boolean;
  82485. TONEMAPPING_ACES: boolean;
  82486. CONTRAST: boolean;
  82487. COLORCURVES: boolean;
  82488. COLORGRADING: boolean;
  82489. COLORGRADING3D: boolean;
  82490. SAMPLER3DGREENDEPTH: boolean;
  82491. SAMPLER3DBGRMAP: boolean;
  82492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82493. EXPOSURE: boolean;
  82494. constructor();
  82495. }
  82496. /**
  82497. * This groups together the common properties used for image processing either in direct forward pass
  82498. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82499. * or not.
  82500. */
  82501. export class ImageProcessingConfiguration {
  82502. /**
  82503. * Default tone mapping applied in BabylonJS.
  82504. */
  82505. static readonly TONEMAPPING_STANDARD: number;
  82506. /**
  82507. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82508. * to other engines rendering to increase portability.
  82509. */
  82510. static readonly TONEMAPPING_ACES: number;
  82511. /**
  82512. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82513. */
  82514. colorCurves: Nullable<ColorCurves>;
  82515. private _colorCurvesEnabled;
  82516. /**
  82517. * Gets wether the color curves effect is enabled.
  82518. */
  82519. get colorCurvesEnabled(): boolean;
  82520. /**
  82521. * Sets wether the color curves effect is enabled.
  82522. */
  82523. set colorCurvesEnabled(value: boolean);
  82524. private _colorGradingTexture;
  82525. /**
  82526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82527. */
  82528. get colorGradingTexture(): Nullable<BaseTexture>;
  82529. /**
  82530. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82531. */
  82532. set colorGradingTexture(value: Nullable<BaseTexture>);
  82533. private _colorGradingEnabled;
  82534. /**
  82535. * Gets wether the color grading effect is enabled.
  82536. */
  82537. get colorGradingEnabled(): boolean;
  82538. /**
  82539. * Sets wether the color grading effect is enabled.
  82540. */
  82541. set colorGradingEnabled(value: boolean);
  82542. private _colorGradingWithGreenDepth;
  82543. /**
  82544. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82545. */
  82546. get colorGradingWithGreenDepth(): boolean;
  82547. /**
  82548. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82549. */
  82550. set colorGradingWithGreenDepth(value: boolean);
  82551. private _colorGradingBGR;
  82552. /**
  82553. * Gets wether the color grading texture contains BGR values.
  82554. */
  82555. get colorGradingBGR(): boolean;
  82556. /**
  82557. * Sets wether the color grading texture contains BGR values.
  82558. */
  82559. set colorGradingBGR(value: boolean);
  82560. /** @hidden */
  82561. _exposure: number;
  82562. /**
  82563. * Gets the Exposure used in the effect.
  82564. */
  82565. get exposure(): number;
  82566. /**
  82567. * Sets the Exposure used in the effect.
  82568. */
  82569. set exposure(value: number);
  82570. private _toneMappingEnabled;
  82571. /**
  82572. * Gets wether the tone mapping effect is enabled.
  82573. */
  82574. get toneMappingEnabled(): boolean;
  82575. /**
  82576. * Sets wether the tone mapping effect is enabled.
  82577. */
  82578. set toneMappingEnabled(value: boolean);
  82579. private _toneMappingType;
  82580. /**
  82581. * Gets the type of tone mapping effect.
  82582. */
  82583. get toneMappingType(): number;
  82584. /**
  82585. * Sets the type of tone mapping effect used in BabylonJS.
  82586. */
  82587. set toneMappingType(value: number);
  82588. protected _contrast: number;
  82589. /**
  82590. * Gets the contrast used in the effect.
  82591. */
  82592. get contrast(): number;
  82593. /**
  82594. * Sets the contrast used in the effect.
  82595. */
  82596. set contrast(value: number);
  82597. /**
  82598. * Vignette stretch size.
  82599. */
  82600. vignetteStretch: number;
  82601. /**
  82602. * Vignette centre X Offset.
  82603. */
  82604. vignetteCentreX: number;
  82605. /**
  82606. * Vignette centre Y Offset.
  82607. */
  82608. vignetteCentreY: number;
  82609. /**
  82610. * Vignette weight or intensity of the vignette effect.
  82611. */
  82612. vignetteWeight: number;
  82613. /**
  82614. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82615. * if vignetteEnabled is set to true.
  82616. */
  82617. vignetteColor: Color4;
  82618. /**
  82619. * Camera field of view used by the Vignette effect.
  82620. */
  82621. vignetteCameraFov: number;
  82622. private _vignetteBlendMode;
  82623. /**
  82624. * Gets the vignette blend mode allowing different kind of effect.
  82625. */
  82626. get vignetteBlendMode(): number;
  82627. /**
  82628. * Sets the vignette blend mode allowing different kind of effect.
  82629. */
  82630. set vignetteBlendMode(value: number);
  82631. private _vignetteEnabled;
  82632. /**
  82633. * Gets wether the vignette effect is enabled.
  82634. */
  82635. get vignetteEnabled(): boolean;
  82636. /**
  82637. * Sets wether the vignette effect is enabled.
  82638. */
  82639. set vignetteEnabled(value: boolean);
  82640. private _applyByPostProcess;
  82641. /**
  82642. * Gets wether the image processing is applied through a post process or not.
  82643. */
  82644. get applyByPostProcess(): boolean;
  82645. /**
  82646. * Sets wether the image processing is applied through a post process or not.
  82647. */
  82648. set applyByPostProcess(value: boolean);
  82649. private _isEnabled;
  82650. /**
  82651. * Gets wether the image processing is enabled or not.
  82652. */
  82653. get isEnabled(): boolean;
  82654. /**
  82655. * Sets wether the image processing is enabled or not.
  82656. */
  82657. set isEnabled(value: boolean);
  82658. /**
  82659. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82660. */
  82661. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82662. /**
  82663. * Method called each time the image processing information changes requires to recompile the effect.
  82664. */
  82665. protected _updateParameters(): void;
  82666. /**
  82667. * Gets the current class name.
  82668. * @return "ImageProcessingConfiguration"
  82669. */
  82670. getClassName(): string;
  82671. /**
  82672. * Prepare the list of uniforms associated with the Image Processing effects.
  82673. * @param uniforms The list of uniforms used in the effect
  82674. * @param defines the list of defines currently in use
  82675. */
  82676. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82677. /**
  82678. * Prepare the list of samplers associated with the Image Processing effects.
  82679. * @param samplersList The list of uniforms used in the effect
  82680. * @param defines the list of defines currently in use
  82681. */
  82682. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82683. /**
  82684. * Prepare the list of defines associated to the shader.
  82685. * @param defines the list of defines to complete
  82686. * @param forPostProcess Define if we are currently in post process mode or not
  82687. */
  82688. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82689. /**
  82690. * Returns true if all the image processing information are ready.
  82691. * @returns True if ready, otherwise, false
  82692. */
  82693. isReady(): boolean;
  82694. /**
  82695. * Binds the image processing to the shader.
  82696. * @param effect The effect to bind to
  82697. * @param overrideAspectRatio Override the aspect ratio of the effect
  82698. */
  82699. bind(effect: Effect, overrideAspectRatio?: number): void;
  82700. /**
  82701. * Clones the current image processing instance.
  82702. * @return The cloned image processing
  82703. */
  82704. clone(): ImageProcessingConfiguration;
  82705. /**
  82706. * Serializes the current image processing instance to a json representation.
  82707. * @return a JSON representation
  82708. */
  82709. serialize(): any;
  82710. /**
  82711. * Parses the image processing from a json representation.
  82712. * @param source the JSON source to parse
  82713. * @return The parsed image processing
  82714. */
  82715. static Parse(source: any): ImageProcessingConfiguration;
  82716. private static _VIGNETTEMODE_MULTIPLY;
  82717. private static _VIGNETTEMODE_OPAQUE;
  82718. /**
  82719. * Used to apply the vignette as a mix with the pixel color.
  82720. */
  82721. static get VIGNETTEMODE_MULTIPLY(): number;
  82722. /**
  82723. * Used to apply the vignette as a replacement of the pixel color.
  82724. */
  82725. static get VIGNETTEMODE_OPAQUE(): number;
  82726. }
  82727. }
  82728. declare module BABYLON {
  82729. /** @hidden */
  82730. export var postprocessVertexShader: {
  82731. name: string;
  82732. shader: string;
  82733. };
  82734. }
  82735. declare module BABYLON {
  82736. interface ThinEngine {
  82737. /**
  82738. * Creates a new render target texture
  82739. * @param size defines the size of the texture
  82740. * @param options defines the options used to create the texture
  82741. * @returns a new render target texture stored in an InternalTexture
  82742. */
  82743. createRenderTargetTexture(size: number | {
  82744. width: number;
  82745. height: number;
  82746. layers?: number;
  82747. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82748. /**
  82749. * Creates a depth stencil texture.
  82750. * This is only available in WebGL 2 or with the depth texture extension available.
  82751. * @param size The size of face edge in the texture.
  82752. * @param options The options defining the texture.
  82753. * @returns The texture
  82754. */
  82755. createDepthStencilTexture(size: number | {
  82756. width: number;
  82757. height: number;
  82758. layers?: number;
  82759. }, options: DepthTextureCreationOptions): InternalTexture;
  82760. /** @hidden */
  82761. _createDepthStencilTexture(size: number | {
  82762. width: number;
  82763. height: number;
  82764. layers?: number;
  82765. }, options: DepthTextureCreationOptions): InternalTexture;
  82766. }
  82767. }
  82768. declare module BABYLON {
  82769. /** Defines supported spaces */
  82770. export enum Space {
  82771. /** Local (object) space */
  82772. LOCAL = 0,
  82773. /** World space */
  82774. WORLD = 1,
  82775. /** Bone space */
  82776. BONE = 2
  82777. }
  82778. /** Defines the 3 main axes */
  82779. export class Axis {
  82780. /** X axis */
  82781. static X: Vector3;
  82782. /** Y axis */
  82783. static Y: Vector3;
  82784. /** Z axis */
  82785. static Z: Vector3;
  82786. }
  82787. }
  82788. declare module BABYLON {
  82789. /**
  82790. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82791. * This is the base of the follow, arc rotate cameras and Free camera
  82792. * @see http://doc.babylonjs.com/features/cameras
  82793. */
  82794. export class TargetCamera extends Camera {
  82795. private static _RigCamTransformMatrix;
  82796. private static _TargetTransformMatrix;
  82797. private static _TargetFocalPoint;
  82798. /**
  82799. * Define the current direction the camera is moving to
  82800. */
  82801. cameraDirection: Vector3;
  82802. /**
  82803. * Define the current rotation the camera is rotating to
  82804. */
  82805. cameraRotation: Vector2;
  82806. /**
  82807. * When set, the up vector of the camera will be updated by the rotation of the camera
  82808. */
  82809. updateUpVectorFromRotation: boolean;
  82810. private _tmpQuaternion;
  82811. /**
  82812. * Define the current rotation of the camera
  82813. */
  82814. rotation: Vector3;
  82815. /**
  82816. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82817. */
  82818. rotationQuaternion: Quaternion;
  82819. /**
  82820. * Define the current speed of the camera
  82821. */
  82822. speed: number;
  82823. /**
  82824. * Add constraint to the camera to prevent it to move freely in all directions and
  82825. * around all axis.
  82826. */
  82827. noRotationConstraint: boolean;
  82828. /**
  82829. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82830. * panning
  82831. */
  82832. invertRotation: boolean;
  82833. /**
  82834. * Speed multiplier for inverse camera panning
  82835. */
  82836. inverseRotationSpeed: number;
  82837. /**
  82838. * Define the current target of the camera as an object or a position.
  82839. */
  82840. lockedTarget: any;
  82841. /** @hidden */
  82842. _currentTarget: Vector3;
  82843. /** @hidden */
  82844. _initialFocalDistance: number;
  82845. /** @hidden */
  82846. _viewMatrix: Matrix;
  82847. /** @hidden */
  82848. _camMatrix: Matrix;
  82849. /** @hidden */
  82850. _cameraTransformMatrix: Matrix;
  82851. /** @hidden */
  82852. _cameraRotationMatrix: Matrix;
  82853. /** @hidden */
  82854. _referencePoint: Vector3;
  82855. /** @hidden */
  82856. _transformedReferencePoint: Vector3;
  82857. protected _globalCurrentTarget: Vector3;
  82858. protected _globalCurrentUpVector: Vector3;
  82859. /** @hidden */
  82860. _reset: () => void;
  82861. private _defaultUp;
  82862. /**
  82863. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82864. * This is the base of the follow, arc rotate cameras and Free camera
  82865. * @see http://doc.babylonjs.com/features/cameras
  82866. * @param name Defines the name of the camera in the scene
  82867. * @param position Defines the start position of the camera in the scene
  82868. * @param scene Defines the scene the camera belongs to
  82869. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82870. */
  82871. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82872. /**
  82873. * Gets the position in front of the camera at a given distance.
  82874. * @param distance The distance from the camera we want the position to be
  82875. * @returns the position
  82876. */
  82877. getFrontPosition(distance: number): Vector3;
  82878. /** @hidden */
  82879. _getLockedTargetPosition(): Nullable<Vector3>;
  82880. private _storedPosition;
  82881. private _storedRotation;
  82882. private _storedRotationQuaternion;
  82883. /**
  82884. * Store current camera state of the camera (fov, position, rotation, etc..)
  82885. * @returns the camera
  82886. */
  82887. storeState(): Camera;
  82888. /**
  82889. * Restored camera state. You must call storeState() first
  82890. * @returns whether it was successful or not
  82891. * @hidden
  82892. */
  82893. _restoreStateValues(): boolean;
  82894. /** @hidden */
  82895. _initCache(): void;
  82896. /** @hidden */
  82897. _updateCache(ignoreParentClass?: boolean): void;
  82898. /** @hidden */
  82899. _isSynchronizedViewMatrix(): boolean;
  82900. /** @hidden */
  82901. _computeLocalCameraSpeed(): number;
  82902. /**
  82903. * Defines the target the camera should look at.
  82904. * @param target Defines the new target as a Vector or a mesh
  82905. */
  82906. setTarget(target: Vector3): void;
  82907. /**
  82908. * Return the current target position of the camera. This value is expressed in local space.
  82909. * @returns the target position
  82910. */
  82911. getTarget(): Vector3;
  82912. /** @hidden */
  82913. _decideIfNeedsToMove(): boolean;
  82914. /** @hidden */
  82915. _updatePosition(): void;
  82916. /** @hidden */
  82917. _checkInputs(): void;
  82918. protected _updateCameraRotationMatrix(): void;
  82919. /**
  82920. * 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)
  82921. * @returns the current camera
  82922. */
  82923. private _rotateUpVectorWithCameraRotationMatrix;
  82924. private _cachedRotationZ;
  82925. private _cachedQuaternionRotationZ;
  82926. /** @hidden */
  82927. _getViewMatrix(): Matrix;
  82928. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82929. /**
  82930. * @hidden
  82931. */
  82932. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82933. /**
  82934. * @hidden
  82935. */
  82936. _updateRigCameras(): void;
  82937. private _getRigCamPositionAndTarget;
  82938. /**
  82939. * Gets the current object class name.
  82940. * @return the class name
  82941. */
  82942. getClassName(): string;
  82943. }
  82944. }
  82945. declare module BABYLON {
  82946. /**
  82947. * Gather the list of keyboard event types as constants.
  82948. */
  82949. export class KeyboardEventTypes {
  82950. /**
  82951. * The keydown event is fired when a key becomes active (pressed).
  82952. */
  82953. static readonly KEYDOWN: number;
  82954. /**
  82955. * The keyup event is fired when a key has been released.
  82956. */
  82957. static readonly KEYUP: number;
  82958. }
  82959. /**
  82960. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82961. */
  82962. export class KeyboardInfo {
  82963. /**
  82964. * Defines the type of event (KeyboardEventTypes)
  82965. */
  82966. type: number;
  82967. /**
  82968. * Defines the related dom event
  82969. */
  82970. event: KeyboardEvent;
  82971. /**
  82972. * Instantiates a new keyboard info.
  82973. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82974. * @param type Defines the type of event (KeyboardEventTypes)
  82975. * @param event Defines the related dom event
  82976. */
  82977. constructor(
  82978. /**
  82979. * Defines the type of event (KeyboardEventTypes)
  82980. */
  82981. type: number,
  82982. /**
  82983. * Defines the related dom event
  82984. */
  82985. event: KeyboardEvent);
  82986. }
  82987. /**
  82988. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82989. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82990. */
  82991. export class KeyboardInfoPre extends KeyboardInfo {
  82992. /**
  82993. * Defines the type of event (KeyboardEventTypes)
  82994. */
  82995. type: number;
  82996. /**
  82997. * Defines the related dom event
  82998. */
  82999. event: KeyboardEvent;
  83000. /**
  83001. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83002. */
  83003. skipOnPointerObservable: boolean;
  83004. /**
  83005. * Instantiates a new keyboard pre info.
  83006. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83007. * @param type Defines the type of event (KeyboardEventTypes)
  83008. * @param event Defines the related dom event
  83009. */
  83010. constructor(
  83011. /**
  83012. * Defines the type of event (KeyboardEventTypes)
  83013. */
  83014. type: number,
  83015. /**
  83016. * Defines the related dom event
  83017. */
  83018. event: KeyboardEvent);
  83019. }
  83020. }
  83021. declare module BABYLON {
  83022. /**
  83023. * Manage the keyboard inputs to control the movement of a free camera.
  83024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83025. */
  83026. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83027. /**
  83028. * Defines the camera the input is attached to.
  83029. */
  83030. camera: FreeCamera;
  83031. /**
  83032. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83033. */
  83034. keysUp: number[];
  83035. /**
  83036. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83037. */
  83038. keysUpward: number[];
  83039. /**
  83040. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83041. */
  83042. keysDown: number[];
  83043. /**
  83044. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83045. */
  83046. keysDownward: number[];
  83047. /**
  83048. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83049. */
  83050. keysLeft: number[];
  83051. /**
  83052. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83053. */
  83054. keysRight: number[];
  83055. private _keys;
  83056. private _onCanvasBlurObserver;
  83057. private _onKeyboardObserver;
  83058. private _engine;
  83059. private _scene;
  83060. /**
  83061. * Attach the input controls to a specific dom element to get the input from.
  83062. * @param element Defines the element the controls should be listened from
  83063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83064. */
  83065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83066. /**
  83067. * Detach the current controls from the specified dom element.
  83068. * @param element Defines the element to stop listening the inputs from
  83069. */
  83070. detachControl(element: Nullable<HTMLElement>): void;
  83071. /**
  83072. * Update the current camera state depending on the inputs that have been used this frame.
  83073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83074. */
  83075. checkInputs(): void;
  83076. /**
  83077. * Gets the class name of the current intput.
  83078. * @returns the class name
  83079. */
  83080. getClassName(): string;
  83081. /** @hidden */
  83082. _onLostFocus(): void;
  83083. /**
  83084. * Get the friendly name associated with the input class.
  83085. * @returns the input friendly name
  83086. */
  83087. getSimpleName(): string;
  83088. }
  83089. }
  83090. declare module BABYLON {
  83091. /**
  83092. * Interface describing all the common properties and methods a shadow light needs to implement.
  83093. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83094. * as well as binding the different shadow properties to the effects.
  83095. */
  83096. export interface IShadowLight extends Light {
  83097. /**
  83098. * The light id in the scene (used in scene.findLighById for instance)
  83099. */
  83100. id: string;
  83101. /**
  83102. * The position the shdow will be casted from.
  83103. */
  83104. position: Vector3;
  83105. /**
  83106. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83107. */
  83108. direction: Vector3;
  83109. /**
  83110. * The transformed position. Position of the light in world space taking parenting in account.
  83111. */
  83112. transformedPosition: Vector3;
  83113. /**
  83114. * The transformed direction. Direction of the light in world space taking parenting in account.
  83115. */
  83116. transformedDirection: Vector3;
  83117. /**
  83118. * The friendly name of the light in the scene.
  83119. */
  83120. name: string;
  83121. /**
  83122. * Defines the shadow projection clipping minimum z value.
  83123. */
  83124. shadowMinZ: number;
  83125. /**
  83126. * Defines the shadow projection clipping maximum z value.
  83127. */
  83128. shadowMaxZ: number;
  83129. /**
  83130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83132. */
  83133. computeTransformedInformation(): boolean;
  83134. /**
  83135. * Gets the scene the light belongs to.
  83136. * @returns The scene
  83137. */
  83138. getScene(): Scene;
  83139. /**
  83140. * Callback defining a custom Projection Matrix Builder.
  83141. * This can be used to override the default projection matrix computation.
  83142. */
  83143. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83144. /**
  83145. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83146. * @param matrix The materix to updated with the projection information
  83147. * @param viewMatrix The transform matrix of the light
  83148. * @param renderList The list of mesh to render in the map
  83149. * @returns The current light
  83150. */
  83151. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83152. /**
  83153. * Gets the current depth scale used in ESM.
  83154. * @returns The scale
  83155. */
  83156. getDepthScale(): number;
  83157. /**
  83158. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83159. * @returns true if a cube texture needs to be use
  83160. */
  83161. needCube(): boolean;
  83162. /**
  83163. * Detects if the projection matrix requires to be recomputed this frame.
  83164. * @returns true if it requires to be recomputed otherwise, false.
  83165. */
  83166. needProjectionMatrixCompute(): boolean;
  83167. /**
  83168. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83169. */
  83170. forceProjectionMatrixCompute(): void;
  83171. /**
  83172. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83175. */
  83176. getShadowDirection(faceIndex?: number): Vector3;
  83177. /**
  83178. * Gets the minZ used for shadow according to both the scene and the light.
  83179. * @param activeCamera The camera we are returning the min for
  83180. * @returns the depth min z
  83181. */
  83182. getDepthMinZ(activeCamera: Camera): number;
  83183. /**
  83184. * Gets the maxZ used for shadow according to both the scene and the light.
  83185. * @param activeCamera The camera we are returning the max for
  83186. * @returns the depth max z
  83187. */
  83188. getDepthMaxZ(activeCamera: Camera): number;
  83189. }
  83190. /**
  83191. * Base implementation IShadowLight
  83192. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83193. */
  83194. export abstract class ShadowLight extends Light implements IShadowLight {
  83195. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83196. protected _position: Vector3;
  83197. protected _setPosition(value: Vector3): void;
  83198. /**
  83199. * Sets the position the shadow will be casted from. Also use as the light position for both
  83200. * point and spot lights.
  83201. */
  83202. get position(): Vector3;
  83203. /**
  83204. * Sets the position the shadow will be casted from. Also use as the light position for both
  83205. * point and spot lights.
  83206. */
  83207. set position(value: Vector3);
  83208. protected _direction: Vector3;
  83209. protected _setDirection(value: Vector3): void;
  83210. /**
  83211. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83212. * Also use as the light direction on spot and directional lights.
  83213. */
  83214. get direction(): Vector3;
  83215. /**
  83216. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83217. * Also use as the light direction on spot and directional lights.
  83218. */
  83219. set direction(value: Vector3);
  83220. protected _shadowMinZ: number;
  83221. /**
  83222. * Gets the shadow projection clipping minimum z value.
  83223. */
  83224. get shadowMinZ(): number;
  83225. /**
  83226. * Sets the shadow projection clipping minimum z value.
  83227. */
  83228. set shadowMinZ(value: number);
  83229. protected _shadowMaxZ: number;
  83230. /**
  83231. * Sets the shadow projection clipping maximum z value.
  83232. */
  83233. get shadowMaxZ(): number;
  83234. /**
  83235. * Gets the shadow projection clipping maximum z value.
  83236. */
  83237. set shadowMaxZ(value: number);
  83238. /**
  83239. * Callback defining a custom Projection Matrix Builder.
  83240. * This can be used to override the default projection matrix computation.
  83241. */
  83242. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83243. /**
  83244. * The transformed position. Position of the light in world space taking parenting in account.
  83245. */
  83246. transformedPosition: Vector3;
  83247. /**
  83248. * The transformed direction. Direction of the light in world space taking parenting in account.
  83249. */
  83250. transformedDirection: Vector3;
  83251. private _needProjectionMatrixCompute;
  83252. /**
  83253. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83254. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83255. */
  83256. computeTransformedInformation(): boolean;
  83257. /**
  83258. * Return the depth scale used for the shadow map.
  83259. * @returns the depth scale.
  83260. */
  83261. getDepthScale(): number;
  83262. /**
  83263. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83264. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83265. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83266. */
  83267. getShadowDirection(faceIndex?: number): Vector3;
  83268. /**
  83269. * Returns the ShadowLight absolute position in the World.
  83270. * @returns the position vector in world space
  83271. */
  83272. getAbsolutePosition(): Vector3;
  83273. /**
  83274. * Sets the ShadowLight direction toward the passed target.
  83275. * @param target The point to target in local space
  83276. * @returns the updated ShadowLight direction
  83277. */
  83278. setDirectionToTarget(target: Vector3): Vector3;
  83279. /**
  83280. * Returns the light rotation in euler definition.
  83281. * @returns the x y z rotation in local space.
  83282. */
  83283. getRotation(): Vector3;
  83284. /**
  83285. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83286. * @returns true if a cube texture needs to be use
  83287. */
  83288. needCube(): boolean;
  83289. /**
  83290. * Detects if the projection matrix requires to be recomputed this frame.
  83291. * @returns true if it requires to be recomputed otherwise, false.
  83292. */
  83293. needProjectionMatrixCompute(): boolean;
  83294. /**
  83295. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83296. */
  83297. forceProjectionMatrixCompute(): void;
  83298. /** @hidden */
  83299. _initCache(): void;
  83300. /** @hidden */
  83301. _isSynchronized(): boolean;
  83302. /**
  83303. * Computes the world matrix of the node
  83304. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83305. * @returns the world matrix
  83306. */
  83307. computeWorldMatrix(force?: boolean): Matrix;
  83308. /**
  83309. * Gets the minZ used for shadow according to both the scene and the light.
  83310. * @param activeCamera The camera we are returning the min for
  83311. * @returns the depth min z
  83312. */
  83313. getDepthMinZ(activeCamera: Camera): number;
  83314. /**
  83315. * Gets the maxZ used for shadow according to both the scene and the light.
  83316. * @param activeCamera The camera we are returning the max for
  83317. * @returns the depth max z
  83318. */
  83319. getDepthMaxZ(activeCamera: Camera): number;
  83320. /**
  83321. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83322. * @param matrix The materix to updated with the projection information
  83323. * @param viewMatrix The transform matrix of the light
  83324. * @param renderList The list of mesh to render in the map
  83325. * @returns The current light
  83326. */
  83327. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83328. }
  83329. }
  83330. declare module BABYLON {
  83331. /**
  83332. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83333. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83334. */
  83335. export class EffectFallbacks implements IEffectFallbacks {
  83336. private _defines;
  83337. private _currentRank;
  83338. private _maxRank;
  83339. private _mesh;
  83340. /**
  83341. * Removes the fallback from the bound mesh.
  83342. */
  83343. unBindMesh(): void;
  83344. /**
  83345. * Adds a fallback on the specified property.
  83346. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83347. * @param define The name of the define in the shader
  83348. */
  83349. addFallback(rank: number, define: string): void;
  83350. /**
  83351. * Sets the mesh to use CPU skinning when needing to fallback.
  83352. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83353. * @param mesh The mesh to use the fallbacks.
  83354. */
  83355. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83356. /**
  83357. * Checks to see if more fallbacks are still availible.
  83358. */
  83359. get hasMoreFallbacks(): boolean;
  83360. /**
  83361. * Removes the defines that should be removed when falling back.
  83362. * @param currentDefines defines the current define statements for the shader.
  83363. * @param effect defines the current effect we try to compile
  83364. * @returns The resulting defines with defines of the current rank removed.
  83365. */
  83366. reduce(currentDefines: string, effect: Effect): string;
  83367. }
  83368. }
  83369. declare module BABYLON {
  83370. /**
  83371. * "Static Class" containing the most commonly used helper while dealing with material for
  83372. * rendering purpose.
  83373. *
  83374. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83375. *
  83376. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83377. */
  83378. export class MaterialHelper {
  83379. /**
  83380. * Bind the current view position to an effect.
  83381. * @param effect The effect to be bound
  83382. * @param scene The scene the eyes position is used from
  83383. */
  83384. static BindEyePosition(effect: Effect, scene: Scene): void;
  83385. /**
  83386. * Helps preparing the defines values about the UVs in used in the effect.
  83387. * UVs are shared as much as we can accross channels in the shaders.
  83388. * @param texture The texture we are preparing the UVs for
  83389. * @param defines The defines to update
  83390. * @param key The channel key "diffuse", "specular"... used in the shader
  83391. */
  83392. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83393. /**
  83394. * Binds a texture matrix value to its corrsponding uniform
  83395. * @param texture The texture to bind the matrix for
  83396. * @param uniformBuffer The uniform buffer receivin the data
  83397. * @param key The channel key "diffuse", "specular"... used in the shader
  83398. */
  83399. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83400. /**
  83401. * Gets the current status of the fog (should it be enabled?)
  83402. * @param mesh defines the mesh to evaluate for fog support
  83403. * @param scene defines the hosting scene
  83404. * @returns true if fog must be enabled
  83405. */
  83406. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83407. /**
  83408. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83409. * @param mesh defines the current mesh
  83410. * @param scene defines the current scene
  83411. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83412. * @param pointsCloud defines if point cloud rendering has to be turned on
  83413. * @param fogEnabled defines if fog has to be turned on
  83414. * @param alphaTest defines if alpha testing has to be turned on
  83415. * @param defines defines the current list of defines
  83416. */
  83417. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83418. /**
  83419. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83420. * @param scene defines the current scene
  83421. * @param engine defines the current engine
  83422. * @param defines specifies the list of active defines
  83423. * @param useInstances defines if instances have to be turned on
  83424. * @param useClipPlane defines if clip plane have to be turned on
  83425. */
  83426. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83427. /**
  83428. * Prepares the defines for bones
  83429. * @param mesh The mesh containing the geometry data we will draw
  83430. * @param defines The defines to update
  83431. */
  83432. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83433. /**
  83434. * Prepares the defines for morph targets
  83435. * @param mesh The mesh containing the geometry data we will draw
  83436. * @param defines The defines to update
  83437. */
  83438. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83439. /**
  83440. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83441. * @param mesh The mesh containing the geometry data we will draw
  83442. * @param defines The defines to update
  83443. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83444. * @param useBones Precise whether bones should be used or not (override mesh info)
  83445. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83446. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83447. * @returns false if defines are considered not dirty and have not been checked
  83448. */
  83449. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83450. /**
  83451. * Prepares the defines related to multiview
  83452. * @param scene The scene we are intending to draw
  83453. * @param defines The defines to update
  83454. */
  83455. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83456. /**
  83457. * Prepares the defines related to the light information passed in parameter
  83458. * @param scene The scene we are intending to draw
  83459. * @param mesh The mesh the effect is compiling for
  83460. * @param light The light the effect is compiling for
  83461. * @param lightIndex The index of the light
  83462. * @param defines The defines to update
  83463. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83464. * @param state Defines the current state regarding what is needed (normals, etc...)
  83465. */
  83466. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83467. needNormals: boolean;
  83468. needRebuild: boolean;
  83469. shadowEnabled: boolean;
  83470. specularEnabled: boolean;
  83471. lightmapMode: boolean;
  83472. }): void;
  83473. /**
  83474. * Prepares the defines related to the light information passed in parameter
  83475. * @param scene The scene we are intending to draw
  83476. * @param mesh The mesh the effect is compiling for
  83477. * @param defines The defines to update
  83478. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83479. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83480. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83481. * @returns true if normals will be required for the rest of the effect
  83482. */
  83483. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83484. /**
  83485. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83486. * @param lightIndex defines the light index
  83487. * @param uniformsList The uniform list
  83488. * @param samplersList The sampler list
  83489. * @param projectedLightTexture defines if projected texture must be used
  83490. * @param uniformBuffersList defines an optional list of uniform buffers
  83491. */
  83492. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83493. /**
  83494. * Prepares the uniforms and samplers list to be used in the effect
  83495. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83496. * @param samplersList The sampler list
  83497. * @param defines The defines helping in the list generation
  83498. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83499. */
  83500. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83501. /**
  83502. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83503. * @param defines The defines to update while falling back
  83504. * @param fallbacks The authorized effect fallbacks
  83505. * @param maxSimultaneousLights The maximum number of lights allowed
  83506. * @param rank the current rank of the Effect
  83507. * @returns The newly affected rank
  83508. */
  83509. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83510. private static _TmpMorphInfluencers;
  83511. /**
  83512. * Prepares the list of attributes required for morph targets according to the effect defines.
  83513. * @param attribs The current list of supported attribs
  83514. * @param mesh The mesh to prepare the morph targets attributes for
  83515. * @param influencers The number of influencers
  83516. */
  83517. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83518. /**
  83519. * Prepares the list of attributes required for morph targets according to the effect defines.
  83520. * @param attribs The current list of supported attribs
  83521. * @param mesh The mesh to prepare the morph targets attributes for
  83522. * @param defines The current Defines of the effect
  83523. */
  83524. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83525. /**
  83526. * Prepares the list of attributes required for bones according to the effect defines.
  83527. * @param attribs The current list of supported attribs
  83528. * @param mesh The mesh to prepare the bones attributes for
  83529. * @param defines The current Defines of the effect
  83530. * @param fallbacks The current efffect fallback strategy
  83531. */
  83532. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83533. /**
  83534. * Check and prepare the list of attributes required for instances according to the effect defines.
  83535. * @param attribs The current list of supported attribs
  83536. * @param defines The current MaterialDefines of the effect
  83537. */
  83538. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83539. /**
  83540. * Add the list of attributes required for instances to the attribs array.
  83541. * @param attribs The current list of supported attribs
  83542. */
  83543. static PushAttributesForInstances(attribs: string[]): void;
  83544. /**
  83545. * Binds the light information to the effect.
  83546. * @param light The light containing the generator
  83547. * @param effect The effect we are binding the data to
  83548. * @param lightIndex The light index in the effect used to render
  83549. */
  83550. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83551. /**
  83552. * Binds the lights information from the scene to the effect for the given mesh.
  83553. * @param light Light to bind
  83554. * @param lightIndex Light index
  83555. * @param scene The scene where the light belongs to
  83556. * @param effect The effect we are binding the data to
  83557. * @param useSpecular Defines if specular is supported
  83558. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83559. */
  83560. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83561. /**
  83562. * Binds the lights information from the scene to the effect for the given mesh.
  83563. * @param scene The scene the lights belongs to
  83564. * @param mesh The mesh we are binding the information to render
  83565. * @param effect The effect we are binding the data to
  83566. * @param defines The generated defines for the effect
  83567. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83568. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83569. */
  83570. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83571. private static _tempFogColor;
  83572. /**
  83573. * Binds the fog information from the scene to the effect for the given mesh.
  83574. * @param scene The scene the lights belongs to
  83575. * @param mesh The mesh we are binding the information to render
  83576. * @param effect The effect we are binding the data to
  83577. * @param linearSpace Defines if the fog effect is applied in linear space
  83578. */
  83579. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83580. /**
  83581. * Binds the bones information from the mesh to the effect.
  83582. * @param mesh The mesh we are binding the information to render
  83583. * @param effect The effect we are binding the data to
  83584. */
  83585. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83586. /**
  83587. * Binds the morph targets information from the mesh to the effect.
  83588. * @param abstractMesh The mesh we are binding the information to render
  83589. * @param effect The effect we are binding the data to
  83590. */
  83591. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83592. /**
  83593. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83594. * @param defines The generated defines used in the effect
  83595. * @param effect The effect we are binding the data to
  83596. * @param scene The scene we are willing to render with logarithmic scale for
  83597. */
  83598. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83599. /**
  83600. * Binds the clip plane information from the scene to the effect.
  83601. * @param scene The scene the clip plane information are extracted from
  83602. * @param effect The effect we are binding the data to
  83603. */
  83604. static BindClipPlane(effect: Effect, scene: Scene): void;
  83605. }
  83606. }
  83607. declare module BABYLON {
  83608. /** @hidden */
  83609. export var packingFunctions: {
  83610. name: string;
  83611. shader: string;
  83612. };
  83613. }
  83614. declare module BABYLON {
  83615. /** @hidden */
  83616. export var clipPlaneFragmentDeclaration: {
  83617. name: string;
  83618. shader: string;
  83619. };
  83620. }
  83621. declare module BABYLON {
  83622. /** @hidden */
  83623. export var clipPlaneFragment: {
  83624. name: string;
  83625. shader: string;
  83626. };
  83627. }
  83628. declare module BABYLON {
  83629. /** @hidden */
  83630. export var shadowMapPixelShader: {
  83631. name: string;
  83632. shader: string;
  83633. };
  83634. }
  83635. declare module BABYLON {
  83636. /** @hidden */
  83637. export var bonesDeclaration: {
  83638. name: string;
  83639. shader: string;
  83640. };
  83641. }
  83642. declare module BABYLON {
  83643. /** @hidden */
  83644. export var morphTargetsVertexGlobalDeclaration: {
  83645. name: string;
  83646. shader: string;
  83647. };
  83648. }
  83649. declare module BABYLON {
  83650. /** @hidden */
  83651. export var morphTargetsVertexDeclaration: {
  83652. name: string;
  83653. shader: string;
  83654. };
  83655. }
  83656. declare module BABYLON {
  83657. /** @hidden */
  83658. export var instancesDeclaration: {
  83659. name: string;
  83660. shader: string;
  83661. };
  83662. }
  83663. declare module BABYLON {
  83664. /** @hidden */
  83665. export var helperFunctions: {
  83666. name: string;
  83667. shader: string;
  83668. };
  83669. }
  83670. declare module BABYLON {
  83671. /** @hidden */
  83672. export var clipPlaneVertexDeclaration: {
  83673. name: string;
  83674. shader: string;
  83675. };
  83676. }
  83677. declare module BABYLON {
  83678. /** @hidden */
  83679. export var morphTargetsVertex: {
  83680. name: string;
  83681. shader: string;
  83682. };
  83683. }
  83684. declare module BABYLON {
  83685. /** @hidden */
  83686. export var instancesVertex: {
  83687. name: string;
  83688. shader: string;
  83689. };
  83690. }
  83691. declare module BABYLON {
  83692. /** @hidden */
  83693. export var bonesVertex: {
  83694. name: string;
  83695. shader: string;
  83696. };
  83697. }
  83698. declare module BABYLON {
  83699. /** @hidden */
  83700. export var clipPlaneVertex: {
  83701. name: string;
  83702. shader: string;
  83703. };
  83704. }
  83705. declare module BABYLON {
  83706. /** @hidden */
  83707. export var shadowMapVertexShader: {
  83708. name: string;
  83709. shader: string;
  83710. };
  83711. }
  83712. declare module BABYLON {
  83713. /** @hidden */
  83714. export var depthBoxBlurPixelShader: {
  83715. name: string;
  83716. shader: string;
  83717. };
  83718. }
  83719. declare module BABYLON {
  83720. /**
  83721. * Class representing a ray with position and direction
  83722. */
  83723. export class Ray {
  83724. /** origin point */
  83725. origin: Vector3;
  83726. /** direction */
  83727. direction: Vector3;
  83728. /** length of the ray */
  83729. length: number;
  83730. private static readonly TmpVector3;
  83731. private _tmpRay;
  83732. /**
  83733. * Creates a new ray
  83734. * @param origin origin point
  83735. * @param direction direction
  83736. * @param length length of the ray
  83737. */
  83738. constructor(
  83739. /** origin point */
  83740. origin: Vector3,
  83741. /** direction */
  83742. direction: Vector3,
  83743. /** length of the ray */
  83744. length?: number);
  83745. /**
  83746. * Checks if the ray intersects a box
  83747. * @param minimum bound of the box
  83748. * @param maximum bound of the box
  83749. * @param intersectionTreshold extra extend to be added to the box in all direction
  83750. * @returns if the box was hit
  83751. */
  83752. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83753. /**
  83754. * Checks if the ray intersects a box
  83755. * @param box the bounding box to check
  83756. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83757. * @returns if the box was hit
  83758. */
  83759. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83760. /**
  83761. * If the ray hits a sphere
  83762. * @param sphere the bounding sphere to check
  83763. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83764. * @returns true if it hits the sphere
  83765. */
  83766. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83767. /**
  83768. * If the ray hits a triange
  83769. * @param vertex0 triangle vertex
  83770. * @param vertex1 triangle vertex
  83771. * @param vertex2 triangle vertex
  83772. * @returns intersection information if hit
  83773. */
  83774. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83775. /**
  83776. * Checks if ray intersects a plane
  83777. * @param plane the plane to check
  83778. * @returns the distance away it was hit
  83779. */
  83780. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83781. /**
  83782. * Calculate the intercept of a ray on a given axis
  83783. * @param axis to check 'x' | 'y' | 'z'
  83784. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83785. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83786. */
  83787. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83788. /**
  83789. * Checks if ray intersects a mesh
  83790. * @param mesh the mesh to check
  83791. * @param fastCheck if only the bounding box should checked
  83792. * @returns picking info of the intersecton
  83793. */
  83794. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83795. /**
  83796. * Checks if ray intersects a mesh
  83797. * @param meshes the meshes to check
  83798. * @param fastCheck if only the bounding box should checked
  83799. * @param results array to store result in
  83800. * @returns Array of picking infos
  83801. */
  83802. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83803. private _comparePickingInfo;
  83804. private static smallnum;
  83805. private static rayl;
  83806. /**
  83807. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83808. * @param sega the first point of the segment to test the intersection against
  83809. * @param segb the second point of the segment to test the intersection against
  83810. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83811. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83812. */
  83813. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83814. /**
  83815. * Update the ray from viewport position
  83816. * @param x position
  83817. * @param y y position
  83818. * @param viewportWidth viewport width
  83819. * @param viewportHeight viewport height
  83820. * @param world world matrix
  83821. * @param view view matrix
  83822. * @param projection projection matrix
  83823. * @returns this ray updated
  83824. */
  83825. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83826. /**
  83827. * Creates a ray with origin and direction of 0,0,0
  83828. * @returns the new ray
  83829. */
  83830. static Zero(): Ray;
  83831. /**
  83832. * Creates a new ray from screen space and viewport
  83833. * @param x position
  83834. * @param y y position
  83835. * @param viewportWidth viewport width
  83836. * @param viewportHeight viewport height
  83837. * @param world world matrix
  83838. * @param view view matrix
  83839. * @param projection projection matrix
  83840. * @returns new ray
  83841. */
  83842. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83843. /**
  83844. * 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
  83845. * transformed to the given world matrix.
  83846. * @param origin The origin point
  83847. * @param end The end point
  83848. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83849. * @returns the new ray
  83850. */
  83851. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83852. /**
  83853. * Transforms a ray by a matrix
  83854. * @param ray ray to transform
  83855. * @param matrix matrix to apply
  83856. * @returns the resulting new ray
  83857. */
  83858. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83859. /**
  83860. * Transforms a ray by a matrix
  83861. * @param ray ray to transform
  83862. * @param matrix matrix to apply
  83863. * @param result ray to store result in
  83864. */
  83865. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83866. /**
  83867. * Unproject a ray from screen space to object space
  83868. * @param sourceX defines the screen space x coordinate to use
  83869. * @param sourceY defines the screen space y coordinate to use
  83870. * @param viewportWidth defines the current width of the viewport
  83871. * @param viewportHeight defines the current height of the viewport
  83872. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83873. * @param view defines the view matrix to use
  83874. * @param projection defines the projection matrix to use
  83875. */
  83876. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83877. }
  83878. /**
  83879. * Type used to define predicate used to select faces when a mesh intersection is detected
  83880. */
  83881. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83882. interface Scene {
  83883. /** @hidden */
  83884. _tempPickingRay: Nullable<Ray>;
  83885. /** @hidden */
  83886. _cachedRayForTransform: Ray;
  83887. /** @hidden */
  83888. _pickWithRayInverseMatrix: Matrix;
  83889. /** @hidden */
  83890. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83891. /** @hidden */
  83892. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83893. }
  83894. }
  83895. declare module BABYLON {
  83896. /**
  83897. * Groups all the scene component constants in one place to ease maintenance.
  83898. * @hidden
  83899. */
  83900. export class SceneComponentConstants {
  83901. static readonly NAME_EFFECTLAYER: string;
  83902. static readonly NAME_LAYER: string;
  83903. static readonly NAME_LENSFLARESYSTEM: string;
  83904. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83905. static readonly NAME_PARTICLESYSTEM: string;
  83906. static readonly NAME_GAMEPAD: string;
  83907. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83908. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83909. static readonly NAME_DEPTHRENDERER: string;
  83910. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83911. static readonly NAME_SPRITE: string;
  83912. static readonly NAME_OUTLINERENDERER: string;
  83913. static readonly NAME_PROCEDURALTEXTURE: string;
  83914. static readonly NAME_SHADOWGENERATOR: string;
  83915. static readonly NAME_OCTREE: string;
  83916. static readonly NAME_PHYSICSENGINE: string;
  83917. static readonly NAME_AUDIO: string;
  83918. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83919. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83920. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83921. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83922. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83923. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83924. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83925. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83926. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83927. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83928. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83929. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83930. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83931. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83932. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83933. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83935. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83936. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83937. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83938. static readonly STEP_AFTERRENDER_AUDIO: number;
  83939. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83940. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83941. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83942. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83943. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83944. static readonly STEP_POINTERMOVE_SPRITE: number;
  83945. static readonly STEP_POINTERDOWN_SPRITE: number;
  83946. static readonly STEP_POINTERUP_SPRITE: number;
  83947. }
  83948. /**
  83949. * This represents a scene component.
  83950. *
  83951. * This is used to decouple the dependency the scene is having on the different workloads like
  83952. * layers, post processes...
  83953. */
  83954. export interface ISceneComponent {
  83955. /**
  83956. * The name of the component. Each component must have a unique name.
  83957. */
  83958. name: string;
  83959. /**
  83960. * The scene the component belongs to.
  83961. */
  83962. scene: Scene;
  83963. /**
  83964. * Register the component to one instance of a scene.
  83965. */
  83966. register(): void;
  83967. /**
  83968. * Rebuilds the elements related to this component in case of
  83969. * context lost for instance.
  83970. */
  83971. rebuild(): void;
  83972. /**
  83973. * Disposes the component and the associated ressources.
  83974. */
  83975. dispose(): void;
  83976. }
  83977. /**
  83978. * This represents a SERIALIZABLE scene component.
  83979. *
  83980. * This extends Scene Component to add Serialization methods on top.
  83981. */
  83982. export interface ISceneSerializableComponent extends ISceneComponent {
  83983. /**
  83984. * Adds all the elements from the container to the scene
  83985. * @param container the container holding the elements
  83986. */
  83987. addFromContainer(container: AbstractScene): void;
  83988. /**
  83989. * Removes all the elements in the container from the scene
  83990. * @param container contains the elements to remove
  83991. * @param dispose if the removed element should be disposed (default: false)
  83992. */
  83993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83994. /**
  83995. * Serializes the component data to the specified json object
  83996. * @param serializationObject The object to serialize to
  83997. */
  83998. serialize(serializationObject: any): void;
  83999. }
  84000. /**
  84001. * Strong typing of a Mesh related stage step action
  84002. */
  84003. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84004. /**
  84005. * Strong typing of a Evaluate Sub Mesh related stage step action
  84006. */
  84007. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84008. /**
  84009. * Strong typing of a Active Mesh related stage step action
  84010. */
  84011. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84012. /**
  84013. * Strong typing of a Camera related stage step action
  84014. */
  84015. export type CameraStageAction = (camera: Camera) => void;
  84016. /**
  84017. * Strong typing of a Camera Frame buffer related stage step action
  84018. */
  84019. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84020. /**
  84021. * Strong typing of a Render Target related stage step action
  84022. */
  84023. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84024. /**
  84025. * Strong typing of a RenderingGroup related stage step action
  84026. */
  84027. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84028. /**
  84029. * Strong typing of a Mesh Render related stage step action
  84030. */
  84031. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84032. /**
  84033. * Strong typing of a simple stage step action
  84034. */
  84035. export type SimpleStageAction = () => void;
  84036. /**
  84037. * Strong typing of a render target action.
  84038. */
  84039. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84040. /**
  84041. * Strong typing of a pointer move action.
  84042. */
  84043. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84044. /**
  84045. * Strong typing of a pointer up/down action.
  84046. */
  84047. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84048. /**
  84049. * Representation of a stage in the scene (Basically a list of ordered steps)
  84050. * @hidden
  84051. */
  84052. export class Stage<T extends Function> extends Array<{
  84053. index: number;
  84054. component: ISceneComponent;
  84055. action: T;
  84056. }> {
  84057. /**
  84058. * Hide ctor from the rest of the world.
  84059. * @param items The items to add.
  84060. */
  84061. private constructor();
  84062. /**
  84063. * Creates a new Stage.
  84064. * @returns A new instance of a Stage
  84065. */
  84066. static Create<T extends Function>(): Stage<T>;
  84067. /**
  84068. * Registers a step in an ordered way in the targeted stage.
  84069. * @param index Defines the position to register the step in
  84070. * @param component Defines the component attached to the step
  84071. * @param action Defines the action to launch during the step
  84072. */
  84073. registerStep(index: number, component: ISceneComponent, action: T): void;
  84074. /**
  84075. * Clears all the steps from the stage.
  84076. */
  84077. clear(): void;
  84078. }
  84079. }
  84080. declare module BABYLON {
  84081. interface Scene {
  84082. /** @hidden */
  84083. _pointerOverSprite: Nullable<Sprite>;
  84084. /** @hidden */
  84085. _pickedDownSprite: Nullable<Sprite>;
  84086. /** @hidden */
  84087. _tempSpritePickingRay: Nullable<Ray>;
  84088. /**
  84089. * All of the sprite managers added to this scene
  84090. * @see http://doc.babylonjs.com/babylon101/sprites
  84091. */
  84092. spriteManagers: Array<ISpriteManager>;
  84093. /**
  84094. * An event triggered when sprites rendering is about to start
  84095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84096. */
  84097. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84098. /**
  84099. * An event triggered when sprites rendering is done
  84100. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84101. */
  84102. onAfterSpritesRenderingObservable: Observable<Scene>;
  84103. /** @hidden */
  84104. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84105. /** Launch a ray to try to pick a sprite in the scene
  84106. * @param x position on screen
  84107. * @param y position on screen
  84108. * @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
  84109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84110. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84111. * @returns a PickingInfo
  84112. */
  84113. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84114. /** Use the given ray to pick a sprite in the scene
  84115. * @param ray The ray (in world space) to use to pick meshes
  84116. * @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
  84117. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84119. * @returns a PickingInfo
  84120. */
  84121. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84122. /** @hidden */
  84123. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84124. /** Launch a ray to try to pick sprites in the scene
  84125. * @param x position on screen
  84126. * @param y position on screen
  84127. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  84128. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84129. * @returns a PickingInfo array
  84130. */
  84131. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84132. /** Use the given ray to pick sprites in the scene
  84133. * @param ray The ray (in world space) to use to pick meshes
  84134. * @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
  84135. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84136. * @returns a PickingInfo array
  84137. */
  84138. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84139. /**
  84140. * Force the sprite under the pointer
  84141. * @param sprite defines the sprite to use
  84142. */
  84143. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84144. /**
  84145. * Gets the sprite under the pointer
  84146. * @returns a Sprite or null if no sprite is under the pointer
  84147. */
  84148. getPointerOverSprite(): Nullable<Sprite>;
  84149. }
  84150. /**
  84151. * Defines the sprite scene component responsible to manage sprites
  84152. * in a given scene.
  84153. */
  84154. export class SpriteSceneComponent implements ISceneComponent {
  84155. /**
  84156. * The component name helpfull to identify the component in the list of scene components.
  84157. */
  84158. readonly name: string;
  84159. /**
  84160. * The scene the component belongs to.
  84161. */
  84162. scene: Scene;
  84163. /** @hidden */
  84164. private _spritePredicate;
  84165. /**
  84166. * Creates a new instance of the component for the given scene
  84167. * @param scene Defines the scene to register the component in
  84168. */
  84169. constructor(scene: Scene);
  84170. /**
  84171. * Registers the component in a given scene
  84172. */
  84173. register(): void;
  84174. /**
  84175. * Rebuilds the elements related to this component in case of
  84176. * context lost for instance.
  84177. */
  84178. rebuild(): void;
  84179. /**
  84180. * Disposes the component and the associated ressources.
  84181. */
  84182. dispose(): void;
  84183. private _pickSpriteButKeepRay;
  84184. private _pointerMove;
  84185. private _pointerDown;
  84186. private _pointerUp;
  84187. }
  84188. }
  84189. declare module BABYLON {
  84190. /** @hidden */
  84191. export var fogFragmentDeclaration: {
  84192. name: string;
  84193. shader: string;
  84194. };
  84195. }
  84196. declare module BABYLON {
  84197. /** @hidden */
  84198. export var fogFragment: {
  84199. name: string;
  84200. shader: string;
  84201. };
  84202. }
  84203. declare module BABYLON {
  84204. /** @hidden */
  84205. export var spritesPixelShader: {
  84206. name: string;
  84207. shader: string;
  84208. };
  84209. }
  84210. declare module BABYLON {
  84211. /** @hidden */
  84212. export var fogVertexDeclaration: {
  84213. name: string;
  84214. shader: string;
  84215. };
  84216. }
  84217. declare module BABYLON {
  84218. /** @hidden */
  84219. export var spritesVertexShader: {
  84220. name: string;
  84221. shader: string;
  84222. };
  84223. }
  84224. declare module BABYLON {
  84225. /**
  84226. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84227. */
  84228. export interface ISpriteManager extends IDisposable {
  84229. /**
  84230. * Restricts the camera to viewing objects with the same layerMask.
  84231. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84232. */
  84233. layerMask: number;
  84234. /**
  84235. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84236. */
  84237. isPickable: boolean;
  84238. /**
  84239. * Specifies the rendering group id for this mesh (0 by default)
  84240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84241. */
  84242. renderingGroupId: number;
  84243. /**
  84244. * Defines the list of sprites managed by the manager.
  84245. */
  84246. sprites: Array<Sprite>;
  84247. /**
  84248. * Tests the intersection of a sprite with a specific ray.
  84249. * @param ray The ray we are sending to test the collision
  84250. * @param camera The camera space we are sending rays in
  84251. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84252. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84253. * @returns picking info or null.
  84254. */
  84255. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84256. /**
  84257. * Intersects the sprites with a ray
  84258. * @param ray defines the ray to intersect with
  84259. * @param camera defines the current active camera
  84260. * @param predicate defines a predicate used to select candidate sprites
  84261. * @returns null if no hit or a PickingInfo array
  84262. */
  84263. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84264. /**
  84265. * Renders the list of sprites on screen.
  84266. */
  84267. render(): void;
  84268. }
  84269. /**
  84270. * Class used to manage multiple sprites on the same spritesheet
  84271. * @see http://doc.babylonjs.com/babylon101/sprites
  84272. */
  84273. export class SpriteManager implements ISpriteManager {
  84274. /** defines the manager's name */
  84275. name: string;
  84276. /** Gets the list of sprites */
  84277. sprites: Sprite[];
  84278. /** Gets or sets the rendering group id (0 by default) */
  84279. renderingGroupId: number;
  84280. /** Gets or sets camera layer mask */
  84281. layerMask: number;
  84282. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84283. fogEnabled: boolean;
  84284. /** Gets or sets a boolean indicating if the sprites are pickable */
  84285. isPickable: boolean;
  84286. /** Defines the default width of a cell in the spritesheet */
  84287. cellWidth: number;
  84288. /** Defines the default height of a cell in the spritesheet */
  84289. cellHeight: number;
  84290. /** Associative array from JSON sprite data file */
  84291. private _cellData;
  84292. /** Array of sprite names from JSON sprite data file */
  84293. private _spriteMap;
  84294. /** True when packed cell data from JSON file is ready*/
  84295. private _packedAndReady;
  84296. /**
  84297. * An event triggered when the manager is disposed.
  84298. */
  84299. onDisposeObservable: Observable<SpriteManager>;
  84300. private _onDisposeObserver;
  84301. /**
  84302. * Callback called when the manager is disposed
  84303. */
  84304. set onDispose(callback: () => void);
  84305. private _capacity;
  84306. private _fromPacked;
  84307. private _spriteTexture;
  84308. private _epsilon;
  84309. private _scene;
  84310. private _vertexData;
  84311. private _buffer;
  84312. private _vertexBuffers;
  84313. private _indexBuffer;
  84314. private _effectBase;
  84315. private _effectFog;
  84316. /**
  84317. * Gets or sets the spritesheet texture
  84318. */
  84319. get texture(): Texture;
  84320. set texture(value: Texture);
  84321. private _blendMode;
  84322. /**
  84323. * Blend mode use to render the particle, it can be any of
  84324. * the static Constants.ALPHA_x properties provided in this class.
  84325. * Default value is Constants.ALPHA_COMBINE
  84326. */
  84327. get blendMode(): number;
  84328. set blendMode(blendMode: number);
  84329. /** Disables writing to the depth buffer when rendering the sprites.
  84330. * It can be handy to disable depth writing when using textures without alpha channel
  84331. * and setting some specific blend modes.
  84332. */
  84333. disableDepthWrite: boolean;
  84334. /**
  84335. * Creates a new sprite manager
  84336. * @param name defines the manager's name
  84337. * @param imgUrl defines the sprite sheet url
  84338. * @param capacity defines the maximum allowed number of sprites
  84339. * @param cellSize defines the size of a sprite cell
  84340. * @param scene defines the hosting scene
  84341. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84342. * @param samplingMode defines the smapling mode to use with spritesheet
  84343. * @param fromPacked set to false; do not alter
  84344. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84345. */
  84346. constructor(
  84347. /** defines the manager's name */
  84348. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84349. private _makePacked;
  84350. private _appendSpriteVertex;
  84351. /**
  84352. * Intersects the sprites with a ray
  84353. * @param ray defines the ray to intersect with
  84354. * @param camera defines the current active camera
  84355. * @param predicate defines a predicate used to select candidate sprites
  84356. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84357. * @returns null if no hit or a PickingInfo
  84358. */
  84359. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84360. /**
  84361. * Intersects the sprites with a ray
  84362. * @param ray defines the ray to intersect with
  84363. * @param camera defines the current active camera
  84364. * @param predicate defines a predicate used to select candidate sprites
  84365. * @returns null if no hit or a PickingInfo array
  84366. */
  84367. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84368. /**
  84369. * Render all child sprites
  84370. */
  84371. render(): void;
  84372. /**
  84373. * Release associated resources
  84374. */
  84375. dispose(): void;
  84376. }
  84377. }
  84378. declare module BABYLON {
  84379. /** Interface used by value gradients (color, factor, ...) */
  84380. export interface IValueGradient {
  84381. /**
  84382. * Gets or sets the gradient value (between 0 and 1)
  84383. */
  84384. gradient: number;
  84385. }
  84386. /** Class used to store color4 gradient */
  84387. export class ColorGradient implements IValueGradient {
  84388. /**
  84389. * Gets or sets the gradient value (between 0 and 1)
  84390. */
  84391. gradient: number;
  84392. /**
  84393. * Gets or sets first associated color
  84394. */
  84395. color1: Color4;
  84396. /**
  84397. * Gets or sets second associated color
  84398. */
  84399. color2?: Color4 | undefined;
  84400. /**
  84401. * Creates a new color4 gradient
  84402. * @param gradient gets or sets the gradient value (between 0 and 1)
  84403. * @param color1 gets or sets first associated color
  84404. * @param color2 gets or sets first second color
  84405. */
  84406. constructor(
  84407. /**
  84408. * Gets or sets the gradient value (between 0 and 1)
  84409. */
  84410. gradient: number,
  84411. /**
  84412. * Gets or sets first associated color
  84413. */
  84414. color1: Color4,
  84415. /**
  84416. * Gets or sets second associated color
  84417. */
  84418. color2?: Color4 | undefined);
  84419. /**
  84420. * Will get a color picked randomly between color1 and color2.
  84421. * If color2 is undefined then color1 will be used
  84422. * @param result defines the target Color4 to store the result in
  84423. */
  84424. getColorToRef(result: Color4): void;
  84425. }
  84426. /** Class used to store color 3 gradient */
  84427. export class Color3Gradient implements IValueGradient {
  84428. /**
  84429. * Gets or sets the gradient value (between 0 and 1)
  84430. */
  84431. gradient: number;
  84432. /**
  84433. * Gets or sets the associated color
  84434. */
  84435. color: Color3;
  84436. /**
  84437. * Creates a new color3 gradient
  84438. * @param gradient gets or sets the gradient value (between 0 and 1)
  84439. * @param color gets or sets associated color
  84440. */
  84441. constructor(
  84442. /**
  84443. * Gets or sets the gradient value (between 0 and 1)
  84444. */
  84445. gradient: number,
  84446. /**
  84447. * Gets or sets the associated color
  84448. */
  84449. color: Color3);
  84450. }
  84451. /** Class used to store factor gradient */
  84452. export class FactorGradient implements IValueGradient {
  84453. /**
  84454. * Gets or sets the gradient value (between 0 and 1)
  84455. */
  84456. gradient: number;
  84457. /**
  84458. * Gets or sets first associated factor
  84459. */
  84460. factor1: number;
  84461. /**
  84462. * Gets or sets second associated factor
  84463. */
  84464. factor2?: number | undefined;
  84465. /**
  84466. * Creates a new factor gradient
  84467. * @param gradient gets or sets the gradient value (between 0 and 1)
  84468. * @param factor1 gets or sets first associated factor
  84469. * @param factor2 gets or sets second associated factor
  84470. */
  84471. constructor(
  84472. /**
  84473. * Gets or sets the gradient value (between 0 and 1)
  84474. */
  84475. gradient: number,
  84476. /**
  84477. * Gets or sets first associated factor
  84478. */
  84479. factor1: number,
  84480. /**
  84481. * Gets or sets second associated factor
  84482. */
  84483. factor2?: number | undefined);
  84484. /**
  84485. * Will get a number picked randomly between factor1 and factor2.
  84486. * If factor2 is undefined then factor1 will be used
  84487. * @returns the picked number
  84488. */
  84489. getFactor(): number;
  84490. }
  84491. /**
  84492. * Helper used to simplify some generic gradient tasks
  84493. */
  84494. export class GradientHelper {
  84495. /**
  84496. * Gets the current gradient from an array of IValueGradient
  84497. * @param ratio defines the current ratio to get
  84498. * @param gradients defines the array of IValueGradient
  84499. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84500. */
  84501. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84502. }
  84503. }
  84504. declare module BABYLON {
  84505. /**
  84506. * Interface for the size containing width and height
  84507. */
  84508. export interface ISize {
  84509. /**
  84510. * Width
  84511. */
  84512. width: number;
  84513. /**
  84514. * Heighht
  84515. */
  84516. height: number;
  84517. }
  84518. /**
  84519. * Size containing widht and height
  84520. */
  84521. export class Size implements ISize {
  84522. /**
  84523. * Width
  84524. */
  84525. width: number;
  84526. /**
  84527. * Height
  84528. */
  84529. height: number;
  84530. /**
  84531. * Creates a Size object from the given width and height (floats).
  84532. * @param width width of the new size
  84533. * @param height height of the new size
  84534. */
  84535. constructor(width: number, height: number);
  84536. /**
  84537. * Returns a string with the Size width and height
  84538. * @returns a string with the Size width and height
  84539. */
  84540. toString(): string;
  84541. /**
  84542. * "Size"
  84543. * @returns the string "Size"
  84544. */
  84545. getClassName(): string;
  84546. /**
  84547. * Returns the Size hash code.
  84548. * @returns a hash code for a unique width and height
  84549. */
  84550. getHashCode(): number;
  84551. /**
  84552. * Updates the current size from the given one.
  84553. * @param src the given size
  84554. */
  84555. copyFrom(src: Size): void;
  84556. /**
  84557. * Updates in place the current Size from the given floats.
  84558. * @param width width of the new size
  84559. * @param height height of the new size
  84560. * @returns the updated Size.
  84561. */
  84562. copyFromFloats(width: number, height: number): Size;
  84563. /**
  84564. * Updates in place the current Size from the given floats.
  84565. * @param width width to set
  84566. * @param height height to set
  84567. * @returns the updated Size.
  84568. */
  84569. set(width: number, height: number): Size;
  84570. /**
  84571. * Multiplies the width and height by numbers
  84572. * @param w factor to multiple the width by
  84573. * @param h factor to multiple the height by
  84574. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84575. */
  84576. multiplyByFloats(w: number, h: number): Size;
  84577. /**
  84578. * Clones the size
  84579. * @returns a new Size copied from the given one.
  84580. */
  84581. clone(): Size;
  84582. /**
  84583. * True if the current Size and the given one width and height are strictly equal.
  84584. * @param other the other size to compare against
  84585. * @returns True if the current Size and the given one width and height are strictly equal.
  84586. */
  84587. equals(other: Size): boolean;
  84588. /**
  84589. * The surface of the Size : width * height (float).
  84590. */
  84591. get surface(): number;
  84592. /**
  84593. * Create a new size of zero
  84594. * @returns a new Size set to (0.0, 0.0)
  84595. */
  84596. static Zero(): Size;
  84597. /**
  84598. * Sums the width and height of two sizes
  84599. * @param otherSize size to add to this size
  84600. * @returns a new Size set as the addition result of the current Size and the given one.
  84601. */
  84602. add(otherSize: Size): Size;
  84603. /**
  84604. * Subtracts the width and height of two
  84605. * @param otherSize size to subtract to this size
  84606. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84607. */
  84608. subtract(otherSize: Size): Size;
  84609. /**
  84610. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84611. * @param start starting size to lerp between
  84612. * @param end end size to lerp between
  84613. * @param amount amount to lerp between the start and end values
  84614. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84615. */
  84616. static Lerp(start: Size, end: Size, amount: number): Size;
  84617. }
  84618. }
  84619. declare module BABYLON {
  84620. interface ThinEngine {
  84621. /**
  84622. * Creates a dynamic texture
  84623. * @param width defines the width of the texture
  84624. * @param height defines the height of the texture
  84625. * @param generateMipMaps defines if the engine should generate the mip levels
  84626. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84627. * @returns the dynamic texture inside an InternalTexture
  84628. */
  84629. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84630. /**
  84631. * Update the content of a dynamic texture
  84632. * @param texture defines the texture to update
  84633. * @param canvas defines the canvas containing the source
  84634. * @param invertY defines if data must be stored with Y axis inverted
  84635. * @param premulAlpha defines if alpha is stored as premultiplied
  84636. * @param format defines the format of the data
  84637. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84638. */
  84639. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84640. }
  84641. }
  84642. declare module BABYLON {
  84643. /**
  84644. * Helper class used to generate a canvas to manipulate images
  84645. */
  84646. export class CanvasGenerator {
  84647. /**
  84648. * Create a new canvas (or offscreen canvas depending on the context)
  84649. * @param width defines the expected width
  84650. * @param height defines the expected height
  84651. * @return a new canvas or offscreen canvas
  84652. */
  84653. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84654. }
  84655. }
  84656. declare module BABYLON {
  84657. /**
  84658. * A class extending Texture allowing drawing on a texture
  84659. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84660. */
  84661. export class DynamicTexture extends Texture {
  84662. private _generateMipMaps;
  84663. private _canvas;
  84664. private _context;
  84665. private _engine;
  84666. /**
  84667. * Creates a DynamicTexture
  84668. * @param name defines the name of the texture
  84669. * @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
  84670. * @param scene defines the scene where you want the texture
  84671. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84672. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84673. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84674. */
  84675. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84676. /**
  84677. * Get the current class name of the texture useful for serialization or dynamic coding.
  84678. * @returns "DynamicTexture"
  84679. */
  84680. getClassName(): string;
  84681. /**
  84682. * Gets the current state of canRescale
  84683. */
  84684. get canRescale(): boolean;
  84685. private _recreate;
  84686. /**
  84687. * Scales the texture
  84688. * @param ratio the scale factor to apply to both width and height
  84689. */
  84690. scale(ratio: number): void;
  84691. /**
  84692. * Resizes the texture
  84693. * @param width the new width
  84694. * @param height the new height
  84695. */
  84696. scaleTo(width: number, height: number): void;
  84697. /**
  84698. * Gets the context of the canvas used by the texture
  84699. * @returns the canvas context of the dynamic texture
  84700. */
  84701. getContext(): CanvasRenderingContext2D;
  84702. /**
  84703. * Clears the texture
  84704. */
  84705. clear(): void;
  84706. /**
  84707. * Updates the texture
  84708. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84709. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84710. */
  84711. update(invertY?: boolean, premulAlpha?: boolean): void;
  84712. /**
  84713. * Draws text onto the texture
  84714. * @param text defines the text to be drawn
  84715. * @param x defines the placement of the text from the left
  84716. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84717. * @param font defines the font to be used with font-style, font-size, font-name
  84718. * @param color defines the color used for the text
  84719. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84720. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84721. * @param update defines whether texture is immediately update (default is true)
  84722. */
  84723. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84724. /**
  84725. * Clones the texture
  84726. * @returns the clone of the texture.
  84727. */
  84728. clone(): DynamicTexture;
  84729. /**
  84730. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84731. * @returns a serialized dynamic texture object
  84732. */
  84733. serialize(): any;
  84734. /** @hidden */
  84735. _rebuild(): void;
  84736. }
  84737. }
  84738. declare module BABYLON {
  84739. interface Engine {
  84740. /**
  84741. * Creates a raw texture
  84742. * @param data defines the data to store in the texture
  84743. * @param width defines the width of the texture
  84744. * @param height defines the height of the texture
  84745. * @param format defines the format of the data
  84746. * @param generateMipMaps defines if the engine should generate the mip levels
  84747. * @param invertY defines if data must be stored with Y axis inverted
  84748. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84749. * @param compression defines the compression used (null by default)
  84750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84751. * @returns the raw texture inside an InternalTexture
  84752. */
  84753. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84754. /**
  84755. * Update a raw texture
  84756. * @param texture defines the texture to update
  84757. * @param data defines the data to store in the texture
  84758. * @param format defines the format of the data
  84759. * @param invertY defines if data must be stored with Y axis inverted
  84760. */
  84761. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84762. /**
  84763. * Update a raw texture
  84764. * @param texture defines the texture to update
  84765. * @param data defines the data to store in the texture
  84766. * @param format defines the format of the data
  84767. * @param invertY defines if data must be stored with Y axis inverted
  84768. * @param compression defines the compression used (null by default)
  84769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84770. */
  84771. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84772. /**
  84773. * Creates a new raw cube texture
  84774. * @param data defines the array of data to use to create each face
  84775. * @param size defines the size of the textures
  84776. * @param format defines the format of the data
  84777. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84778. * @param generateMipMaps defines if the engine should generate the mip levels
  84779. * @param invertY defines if data must be stored with Y axis inverted
  84780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84781. * @param compression defines the compression used (null by default)
  84782. * @returns the cube texture as an InternalTexture
  84783. */
  84784. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84785. /**
  84786. * Update a raw cube texture
  84787. * @param texture defines the texture to udpdate
  84788. * @param data defines the data to store
  84789. * @param format defines the data format
  84790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84791. * @param invertY defines if data must be stored with Y axis inverted
  84792. */
  84793. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84794. /**
  84795. * Update a raw cube texture
  84796. * @param texture defines the texture to udpdate
  84797. * @param data defines the data to store
  84798. * @param format defines the data format
  84799. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84800. * @param invertY defines if data must be stored with Y axis inverted
  84801. * @param compression defines the compression used (null by default)
  84802. */
  84803. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84804. /**
  84805. * Update a raw cube texture
  84806. * @param texture defines the texture to udpdate
  84807. * @param data defines the data to store
  84808. * @param format defines the data format
  84809. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84810. * @param invertY defines if data must be stored with Y axis inverted
  84811. * @param compression defines the compression used (null by default)
  84812. * @param level defines which level of the texture to update
  84813. */
  84814. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84815. /**
  84816. * Creates a new raw cube texture from a specified url
  84817. * @param url defines the url where the data is located
  84818. * @param scene defines the current scene
  84819. * @param size defines the size of the textures
  84820. * @param format defines the format of the data
  84821. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84822. * @param noMipmap defines if the engine should avoid generating the mip levels
  84823. * @param callback defines a callback used to extract texture data from loaded data
  84824. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84825. * @param onLoad defines a callback called when texture is loaded
  84826. * @param onError defines a callback called if there is an error
  84827. * @returns the cube texture as an InternalTexture
  84828. */
  84829. 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;
  84830. /**
  84831. * Creates a new raw cube texture from a specified url
  84832. * @param url defines the url where the data is located
  84833. * @param scene defines the current scene
  84834. * @param size defines the size of the textures
  84835. * @param format defines the format of the data
  84836. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84837. * @param noMipmap defines if the engine should avoid generating the mip levels
  84838. * @param callback defines a callback used to extract texture data from loaded data
  84839. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84840. * @param onLoad defines a callback called when texture is loaded
  84841. * @param onError defines a callback called if there is an error
  84842. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84843. * @param invertY defines if data must be stored with Y axis inverted
  84844. * @returns the cube texture as an InternalTexture
  84845. */
  84846. 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;
  84847. /**
  84848. * Creates a new raw 3D texture
  84849. * @param data defines the data used to create the texture
  84850. * @param width defines the width of the texture
  84851. * @param height defines the height of the texture
  84852. * @param depth defines the depth of the texture
  84853. * @param format defines the format of the texture
  84854. * @param generateMipMaps defines if the engine must generate mip levels
  84855. * @param invertY defines if data must be stored with Y axis inverted
  84856. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84857. * @param compression defines the compressed used (can be null)
  84858. * @param textureType defines the compressed used (can be null)
  84859. * @returns a new raw 3D texture (stored in an InternalTexture)
  84860. */
  84861. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84862. /**
  84863. * Update a raw 3D texture
  84864. * @param texture defines the texture to update
  84865. * @param data defines the data to store
  84866. * @param format defines the data format
  84867. * @param invertY defines if data must be stored with Y axis inverted
  84868. */
  84869. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84870. /**
  84871. * Update a raw 3D texture
  84872. * @param texture defines the texture to update
  84873. * @param data defines the data to store
  84874. * @param format defines the data format
  84875. * @param invertY defines if data must be stored with Y axis inverted
  84876. * @param compression defines the used compression (can be null)
  84877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84878. */
  84879. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84880. /**
  84881. * Creates a new raw 2D array texture
  84882. * @param data defines the data used to create the texture
  84883. * @param width defines the width of the texture
  84884. * @param height defines the height of the texture
  84885. * @param depth defines the number of layers of the texture
  84886. * @param format defines the format of the texture
  84887. * @param generateMipMaps defines if the engine must generate mip levels
  84888. * @param invertY defines if data must be stored with Y axis inverted
  84889. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84890. * @param compression defines the compressed used (can be null)
  84891. * @param textureType defines the compressed used (can be null)
  84892. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84893. */
  84894. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84895. /**
  84896. * Update a raw 2D array texture
  84897. * @param texture defines the texture to update
  84898. * @param data defines the data to store
  84899. * @param format defines the data format
  84900. * @param invertY defines if data must be stored with Y axis inverted
  84901. */
  84902. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84903. /**
  84904. * Update a raw 2D array texture
  84905. * @param texture defines the texture to update
  84906. * @param data defines the data to store
  84907. * @param format defines the data format
  84908. * @param invertY defines if data must be stored with Y axis inverted
  84909. * @param compression defines the used compression (can be null)
  84910. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84911. */
  84912. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84913. }
  84914. }
  84915. declare module BABYLON {
  84916. /**
  84917. * Raw texture can help creating a texture directly from an array of data.
  84918. * This can be super useful if you either get the data from an uncompressed source or
  84919. * if you wish to create your texture pixel by pixel.
  84920. */
  84921. export class RawTexture extends Texture {
  84922. /**
  84923. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84924. */
  84925. format: number;
  84926. private _engine;
  84927. /**
  84928. * Instantiates a new RawTexture.
  84929. * Raw texture can help creating a texture directly from an array of data.
  84930. * This can be super useful if you either get the data from an uncompressed source or
  84931. * if you wish to create your texture pixel by pixel.
  84932. * @param data define the array of data to use to create the texture
  84933. * @param width define the width of the texture
  84934. * @param height define the height of the texture
  84935. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84936. * @param scene define the scene the texture belongs to
  84937. * @param generateMipMaps define whether mip maps should be generated or not
  84938. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84939. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84940. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84941. */
  84942. constructor(data: ArrayBufferView, width: number, height: number,
  84943. /**
  84944. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84945. */
  84946. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84947. /**
  84948. * Updates the texture underlying data.
  84949. * @param data Define the new data of the texture
  84950. */
  84951. update(data: ArrayBufferView): void;
  84952. /**
  84953. * Creates a luminance texture from some data.
  84954. * @param data Define the texture data
  84955. * @param width Define the width of the texture
  84956. * @param height Define the height of the texture
  84957. * @param scene Define the scene the texture belongs to
  84958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  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. * @returns the luminance texture
  84962. */
  84963. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84964. /**
  84965. * Creates a luminance alpha texture from some data.
  84966. * @param data Define the texture data
  84967. * @param width Define the width of the texture
  84968. * @param height Define the height of the texture
  84969. * @param scene Define the scene the texture belongs to
  84970. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84971. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84972. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84973. * @returns the luminance alpha texture
  84974. */
  84975. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84976. /**
  84977. * Creates an alpha texture from some data.
  84978. * @param data Define the texture data
  84979. * @param width Define the width of the texture
  84980. * @param height Define the height of the texture
  84981. * @param scene Define the scene the texture belongs to
  84982. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84983. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84984. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84985. * @returns the alpha texture
  84986. */
  84987. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84988. /**
  84989. * Creates a RGB texture from some data.
  84990. * @param data Define the texture data
  84991. * @param width Define the width of the texture
  84992. * @param height Define the height of the texture
  84993. * @param scene Define the scene the texture belongs to
  84994. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84995. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84996. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84997. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84998. * @returns the RGB alpha texture
  84999. */
  85000. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85001. /**
  85002. * Creates a RGBA texture from some data.
  85003. * @param data Define the texture data
  85004. * @param width Define the width of the texture
  85005. * @param height Define the height of the texture
  85006. * @param scene Define the scene the texture belongs to
  85007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85011. * @returns the RGBA texture
  85012. */
  85013. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85014. /**
  85015. * Creates a R texture from some data.
  85016. * @param data Define the texture data
  85017. * @param width Define the width of the texture
  85018. * @param height Define the height of the texture
  85019. * @param scene Define the scene the texture belongs to
  85020. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85021. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85022. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85023. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85024. * @returns the R texture
  85025. */
  85026. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85027. }
  85028. }
  85029. declare module BABYLON {
  85030. interface AbstractScene {
  85031. /**
  85032. * The list of procedural textures added to the scene
  85033. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85034. */
  85035. proceduralTextures: Array<ProceduralTexture>;
  85036. }
  85037. /**
  85038. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85039. * in a given scene.
  85040. */
  85041. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85042. /**
  85043. * The component name helpfull to identify the component in the list of scene components.
  85044. */
  85045. readonly name: string;
  85046. /**
  85047. * The scene the component belongs to.
  85048. */
  85049. scene: Scene;
  85050. /**
  85051. * Creates a new instance of the component for the given scene
  85052. * @param scene Defines the scene to register the component in
  85053. */
  85054. constructor(scene: Scene);
  85055. /**
  85056. * Registers the component in a given scene
  85057. */
  85058. register(): void;
  85059. /**
  85060. * Rebuilds the elements related to this component in case of
  85061. * context lost for instance.
  85062. */
  85063. rebuild(): void;
  85064. /**
  85065. * Disposes the component and the associated ressources.
  85066. */
  85067. dispose(): void;
  85068. private _beforeClear;
  85069. }
  85070. }
  85071. declare module BABYLON {
  85072. interface ThinEngine {
  85073. /**
  85074. * Creates a new render target cube texture
  85075. * @param size defines the size of the texture
  85076. * @param options defines the options used to create the texture
  85077. * @returns a new render target cube texture stored in an InternalTexture
  85078. */
  85079. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85080. }
  85081. }
  85082. declare module BABYLON {
  85083. /** @hidden */
  85084. export var proceduralVertexShader: {
  85085. name: string;
  85086. shader: string;
  85087. };
  85088. }
  85089. declare module BABYLON {
  85090. /**
  85091. * 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.
  85092. * This is the base class of any Procedural texture and contains most of the shareable code.
  85093. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85094. */
  85095. export class ProceduralTexture extends Texture {
  85096. isCube: boolean;
  85097. /**
  85098. * Define if the texture is enabled or not (disabled texture will not render)
  85099. */
  85100. isEnabled: boolean;
  85101. /**
  85102. * Define if the texture must be cleared before rendering (default is true)
  85103. */
  85104. autoClear: boolean;
  85105. /**
  85106. * Callback called when the texture is generated
  85107. */
  85108. onGenerated: () => void;
  85109. /**
  85110. * Event raised when the texture is generated
  85111. */
  85112. onGeneratedObservable: Observable<ProceduralTexture>;
  85113. /** @hidden */
  85114. _generateMipMaps: boolean;
  85115. /** @hidden **/
  85116. _effect: Effect;
  85117. /** @hidden */
  85118. _textures: {
  85119. [key: string]: Texture;
  85120. };
  85121. /** @hidden */
  85122. protected _fallbackTexture: Nullable<Texture>;
  85123. private _size;
  85124. private _currentRefreshId;
  85125. private _frameId;
  85126. private _refreshRate;
  85127. private _vertexBuffers;
  85128. private _indexBuffer;
  85129. private _uniforms;
  85130. private _samplers;
  85131. private _fragment;
  85132. private _floats;
  85133. private _ints;
  85134. private _floatsArrays;
  85135. private _colors3;
  85136. private _colors4;
  85137. private _vectors2;
  85138. private _vectors3;
  85139. private _matrices;
  85140. private _fallbackTextureUsed;
  85141. private _engine;
  85142. private _cachedDefines;
  85143. private _contentUpdateId;
  85144. private _contentData;
  85145. /**
  85146. * Instantiates a new procedural texture.
  85147. * 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.
  85148. * This is the base class of any Procedural texture and contains most of the shareable code.
  85149. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85150. * @param name Define the name of the texture
  85151. * @param size Define the size of the texture to create
  85152. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85153. * @param scene Define the scene the texture belongs to
  85154. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85155. * @param generateMipMaps Define if the texture should creates mip maps or not
  85156. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85157. */
  85158. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85159. /**
  85160. * The effect that is created when initializing the post process.
  85161. * @returns The created effect corresponding the the postprocess.
  85162. */
  85163. getEffect(): Effect;
  85164. /**
  85165. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85166. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85167. */
  85168. getContent(): Nullable<ArrayBufferView>;
  85169. private _createIndexBuffer;
  85170. /** @hidden */
  85171. _rebuild(): void;
  85172. /**
  85173. * Resets the texture in order to recreate its associated resources.
  85174. * This can be called in case of context loss
  85175. */
  85176. reset(): void;
  85177. protected _getDefines(): string;
  85178. /**
  85179. * Is the texture ready to be used ? (rendered at least once)
  85180. * @returns true if ready, otherwise, false.
  85181. */
  85182. isReady(): boolean;
  85183. /**
  85184. * Resets the refresh counter of the texture and start bak from scratch.
  85185. * Could be useful to regenerate the texture if it is setup to render only once.
  85186. */
  85187. resetRefreshCounter(): void;
  85188. /**
  85189. * Set the fragment shader to use in order to render the texture.
  85190. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85191. */
  85192. setFragment(fragment: any): void;
  85193. /**
  85194. * Define the refresh rate of the texture or the rendering frequency.
  85195. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85196. */
  85197. get refreshRate(): number;
  85198. set refreshRate(value: number);
  85199. /** @hidden */
  85200. _shouldRender(): boolean;
  85201. /**
  85202. * Get the size the texture is rendering at.
  85203. * @returns the size (texture is always squared)
  85204. */
  85205. getRenderSize(): number;
  85206. /**
  85207. * Resize the texture to new value.
  85208. * @param size Define the new size the texture should have
  85209. * @param generateMipMaps Define whether the new texture should create mip maps
  85210. */
  85211. resize(size: number, generateMipMaps: boolean): void;
  85212. private _checkUniform;
  85213. /**
  85214. * Set a texture in the shader program used to render.
  85215. * @param name Define the name of the uniform samplers as defined in the shader
  85216. * @param texture Define the texture to bind to this sampler
  85217. * @return the texture itself allowing "fluent" like uniform updates
  85218. */
  85219. setTexture(name: string, texture: Texture): ProceduralTexture;
  85220. /**
  85221. * Set a float in the shader.
  85222. * @param name Define the name of the uniform as defined in the shader
  85223. * @param value Define the value to give to the uniform
  85224. * @return the texture itself allowing "fluent" like uniform updates
  85225. */
  85226. setFloat(name: string, value: number): ProceduralTexture;
  85227. /**
  85228. * Set a int in the shader.
  85229. * @param name Define the name of the uniform as defined in the shader
  85230. * @param value Define the value to give to the uniform
  85231. * @return the texture itself allowing "fluent" like uniform updates
  85232. */
  85233. setInt(name: string, value: number): ProceduralTexture;
  85234. /**
  85235. * Set an array of floats in the shader.
  85236. * @param name Define the name of the uniform as defined in the shader
  85237. * @param value Define the value to give to the uniform
  85238. * @return the texture itself allowing "fluent" like uniform updates
  85239. */
  85240. setFloats(name: string, value: number[]): ProceduralTexture;
  85241. /**
  85242. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  85248. /**
  85249. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  85255. /**
  85256. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  85262. /**
  85263. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  85269. /**
  85270. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85276. /**
  85277. * Render the texture to its associated render target.
  85278. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85279. */
  85280. render(useCameraPostProcess?: boolean): void;
  85281. /**
  85282. * Clone the texture.
  85283. * @returns the cloned texture
  85284. */
  85285. clone(): ProceduralTexture;
  85286. /**
  85287. * Dispose the texture and release its asoociated resources.
  85288. */
  85289. dispose(): void;
  85290. }
  85291. }
  85292. declare module BABYLON {
  85293. /**
  85294. * This represents the base class for particle system in Babylon.
  85295. * 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.
  85296. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85297. * @example https://doc.babylonjs.com/babylon101/particles
  85298. */
  85299. export class BaseParticleSystem {
  85300. /**
  85301. * Source color is added to the destination color without alpha affecting the result
  85302. */
  85303. static BLENDMODE_ONEONE: number;
  85304. /**
  85305. * Blend current color and particle color using particle’s alpha
  85306. */
  85307. static BLENDMODE_STANDARD: number;
  85308. /**
  85309. * Add current color and particle color multiplied by particle’s alpha
  85310. */
  85311. static BLENDMODE_ADD: number;
  85312. /**
  85313. * Multiply current color with particle color
  85314. */
  85315. static BLENDMODE_MULTIPLY: number;
  85316. /**
  85317. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85318. */
  85319. static BLENDMODE_MULTIPLYADD: number;
  85320. /**
  85321. * List of animations used by the particle system.
  85322. */
  85323. animations: Animation[];
  85324. /**
  85325. * Gets or sets the unique id of the particle system
  85326. */
  85327. uniqueId: number;
  85328. /**
  85329. * The id of the Particle system.
  85330. */
  85331. id: string;
  85332. /**
  85333. * The friendly name of the Particle system.
  85334. */
  85335. name: string;
  85336. /**
  85337. * Snippet ID if the particle system was created from the snippet server
  85338. */
  85339. snippetId: string;
  85340. /**
  85341. * The rendering group used by the Particle system to chose when to render.
  85342. */
  85343. renderingGroupId: number;
  85344. /**
  85345. * The emitter represents the Mesh or position we are attaching the particle system to.
  85346. */
  85347. emitter: Nullable<AbstractMesh | Vector3>;
  85348. /**
  85349. * The maximum number of particles to emit per frame
  85350. */
  85351. emitRate: number;
  85352. /**
  85353. * If you want to launch only a few particles at once, that can be done, as well.
  85354. */
  85355. manualEmitCount: number;
  85356. /**
  85357. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85358. */
  85359. updateSpeed: number;
  85360. /**
  85361. * The amount of time the particle system is running (depends of the overall update speed).
  85362. */
  85363. targetStopDuration: number;
  85364. /**
  85365. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85366. */
  85367. disposeOnStop: boolean;
  85368. /**
  85369. * Minimum power of emitting particles.
  85370. */
  85371. minEmitPower: number;
  85372. /**
  85373. * Maximum power of emitting particles.
  85374. */
  85375. maxEmitPower: number;
  85376. /**
  85377. * Minimum life time of emitting particles.
  85378. */
  85379. minLifeTime: number;
  85380. /**
  85381. * Maximum life time of emitting particles.
  85382. */
  85383. maxLifeTime: number;
  85384. /**
  85385. * Minimum Size of emitting particles.
  85386. */
  85387. minSize: number;
  85388. /**
  85389. * Maximum Size of emitting particles.
  85390. */
  85391. maxSize: number;
  85392. /**
  85393. * Minimum scale of emitting particles on X axis.
  85394. */
  85395. minScaleX: number;
  85396. /**
  85397. * Maximum scale of emitting particles on X axis.
  85398. */
  85399. maxScaleX: number;
  85400. /**
  85401. * Minimum scale of emitting particles on Y axis.
  85402. */
  85403. minScaleY: number;
  85404. /**
  85405. * Maximum scale of emitting particles on Y axis.
  85406. */
  85407. maxScaleY: number;
  85408. /**
  85409. * Gets or sets the minimal initial rotation in radians.
  85410. */
  85411. minInitialRotation: number;
  85412. /**
  85413. * Gets or sets the maximal initial rotation in radians.
  85414. */
  85415. maxInitialRotation: number;
  85416. /**
  85417. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85418. */
  85419. minAngularSpeed: number;
  85420. /**
  85421. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85422. */
  85423. maxAngularSpeed: number;
  85424. /**
  85425. * The texture used to render each particle. (this can be a spritesheet)
  85426. */
  85427. particleTexture: Nullable<Texture>;
  85428. /**
  85429. * The layer mask we are rendering the particles through.
  85430. */
  85431. layerMask: number;
  85432. /**
  85433. * This can help using your own shader to render the particle system.
  85434. * The according effect will be created
  85435. */
  85436. customShader: any;
  85437. /**
  85438. * By default particle system starts as soon as they are created. This prevents the
  85439. * automatic start to happen and let you decide when to start emitting particles.
  85440. */
  85441. preventAutoStart: boolean;
  85442. private _noiseTexture;
  85443. /**
  85444. * Gets or sets a texture used to add random noise to particle positions
  85445. */
  85446. get noiseTexture(): Nullable<ProceduralTexture>;
  85447. set noiseTexture(value: Nullable<ProceduralTexture>);
  85448. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85449. noiseStrength: Vector3;
  85450. /**
  85451. * Callback triggered when the particle animation is ending.
  85452. */
  85453. onAnimationEnd: Nullable<() => void>;
  85454. /**
  85455. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85456. */
  85457. blendMode: number;
  85458. /**
  85459. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85460. * to override the particles.
  85461. */
  85462. forceDepthWrite: boolean;
  85463. /** 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 */
  85464. preWarmCycles: number;
  85465. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85466. preWarmStepOffset: number;
  85467. /**
  85468. * 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)
  85469. */
  85470. spriteCellChangeSpeed: number;
  85471. /**
  85472. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85473. */
  85474. startSpriteCellID: number;
  85475. /**
  85476. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85477. */
  85478. endSpriteCellID: number;
  85479. /**
  85480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85481. */
  85482. spriteCellWidth: number;
  85483. /**
  85484. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85485. */
  85486. spriteCellHeight: number;
  85487. /**
  85488. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85489. */
  85490. spriteRandomStartCell: boolean;
  85491. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85492. translationPivot: Vector2;
  85493. /** @hidden */
  85494. protected _isAnimationSheetEnabled: boolean;
  85495. /**
  85496. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85497. */
  85498. beginAnimationOnStart: boolean;
  85499. /**
  85500. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85501. */
  85502. beginAnimationFrom: number;
  85503. /**
  85504. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85505. */
  85506. beginAnimationTo: number;
  85507. /**
  85508. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85509. */
  85510. beginAnimationLoop: boolean;
  85511. /**
  85512. * Gets or sets a world offset applied to all particles
  85513. */
  85514. worldOffset: Vector3;
  85515. /**
  85516. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85517. */
  85518. get isAnimationSheetEnabled(): boolean;
  85519. set isAnimationSheetEnabled(value: boolean);
  85520. /**
  85521. * Get hosting scene
  85522. * @returns the scene
  85523. */
  85524. getScene(): Scene;
  85525. /**
  85526. * You can use gravity if you want to give an orientation to your particles.
  85527. */
  85528. gravity: Vector3;
  85529. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85530. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85531. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85532. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85533. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85534. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85535. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85536. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85537. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85538. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85539. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85540. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85541. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85542. /**
  85543. * Defines the delay in milliseconds before starting the system (0 by default)
  85544. */
  85545. startDelay: number;
  85546. /**
  85547. * Gets the current list of drag gradients.
  85548. * You must use addDragGradient and removeDragGradient to udpate this list
  85549. * @returns the list of drag gradients
  85550. */
  85551. getDragGradients(): Nullable<Array<FactorGradient>>;
  85552. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85553. limitVelocityDamping: number;
  85554. /**
  85555. * Gets the current list of limit velocity gradients.
  85556. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85557. * @returns the list of limit velocity gradients
  85558. */
  85559. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85560. /**
  85561. * Gets the current list of color gradients.
  85562. * You must use addColorGradient and removeColorGradient to udpate this list
  85563. * @returns the list of color gradients
  85564. */
  85565. getColorGradients(): Nullable<Array<ColorGradient>>;
  85566. /**
  85567. * Gets the current list of size gradients.
  85568. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85569. * @returns the list of size gradients
  85570. */
  85571. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85572. /**
  85573. * Gets the current list of color remap gradients.
  85574. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85575. * @returns the list of color remap gradients
  85576. */
  85577. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85578. /**
  85579. * Gets the current list of alpha remap gradients.
  85580. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85581. * @returns the list of alpha remap gradients
  85582. */
  85583. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85584. /**
  85585. * Gets the current list of life time gradients.
  85586. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85587. * @returns the list of life time gradients
  85588. */
  85589. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85590. /**
  85591. * Gets the current list of angular speed gradients.
  85592. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85593. * @returns the list of angular speed gradients
  85594. */
  85595. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85596. /**
  85597. * Gets the current list of velocity gradients.
  85598. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85599. * @returns the list of velocity gradients
  85600. */
  85601. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85602. /**
  85603. * Gets the current list of start size gradients.
  85604. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85605. * @returns the list of start size gradients
  85606. */
  85607. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85608. /**
  85609. * Gets the current list of emit rate gradients.
  85610. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85611. * @returns the list of emit rate gradients
  85612. */
  85613. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85614. /**
  85615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85616. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85617. */
  85618. get direction1(): Vector3;
  85619. set direction1(value: Vector3);
  85620. /**
  85621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85622. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85623. */
  85624. get direction2(): Vector3;
  85625. set direction2(value: Vector3);
  85626. /**
  85627. * 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.
  85628. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85629. */
  85630. get minEmitBox(): Vector3;
  85631. set minEmitBox(value: Vector3);
  85632. /**
  85633. * 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.
  85634. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85635. */
  85636. get maxEmitBox(): Vector3;
  85637. set maxEmitBox(value: Vector3);
  85638. /**
  85639. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85640. */
  85641. color1: Color4;
  85642. /**
  85643. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85644. */
  85645. color2: Color4;
  85646. /**
  85647. * Color the particle will have at the end of its lifetime
  85648. */
  85649. colorDead: Color4;
  85650. /**
  85651. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85652. */
  85653. textureMask: Color4;
  85654. /**
  85655. * The particle emitter type defines the emitter used by the particle system.
  85656. * It can be for example box, sphere, or cone...
  85657. */
  85658. particleEmitterType: IParticleEmitterType;
  85659. /** @hidden */
  85660. _isSubEmitter: boolean;
  85661. /**
  85662. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85663. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85664. */
  85665. billboardMode: number;
  85666. protected _isBillboardBased: boolean;
  85667. /**
  85668. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85669. */
  85670. get isBillboardBased(): boolean;
  85671. set isBillboardBased(value: boolean);
  85672. /**
  85673. * The scene the particle system belongs to.
  85674. */
  85675. protected _scene: Scene;
  85676. /**
  85677. * Local cache of defines for image processing.
  85678. */
  85679. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85680. /**
  85681. * Default configuration related to image processing available in the standard Material.
  85682. */
  85683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85684. /**
  85685. * Gets the image processing configuration used either in this material.
  85686. */
  85687. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85688. /**
  85689. * Sets the Default image processing configuration used either in the this material.
  85690. *
  85691. * If sets to null, the scene one is in use.
  85692. */
  85693. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85694. /**
  85695. * Attaches a new image processing configuration to the Standard Material.
  85696. * @param configuration
  85697. */
  85698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85699. /** @hidden */
  85700. protected _reset(): void;
  85701. /** @hidden */
  85702. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85703. /**
  85704. * Instantiates a particle system.
  85705. * 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.
  85706. * @param name The name of the particle system
  85707. */
  85708. constructor(name: string);
  85709. /**
  85710. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85713. * @returns the emitter
  85714. */
  85715. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85716. /**
  85717. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85718. * @param radius The radius of the hemisphere to emit from
  85719. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85720. * @returns the emitter
  85721. */
  85722. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85723. /**
  85724. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85725. * @param radius The radius of the sphere to emit from
  85726. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85727. * @returns the emitter
  85728. */
  85729. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85730. /**
  85731. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85732. * @param radius The radius of the sphere to emit from
  85733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85735. * @returns the emitter
  85736. */
  85737. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85738. /**
  85739. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85740. * @param radius The radius of the emission cylinder
  85741. * @param height The height of the emission cylinder
  85742. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85743. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85744. * @returns the emitter
  85745. */
  85746. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85747. /**
  85748. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85749. * @param radius The radius of the cylinder to emit from
  85750. * @param height The height of the emission cylinder
  85751. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85752. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85753. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85754. * @returns the emitter
  85755. */
  85756. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85757. /**
  85758. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85759. * @param radius The radius of the cone to emit from
  85760. * @param angle The base angle of the cone
  85761. * @returns the emitter
  85762. */
  85763. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85764. /**
  85765. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85768. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85769. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85770. * @returns the emitter
  85771. */
  85772. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85773. }
  85774. }
  85775. declare module BABYLON {
  85776. /**
  85777. * Type of sub emitter
  85778. */
  85779. export enum SubEmitterType {
  85780. /**
  85781. * Attached to the particle over it's lifetime
  85782. */
  85783. ATTACHED = 0,
  85784. /**
  85785. * Created when the particle dies
  85786. */
  85787. END = 1
  85788. }
  85789. /**
  85790. * Sub emitter class used to emit particles from an existing particle
  85791. */
  85792. export class SubEmitter {
  85793. /**
  85794. * the particle system to be used by the sub emitter
  85795. */
  85796. particleSystem: ParticleSystem;
  85797. /**
  85798. * Type of the submitter (Default: END)
  85799. */
  85800. type: SubEmitterType;
  85801. /**
  85802. * 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)
  85803. * Note: This only is supported when using an emitter of type Mesh
  85804. */
  85805. inheritDirection: boolean;
  85806. /**
  85807. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85808. */
  85809. inheritedVelocityAmount: number;
  85810. /**
  85811. * Creates a sub emitter
  85812. * @param particleSystem the particle system to be used by the sub emitter
  85813. */
  85814. constructor(
  85815. /**
  85816. * the particle system to be used by the sub emitter
  85817. */
  85818. particleSystem: ParticleSystem);
  85819. /**
  85820. * Clones the sub emitter
  85821. * @returns the cloned sub emitter
  85822. */
  85823. clone(): SubEmitter;
  85824. /**
  85825. * Serialize current object to a JSON object
  85826. * @returns the serialized object
  85827. */
  85828. serialize(): any;
  85829. /** @hidden */
  85830. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85831. /**
  85832. * Creates a new SubEmitter from a serialized JSON version
  85833. * @param serializationObject defines the JSON object to read from
  85834. * @param scene defines the hosting scene
  85835. * @param rootUrl defines the rootUrl for data loading
  85836. * @returns a new SubEmitter
  85837. */
  85838. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85839. /** Release associated resources */
  85840. dispose(): void;
  85841. }
  85842. }
  85843. declare module BABYLON {
  85844. /** @hidden */
  85845. export var imageProcessingDeclaration: {
  85846. name: string;
  85847. shader: string;
  85848. };
  85849. }
  85850. declare module BABYLON {
  85851. /** @hidden */
  85852. export var imageProcessingFunctions: {
  85853. name: string;
  85854. shader: string;
  85855. };
  85856. }
  85857. declare module BABYLON {
  85858. /** @hidden */
  85859. export var particlesPixelShader: {
  85860. name: string;
  85861. shader: string;
  85862. };
  85863. }
  85864. declare module BABYLON {
  85865. /** @hidden */
  85866. export var particlesVertexShader: {
  85867. name: string;
  85868. shader: string;
  85869. };
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * This represents a particle system in Babylon.
  85874. * 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.
  85875. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85876. * @example https://doc.babylonjs.com/babylon101/particles
  85877. */
  85878. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85879. /**
  85880. * Billboard mode will only apply to Y axis
  85881. */
  85882. static readonly BILLBOARDMODE_Y: number;
  85883. /**
  85884. * Billboard mode will apply to all axes
  85885. */
  85886. static readonly BILLBOARDMODE_ALL: number;
  85887. /**
  85888. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85889. */
  85890. static readonly BILLBOARDMODE_STRETCHED: number;
  85891. /**
  85892. * This function can be defined to provide custom update for active particles.
  85893. * This function will be called instead of regular update (age, position, color, etc.).
  85894. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85895. */
  85896. updateFunction: (particles: Particle[]) => void;
  85897. private _emitterWorldMatrix;
  85898. /**
  85899. * This function can be defined to specify initial direction for every new particle.
  85900. * It by default use the emitterType defined function
  85901. */
  85902. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85903. /**
  85904. * This function can be defined to specify initial position for every new particle.
  85905. * It by default use the emitterType defined function
  85906. */
  85907. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85908. /**
  85909. * @hidden
  85910. */
  85911. _inheritedVelocityOffset: Vector3;
  85912. /**
  85913. * An event triggered when the system is disposed
  85914. */
  85915. onDisposeObservable: Observable<ParticleSystem>;
  85916. private _onDisposeObserver;
  85917. /**
  85918. * Sets a callback that will be triggered when the system is disposed
  85919. */
  85920. set onDispose(callback: () => void);
  85921. private _particles;
  85922. private _epsilon;
  85923. private _capacity;
  85924. private _stockParticles;
  85925. private _newPartsExcess;
  85926. private _vertexData;
  85927. private _vertexBuffer;
  85928. private _vertexBuffers;
  85929. private _spriteBuffer;
  85930. private _indexBuffer;
  85931. private _effect;
  85932. private _customEffect;
  85933. private _cachedDefines;
  85934. private _scaledColorStep;
  85935. private _colorDiff;
  85936. private _scaledDirection;
  85937. private _scaledGravity;
  85938. private _currentRenderId;
  85939. private _alive;
  85940. private _useInstancing;
  85941. private _started;
  85942. private _stopped;
  85943. private _actualFrame;
  85944. private _scaledUpdateSpeed;
  85945. private _vertexBufferSize;
  85946. /** @hidden */
  85947. _currentEmitRateGradient: Nullable<FactorGradient>;
  85948. /** @hidden */
  85949. _currentEmitRate1: number;
  85950. /** @hidden */
  85951. _currentEmitRate2: number;
  85952. /** @hidden */
  85953. _currentStartSizeGradient: Nullable<FactorGradient>;
  85954. /** @hidden */
  85955. _currentStartSize1: number;
  85956. /** @hidden */
  85957. _currentStartSize2: number;
  85958. private readonly _rawTextureWidth;
  85959. private _rampGradientsTexture;
  85960. private _useRampGradients;
  85961. /** Gets or sets a boolean indicating that ramp gradients must be used
  85962. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85963. */
  85964. get useRampGradients(): boolean;
  85965. set useRampGradients(value: boolean);
  85966. /**
  85967. * 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.
  85968. * 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: [])
  85969. */
  85970. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85971. private _subEmitters;
  85972. /**
  85973. * @hidden
  85974. * If the particle systems emitter should be disposed when the particle system is disposed
  85975. */
  85976. _disposeEmitterOnDispose: boolean;
  85977. /**
  85978. * The current active Sub-systems, this property is used by the root particle system only.
  85979. */
  85980. activeSubSystems: Array<ParticleSystem>;
  85981. /**
  85982. * Specifies if the particles are updated in emitter local space or world space
  85983. */
  85984. isLocal: boolean;
  85985. private _rootParticleSystem;
  85986. /**
  85987. * Gets the current list of active particles
  85988. */
  85989. get particles(): Particle[];
  85990. /**
  85991. * Gets the number of particles active at the same time.
  85992. * @returns The number of active particles.
  85993. */
  85994. getActiveCount(): number;
  85995. /**
  85996. * Returns the string "ParticleSystem"
  85997. * @returns a string containing the class name
  85998. */
  85999. getClassName(): string;
  86000. /**
  86001. * Gets a boolean indicating that the system is stopping
  86002. * @returns true if the system is currently stopping
  86003. */
  86004. isStopping(): boolean;
  86005. /**
  86006. * Instantiates a particle system.
  86007. * 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.
  86008. * @param name The name of the particle system
  86009. * @param capacity The max number of particles alive at the same time
  86010. * @param scene The scene the particle system belongs to
  86011. * @param customEffect a custom effect used to change the way particles are rendered by default
  86012. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86013. * @param epsilon Offset used to render the particles
  86014. */
  86015. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86016. private _addFactorGradient;
  86017. private _removeFactorGradient;
  86018. /**
  86019. * Adds a new life time gradient
  86020. * @param gradient defines the gradient to use (between 0 and 1)
  86021. * @param factor defines the life time factor to affect to the specified gradient
  86022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86023. * @returns the current particle system
  86024. */
  86025. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86026. /**
  86027. * Remove a specific life time gradient
  86028. * @param gradient defines the gradient to remove
  86029. * @returns the current particle system
  86030. */
  86031. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86032. /**
  86033. * Adds a new size gradient
  86034. * @param gradient defines the gradient to use (between 0 and 1)
  86035. * @param factor defines the size factor to affect to the specified gradient
  86036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86037. * @returns the current particle system
  86038. */
  86039. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86040. /**
  86041. * Remove a specific size gradient
  86042. * @param gradient defines the gradient to remove
  86043. * @returns the current particle system
  86044. */
  86045. removeSizeGradient(gradient: number): IParticleSystem;
  86046. /**
  86047. * Adds a new color remap gradient
  86048. * @param gradient defines the gradient to use (between 0 and 1)
  86049. * @param min defines the color remap minimal range
  86050. * @param max defines the color remap maximal range
  86051. * @returns the current particle system
  86052. */
  86053. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86054. /**
  86055. * Remove a specific color remap gradient
  86056. * @param gradient defines the gradient to remove
  86057. * @returns the current particle system
  86058. */
  86059. removeColorRemapGradient(gradient: number): IParticleSystem;
  86060. /**
  86061. * Adds a new alpha remap gradient
  86062. * @param gradient defines the gradient to use (between 0 and 1)
  86063. * @param min defines the alpha remap minimal range
  86064. * @param max defines the alpha remap maximal range
  86065. * @returns the current particle system
  86066. */
  86067. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86068. /**
  86069. * Remove a specific alpha remap gradient
  86070. * @param gradient defines the gradient to remove
  86071. * @returns the current particle system
  86072. */
  86073. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86074. /**
  86075. * Adds a new angular speed gradient
  86076. * @param gradient defines the gradient to use (between 0 and 1)
  86077. * @param factor defines the angular speed to affect to the specified gradient
  86078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86079. * @returns the current particle system
  86080. */
  86081. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86082. /**
  86083. * Remove a specific angular speed gradient
  86084. * @param gradient defines the gradient to remove
  86085. * @returns the current particle system
  86086. */
  86087. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86088. /**
  86089. * Adds a new velocity gradient
  86090. * @param gradient defines the gradient to use (between 0 and 1)
  86091. * @param factor defines the velocity to affect to the specified gradient
  86092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86093. * @returns the current particle system
  86094. */
  86095. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86096. /**
  86097. * Remove a specific velocity gradient
  86098. * @param gradient defines the gradient to remove
  86099. * @returns the current particle system
  86100. */
  86101. removeVelocityGradient(gradient: number): IParticleSystem;
  86102. /**
  86103. * Adds a new limit velocity gradient
  86104. * @param gradient defines the gradient to use (between 0 and 1)
  86105. * @param factor defines the limit velocity value to affect to the specified gradient
  86106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86107. * @returns the current particle system
  86108. */
  86109. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86110. /**
  86111. * Remove a specific limit velocity gradient
  86112. * @param gradient defines the gradient to remove
  86113. * @returns the current particle system
  86114. */
  86115. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86116. /**
  86117. * Adds a new drag gradient
  86118. * @param gradient defines the gradient to use (between 0 and 1)
  86119. * @param factor defines the drag value to affect to the specified gradient
  86120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86121. * @returns the current particle system
  86122. */
  86123. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86124. /**
  86125. * Remove a specific drag gradient
  86126. * @param gradient defines the gradient to remove
  86127. * @returns the current particle system
  86128. */
  86129. removeDragGradient(gradient: number): IParticleSystem;
  86130. /**
  86131. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86132. * @param gradient defines the gradient to use (between 0 and 1)
  86133. * @param factor defines the emit rate value to affect to the specified gradient
  86134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86135. * @returns the current particle system
  86136. */
  86137. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86138. /**
  86139. * Remove a specific emit rate gradient
  86140. * @param gradient defines the gradient to remove
  86141. * @returns the current particle system
  86142. */
  86143. removeEmitRateGradient(gradient: number): IParticleSystem;
  86144. /**
  86145. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86146. * @param gradient defines the gradient to use (between 0 and 1)
  86147. * @param factor defines the start size value to affect to the specified gradient
  86148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86149. * @returns the current particle system
  86150. */
  86151. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86152. /**
  86153. * Remove a specific start size gradient
  86154. * @param gradient defines the gradient to remove
  86155. * @returns the current particle system
  86156. */
  86157. removeStartSizeGradient(gradient: number): IParticleSystem;
  86158. private _createRampGradientTexture;
  86159. /**
  86160. * Gets the current list of ramp gradients.
  86161. * You must use addRampGradient and removeRampGradient to udpate this list
  86162. * @returns the list of ramp gradients
  86163. */
  86164. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86165. /**
  86166. * Adds a new ramp gradient used to remap particle colors
  86167. * @param gradient defines the gradient to use (between 0 and 1)
  86168. * @param color defines the color to affect to the specified gradient
  86169. * @returns the current particle system
  86170. */
  86171. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86172. /**
  86173. * Remove a specific ramp gradient
  86174. * @param gradient defines the gradient to remove
  86175. * @returns the current particle system
  86176. */
  86177. removeRampGradient(gradient: number): ParticleSystem;
  86178. /**
  86179. * Adds a new color gradient
  86180. * @param gradient defines the gradient to use (between 0 and 1)
  86181. * @param color1 defines the color to affect to the specified gradient
  86182. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86183. * @returns this particle system
  86184. */
  86185. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86186. /**
  86187. * Remove a specific color gradient
  86188. * @param gradient defines the gradient to remove
  86189. * @returns this particle system
  86190. */
  86191. removeColorGradient(gradient: number): IParticleSystem;
  86192. private _fetchR;
  86193. protected _reset(): void;
  86194. private _resetEffect;
  86195. private _createVertexBuffers;
  86196. private _createIndexBuffer;
  86197. /**
  86198. * Gets the maximum number of particles active at the same time.
  86199. * @returns The max number of active particles.
  86200. */
  86201. getCapacity(): number;
  86202. /**
  86203. * Gets whether there are still active particles in the system.
  86204. * @returns True if it is alive, otherwise false.
  86205. */
  86206. isAlive(): boolean;
  86207. /**
  86208. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86209. * @returns True if it has been started, otherwise false.
  86210. */
  86211. isStarted(): boolean;
  86212. private _prepareSubEmitterInternalArray;
  86213. /**
  86214. * Starts the particle system and begins to emit
  86215. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86216. */
  86217. start(delay?: number): void;
  86218. /**
  86219. * Stops the particle system.
  86220. * @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.
  86221. */
  86222. stop(stopSubEmitters?: boolean): void;
  86223. /**
  86224. * Remove all active particles
  86225. */
  86226. reset(): void;
  86227. /**
  86228. * @hidden (for internal use only)
  86229. */
  86230. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86231. /**
  86232. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86233. * Its lifetime will start back at 0.
  86234. */
  86235. recycleParticle: (particle: Particle) => void;
  86236. private _stopSubEmitters;
  86237. private _createParticle;
  86238. private _removeFromRoot;
  86239. private _emitFromParticle;
  86240. private _update;
  86241. /** @hidden */
  86242. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86243. /** @hidden */
  86244. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86245. /** @hidden */
  86246. private _getEffect;
  86247. /**
  86248. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86249. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86250. */
  86251. animate(preWarmOnly?: boolean): void;
  86252. private _appendParticleVertices;
  86253. /**
  86254. * Rebuilds the particle system.
  86255. */
  86256. rebuild(): void;
  86257. /**
  86258. * Is this system ready to be used/rendered
  86259. * @return true if the system is ready
  86260. */
  86261. isReady(): boolean;
  86262. private _render;
  86263. /**
  86264. * Renders the particle system in its current state.
  86265. * @returns the current number of particles
  86266. */
  86267. render(): number;
  86268. /**
  86269. * Disposes the particle system and free the associated resources
  86270. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86271. */
  86272. dispose(disposeTexture?: boolean): void;
  86273. /**
  86274. * Clones the particle system.
  86275. * @param name The name of the cloned object
  86276. * @param newEmitter The new emitter to use
  86277. * @returns the cloned particle system
  86278. */
  86279. clone(name: string, newEmitter: any): ParticleSystem;
  86280. /**
  86281. * Serializes the particle system to a JSON object.
  86282. * @returns the JSON object
  86283. */
  86284. serialize(): any;
  86285. /** @hidden */
  86286. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86287. /** @hidden */
  86288. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86289. /**
  86290. * Parses a JSON object to create a particle system.
  86291. * @param parsedParticleSystem The JSON object to parse
  86292. * @param scene The scene to create the particle system in
  86293. * @param rootUrl The root url to use to load external dependencies like texture
  86294. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86295. * @returns the Parsed particle system
  86296. */
  86297. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /**
  86302. * A particle represents one of the element emitted by a particle system.
  86303. * This is mainly define by its coordinates, direction, velocity and age.
  86304. */
  86305. export class Particle {
  86306. /**
  86307. * The particle system the particle belongs to.
  86308. */
  86309. particleSystem: ParticleSystem;
  86310. private static _Count;
  86311. /**
  86312. * Unique ID of the particle
  86313. */
  86314. id: number;
  86315. /**
  86316. * The world position of the particle in the scene.
  86317. */
  86318. position: Vector3;
  86319. /**
  86320. * The world direction of the particle in the scene.
  86321. */
  86322. direction: Vector3;
  86323. /**
  86324. * The color of the particle.
  86325. */
  86326. color: Color4;
  86327. /**
  86328. * The color change of the particle per step.
  86329. */
  86330. colorStep: Color4;
  86331. /**
  86332. * Defines how long will the life of the particle be.
  86333. */
  86334. lifeTime: number;
  86335. /**
  86336. * The current age of the particle.
  86337. */
  86338. age: number;
  86339. /**
  86340. * The current size of the particle.
  86341. */
  86342. size: number;
  86343. /**
  86344. * The current scale of the particle.
  86345. */
  86346. scale: Vector2;
  86347. /**
  86348. * The current angle of the particle.
  86349. */
  86350. angle: number;
  86351. /**
  86352. * Defines how fast is the angle changing.
  86353. */
  86354. angularSpeed: number;
  86355. /**
  86356. * Defines the cell index used by the particle to be rendered from a sprite.
  86357. */
  86358. cellIndex: number;
  86359. /**
  86360. * The information required to support color remapping
  86361. */
  86362. remapData: Vector4;
  86363. /** @hidden */
  86364. _randomCellOffset?: number;
  86365. /** @hidden */
  86366. _initialDirection: Nullable<Vector3>;
  86367. /** @hidden */
  86368. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86369. /** @hidden */
  86370. _initialStartSpriteCellID: number;
  86371. /** @hidden */
  86372. _initialEndSpriteCellID: number;
  86373. /** @hidden */
  86374. _currentColorGradient: Nullable<ColorGradient>;
  86375. /** @hidden */
  86376. _currentColor1: Color4;
  86377. /** @hidden */
  86378. _currentColor2: Color4;
  86379. /** @hidden */
  86380. _currentSizeGradient: Nullable<FactorGradient>;
  86381. /** @hidden */
  86382. _currentSize1: number;
  86383. /** @hidden */
  86384. _currentSize2: number;
  86385. /** @hidden */
  86386. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86387. /** @hidden */
  86388. _currentAngularSpeed1: number;
  86389. /** @hidden */
  86390. _currentAngularSpeed2: number;
  86391. /** @hidden */
  86392. _currentVelocityGradient: Nullable<FactorGradient>;
  86393. /** @hidden */
  86394. _currentVelocity1: number;
  86395. /** @hidden */
  86396. _currentVelocity2: number;
  86397. /** @hidden */
  86398. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86399. /** @hidden */
  86400. _currentLimitVelocity1: number;
  86401. /** @hidden */
  86402. _currentLimitVelocity2: number;
  86403. /** @hidden */
  86404. _currentDragGradient: Nullable<FactorGradient>;
  86405. /** @hidden */
  86406. _currentDrag1: number;
  86407. /** @hidden */
  86408. _currentDrag2: number;
  86409. /** @hidden */
  86410. _randomNoiseCoordinates1: Vector3;
  86411. /** @hidden */
  86412. _randomNoiseCoordinates2: Vector3;
  86413. /** @hidden */
  86414. _localPosition?: Vector3;
  86415. /**
  86416. * Creates a new instance Particle
  86417. * @param particleSystem the particle system the particle belongs to
  86418. */
  86419. constructor(
  86420. /**
  86421. * The particle system the particle belongs to.
  86422. */
  86423. particleSystem: ParticleSystem);
  86424. private updateCellInfoFromSystem;
  86425. /**
  86426. * Defines how the sprite cell index is updated for the particle
  86427. */
  86428. updateCellIndex(): void;
  86429. /** @hidden */
  86430. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86431. /** @hidden */
  86432. _inheritParticleInfoToSubEmitters(): void;
  86433. /** @hidden */
  86434. _reset(): void;
  86435. /**
  86436. * Copy the properties of particle to another one.
  86437. * @param other the particle to copy the information to.
  86438. */
  86439. copyTo(other: Particle): void;
  86440. }
  86441. }
  86442. declare module BABYLON {
  86443. /**
  86444. * Particle emitter represents a volume emitting particles.
  86445. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86446. */
  86447. export interface IParticleEmitterType {
  86448. /**
  86449. * Called by the particle System when the direction is computed for the created particle.
  86450. * @param worldMatrix is the world matrix of the particle system
  86451. * @param directionToUpdate is the direction vector to update with the result
  86452. * @param particle is the particle we are computed the direction for
  86453. * @param isLocal defines if the direction should be set in local space
  86454. */
  86455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86456. /**
  86457. * Called by the particle System when the position is computed for the created particle.
  86458. * @param worldMatrix is the world matrix of the particle system
  86459. * @param positionToUpdate is the position vector to update with the result
  86460. * @param particle is the particle we are computed the position for
  86461. * @param isLocal defines if the position should be set in local space
  86462. */
  86463. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86464. /**
  86465. * Clones the current emitter and returns a copy of it
  86466. * @returns the new emitter
  86467. */
  86468. clone(): IParticleEmitterType;
  86469. /**
  86470. * Called by the GPUParticleSystem to setup the update shader
  86471. * @param effect defines the update shader
  86472. */
  86473. applyToShader(effect: Effect): void;
  86474. /**
  86475. * Returns a string to use to update the GPU particles update shader
  86476. * @returns the effect defines string
  86477. */
  86478. getEffectDefines(): string;
  86479. /**
  86480. * Returns a string representing the class name
  86481. * @returns a string containing the class name
  86482. */
  86483. getClassName(): string;
  86484. /**
  86485. * Serializes the particle system to a JSON object.
  86486. * @returns the JSON object
  86487. */
  86488. serialize(): any;
  86489. /**
  86490. * Parse properties from a JSON object
  86491. * @param serializationObject defines the JSON object
  86492. * @param scene defines the hosting scene
  86493. */
  86494. parse(serializationObject: any, scene: Scene): void;
  86495. }
  86496. }
  86497. declare module BABYLON {
  86498. /**
  86499. * Particle emitter emitting particles from the inside of a box.
  86500. * It emits the particles randomly between 2 given directions.
  86501. */
  86502. export class BoxParticleEmitter implements IParticleEmitterType {
  86503. /**
  86504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86505. */
  86506. direction1: Vector3;
  86507. /**
  86508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86509. */
  86510. direction2: Vector3;
  86511. /**
  86512. * 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.
  86513. */
  86514. minEmitBox: Vector3;
  86515. /**
  86516. * 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.
  86517. */
  86518. maxEmitBox: Vector3;
  86519. /**
  86520. * Creates a new instance BoxParticleEmitter
  86521. */
  86522. constructor();
  86523. /**
  86524. * Called by the particle System when the direction is computed for the created particle.
  86525. * @param worldMatrix is the world matrix of the particle system
  86526. * @param directionToUpdate is the direction vector to update with the result
  86527. * @param particle is the particle we are computed the direction for
  86528. * @param isLocal defines if the direction should be set in local space
  86529. */
  86530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86531. /**
  86532. * Called by the particle System when the position is computed for the created particle.
  86533. * @param worldMatrix is the world matrix of the particle system
  86534. * @param positionToUpdate is the position vector to update with the result
  86535. * @param particle is the particle we are computed the position for
  86536. * @param isLocal defines if the position should be set in local space
  86537. */
  86538. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86539. /**
  86540. * Clones the current emitter and returns a copy of it
  86541. * @returns the new emitter
  86542. */
  86543. clone(): BoxParticleEmitter;
  86544. /**
  86545. * Called by the GPUParticleSystem to setup the update shader
  86546. * @param effect defines the update shader
  86547. */
  86548. applyToShader(effect: Effect): void;
  86549. /**
  86550. * Returns a string to use to update the GPU particles update shader
  86551. * @returns a string containng the defines string
  86552. */
  86553. getEffectDefines(): string;
  86554. /**
  86555. * Returns the string "BoxParticleEmitter"
  86556. * @returns a string containing the class name
  86557. */
  86558. getClassName(): string;
  86559. /**
  86560. * Serializes the particle system to a JSON object.
  86561. * @returns the JSON object
  86562. */
  86563. serialize(): any;
  86564. /**
  86565. * Parse properties from a JSON object
  86566. * @param serializationObject defines the JSON object
  86567. */
  86568. parse(serializationObject: any): void;
  86569. }
  86570. }
  86571. declare module BABYLON {
  86572. /**
  86573. * Particle emitter emitting particles from the inside of a cone.
  86574. * It emits the particles alongside the cone volume from the base to the particle.
  86575. * The emission direction might be randomized.
  86576. */
  86577. export class ConeParticleEmitter implements IParticleEmitterType {
  86578. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86579. directionRandomizer: number;
  86580. private _radius;
  86581. private _angle;
  86582. private _height;
  86583. /**
  86584. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86585. */
  86586. radiusRange: number;
  86587. /**
  86588. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86589. */
  86590. heightRange: number;
  86591. /**
  86592. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86593. */
  86594. emitFromSpawnPointOnly: boolean;
  86595. /**
  86596. * Gets or sets the radius of the emission cone
  86597. */
  86598. get radius(): number;
  86599. set radius(value: number);
  86600. /**
  86601. * Gets or sets the angle of the emission cone
  86602. */
  86603. get angle(): number;
  86604. set angle(value: number);
  86605. private _buildHeight;
  86606. /**
  86607. * Creates a new instance ConeParticleEmitter
  86608. * @param radius the radius of the emission cone (1 by default)
  86609. * @param angle the cone base angle (PI by default)
  86610. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86611. */
  86612. constructor(radius?: number, angle?: number,
  86613. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86614. directionRandomizer?: number);
  86615. /**
  86616. * Called by the particle System when the direction is computed for the created particle.
  86617. * @param worldMatrix is the world matrix of the particle system
  86618. * @param directionToUpdate is the direction vector to update with the result
  86619. * @param particle is the particle we are computed the direction for
  86620. * @param isLocal defines if the direction should be set in local space
  86621. */
  86622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86623. /**
  86624. * Called by the particle System when the position is computed for the created particle.
  86625. * @param worldMatrix is the world matrix of the particle system
  86626. * @param positionToUpdate is the position vector to update with the result
  86627. * @param particle is the particle we are computed the position for
  86628. * @param isLocal defines if the position should be set in local space
  86629. */
  86630. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86631. /**
  86632. * Clones the current emitter and returns a copy of it
  86633. * @returns the new emitter
  86634. */
  86635. clone(): ConeParticleEmitter;
  86636. /**
  86637. * Called by the GPUParticleSystem to setup the update shader
  86638. * @param effect defines the update shader
  86639. */
  86640. applyToShader(effect: Effect): void;
  86641. /**
  86642. * Returns a string to use to update the GPU particles update shader
  86643. * @returns a string containng the defines string
  86644. */
  86645. getEffectDefines(): string;
  86646. /**
  86647. * Returns the string "ConeParticleEmitter"
  86648. * @returns a string containing the class name
  86649. */
  86650. getClassName(): string;
  86651. /**
  86652. * Serializes the particle system to a JSON object.
  86653. * @returns the JSON object
  86654. */
  86655. serialize(): any;
  86656. /**
  86657. * Parse properties from a JSON object
  86658. * @param serializationObject defines the JSON object
  86659. */
  86660. parse(serializationObject: any): void;
  86661. }
  86662. }
  86663. declare module BABYLON {
  86664. /**
  86665. * Particle emitter emitting particles from the inside of a cylinder.
  86666. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86667. */
  86668. export class CylinderParticleEmitter implements IParticleEmitterType {
  86669. /**
  86670. * The radius of the emission cylinder.
  86671. */
  86672. radius: number;
  86673. /**
  86674. * The height of the emission cylinder.
  86675. */
  86676. height: number;
  86677. /**
  86678. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86679. */
  86680. radiusRange: number;
  86681. /**
  86682. * How much to randomize the particle direction [0-1].
  86683. */
  86684. directionRandomizer: number;
  86685. /**
  86686. * Creates a new instance CylinderParticleEmitter
  86687. * @param radius the radius of the emission cylinder (1 by default)
  86688. * @param height the height of the emission cylinder (1 by default)
  86689. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86690. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86691. */
  86692. constructor(
  86693. /**
  86694. * The radius of the emission cylinder.
  86695. */
  86696. radius?: number,
  86697. /**
  86698. * The height of the emission cylinder.
  86699. */
  86700. height?: number,
  86701. /**
  86702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86703. */
  86704. radiusRange?: number,
  86705. /**
  86706. * How much to randomize the particle direction [0-1].
  86707. */
  86708. directionRandomizer?: number);
  86709. /**
  86710. * Called by the particle System when the direction is computed for the created particle.
  86711. * @param worldMatrix is the world matrix of the particle system
  86712. * @param directionToUpdate is the direction vector to update with the result
  86713. * @param particle is the particle we are computed the direction for
  86714. * @param isLocal defines if the direction should be set in local space
  86715. */
  86716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86717. /**
  86718. * Called by the particle System when the position is computed for the created particle.
  86719. * @param worldMatrix is the world matrix of the particle system
  86720. * @param positionToUpdate is the position vector to update with the result
  86721. * @param particle is the particle we are computed the position for
  86722. * @param isLocal defines if the position should be set in local space
  86723. */
  86724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86725. /**
  86726. * Clones the current emitter and returns a copy of it
  86727. * @returns the new emitter
  86728. */
  86729. clone(): CylinderParticleEmitter;
  86730. /**
  86731. * Called by the GPUParticleSystem to setup the update shader
  86732. * @param effect defines the update shader
  86733. */
  86734. applyToShader(effect: Effect): void;
  86735. /**
  86736. * Returns a string to use to update the GPU particles update shader
  86737. * @returns a string containng the defines string
  86738. */
  86739. getEffectDefines(): string;
  86740. /**
  86741. * Returns the string "CylinderParticleEmitter"
  86742. * @returns a string containing the class name
  86743. */
  86744. getClassName(): string;
  86745. /**
  86746. * Serializes the particle system to a JSON object.
  86747. * @returns the JSON object
  86748. */
  86749. serialize(): any;
  86750. /**
  86751. * Parse properties from a JSON object
  86752. * @param serializationObject defines the JSON object
  86753. */
  86754. parse(serializationObject: any): void;
  86755. }
  86756. /**
  86757. * Particle emitter emitting particles from the inside of a cylinder.
  86758. * It emits the particles randomly between two vectors.
  86759. */
  86760. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86761. /**
  86762. * The min limit of the emission direction.
  86763. */
  86764. direction1: Vector3;
  86765. /**
  86766. * The max limit of the emission direction.
  86767. */
  86768. direction2: Vector3;
  86769. /**
  86770. * Creates a new instance CylinderDirectedParticleEmitter
  86771. * @param radius the radius of the emission cylinder (1 by default)
  86772. * @param height the height of the emission cylinder (1 by default)
  86773. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86774. * @param direction1 the min limit of the emission direction (up vector by default)
  86775. * @param direction2 the max limit of the emission direction (up vector by default)
  86776. */
  86777. constructor(radius?: number, height?: number, radiusRange?: number,
  86778. /**
  86779. * The min limit of the emission direction.
  86780. */
  86781. direction1?: Vector3,
  86782. /**
  86783. * The max limit of the emission direction.
  86784. */
  86785. direction2?: Vector3);
  86786. /**
  86787. * Called by the particle System when the direction is computed for the created particle.
  86788. * @param worldMatrix is the world matrix of the particle system
  86789. * @param directionToUpdate is the direction vector to update with the result
  86790. * @param particle is the particle we are computed the direction for
  86791. */
  86792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86793. /**
  86794. * Clones the current emitter and returns a copy of it
  86795. * @returns the new emitter
  86796. */
  86797. clone(): CylinderDirectedParticleEmitter;
  86798. /**
  86799. * Called by the GPUParticleSystem to setup the update shader
  86800. * @param effect defines the update shader
  86801. */
  86802. applyToShader(effect: Effect): void;
  86803. /**
  86804. * Returns a string to use to update the GPU particles update shader
  86805. * @returns a string containng the defines string
  86806. */
  86807. getEffectDefines(): string;
  86808. /**
  86809. * Returns the string "CylinderDirectedParticleEmitter"
  86810. * @returns a string containing the class name
  86811. */
  86812. getClassName(): string;
  86813. /**
  86814. * Serializes the particle system to a JSON object.
  86815. * @returns the JSON object
  86816. */
  86817. serialize(): any;
  86818. /**
  86819. * Parse properties from a JSON object
  86820. * @param serializationObject defines the JSON object
  86821. */
  86822. parse(serializationObject: any): void;
  86823. }
  86824. }
  86825. declare module BABYLON {
  86826. /**
  86827. * Particle emitter emitting particles from the inside of a hemisphere.
  86828. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86829. */
  86830. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86831. /**
  86832. * The radius of the emission hemisphere.
  86833. */
  86834. radius: number;
  86835. /**
  86836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86837. */
  86838. radiusRange: number;
  86839. /**
  86840. * How much to randomize the particle direction [0-1].
  86841. */
  86842. directionRandomizer: number;
  86843. /**
  86844. * Creates a new instance HemisphericParticleEmitter
  86845. * @param radius the radius of the emission hemisphere (1 by default)
  86846. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86847. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86848. */
  86849. constructor(
  86850. /**
  86851. * The radius of the emission hemisphere.
  86852. */
  86853. radius?: number,
  86854. /**
  86855. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86856. */
  86857. radiusRange?: number,
  86858. /**
  86859. * How much to randomize the particle direction [0-1].
  86860. */
  86861. directionRandomizer?: number);
  86862. /**
  86863. * Called by the particle System when the direction is computed for the created particle.
  86864. * @param worldMatrix is the world matrix of the particle system
  86865. * @param directionToUpdate is the direction vector to update with the result
  86866. * @param particle is the particle we are computed the direction for
  86867. * @param isLocal defines if the direction should be set in local space
  86868. */
  86869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86870. /**
  86871. * Called by the particle System when the position is computed for the created particle.
  86872. * @param worldMatrix is the world matrix of the particle system
  86873. * @param positionToUpdate is the position vector to update with the result
  86874. * @param particle is the particle we are computed the position for
  86875. * @param isLocal defines if the position should be set in local space
  86876. */
  86877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86878. /**
  86879. * Clones the current emitter and returns a copy of it
  86880. * @returns the new emitter
  86881. */
  86882. clone(): HemisphericParticleEmitter;
  86883. /**
  86884. * Called by the GPUParticleSystem to setup the update shader
  86885. * @param effect defines the update shader
  86886. */
  86887. applyToShader(effect: Effect): void;
  86888. /**
  86889. * Returns a string to use to update the GPU particles update shader
  86890. * @returns a string containng the defines string
  86891. */
  86892. getEffectDefines(): string;
  86893. /**
  86894. * Returns the string "HemisphericParticleEmitter"
  86895. * @returns a string containing the class name
  86896. */
  86897. getClassName(): string;
  86898. /**
  86899. * Serializes the particle system to a JSON object.
  86900. * @returns the JSON object
  86901. */
  86902. serialize(): any;
  86903. /**
  86904. * Parse properties from a JSON object
  86905. * @param serializationObject defines the JSON object
  86906. */
  86907. parse(serializationObject: any): void;
  86908. }
  86909. }
  86910. declare module BABYLON {
  86911. /**
  86912. * Particle emitter emitting particles from a point.
  86913. * It emits the particles randomly between 2 given directions.
  86914. */
  86915. export class PointParticleEmitter implements IParticleEmitterType {
  86916. /**
  86917. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86918. */
  86919. direction1: Vector3;
  86920. /**
  86921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86922. */
  86923. direction2: Vector3;
  86924. /**
  86925. * Creates a new instance PointParticleEmitter
  86926. */
  86927. constructor();
  86928. /**
  86929. * Called by the particle System when the direction is computed for the created particle.
  86930. * @param worldMatrix is the world matrix of the particle system
  86931. * @param directionToUpdate is the direction vector to update with the result
  86932. * @param particle is the particle we are computed the direction for
  86933. * @param isLocal defines if the direction should be set in local space
  86934. */
  86935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86936. /**
  86937. * Called by the particle System when the position is computed for the created particle.
  86938. * @param worldMatrix is the world matrix of the particle system
  86939. * @param positionToUpdate is the position vector to update with the result
  86940. * @param particle is the particle we are computed the position for
  86941. * @param isLocal defines if the position should be set in local space
  86942. */
  86943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86944. /**
  86945. * Clones the current emitter and returns a copy of it
  86946. * @returns the new emitter
  86947. */
  86948. clone(): PointParticleEmitter;
  86949. /**
  86950. * Called by the GPUParticleSystem to setup the update shader
  86951. * @param effect defines the update shader
  86952. */
  86953. applyToShader(effect: Effect): void;
  86954. /**
  86955. * Returns a string to use to update the GPU particles update shader
  86956. * @returns a string containng the defines string
  86957. */
  86958. getEffectDefines(): string;
  86959. /**
  86960. * Returns the string "PointParticleEmitter"
  86961. * @returns a string containing the class name
  86962. */
  86963. getClassName(): string;
  86964. /**
  86965. * Serializes the particle system to a JSON object.
  86966. * @returns the JSON object
  86967. */
  86968. serialize(): any;
  86969. /**
  86970. * Parse properties from a JSON object
  86971. * @param serializationObject defines the JSON object
  86972. */
  86973. parse(serializationObject: any): void;
  86974. }
  86975. }
  86976. declare module BABYLON {
  86977. /**
  86978. * Particle emitter emitting particles from the inside of a sphere.
  86979. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86980. */
  86981. export class SphereParticleEmitter implements IParticleEmitterType {
  86982. /**
  86983. * The radius of the emission sphere.
  86984. */
  86985. radius: number;
  86986. /**
  86987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86988. */
  86989. radiusRange: number;
  86990. /**
  86991. * How much to randomize the particle direction [0-1].
  86992. */
  86993. directionRandomizer: number;
  86994. /**
  86995. * Creates a new instance SphereParticleEmitter
  86996. * @param radius the radius of the emission sphere (1 by default)
  86997. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86999. */
  87000. constructor(
  87001. /**
  87002. * The radius of the emission sphere.
  87003. */
  87004. radius?: number,
  87005. /**
  87006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87007. */
  87008. radiusRange?: number,
  87009. /**
  87010. * How much to randomize the particle direction [0-1].
  87011. */
  87012. directionRandomizer?: number);
  87013. /**
  87014. * Called by the particle System when the direction is computed for the created particle.
  87015. * @param worldMatrix is the world matrix of the particle system
  87016. * @param directionToUpdate is the direction vector to update with the result
  87017. * @param particle is the particle we are computed the direction for
  87018. * @param isLocal defines if the direction should be set in local space
  87019. */
  87020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87021. /**
  87022. * Called by the particle System when the position is computed for the created particle.
  87023. * @param worldMatrix is the world matrix of the particle system
  87024. * @param positionToUpdate is the position vector to update with the result
  87025. * @param particle is the particle we are computed the position for
  87026. * @param isLocal defines if the position should be set in local space
  87027. */
  87028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87029. /**
  87030. * Clones the current emitter and returns a copy of it
  87031. * @returns the new emitter
  87032. */
  87033. clone(): SphereParticleEmitter;
  87034. /**
  87035. * Called by the GPUParticleSystem to setup the update shader
  87036. * @param effect defines the update shader
  87037. */
  87038. applyToShader(effect: Effect): void;
  87039. /**
  87040. * Returns a string to use to update the GPU particles update shader
  87041. * @returns a string containng the defines string
  87042. */
  87043. getEffectDefines(): string;
  87044. /**
  87045. * Returns the string "SphereParticleEmitter"
  87046. * @returns a string containing the class name
  87047. */
  87048. getClassName(): string;
  87049. /**
  87050. * Serializes the particle system to a JSON object.
  87051. * @returns the JSON object
  87052. */
  87053. serialize(): any;
  87054. /**
  87055. * Parse properties from a JSON object
  87056. * @param serializationObject defines the JSON object
  87057. */
  87058. parse(serializationObject: any): void;
  87059. }
  87060. /**
  87061. * Particle emitter emitting particles from the inside of a sphere.
  87062. * It emits the particles randomly between two vectors.
  87063. */
  87064. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87065. /**
  87066. * The min limit of the emission direction.
  87067. */
  87068. direction1: Vector3;
  87069. /**
  87070. * The max limit of the emission direction.
  87071. */
  87072. direction2: Vector3;
  87073. /**
  87074. * Creates a new instance SphereDirectedParticleEmitter
  87075. * @param radius the radius of the emission sphere (1 by default)
  87076. * @param direction1 the min limit of the emission direction (up vector by default)
  87077. * @param direction2 the max limit of the emission direction (up vector by default)
  87078. */
  87079. constructor(radius?: number,
  87080. /**
  87081. * The min limit of the emission direction.
  87082. */
  87083. direction1?: Vector3,
  87084. /**
  87085. * The max limit of the emission direction.
  87086. */
  87087. direction2?: Vector3);
  87088. /**
  87089. * Called by the particle System when the direction is computed for the created particle.
  87090. * @param worldMatrix is the world matrix of the particle system
  87091. * @param directionToUpdate is the direction vector to update with the result
  87092. * @param particle is the particle we are computed the direction for
  87093. */
  87094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87095. /**
  87096. * Clones the current emitter and returns a copy of it
  87097. * @returns the new emitter
  87098. */
  87099. clone(): SphereDirectedParticleEmitter;
  87100. /**
  87101. * Called by the GPUParticleSystem to setup the update shader
  87102. * @param effect defines the update shader
  87103. */
  87104. applyToShader(effect: Effect): void;
  87105. /**
  87106. * Returns a string to use to update the GPU particles update shader
  87107. * @returns a string containng the defines string
  87108. */
  87109. getEffectDefines(): string;
  87110. /**
  87111. * Returns the string "SphereDirectedParticleEmitter"
  87112. * @returns a string containing the class name
  87113. */
  87114. getClassName(): string;
  87115. /**
  87116. * Serializes the particle system to a JSON object.
  87117. * @returns the JSON object
  87118. */
  87119. serialize(): any;
  87120. /**
  87121. * Parse properties from a JSON object
  87122. * @param serializationObject defines the JSON object
  87123. */
  87124. parse(serializationObject: any): void;
  87125. }
  87126. }
  87127. declare module BABYLON {
  87128. /**
  87129. * Particle emitter emitting particles from a custom list of positions.
  87130. */
  87131. export class CustomParticleEmitter implements IParticleEmitterType {
  87132. /**
  87133. * Gets or sets the position generator that will create the inital position of each particle.
  87134. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87135. */
  87136. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87137. /**
  87138. * Gets or sets the destination generator that will create the final destination of each particle.
  87139. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87140. */
  87141. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87142. /**
  87143. * Creates a new instance CustomParticleEmitter
  87144. */
  87145. constructor();
  87146. /**
  87147. * Called by the particle System when the direction is computed for the created particle.
  87148. * @param worldMatrix is the world matrix of the particle system
  87149. * @param directionToUpdate is the direction vector to update with the result
  87150. * @param particle is the particle we are computed the direction for
  87151. * @param isLocal defines if the direction should be set in local space
  87152. */
  87153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87154. /**
  87155. * Called by the particle System when the position is computed for the created particle.
  87156. * @param worldMatrix is the world matrix of the particle system
  87157. * @param positionToUpdate is the position vector to update with the result
  87158. * @param particle is the particle we are computed the position for
  87159. * @param isLocal defines if the position should be set in local space
  87160. */
  87161. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87162. /**
  87163. * Clones the current emitter and returns a copy of it
  87164. * @returns the new emitter
  87165. */
  87166. clone(): CustomParticleEmitter;
  87167. /**
  87168. * Called by the GPUParticleSystem to setup the update shader
  87169. * @param effect defines the update shader
  87170. */
  87171. applyToShader(effect: Effect): void;
  87172. /**
  87173. * Returns a string to use to update the GPU particles update shader
  87174. * @returns a string containng the defines string
  87175. */
  87176. getEffectDefines(): string;
  87177. /**
  87178. * Returns the string "PointParticleEmitter"
  87179. * @returns a string containing the class name
  87180. */
  87181. getClassName(): string;
  87182. /**
  87183. * Serializes the particle system to a JSON object.
  87184. * @returns the JSON object
  87185. */
  87186. serialize(): any;
  87187. /**
  87188. * Parse properties from a JSON object
  87189. * @param serializationObject defines the JSON object
  87190. */
  87191. parse(serializationObject: any): void;
  87192. }
  87193. }
  87194. declare module BABYLON {
  87195. /**
  87196. * Particle emitter emitting particles from the inside of a box.
  87197. * It emits the particles randomly between 2 given directions.
  87198. */
  87199. export class MeshParticleEmitter implements IParticleEmitterType {
  87200. private _indices;
  87201. private _positions;
  87202. private _normals;
  87203. private _storedNormal;
  87204. private _mesh;
  87205. /**
  87206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87207. */
  87208. direction1: Vector3;
  87209. /**
  87210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87211. */
  87212. direction2: Vector3;
  87213. /**
  87214. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87215. */
  87216. useMeshNormalsForDirection: boolean;
  87217. /** Defines the mesh to use as source */
  87218. get mesh(): Nullable<AbstractMesh>;
  87219. set mesh(value: Nullable<AbstractMesh>);
  87220. /**
  87221. * Creates a new instance MeshParticleEmitter
  87222. * @param mesh defines the mesh to use as source
  87223. */
  87224. constructor(mesh?: Nullable<AbstractMesh>);
  87225. /**
  87226. * Called by the particle System when the direction is computed for the created particle.
  87227. * @param worldMatrix is the world matrix of the particle system
  87228. * @param directionToUpdate is the direction vector to update with the result
  87229. * @param particle is the particle we are computed the direction for
  87230. * @param isLocal defines if the direction should be set in local space
  87231. */
  87232. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87233. /**
  87234. * Called by the particle System when the position is computed for the created particle.
  87235. * @param worldMatrix is the world matrix of the particle system
  87236. * @param positionToUpdate is the position vector to update with the result
  87237. * @param particle is the particle we are computed the position for
  87238. * @param isLocal defines if the position should be set in local space
  87239. */
  87240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87241. /**
  87242. * Clones the current emitter and returns a copy of it
  87243. * @returns the new emitter
  87244. */
  87245. clone(): MeshParticleEmitter;
  87246. /**
  87247. * Called by the GPUParticleSystem to setup the update shader
  87248. * @param effect defines the update shader
  87249. */
  87250. applyToShader(effect: Effect): void;
  87251. /**
  87252. * Returns a string to use to update the GPU particles update shader
  87253. * @returns a string containng the defines string
  87254. */
  87255. getEffectDefines(): string;
  87256. /**
  87257. * Returns the string "BoxParticleEmitter"
  87258. * @returns a string containing the class name
  87259. */
  87260. getClassName(): string;
  87261. /**
  87262. * Serializes the particle system to a JSON object.
  87263. * @returns the JSON object
  87264. */
  87265. serialize(): any;
  87266. /**
  87267. * Parse properties from a JSON object
  87268. * @param serializationObject defines the JSON object
  87269. * @param scene defines the hosting scene
  87270. */
  87271. parse(serializationObject: any, scene: Scene): void;
  87272. }
  87273. }
  87274. declare module BABYLON {
  87275. /**
  87276. * Interface representing a particle system in Babylon.js.
  87277. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87278. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87279. */
  87280. export interface IParticleSystem {
  87281. /**
  87282. * List of animations used by the particle system.
  87283. */
  87284. animations: Animation[];
  87285. /**
  87286. * The id of the Particle system.
  87287. */
  87288. id: string;
  87289. /**
  87290. * The name of the Particle system.
  87291. */
  87292. name: string;
  87293. /**
  87294. * The emitter represents the Mesh or position we are attaching the particle system to.
  87295. */
  87296. emitter: Nullable<AbstractMesh | Vector3>;
  87297. /**
  87298. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87299. */
  87300. isBillboardBased: boolean;
  87301. /**
  87302. * The rendering group used by the Particle system to chose when to render.
  87303. */
  87304. renderingGroupId: number;
  87305. /**
  87306. * The layer mask we are rendering the particles through.
  87307. */
  87308. layerMask: number;
  87309. /**
  87310. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87311. */
  87312. updateSpeed: number;
  87313. /**
  87314. * The amount of time the particle system is running (depends of the overall update speed).
  87315. */
  87316. targetStopDuration: number;
  87317. /**
  87318. * The texture used to render each particle. (this can be a spritesheet)
  87319. */
  87320. particleTexture: Nullable<Texture>;
  87321. /**
  87322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87323. */
  87324. blendMode: number;
  87325. /**
  87326. * Minimum life time of emitting particles.
  87327. */
  87328. minLifeTime: number;
  87329. /**
  87330. * Maximum life time of emitting particles.
  87331. */
  87332. maxLifeTime: number;
  87333. /**
  87334. * Minimum Size of emitting particles.
  87335. */
  87336. minSize: number;
  87337. /**
  87338. * Maximum Size of emitting particles.
  87339. */
  87340. maxSize: number;
  87341. /**
  87342. * Minimum scale of emitting particles on X axis.
  87343. */
  87344. minScaleX: number;
  87345. /**
  87346. * Maximum scale of emitting particles on X axis.
  87347. */
  87348. maxScaleX: number;
  87349. /**
  87350. * Minimum scale of emitting particles on Y axis.
  87351. */
  87352. minScaleY: number;
  87353. /**
  87354. * Maximum scale of emitting particles on Y axis.
  87355. */
  87356. maxScaleY: number;
  87357. /**
  87358. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87359. */
  87360. color1: Color4;
  87361. /**
  87362. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87363. */
  87364. color2: Color4;
  87365. /**
  87366. * Color the particle will have at the end of its lifetime.
  87367. */
  87368. colorDead: Color4;
  87369. /**
  87370. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87371. */
  87372. emitRate: number;
  87373. /**
  87374. * You can use gravity if you want to give an orientation to your particles.
  87375. */
  87376. gravity: Vector3;
  87377. /**
  87378. * Minimum power of emitting particles.
  87379. */
  87380. minEmitPower: number;
  87381. /**
  87382. * Maximum power of emitting particles.
  87383. */
  87384. maxEmitPower: number;
  87385. /**
  87386. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87387. */
  87388. minAngularSpeed: number;
  87389. /**
  87390. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87391. */
  87392. maxAngularSpeed: number;
  87393. /**
  87394. * Gets or sets the minimal initial rotation in radians.
  87395. */
  87396. minInitialRotation: number;
  87397. /**
  87398. * Gets or sets the maximal initial rotation in radians.
  87399. */
  87400. maxInitialRotation: number;
  87401. /**
  87402. * The particle emitter type defines the emitter used by the particle system.
  87403. * It can be for example box, sphere, or cone...
  87404. */
  87405. particleEmitterType: Nullable<IParticleEmitterType>;
  87406. /**
  87407. * Defines the delay in milliseconds before starting the system (0 by default)
  87408. */
  87409. startDelay: number;
  87410. /**
  87411. * 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
  87412. */
  87413. preWarmCycles: number;
  87414. /**
  87415. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87416. */
  87417. preWarmStepOffset: number;
  87418. /**
  87419. * 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)
  87420. */
  87421. spriteCellChangeSpeed: number;
  87422. /**
  87423. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87424. */
  87425. startSpriteCellID: number;
  87426. /**
  87427. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87428. */
  87429. endSpriteCellID: number;
  87430. /**
  87431. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87432. */
  87433. spriteCellWidth: number;
  87434. /**
  87435. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87436. */
  87437. spriteCellHeight: number;
  87438. /**
  87439. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87440. */
  87441. spriteRandomStartCell: boolean;
  87442. /**
  87443. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87444. */
  87445. isAnimationSheetEnabled: boolean;
  87446. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87447. translationPivot: Vector2;
  87448. /**
  87449. * Gets or sets a texture used to add random noise to particle positions
  87450. */
  87451. noiseTexture: Nullable<BaseTexture>;
  87452. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87453. noiseStrength: Vector3;
  87454. /**
  87455. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87456. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87457. */
  87458. billboardMode: number;
  87459. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87460. limitVelocityDamping: number;
  87461. /**
  87462. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87463. */
  87464. beginAnimationOnStart: boolean;
  87465. /**
  87466. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87467. */
  87468. beginAnimationFrom: number;
  87469. /**
  87470. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87471. */
  87472. beginAnimationTo: number;
  87473. /**
  87474. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87475. */
  87476. beginAnimationLoop: boolean;
  87477. /**
  87478. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87479. */
  87480. disposeOnStop: boolean;
  87481. /**
  87482. * Specifies if the particles are updated in emitter local space or world space
  87483. */
  87484. isLocal: boolean;
  87485. /** Snippet ID if the particle system was created from the snippet server */
  87486. snippetId: string;
  87487. /**
  87488. * Gets the maximum number of particles active at the same time.
  87489. * @returns The max number of active particles.
  87490. */
  87491. getCapacity(): number;
  87492. /**
  87493. * Gets the number of particles active at the same time.
  87494. * @returns The number of active particles.
  87495. */
  87496. getActiveCount(): number;
  87497. /**
  87498. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87499. * @returns True if it has been started, otherwise false.
  87500. */
  87501. isStarted(): boolean;
  87502. /**
  87503. * Animates the particle system for this frame.
  87504. */
  87505. animate(): void;
  87506. /**
  87507. * Renders the particle system in its current state.
  87508. * @returns the current number of particles
  87509. */
  87510. render(): number;
  87511. /**
  87512. * Dispose the particle system and frees its associated resources.
  87513. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87514. */
  87515. dispose(disposeTexture?: boolean): void;
  87516. /**
  87517. * Clones the particle system.
  87518. * @param name The name of the cloned object
  87519. * @param newEmitter The new emitter to use
  87520. * @returns the cloned particle system
  87521. */
  87522. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87523. /**
  87524. * Serializes the particle system to a JSON object.
  87525. * @returns the JSON object
  87526. */
  87527. serialize(): any;
  87528. /**
  87529. * Rebuild the particle system
  87530. */
  87531. rebuild(): void;
  87532. /**
  87533. * Starts the particle system and begins to emit
  87534. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87535. */
  87536. start(delay?: number): void;
  87537. /**
  87538. * Stops the particle system.
  87539. */
  87540. stop(): void;
  87541. /**
  87542. * Remove all active particles
  87543. */
  87544. reset(): void;
  87545. /**
  87546. * Gets a boolean indicating that the system is stopping
  87547. * @returns true if the system is currently stopping
  87548. */
  87549. isStopping(): boolean;
  87550. /**
  87551. * Is this system ready to be used/rendered
  87552. * @return true if the system is ready
  87553. */
  87554. isReady(): boolean;
  87555. /**
  87556. * Returns the string "ParticleSystem"
  87557. * @returns a string containing the class name
  87558. */
  87559. getClassName(): string;
  87560. /**
  87561. * Adds a new color gradient
  87562. * @param gradient defines the gradient to use (between 0 and 1)
  87563. * @param color1 defines the color to affect to the specified gradient
  87564. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87565. * @returns the current particle system
  87566. */
  87567. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87568. /**
  87569. * Remove a specific color gradient
  87570. * @param gradient defines the gradient to remove
  87571. * @returns the current particle system
  87572. */
  87573. removeColorGradient(gradient: number): IParticleSystem;
  87574. /**
  87575. * Adds a new size gradient
  87576. * @param gradient defines the gradient to use (between 0 and 1)
  87577. * @param factor defines the size factor to affect to the specified gradient
  87578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87579. * @returns the current particle system
  87580. */
  87581. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87582. /**
  87583. * Remove a specific size gradient
  87584. * @param gradient defines the gradient to remove
  87585. * @returns the current particle system
  87586. */
  87587. removeSizeGradient(gradient: number): IParticleSystem;
  87588. /**
  87589. * Gets the current list of color gradients.
  87590. * You must use addColorGradient and removeColorGradient to udpate this list
  87591. * @returns the list of color gradients
  87592. */
  87593. getColorGradients(): Nullable<Array<ColorGradient>>;
  87594. /**
  87595. * Gets the current list of size gradients.
  87596. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87597. * @returns the list of size gradients
  87598. */
  87599. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87600. /**
  87601. * Gets the current list of angular speed gradients.
  87602. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87603. * @returns the list of angular speed gradients
  87604. */
  87605. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87606. /**
  87607. * Adds a new angular speed gradient
  87608. * @param gradient defines the gradient to use (between 0 and 1)
  87609. * @param factor defines the angular speed to affect to the specified gradient
  87610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87611. * @returns the current particle system
  87612. */
  87613. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87614. /**
  87615. * Remove a specific angular speed gradient
  87616. * @param gradient defines the gradient to remove
  87617. * @returns the current particle system
  87618. */
  87619. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87620. /**
  87621. * Gets the current list of velocity gradients.
  87622. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87623. * @returns the list of velocity gradients
  87624. */
  87625. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87626. /**
  87627. * Adds a new velocity gradient
  87628. * @param gradient defines the gradient to use (between 0 and 1)
  87629. * @param factor defines the velocity to affect to the specified gradient
  87630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87631. * @returns the current particle system
  87632. */
  87633. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87634. /**
  87635. * Remove a specific velocity gradient
  87636. * @param gradient defines the gradient to remove
  87637. * @returns the current particle system
  87638. */
  87639. removeVelocityGradient(gradient: number): IParticleSystem;
  87640. /**
  87641. * Gets the current list of limit velocity gradients.
  87642. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87643. * @returns the list of limit velocity gradients
  87644. */
  87645. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87646. /**
  87647. * Adds a new limit velocity gradient
  87648. * @param gradient defines the gradient to use (between 0 and 1)
  87649. * @param factor defines the limit velocity to affect to the specified gradient
  87650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87651. * @returns the current particle system
  87652. */
  87653. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87654. /**
  87655. * Remove a specific limit velocity gradient
  87656. * @param gradient defines the gradient to remove
  87657. * @returns the current particle system
  87658. */
  87659. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87660. /**
  87661. * Adds a new drag gradient
  87662. * @param gradient defines the gradient to use (between 0 and 1)
  87663. * @param factor defines the drag to affect to the specified gradient
  87664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87665. * @returns the current particle system
  87666. */
  87667. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87668. /**
  87669. * Remove a specific drag gradient
  87670. * @param gradient defines the gradient to remove
  87671. * @returns the current particle system
  87672. */
  87673. removeDragGradient(gradient: number): IParticleSystem;
  87674. /**
  87675. * Gets the current list of drag gradients.
  87676. * You must use addDragGradient and removeDragGradient to udpate this list
  87677. * @returns the list of drag gradients
  87678. */
  87679. getDragGradients(): Nullable<Array<FactorGradient>>;
  87680. /**
  87681. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87682. * @param gradient defines the gradient to use (between 0 and 1)
  87683. * @param factor defines the emit rate to affect to the specified gradient
  87684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87685. * @returns the current particle system
  87686. */
  87687. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87688. /**
  87689. * Remove a specific emit rate gradient
  87690. * @param gradient defines the gradient to remove
  87691. * @returns the current particle system
  87692. */
  87693. removeEmitRateGradient(gradient: number): IParticleSystem;
  87694. /**
  87695. * Gets the current list of emit rate gradients.
  87696. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87697. * @returns the list of emit rate gradients
  87698. */
  87699. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87700. /**
  87701. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87702. * @param gradient defines the gradient to use (between 0 and 1)
  87703. * @param factor defines the start size to affect to the specified gradient
  87704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87705. * @returns the current particle system
  87706. */
  87707. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87708. /**
  87709. * Remove a specific start size gradient
  87710. * @param gradient defines the gradient to remove
  87711. * @returns the current particle system
  87712. */
  87713. removeStartSizeGradient(gradient: number): IParticleSystem;
  87714. /**
  87715. * Gets the current list of start size gradients.
  87716. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87717. * @returns the list of start size gradients
  87718. */
  87719. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87720. /**
  87721. * Adds a new life time gradient
  87722. * @param gradient defines the gradient to use (between 0 and 1)
  87723. * @param factor defines the life time factor to affect to the specified gradient
  87724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87725. * @returns the current particle system
  87726. */
  87727. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87728. /**
  87729. * Remove a specific life time gradient
  87730. * @param gradient defines the gradient to remove
  87731. * @returns the current particle system
  87732. */
  87733. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87734. /**
  87735. * Gets the current list of life time gradients.
  87736. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87737. * @returns the list of life time gradients
  87738. */
  87739. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87740. /**
  87741. * Gets the current list of color gradients.
  87742. * You must use addColorGradient and removeColorGradient to udpate this list
  87743. * @returns the list of color gradients
  87744. */
  87745. getColorGradients(): Nullable<Array<ColorGradient>>;
  87746. /**
  87747. * Adds a new ramp gradient used to remap particle colors
  87748. * @param gradient defines the gradient to use (between 0 and 1)
  87749. * @param color defines the color to affect to the specified gradient
  87750. * @returns the current particle system
  87751. */
  87752. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87753. /**
  87754. * Gets the current list of ramp gradients.
  87755. * You must use addRampGradient and removeRampGradient to udpate this list
  87756. * @returns the list of ramp gradients
  87757. */
  87758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87759. /** Gets or sets a boolean indicating that ramp gradients must be used
  87760. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87761. */
  87762. useRampGradients: boolean;
  87763. /**
  87764. * Adds a new color remap gradient
  87765. * @param gradient defines the gradient to use (between 0 and 1)
  87766. * @param min defines the color remap minimal range
  87767. * @param max defines the color remap maximal range
  87768. * @returns the current particle system
  87769. */
  87770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87771. /**
  87772. * Gets the current list of color remap gradients.
  87773. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87774. * @returns the list of color remap gradients
  87775. */
  87776. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87777. /**
  87778. * Adds a new alpha remap gradient
  87779. * @param gradient defines the gradient to use (between 0 and 1)
  87780. * @param min defines the alpha remap minimal range
  87781. * @param max defines the alpha remap maximal range
  87782. * @returns the current particle system
  87783. */
  87784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87785. /**
  87786. * Gets the current list of alpha remap gradients.
  87787. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87788. * @returns the list of alpha remap gradients
  87789. */
  87790. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87791. /**
  87792. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87795. * @returns the emitter
  87796. */
  87797. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87798. /**
  87799. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87800. * @param radius The radius of the hemisphere to emit from
  87801. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87802. * @returns the emitter
  87803. */
  87804. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87805. /**
  87806. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87807. * @param radius The radius of the sphere to emit from
  87808. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87809. * @returns the emitter
  87810. */
  87811. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87812. /**
  87813. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87814. * @param radius The radius of the sphere to emit from
  87815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87817. * @returns the emitter
  87818. */
  87819. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87820. /**
  87821. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87822. * @param radius The radius of the emission cylinder
  87823. * @param height The height of the emission cylinder
  87824. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87825. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87826. * @returns the emitter
  87827. */
  87828. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87829. /**
  87830. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87831. * @param radius The radius of the cylinder to emit from
  87832. * @param height The height of the emission cylinder
  87833. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87836. * @returns the emitter
  87837. */
  87838. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87839. /**
  87840. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87841. * @param radius The radius of the cone to emit from
  87842. * @param angle The base angle of the cone
  87843. * @returns the emitter
  87844. */
  87845. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87846. /**
  87847. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87850. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87851. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87852. * @returns the emitter
  87853. */
  87854. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87855. /**
  87856. * Get hosting scene
  87857. * @returns the scene
  87858. */
  87859. getScene(): Scene;
  87860. }
  87861. }
  87862. declare module BABYLON {
  87863. /**
  87864. * 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.
  87865. * @see https://doc.babylonjs.com/how_to/transformnode
  87866. */
  87867. export class TransformNode extends Node {
  87868. /**
  87869. * Object will not rotate to face the camera
  87870. */
  87871. static BILLBOARDMODE_NONE: number;
  87872. /**
  87873. * Object will rotate to face the camera but only on the x axis
  87874. */
  87875. static BILLBOARDMODE_X: number;
  87876. /**
  87877. * Object will rotate to face the camera but only on the y axis
  87878. */
  87879. static BILLBOARDMODE_Y: number;
  87880. /**
  87881. * Object will rotate to face the camera but only on the z axis
  87882. */
  87883. static BILLBOARDMODE_Z: number;
  87884. /**
  87885. * Object will rotate to face the camera
  87886. */
  87887. static BILLBOARDMODE_ALL: number;
  87888. /**
  87889. * Object will rotate to face the camera's position instead of orientation
  87890. */
  87891. static BILLBOARDMODE_USE_POSITION: number;
  87892. private _forward;
  87893. private _forwardInverted;
  87894. private _up;
  87895. private _right;
  87896. private _rightInverted;
  87897. private _position;
  87898. private _rotation;
  87899. private _rotationQuaternion;
  87900. protected _scaling: Vector3;
  87901. protected _isDirty: boolean;
  87902. private _transformToBoneReferal;
  87903. private _isAbsoluteSynced;
  87904. private _billboardMode;
  87905. /**
  87906. * Gets or sets the billboard mode. Default is 0.
  87907. *
  87908. * | Value | Type | Description |
  87909. * | --- | --- | --- |
  87910. * | 0 | BILLBOARDMODE_NONE | |
  87911. * | 1 | BILLBOARDMODE_X | |
  87912. * | 2 | BILLBOARDMODE_Y | |
  87913. * | 4 | BILLBOARDMODE_Z | |
  87914. * | 7 | BILLBOARDMODE_ALL | |
  87915. *
  87916. */
  87917. get billboardMode(): number;
  87918. set billboardMode(value: number);
  87919. private _preserveParentRotationForBillboard;
  87920. /**
  87921. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87922. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87923. */
  87924. get preserveParentRotationForBillboard(): boolean;
  87925. set preserveParentRotationForBillboard(value: boolean);
  87926. /**
  87927. * 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
  87928. */
  87929. scalingDeterminant: number;
  87930. private _infiniteDistance;
  87931. /**
  87932. * Gets or sets the distance of the object to max, often used by skybox
  87933. */
  87934. get infiniteDistance(): boolean;
  87935. set infiniteDistance(value: boolean);
  87936. /**
  87937. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87938. * By default the system will update normals to compensate
  87939. */
  87940. ignoreNonUniformScaling: boolean;
  87941. /**
  87942. * 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
  87943. */
  87944. reIntegrateRotationIntoRotationQuaternion: boolean;
  87945. /** @hidden */
  87946. _poseMatrix: Nullable<Matrix>;
  87947. /** @hidden */
  87948. _localMatrix: Matrix;
  87949. private _usePivotMatrix;
  87950. private _absolutePosition;
  87951. private _absoluteScaling;
  87952. private _absoluteRotationQuaternion;
  87953. private _pivotMatrix;
  87954. private _pivotMatrixInverse;
  87955. protected _postMultiplyPivotMatrix: boolean;
  87956. protected _isWorldMatrixFrozen: boolean;
  87957. /** @hidden */
  87958. _indexInSceneTransformNodesArray: number;
  87959. /**
  87960. * An event triggered after the world matrix is updated
  87961. */
  87962. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87963. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87964. /**
  87965. * Gets a string identifying the name of the class
  87966. * @returns "TransformNode" string
  87967. */
  87968. getClassName(): string;
  87969. /**
  87970. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87971. */
  87972. get position(): Vector3;
  87973. set position(newPosition: Vector3);
  87974. /**
  87975. * 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)).
  87976. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87977. */
  87978. get rotation(): Vector3;
  87979. set rotation(newRotation: Vector3);
  87980. /**
  87981. * 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)).
  87982. */
  87983. get scaling(): Vector3;
  87984. set scaling(newScaling: Vector3);
  87985. /**
  87986. * 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).
  87987. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87988. */
  87989. get rotationQuaternion(): Nullable<Quaternion>;
  87990. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87991. /**
  87992. * The forward direction of that transform in world space.
  87993. */
  87994. get forward(): Vector3;
  87995. /**
  87996. * The up direction of that transform in world space.
  87997. */
  87998. get up(): Vector3;
  87999. /**
  88000. * The right direction of that transform in world space.
  88001. */
  88002. get right(): Vector3;
  88003. /**
  88004. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88005. * @param matrix the matrix to copy the pose from
  88006. * @returns this TransformNode.
  88007. */
  88008. updatePoseMatrix(matrix: Matrix): TransformNode;
  88009. /**
  88010. * Returns the mesh Pose matrix.
  88011. * @returns the pose matrix
  88012. */
  88013. getPoseMatrix(): Matrix;
  88014. /** @hidden */
  88015. _isSynchronized(): boolean;
  88016. /** @hidden */
  88017. _initCache(): void;
  88018. /**
  88019. * Flag the transform node as dirty (Forcing it to update everything)
  88020. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88021. * @returns this transform node
  88022. */
  88023. markAsDirty(property: string): TransformNode;
  88024. /**
  88025. * Returns the current mesh absolute position.
  88026. * Returns a Vector3.
  88027. */
  88028. get absolutePosition(): Vector3;
  88029. /**
  88030. * Returns the current mesh absolute scaling.
  88031. * Returns a Vector3.
  88032. */
  88033. get absoluteScaling(): Vector3;
  88034. /**
  88035. * Returns the current mesh absolute rotation.
  88036. * Returns a Quaternion.
  88037. */
  88038. get absoluteRotationQuaternion(): Quaternion;
  88039. /**
  88040. * Sets a new matrix to apply before all other transformation
  88041. * @param matrix defines the transform matrix
  88042. * @returns the current TransformNode
  88043. */
  88044. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88045. /**
  88046. * Sets a new pivot matrix to the current node
  88047. * @param matrix defines the new pivot matrix to use
  88048. * @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
  88049. * @returns the current TransformNode
  88050. */
  88051. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88052. /**
  88053. * Returns the mesh pivot matrix.
  88054. * Default : Identity.
  88055. * @returns the matrix
  88056. */
  88057. getPivotMatrix(): Matrix;
  88058. /**
  88059. * Instantiate (when possible) or clone that node with its hierarchy
  88060. * @param newParent defines the new parent to use for the instance (or clone)
  88061. * @param options defines options to configure how copy is done
  88062. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88063. * @returns an instance (or a clone) of the current node with its hiearchy
  88064. */
  88065. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88066. doNotInstantiate: boolean;
  88067. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88068. /**
  88069. * Prevents the World matrix to be computed any longer
  88070. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88071. * @returns the TransformNode.
  88072. */
  88073. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88074. /**
  88075. * Allows back the World matrix computation.
  88076. * @returns the TransformNode.
  88077. */
  88078. unfreezeWorldMatrix(): this;
  88079. /**
  88080. * True if the World matrix has been frozen.
  88081. */
  88082. get isWorldMatrixFrozen(): boolean;
  88083. /**
  88084. * Retuns the mesh absolute position in the World.
  88085. * @returns a Vector3.
  88086. */
  88087. getAbsolutePosition(): Vector3;
  88088. /**
  88089. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88090. * @param absolutePosition the absolute position to set
  88091. * @returns the TransformNode.
  88092. */
  88093. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88094. /**
  88095. * Sets the mesh position in its local space.
  88096. * @param vector3 the position to set in localspace
  88097. * @returns the TransformNode.
  88098. */
  88099. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88100. /**
  88101. * Returns the mesh position in the local space from the current World matrix values.
  88102. * @returns a new Vector3.
  88103. */
  88104. getPositionExpressedInLocalSpace(): Vector3;
  88105. /**
  88106. * Translates the mesh along the passed Vector3 in its local space.
  88107. * @param vector3 the distance to translate in localspace
  88108. * @returns the TransformNode.
  88109. */
  88110. locallyTranslate(vector3: Vector3): TransformNode;
  88111. private static _lookAtVectorCache;
  88112. /**
  88113. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88114. * @param targetPoint the position (must be in same space as current mesh) to look at
  88115. * @param yawCor optional yaw (y-axis) correction in radians
  88116. * @param pitchCor optional pitch (x-axis) correction in radians
  88117. * @param rollCor optional roll (z-axis) correction in radians
  88118. * @param space the choosen space of the target
  88119. * @returns the TransformNode.
  88120. */
  88121. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88122. /**
  88123. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88124. * This Vector3 is expressed in the World space.
  88125. * @param localAxis axis to rotate
  88126. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88127. */
  88128. getDirection(localAxis: Vector3): Vector3;
  88129. /**
  88130. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88131. * localAxis is expressed in the mesh local space.
  88132. * result is computed in the Wordl space from the mesh World matrix.
  88133. * @param localAxis axis to rotate
  88134. * @param result the resulting transformnode
  88135. * @returns this TransformNode.
  88136. */
  88137. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88138. /**
  88139. * Sets this transform node rotation to the given local axis.
  88140. * @param localAxis the axis in local space
  88141. * @param yawCor optional yaw (y-axis) correction in radians
  88142. * @param pitchCor optional pitch (x-axis) correction in radians
  88143. * @param rollCor optional roll (z-axis) correction in radians
  88144. * @returns this TransformNode
  88145. */
  88146. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88147. /**
  88148. * Sets a new pivot point to the current node
  88149. * @param point defines the new pivot point to use
  88150. * @param space defines if the point is in world or local space (local by default)
  88151. * @returns the current TransformNode
  88152. */
  88153. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88154. /**
  88155. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88156. * @returns the pivot point
  88157. */
  88158. getPivotPoint(): Vector3;
  88159. /**
  88160. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88161. * @param result the vector3 to store the result
  88162. * @returns this TransformNode.
  88163. */
  88164. getPivotPointToRef(result: Vector3): TransformNode;
  88165. /**
  88166. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88167. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88168. */
  88169. getAbsolutePivotPoint(): Vector3;
  88170. /**
  88171. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88172. * @param result vector3 to store the result
  88173. * @returns this TransformNode.
  88174. */
  88175. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88176. /**
  88177. * Defines the passed node as the parent of the current node.
  88178. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88179. * @see https://doc.babylonjs.com/how_to/parenting
  88180. * @param node the node ot set as the parent
  88181. * @returns this TransformNode.
  88182. */
  88183. setParent(node: Nullable<Node>): TransformNode;
  88184. private _nonUniformScaling;
  88185. /**
  88186. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88187. */
  88188. get nonUniformScaling(): boolean;
  88189. /** @hidden */
  88190. _updateNonUniformScalingState(value: boolean): boolean;
  88191. /**
  88192. * Attach the current TransformNode to another TransformNode associated with a bone
  88193. * @param bone Bone affecting the TransformNode
  88194. * @param affectedTransformNode TransformNode associated with the bone
  88195. * @returns this object
  88196. */
  88197. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88198. /**
  88199. * Detach the transform node if its associated with a bone
  88200. * @returns this object
  88201. */
  88202. detachFromBone(): TransformNode;
  88203. private static _rotationAxisCache;
  88204. /**
  88205. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88206. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88207. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88208. * The passed axis is also normalized.
  88209. * @param axis the axis to rotate around
  88210. * @param amount the amount to rotate in radians
  88211. * @param space Space to rotate in (Default: local)
  88212. * @returns the TransformNode.
  88213. */
  88214. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88215. /**
  88216. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88217. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88218. * The passed axis is also normalized. .
  88219. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88220. * @param point the point to rotate around
  88221. * @param axis the axis to rotate around
  88222. * @param amount the amount to rotate in radians
  88223. * @returns the TransformNode
  88224. */
  88225. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88226. /**
  88227. * Translates the mesh along the axis vector for the passed distance in the given space.
  88228. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88229. * @param axis the axis to translate in
  88230. * @param distance the distance to translate
  88231. * @param space Space to rotate in (Default: local)
  88232. * @returns the TransformNode.
  88233. */
  88234. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88235. /**
  88236. * Adds a rotation step to the mesh current rotation.
  88237. * x, y, z are Euler angles expressed in radians.
  88238. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88239. * This means this rotation is made in the mesh local space only.
  88240. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88241. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88242. * ```javascript
  88243. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88244. * ```
  88245. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88246. * 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.
  88247. * @param x Rotation to add
  88248. * @param y Rotation to add
  88249. * @param z Rotation to add
  88250. * @returns the TransformNode.
  88251. */
  88252. addRotation(x: number, y: number, z: number): TransformNode;
  88253. /**
  88254. * @hidden
  88255. */
  88256. protected _getEffectiveParent(): Nullable<Node>;
  88257. /**
  88258. * Computes the world matrix of the node
  88259. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88260. * @returns the world matrix
  88261. */
  88262. computeWorldMatrix(force?: boolean): Matrix;
  88263. /**
  88264. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88265. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88266. */
  88267. resetLocalMatrix(independentOfChildren?: boolean): void;
  88268. protected _afterComputeWorldMatrix(): void;
  88269. /**
  88270. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88271. * @param func callback function to add
  88272. *
  88273. * @returns the TransformNode.
  88274. */
  88275. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88276. /**
  88277. * Removes a registered callback function.
  88278. * @param func callback function to remove
  88279. * @returns the TransformNode.
  88280. */
  88281. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88282. /**
  88283. * Gets the position of the current mesh in camera space
  88284. * @param camera defines the camera to use
  88285. * @returns a position
  88286. */
  88287. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88288. /**
  88289. * Returns the distance from the mesh to the active camera
  88290. * @param camera defines the camera to use
  88291. * @returns the distance
  88292. */
  88293. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88294. /**
  88295. * Clone the current transform node
  88296. * @param name Name of the new clone
  88297. * @param newParent New parent for the clone
  88298. * @param doNotCloneChildren Do not clone children hierarchy
  88299. * @returns the new transform node
  88300. */
  88301. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88302. /**
  88303. * Serializes the objects information.
  88304. * @param currentSerializationObject defines the object to serialize in
  88305. * @returns the serialized object
  88306. */
  88307. serialize(currentSerializationObject?: any): any;
  88308. /**
  88309. * Returns a new TransformNode object parsed from the source provided.
  88310. * @param parsedTransformNode is the source.
  88311. * @param scene the scne the object belongs to
  88312. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88313. * @returns a new TransformNode object parsed from the source provided.
  88314. */
  88315. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88316. /**
  88317. * Get all child-transformNodes of this node
  88318. * @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
  88319. * @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
  88320. * @returns an array of TransformNode
  88321. */
  88322. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88323. /**
  88324. * Releases resources associated with this transform node.
  88325. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88326. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88327. */
  88328. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88329. /**
  88330. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88331. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88332. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88333. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88334. * @returns the current mesh
  88335. */
  88336. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88337. private _syncAbsoluteScalingAndRotation;
  88338. }
  88339. }
  88340. declare module BABYLON {
  88341. /**
  88342. * Class used to override all child animations of a given target
  88343. */
  88344. export class AnimationPropertiesOverride {
  88345. /**
  88346. * Gets or sets a value indicating if animation blending must be used
  88347. */
  88348. enableBlending: boolean;
  88349. /**
  88350. * Gets or sets the blending speed to use when enableBlending is true
  88351. */
  88352. blendingSpeed: number;
  88353. /**
  88354. * Gets or sets the default loop mode to use
  88355. */
  88356. loopMode: number;
  88357. }
  88358. }
  88359. declare module BABYLON {
  88360. /**
  88361. * Class used to store bone information
  88362. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88363. */
  88364. export class Bone extends Node {
  88365. /**
  88366. * defines the bone name
  88367. */
  88368. name: string;
  88369. private static _tmpVecs;
  88370. private static _tmpQuat;
  88371. private static _tmpMats;
  88372. /**
  88373. * Gets the list of child bones
  88374. */
  88375. children: Bone[];
  88376. /** Gets the animations associated with this bone */
  88377. animations: Animation[];
  88378. /**
  88379. * Gets or sets bone length
  88380. */
  88381. length: number;
  88382. /**
  88383. * @hidden Internal only
  88384. * Set this value to map this bone to a different index in the transform matrices
  88385. * Set this value to -1 to exclude the bone from the transform matrices
  88386. */
  88387. _index: Nullable<number>;
  88388. private _skeleton;
  88389. private _localMatrix;
  88390. private _restPose;
  88391. private _baseMatrix;
  88392. private _absoluteTransform;
  88393. private _invertedAbsoluteTransform;
  88394. private _parent;
  88395. private _scalingDeterminant;
  88396. private _worldTransform;
  88397. private _localScaling;
  88398. private _localRotation;
  88399. private _localPosition;
  88400. private _needToDecompose;
  88401. private _needToCompose;
  88402. /** @hidden */
  88403. _linkedTransformNode: Nullable<TransformNode>;
  88404. /** @hidden */
  88405. _waitingTransformNodeId: Nullable<string>;
  88406. /** @hidden */
  88407. get _matrix(): Matrix;
  88408. /** @hidden */
  88409. set _matrix(value: Matrix);
  88410. /**
  88411. * Create a new bone
  88412. * @param name defines the bone name
  88413. * @param skeleton defines the parent skeleton
  88414. * @param parentBone defines the parent (can be null if the bone is the root)
  88415. * @param localMatrix defines the local matrix
  88416. * @param restPose defines the rest pose matrix
  88417. * @param baseMatrix defines the base matrix
  88418. * @param index defines index of the bone in the hiearchy
  88419. */
  88420. constructor(
  88421. /**
  88422. * defines the bone name
  88423. */
  88424. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88425. /**
  88426. * Gets the current object class name.
  88427. * @return the class name
  88428. */
  88429. getClassName(): string;
  88430. /**
  88431. * Gets the parent skeleton
  88432. * @returns a skeleton
  88433. */
  88434. getSkeleton(): Skeleton;
  88435. /**
  88436. * Gets parent bone
  88437. * @returns a bone or null if the bone is the root of the bone hierarchy
  88438. */
  88439. getParent(): Nullable<Bone>;
  88440. /**
  88441. * Returns an array containing the root bones
  88442. * @returns an array containing the root bones
  88443. */
  88444. getChildren(): Array<Bone>;
  88445. /**
  88446. * Gets the node index in matrix array generated for rendering
  88447. * @returns the node index
  88448. */
  88449. getIndex(): number;
  88450. /**
  88451. * Sets the parent bone
  88452. * @param parent defines the parent (can be null if the bone is the root)
  88453. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88454. */
  88455. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88456. /**
  88457. * Gets the local matrix
  88458. * @returns a matrix
  88459. */
  88460. getLocalMatrix(): Matrix;
  88461. /**
  88462. * Gets the base matrix (initial matrix which remains unchanged)
  88463. * @returns a matrix
  88464. */
  88465. getBaseMatrix(): Matrix;
  88466. /**
  88467. * Gets the rest pose matrix
  88468. * @returns a matrix
  88469. */
  88470. getRestPose(): Matrix;
  88471. /**
  88472. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88473. */
  88474. getWorldMatrix(): Matrix;
  88475. /**
  88476. * Sets the local matrix to rest pose matrix
  88477. */
  88478. returnToRest(): void;
  88479. /**
  88480. * Gets the inverse of the absolute transform matrix.
  88481. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88482. * @returns a matrix
  88483. */
  88484. getInvertedAbsoluteTransform(): Matrix;
  88485. /**
  88486. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88487. * @returns a matrix
  88488. */
  88489. getAbsoluteTransform(): Matrix;
  88490. /**
  88491. * Links with the given transform node.
  88492. * The local matrix of this bone is copied from the transform node every frame.
  88493. * @param transformNode defines the transform node to link to
  88494. */
  88495. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88496. /**
  88497. * Gets the node used to drive the bone's transformation
  88498. * @returns a transform node or null
  88499. */
  88500. getTransformNode(): Nullable<TransformNode>;
  88501. /** Gets or sets current position (in local space) */
  88502. get position(): Vector3;
  88503. set position(newPosition: Vector3);
  88504. /** Gets or sets current rotation (in local space) */
  88505. get rotation(): Vector3;
  88506. set rotation(newRotation: Vector3);
  88507. /** Gets or sets current rotation quaternion (in local space) */
  88508. get rotationQuaternion(): Quaternion;
  88509. set rotationQuaternion(newRotation: Quaternion);
  88510. /** Gets or sets current scaling (in local space) */
  88511. get scaling(): Vector3;
  88512. set scaling(newScaling: Vector3);
  88513. /**
  88514. * Gets the animation properties override
  88515. */
  88516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88517. private _decompose;
  88518. private _compose;
  88519. /**
  88520. * Update the base and local matrices
  88521. * @param matrix defines the new base or local matrix
  88522. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88523. * @param updateLocalMatrix defines if the local matrix should be updated
  88524. */
  88525. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88526. /** @hidden */
  88527. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88528. /**
  88529. * Flag the bone as dirty (Forcing it to update everything)
  88530. */
  88531. markAsDirty(): void;
  88532. /** @hidden */
  88533. _markAsDirtyAndCompose(): void;
  88534. private _markAsDirtyAndDecompose;
  88535. /**
  88536. * Translate the bone in local or world space
  88537. * @param vec The amount to translate the bone
  88538. * @param space The space that the translation is in
  88539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88540. */
  88541. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88542. /**
  88543. * Set the postion of the bone in local or world space
  88544. * @param position The position to set the bone
  88545. * @param space The space that the position is in
  88546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88547. */
  88548. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88549. /**
  88550. * Set the absolute position of the bone (world space)
  88551. * @param position The position to set the bone
  88552. * @param mesh The mesh that this bone is attached to
  88553. */
  88554. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88555. /**
  88556. * Scale the bone on the x, y and z axes (in local space)
  88557. * @param x The amount to scale the bone on the x axis
  88558. * @param y The amount to scale the bone on the y axis
  88559. * @param z The amount to scale the bone on the z axis
  88560. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88561. */
  88562. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88563. /**
  88564. * Set the bone scaling in local space
  88565. * @param scale defines the scaling vector
  88566. */
  88567. setScale(scale: Vector3): void;
  88568. /**
  88569. * Gets the current scaling in local space
  88570. * @returns the current scaling vector
  88571. */
  88572. getScale(): Vector3;
  88573. /**
  88574. * Gets the current scaling in local space and stores it in a target vector
  88575. * @param result defines the target vector
  88576. */
  88577. getScaleToRef(result: Vector3): void;
  88578. /**
  88579. * Set the yaw, pitch, and roll of the bone in local or world space
  88580. * @param yaw The rotation of the bone on the y axis
  88581. * @param pitch The rotation of the bone on the x axis
  88582. * @param roll The rotation of the bone on the z axis
  88583. * @param space The space that the axes of rotation are in
  88584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88585. */
  88586. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88587. /**
  88588. * Add a rotation to the bone on an axis in local or world space
  88589. * @param axis The axis to rotate the bone on
  88590. * @param amount The amount to rotate the bone
  88591. * @param space The space that the axis is in
  88592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88593. */
  88594. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88595. /**
  88596. * Set the rotation of the bone to a particular axis angle in local or world space
  88597. * @param axis The axis to rotate the bone on
  88598. * @param angle The angle that the bone should be rotated to
  88599. * @param space The space that the axis is in
  88600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88601. */
  88602. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88603. /**
  88604. * Set the euler rotation of the bone in local of world space
  88605. * @param rotation The euler rotation that the bone should be set to
  88606. * @param space The space that the rotation is in
  88607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88608. */
  88609. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88610. /**
  88611. * Set the quaternion rotation of the bone in local of world space
  88612. * @param quat The quaternion rotation that the bone should be set to
  88613. * @param space The space that the rotation is in
  88614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88615. */
  88616. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88617. /**
  88618. * Set the rotation matrix of the bone in local of world space
  88619. * @param rotMat The rotation matrix that the bone should be set to
  88620. * @param space The space that the rotation is in
  88621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88622. */
  88623. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88624. private _rotateWithMatrix;
  88625. private _getNegativeRotationToRef;
  88626. /**
  88627. * Get the position of the bone in local or world space
  88628. * @param space The space that the returned position is in
  88629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88630. * @returns The position of the bone
  88631. */
  88632. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88633. /**
  88634. * Copy the position of the bone to a vector3 in local or world space
  88635. * @param space The space that the returned position is in
  88636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88637. * @param result The vector3 to copy the position to
  88638. */
  88639. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88640. /**
  88641. * Get the absolute position of the bone (world space)
  88642. * @param mesh The mesh that this bone is attached to
  88643. * @returns The absolute position of the bone
  88644. */
  88645. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88646. /**
  88647. * Copy the absolute position of the bone (world space) to the result param
  88648. * @param mesh The mesh that this bone is attached to
  88649. * @param result The vector3 to copy the absolute position to
  88650. */
  88651. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88652. /**
  88653. * Compute the absolute transforms of this bone and its children
  88654. */
  88655. computeAbsoluteTransforms(): void;
  88656. /**
  88657. * Get the world direction from an axis that is in the local space of the bone
  88658. * @param localAxis The local direction that is used to compute the world direction
  88659. * @param mesh The mesh that this bone is attached to
  88660. * @returns The world direction
  88661. */
  88662. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88663. /**
  88664. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88665. * @param localAxis The local direction that is used to compute the world direction
  88666. * @param mesh The mesh that this bone is attached to
  88667. * @param result The vector3 that the world direction will be copied to
  88668. */
  88669. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88670. /**
  88671. * Get the euler rotation of the bone in local or world space
  88672. * @param space The space that the rotation should be in
  88673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88674. * @returns The euler rotation
  88675. */
  88676. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88677. /**
  88678. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88679. * @param space The space that the rotation should be in
  88680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88681. * @param result The vector3 that the rotation should be copied to
  88682. */
  88683. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88684. /**
  88685. * Get the quaternion rotation of the bone in either local or world space
  88686. * @param space The space that the rotation should be in
  88687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88688. * @returns The quaternion rotation
  88689. */
  88690. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88691. /**
  88692. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88693. * @param space The space that the rotation should be in
  88694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88695. * @param result The quaternion that the rotation should be copied to
  88696. */
  88697. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88698. /**
  88699. * Get the rotation matrix 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 rotation matrix
  88703. */
  88704. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88705. /**
  88706. * Copy the rotation matrix of the bone to a matrix. 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 quaternion that the rotation should be copied to
  88710. */
  88711. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88712. /**
  88713. * Get the world position of a point that is in the local space of the bone
  88714. * @param position The local position
  88715. * @param mesh The mesh that this bone is attached to
  88716. * @returns The world position
  88717. */
  88718. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88719. /**
  88720. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88721. * @param position The local position
  88722. * @param mesh The mesh that this bone is attached to
  88723. * @param result The vector3 that the world position should be copied to
  88724. */
  88725. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88726. /**
  88727. * Get the local position of a point that is in world space
  88728. * @param position The world position
  88729. * @param mesh The mesh that this bone is attached to
  88730. * @returns The local position
  88731. */
  88732. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88733. /**
  88734. * Get the local position of a point that is in world space and copy it to the result param
  88735. * @param position The world position
  88736. * @param mesh The mesh that this bone is attached to
  88737. * @param result The vector3 that the local position should be copied to
  88738. */
  88739. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88740. }
  88741. }
  88742. declare module BABYLON {
  88743. /**
  88744. * Defines a runtime animation
  88745. */
  88746. export class RuntimeAnimation {
  88747. private _events;
  88748. /**
  88749. * The current frame of the runtime animation
  88750. */
  88751. private _currentFrame;
  88752. /**
  88753. * The animation used by the runtime animation
  88754. */
  88755. private _animation;
  88756. /**
  88757. * The target of the runtime animation
  88758. */
  88759. private _target;
  88760. /**
  88761. * The initiating animatable
  88762. */
  88763. private _host;
  88764. /**
  88765. * The original value of the runtime animation
  88766. */
  88767. private _originalValue;
  88768. /**
  88769. * The original blend value of the runtime animation
  88770. */
  88771. private _originalBlendValue;
  88772. /**
  88773. * The offsets cache of the runtime animation
  88774. */
  88775. private _offsetsCache;
  88776. /**
  88777. * The high limits cache of the runtime animation
  88778. */
  88779. private _highLimitsCache;
  88780. /**
  88781. * Specifies if the runtime animation has been stopped
  88782. */
  88783. private _stopped;
  88784. /**
  88785. * The blending factor of the runtime animation
  88786. */
  88787. private _blendingFactor;
  88788. /**
  88789. * The BabylonJS scene
  88790. */
  88791. private _scene;
  88792. /**
  88793. * The current value of the runtime animation
  88794. */
  88795. private _currentValue;
  88796. /** @hidden */
  88797. _animationState: _IAnimationState;
  88798. /**
  88799. * The active target of the runtime animation
  88800. */
  88801. private _activeTargets;
  88802. private _currentActiveTarget;
  88803. private _directTarget;
  88804. /**
  88805. * The target path of the runtime animation
  88806. */
  88807. private _targetPath;
  88808. /**
  88809. * The weight of the runtime animation
  88810. */
  88811. private _weight;
  88812. /**
  88813. * The ratio offset of the runtime animation
  88814. */
  88815. private _ratioOffset;
  88816. /**
  88817. * The previous delay of the runtime animation
  88818. */
  88819. private _previousDelay;
  88820. /**
  88821. * The previous ratio of the runtime animation
  88822. */
  88823. private _previousRatio;
  88824. private _enableBlending;
  88825. private _keys;
  88826. private _minFrame;
  88827. private _maxFrame;
  88828. private _minValue;
  88829. private _maxValue;
  88830. private _targetIsArray;
  88831. /**
  88832. * Gets the current frame of the runtime animation
  88833. */
  88834. get currentFrame(): number;
  88835. /**
  88836. * Gets the weight of the runtime animation
  88837. */
  88838. get weight(): number;
  88839. /**
  88840. * Gets the current value of the runtime animation
  88841. */
  88842. get currentValue(): any;
  88843. /**
  88844. * Gets the target path of the runtime animation
  88845. */
  88846. get targetPath(): string;
  88847. /**
  88848. * Gets the actual target of the runtime animation
  88849. */
  88850. get target(): any;
  88851. /**
  88852. * Gets the additive state of the runtime animation
  88853. */
  88854. get isAdditive(): boolean;
  88855. /** @hidden */
  88856. _onLoop: () => void;
  88857. /**
  88858. * Create a new RuntimeAnimation object
  88859. * @param target defines the target of the animation
  88860. * @param animation defines the source animation object
  88861. * @param scene defines the hosting scene
  88862. * @param host defines the initiating Animatable
  88863. */
  88864. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88865. private _preparePath;
  88866. /**
  88867. * Gets the animation from the runtime animation
  88868. */
  88869. get animation(): Animation;
  88870. /**
  88871. * Resets the runtime animation to the beginning
  88872. * @param restoreOriginal defines whether to restore the target property to the original value
  88873. */
  88874. reset(restoreOriginal?: boolean): void;
  88875. /**
  88876. * Specifies if the runtime animation is stopped
  88877. * @returns Boolean specifying if the runtime animation is stopped
  88878. */
  88879. isStopped(): boolean;
  88880. /**
  88881. * Disposes of the runtime animation
  88882. */
  88883. dispose(): void;
  88884. /**
  88885. * Apply the interpolated value to the target
  88886. * @param currentValue defines the value computed by the animation
  88887. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88888. */
  88889. setValue(currentValue: any, weight: number): void;
  88890. private _getOriginalValues;
  88891. private _setValue;
  88892. /**
  88893. * Gets the loop pmode of the runtime animation
  88894. * @returns Loop Mode
  88895. */
  88896. private _getCorrectLoopMode;
  88897. /**
  88898. * Move the current animation to a given frame
  88899. * @param frame defines the frame to move to
  88900. */
  88901. goToFrame(frame: number): void;
  88902. /**
  88903. * @hidden Internal use only
  88904. */
  88905. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88906. /**
  88907. * Execute the current animation
  88908. * @param delay defines the delay to add to the current frame
  88909. * @param from defines the lower bound of the animation range
  88910. * @param to defines the upper bound of the animation range
  88911. * @param loop defines if the current animation must loop
  88912. * @param speedRatio defines the current speed ratio
  88913. * @param weight defines the weight of the animation (default is -1 so no weight)
  88914. * @param onLoop optional callback called when animation loops
  88915. * @returns a boolean indicating if the animation is running
  88916. */
  88917. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88918. }
  88919. }
  88920. declare module BABYLON {
  88921. /**
  88922. * Class used to store an actual running animation
  88923. */
  88924. export class Animatable {
  88925. /** defines the target object */
  88926. target: any;
  88927. /** defines the starting frame number (default is 0) */
  88928. fromFrame: number;
  88929. /** defines the ending frame number (default is 100) */
  88930. toFrame: number;
  88931. /** defines if the animation must loop (default is false) */
  88932. loopAnimation: boolean;
  88933. /** defines a callback to call when animation ends if it is not looping */
  88934. onAnimationEnd?: (() => void) | null | undefined;
  88935. /** defines a callback to call when animation loops */
  88936. onAnimationLoop?: (() => void) | null | undefined;
  88937. /** defines whether the animation should be evaluated additively */
  88938. isAdditive: boolean;
  88939. private _localDelayOffset;
  88940. private _pausedDelay;
  88941. private _runtimeAnimations;
  88942. private _paused;
  88943. private _scene;
  88944. private _speedRatio;
  88945. private _weight;
  88946. private _syncRoot;
  88947. /**
  88948. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88949. * This will only apply for non looping animation (default is true)
  88950. */
  88951. disposeOnEnd: boolean;
  88952. /**
  88953. * Gets a boolean indicating if the animation has started
  88954. */
  88955. animationStarted: boolean;
  88956. /**
  88957. * Observer raised when the animation ends
  88958. */
  88959. onAnimationEndObservable: Observable<Animatable>;
  88960. /**
  88961. * Observer raised when the animation loops
  88962. */
  88963. onAnimationLoopObservable: Observable<Animatable>;
  88964. /**
  88965. * Gets the root Animatable used to synchronize and normalize animations
  88966. */
  88967. get syncRoot(): Nullable<Animatable>;
  88968. /**
  88969. * Gets the current frame of the first RuntimeAnimation
  88970. * Used to synchronize Animatables
  88971. */
  88972. get masterFrame(): number;
  88973. /**
  88974. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88975. */
  88976. get weight(): number;
  88977. set weight(value: number);
  88978. /**
  88979. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88980. */
  88981. get speedRatio(): number;
  88982. set speedRatio(value: number);
  88983. /**
  88984. * Creates a new Animatable
  88985. * @param scene defines the hosting scene
  88986. * @param target defines the target object
  88987. * @param fromFrame defines the starting frame number (default is 0)
  88988. * @param toFrame defines the ending frame number (default is 100)
  88989. * @param loopAnimation defines if the animation must loop (default is false)
  88990. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88991. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88992. * @param animations defines a group of animation to add to the new Animatable
  88993. * @param onAnimationLoop defines a callback to call when animation loops
  88994. * @param isAdditive defines whether the animation should be evaluated additively
  88995. */
  88996. constructor(scene: Scene,
  88997. /** defines the target object */
  88998. target: any,
  88999. /** defines the starting frame number (default is 0) */
  89000. fromFrame?: number,
  89001. /** defines the ending frame number (default is 100) */
  89002. toFrame?: number,
  89003. /** defines if the animation must loop (default is false) */
  89004. loopAnimation?: boolean, speedRatio?: number,
  89005. /** defines a callback to call when animation ends if it is not looping */
  89006. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89007. /** defines a callback to call when animation loops */
  89008. onAnimationLoop?: (() => void) | null | undefined,
  89009. /** defines whether the animation should be evaluated additively */
  89010. isAdditive?: boolean);
  89011. /**
  89012. * Synchronize and normalize current Animatable with a source Animatable
  89013. * This is useful when using animation weights and when animations are not of the same length
  89014. * @param root defines the root Animatable to synchronize with
  89015. * @returns the current Animatable
  89016. */
  89017. syncWith(root: Animatable): Animatable;
  89018. /**
  89019. * Gets the list of runtime animations
  89020. * @returns an array of RuntimeAnimation
  89021. */
  89022. getAnimations(): RuntimeAnimation[];
  89023. /**
  89024. * Adds more animations to the current animatable
  89025. * @param target defines the target of the animations
  89026. * @param animations defines the new animations to add
  89027. */
  89028. appendAnimations(target: any, animations: Animation[]): void;
  89029. /**
  89030. * Gets the source animation for a specific property
  89031. * @param property defines the propertyu to look for
  89032. * @returns null or the source animation for the given property
  89033. */
  89034. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89035. /**
  89036. * Gets the runtime animation for a specific property
  89037. * @param property defines the propertyu to look for
  89038. * @returns null or the runtime animation for the given property
  89039. */
  89040. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89041. /**
  89042. * Resets the animatable to its original state
  89043. */
  89044. reset(): void;
  89045. /**
  89046. * Allows the animatable to blend with current running animations
  89047. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89048. * @param blendingSpeed defines the blending speed to use
  89049. */
  89050. enableBlending(blendingSpeed: number): void;
  89051. /**
  89052. * Disable animation blending
  89053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89054. */
  89055. disableBlending(): void;
  89056. /**
  89057. * Jump directly to a given frame
  89058. * @param frame defines the frame to jump to
  89059. */
  89060. goToFrame(frame: number): void;
  89061. /**
  89062. * Pause the animation
  89063. */
  89064. pause(): void;
  89065. /**
  89066. * Restart the animation
  89067. */
  89068. restart(): void;
  89069. private _raiseOnAnimationEnd;
  89070. /**
  89071. * Stop and delete the current animation
  89072. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89073. * @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)
  89074. */
  89075. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89076. /**
  89077. * Wait asynchronously for the animation to end
  89078. * @returns a promise which will be fullfilled when the animation ends
  89079. */
  89080. waitAsync(): Promise<Animatable>;
  89081. /** @hidden */
  89082. _animate(delay: number): boolean;
  89083. }
  89084. interface Scene {
  89085. /** @hidden */
  89086. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89087. /** @hidden */
  89088. _processLateAnimationBindingsForMatrices(holder: {
  89089. totalWeight: number;
  89090. totalAdditiveWeight: number;
  89091. animations: RuntimeAnimation[];
  89092. additiveAnimations: RuntimeAnimation[];
  89093. originalValue: Matrix;
  89094. }): any;
  89095. /** @hidden */
  89096. _processLateAnimationBindingsForQuaternions(holder: {
  89097. totalWeight: number;
  89098. totalAdditiveWeight: number;
  89099. animations: RuntimeAnimation[];
  89100. additiveAnimations: RuntimeAnimation[];
  89101. originalValue: Quaternion;
  89102. }, refQuaternion: Quaternion): Quaternion;
  89103. /** @hidden */
  89104. _processLateAnimationBindings(): void;
  89105. /**
  89106. * Will start the animation sequence of a given target
  89107. * @param target defines the target
  89108. * @param from defines from which frame should animation start
  89109. * @param to defines until which frame should animation run.
  89110. * @param weight defines the weight to apply to the animation (1.0 by default)
  89111. * @param loop defines if the animation loops
  89112. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89113. * @param onAnimationEnd defines the function to be executed when the animation ends
  89114. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89115. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89116. * @param onAnimationLoop defines the callback to call when an animation loops
  89117. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89118. * @returns the animatable object created for this animation
  89119. */
  89120. 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;
  89121. /**
  89122. * Will start the animation sequence of a given target
  89123. * @param target defines the target
  89124. * @param from defines from which frame should animation start
  89125. * @param to defines until which frame should animation run.
  89126. * @param loop defines if the animation loops
  89127. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89128. * @param onAnimationEnd defines the function to be executed when the animation ends
  89129. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89130. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89131. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89132. * @param onAnimationLoop defines the callback to call when an animation loops
  89133. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89134. * @returns the animatable object created for this animation
  89135. */
  89136. 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;
  89137. /**
  89138. * Will start the animation sequence of a given target and its hierarchy
  89139. * @param target defines the target
  89140. * @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.
  89141. * @param from defines from which frame should animation start
  89142. * @param to defines until which frame should animation run.
  89143. * @param loop defines if the animation loops
  89144. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89145. * @param onAnimationEnd defines the function to be executed when the animation ends
  89146. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89147. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89148. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89149. * @param onAnimationLoop defines the callback to call when an animation loops
  89150. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89151. * @returns the list of created animatables
  89152. */
  89153. 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[];
  89154. /**
  89155. * Begin a new animation on a given node
  89156. * @param target defines the target where the animation will take place
  89157. * @param animations defines the list of animations to start
  89158. * @param from defines the initial value
  89159. * @param to defines the final value
  89160. * @param loop defines if you want animation to loop (off by default)
  89161. * @param speedRatio defines the speed ratio to apply to all animations
  89162. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89163. * @param onAnimationLoop defines the callback to call when an animation loops
  89164. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89165. * @returns the list of created animatables
  89166. */
  89167. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89168. /**
  89169. * Begin a new animation on a given node and its hierarchy
  89170. * @param target defines the root node where the animation will take place
  89171. * @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.
  89172. * @param animations defines the list of animations to start
  89173. * @param from defines the initial value
  89174. * @param to defines the final value
  89175. * @param loop defines if you want animation to loop (off by default)
  89176. * @param speedRatio defines the speed ratio to apply to all animations
  89177. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89178. * @param onAnimationLoop defines the callback to call when an animation loops
  89179. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89180. * @returns the list of animatables created for all nodes
  89181. */
  89182. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89183. /**
  89184. * Gets the animatable associated with a specific target
  89185. * @param target defines the target of the animatable
  89186. * @returns the required animatable if found
  89187. */
  89188. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89189. /**
  89190. * Gets all animatables associated with a given target
  89191. * @param target defines the target to look animatables for
  89192. * @returns an array of Animatables
  89193. */
  89194. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89195. /**
  89196. * Stops and removes all animations that have been applied to the scene
  89197. */
  89198. stopAllAnimations(): void;
  89199. /**
  89200. * Gets the current delta time used by animation engine
  89201. */
  89202. deltaTime: number;
  89203. }
  89204. interface Bone {
  89205. /**
  89206. * Copy an animation range from another bone
  89207. * @param source defines the source bone
  89208. * @param rangeName defines the range name to copy
  89209. * @param frameOffset defines the frame offset
  89210. * @param rescaleAsRequired defines if rescaling must be applied if required
  89211. * @param skelDimensionsRatio defines the scaling ratio
  89212. * @returns true if operation was successful
  89213. */
  89214. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89215. }
  89216. }
  89217. declare module BABYLON {
  89218. /**
  89219. * Class used to handle skinning animations
  89220. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89221. */
  89222. export class Skeleton implements IAnimatable {
  89223. /** defines the skeleton name */
  89224. name: string;
  89225. /** defines the skeleton Id */
  89226. id: string;
  89227. /**
  89228. * Defines the list of child bones
  89229. */
  89230. bones: Bone[];
  89231. /**
  89232. * Defines an estimate of the dimension of the skeleton at rest
  89233. */
  89234. dimensionsAtRest: Vector3;
  89235. /**
  89236. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89237. */
  89238. needInitialSkinMatrix: boolean;
  89239. /**
  89240. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89241. */
  89242. overrideMesh: Nullable<AbstractMesh>;
  89243. /**
  89244. * Gets the list of animations attached to this skeleton
  89245. */
  89246. animations: Array<Animation>;
  89247. private _scene;
  89248. private _isDirty;
  89249. private _transformMatrices;
  89250. private _transformMatrixTexture;
  89251. private _meshesWithPoseMatrix;
  89252. private _animatables;
  89253. private _identity;
  89254. private _synchronizedWithMesh;
  89255. private _ranges;
  89256. private _lastAbsoluteTransformsUpdateId;
  89257. private _canUseTextureForBones;
  89258. private _uniqueId;
  89259. /** @hidden */
  89260. _numBonesWithLinkedTransformNode: number;
  89261. /** @hidden */
  89262. _hasWaitingData: Nullable<boolean>;
  89263. /**
  89264. * Specifies if the skeleton should be serialized
  89265. */
  89266. doNotSerialize: boolean;
  89267. private _useTextureToStoreBoneMatrices;
  89268. /**
  89269. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89270. * Please note that this option is not available if the hardware does not support it
  89271. */
  89272. get useTextureToStoreBoneMatrices(): boolean;
  89273. set useTextureToStoreBoneMatrices(value: boolean);
  89274. private _animationPropertiesOverride;
  89275. /**
  89276. * Gets or sets the animation properties override
  89277. */
  89278. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89279. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89280. /**
  89281. * List of inspectable custom properties (used by the Inspector)
  89282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89283. */
  89284. inspectableCustomProperties: IInspectable[];
  89285. /**
  89286. * An observable triggered before computing the skeleton's matrices
  89287. */
  89288. onBeforeComputeObservable: Observable<Skeleton>;
  89289. /**
  89290. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89291. */
  89292. get isUsingTextureForMatrices(): boolean;
  89293. /**
  89294. * Gets the unique ID of this skeleton
  89295. */
  89296. get uniqueId(): number;
  89297. /**
  89298. * Creates a new skeleton
  89299. * @param name defines the skeleton name
  89300. * @param id defines the skeleton Id
  89301. * @param scene defines the hosting scene
  89302. */
  89303. constructor(
  89304. /** defines the skeleton name */
  89305. name: string,
  89306. /** defines the skeleton Id */
  89307. id: string, scene: Scene);
  89308. /**
  89309. * Gets the current object class name.
  89310. * @return the class name
  89311. */
  89312. getClassName(): string;
  89313. /**
  89314. * Returns an array containing the root bones
  89315. * @returns an array containing the root bones
  89316. */
  89317. getChildren(): Array<Bone>;
  89318. /**
  89319. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89320. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89321. * @returns a Float32Array containing matrices data
  89322. */
  89323. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89324. /**
  89325. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89326. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89327. * @returns a raw texture containing the data
  89328. */
  89329. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89330. /**
  89331. * Gets the current hosting scene
  89332. * @returns a scene object
  89333. */
  89334. getScene(): Scene;
  89335. /**
  89336. * Gets a string representing the current skeleton data
  89337. * @param fullDetails defines a boolean indicating if we want a verbose version
  89338. * @returns a string representing the current skeleton data
  89339. */
  89340. toString(fullDetails?: boolean): string;
  89341. /**
  89342. * Get bone's index searching by name
  89343. * @param name defines bone's name to search for
  89344. * @return the indice of the bone. Returns -1 if not found
  89345. */
  89346. getBoneIndexByName(name: string): number;
  89347. /**
  89348. * Creater a new animation range
  89349. * @param name defines the name of the range
  89350. * @param from defines the start key
  89351. * @param to defines the end key
  89352. */
  89353. createAnimationRange(name: string, from: number, to: number): void;
  89354. /**
  89355. * Delete a specific animation range
  89356. * @param name defines the name of the range
  89357. * @param deleteFrames defines if frames must be removed as well
  89358. */
  89359. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89360. /**
  89361. * Gets a specific animation range
  89362. * @param name defines the name of the range to look for
  89363. * @returns the requested animation range or null if not found
  89364. */
  89365. getAnimationRange(name: string): Nullable<AnimationRange>;
  89366. /**
  89367. * Gets the list of all animation ranges defined on this skeleton
  89368. * @returns an array
  89369. */
  89370. getAnimationRanges(): Nullable<AnimationRange>[];
  89371. /**
  89372. * Copy animation range from a source skeleton.
  89373. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89374. * @param source defines the source skeleton
  89375. * @param name defines the name of the range to copy
  89376. * @param rescaleAsRequired defines if rescaling must be applied if required
  89377. * @returns true if operation was successful
  89378. */
  89379. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89380. /**
  89381. * Forces the skeleton to go to rest pose
  89382. */
  89383. returnToRest(): void;
  89384. private _getHighestAnimationFrame;
  89385. /**
  89386. * Begin a specific animation range
  89387. * @param name defines the name of the range to start
  89388. * @param loop defines if looping must be turned on (false by default)
  89389. * @param speedRatio defines the speed ratio to apply (1 by default)
  89390. * @param onAnimationEnd defines a callback which will be called when animation will end
  89391. * @returns a new animatable
  89392. */
  89393. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89394. /**
  89395. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89396. * @param skeleton defines the Skeleton containing the animation range to convert
  89397. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89398. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89399. * @returns the original skeleton
  89400. */
  89401. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89402. /** @hidden */
  89403. _markAsDirty(): void;
  89404. /** @hidden */
  89405. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89406. /** @hidden */
  89407. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89408. private _computeTransformMatrices;
  89409. /**
  89410. * Build all resources required to render a skeleton
  89411. */
  89412. prepare(): void;
  89413. /**
  89414. * Gets the list of animatables currently running for this skeleton
  89415. * @returns an array of animatables
  89416. */
  89417. getAnimatables(): IAnimatable[];
  89418. /**
  89419. * Clone the current skeleton
  89420. * @param name defines the name of the new skeleton
  89421. * @param id defines the id of the new skeleton
  89422. * @returns the new skeleton
  89423. */
  89424. clone(name: string, id?: string): Skeleton;
  89425. /**
  89426. * Enable animation blending for this skeleton
  89427. * @param blendingSpeed defines the blending speed to apply
  89428. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89429. */
  89430. enableBlending(blendingSpeed?: number): void;
  89431. /**
  89432. * Releases all resources associated with the current skeleton
  89433. */
  89434. dispose(): void;
  89435. /**
  89436. * Serialize the skeleton in a JSON object
  89437. * @returns a JSON object
  89438. */
  89439. serialize(): any;
  89440. /**
  89441. * Creates a new skeleton from serialized data
  89442. * @param parsedSkeleton defines the serialized data
  89443. * @param scene defines the hosting scene
  89444. * @returns a new skeleton
  89445. */
  89446. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89447. /**
  89448. * Compute all node absolute transforms
  89449. * @param forceUpdate defines if computation must be done even if cache is up to date
  89450. */
  89451. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89452. /**
  89453. * Gets the root pose matrix
  89454. * @returns a matrix
  89455. */
  89456. getPoseMatrix(): Nullable<Matrix>;
  89457. /**
  89458. * Sorts bones per internal index
  89459. */
  89460. sortBones(): void;
  89461. private _sortBones;
  89462. }
  89463. }
  89464. declare module BABYLON {
  89465. /**
  89466. * Creates an instance based on a source mesh.
  89467. */
  89468. export class InstancedMesh extends AbstractMesh {
  89469. private _sourceMesh;
  89470. private _currentLOD;
  89471. /** @hidden */
  89472. _indexInSourceMeshInstanceArray: number;
  89473. constructor(name: string, source: Mesh);
  89474. /**
  89475. * Returns the string "InstancedMesh".
  89476. */
  89477. getClassName(): string;
  89478. /** Gets the list of lights affecting that mesh */
  89479. get lightSources(): Light[];
  89480. _resyncLightSources(): void;
  89481. _resyncLightSource(light: Light): void;
  89482. _removeLightSource(light: Light, dispose: boolean): void;
  89483. /**
  89484. * If the source mesh receives shadows
  89485. */
  89486. get receiveShadows(): boolean;
  89487. /**
  89488. * The material of the source mesh
  89489. */
  89490. get material(): Nullable<Material>;
  89491. /**
  89492. * Visibility of the source mesh
  89493. */
  89494. get visibility(): number;
  89495. /**
  89496. * Skeleton of the source mesh
  89497. */
  89498. get skeleton(): Nullable<Skeleton>;
  89499. /**
  89500. * Rendering ground id of the source mesh
  89501. */
  89502. get renderingGroupId(): number;
  89503. set renderingGroupId(value: number);
  89504. /**
  89505. * Returns the total number of vertices (integer).
  89506. */
  89507. getTotalVertices(): number;
  89508. /**
  89509. * Returns a positive integer : the total number of indices in this mesh geometry.
  89510. * @returns the numner of indices or zero if the mesh has no geometry.
  89511. */
  89512. getTotalIndices(): number;
  89513. /**
  89514. * The source mesh of the instance
  89515. */
  89516. get sourceMesh(): Mesh;
  89517. /**
  89518. * Is this node ready to be used/rendered
  89519. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89520. * @return {boolean} is it ready
  89521. */
  89522. isReady(completeCheck?: boolean): boolean;
  89523. /**
  89524. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89525. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89526. * @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.
  89527. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89528. */
  89529. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89530. /**
  89531. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89532. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89533. * The `data` are either a numeric array either a Float32Array.
  89534. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89535. * 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).
  89536. * Note that a new underlying VertexBuffer object is created each call.
  89537. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89538. *
  89539. * Possible `kind` values :
  89540. * - VertexBuffer.PositionKind
  89541. * - VertexBuffer.UVKind
  89542. * - VertexBuffer.UV2Kind
  89543. * - VertexBuffer.UV3Kind
  89544. * - VertexBuffer.UV4Kind
  89545. * - VertexBuffer.UV5Kind
  89546. * - VertexBuffer.UV6Kind
  89547. * - VertexBuffer.ColorKind
  89548. * - VertexBuffer.MatricesIndicesKind
  89549. * - VertexBuffer.MatricesIndicesExtraKind
  89550. * - VertexBuffer.MatricesWeightsKind
  89551. * - VertexBuffer.MatricesWeightsExtraKind
  89552. *
  89553. * Returns the Mesh.
  89554. */
  89555. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89556. /**
  89557. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89558. * If the mesh has no geometry, it is simply returned as it is.
  89559. * The `data` are either a numeric array either a Float32Array.
  89560. * No new underlying VertexBuffer object is created.
  89561. * 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.
  89562. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89563. *
  89564. * Possible `kind` values :
  89565. * - VertexBuffer.PositionKind
  89566. * - VertexBuffer.UVKind
  89567. * - VertexBuffer.UV2Kind
  89568. * - VertexBuffer.UV3Kind
  89569. * - VertexBuffer.UV4Kind
  89570. * - VertexBuffer.UV5Kind
  89571. * - VertexBuffer.UV6Kind
  89572. * - VertexBuffer.ColorKind
  89573. * - VertexBuffer.MatricesIndicesKind
  89574. * - VertexBuffer.MatricesIndicesExtraKind
  89575. * - VertexBuffer.MatricesWeightsKind
  89576. * - VertexBuffer.MatricesWeightsExtraKind
  89577. *
  89578. * Returns the Mesh.
  89579. */
  89580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89581. /**
  89582. * Sets the mesh indices.
  89583. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89584. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89585. * This method creates a new index buffer each call.
  89586. * Returns the Mesh.
  89587. */
  89588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89589. /**
  89590. * Boolean : True if the mesh owns the requested kind of data.
  89591. */
  89592. isVerticesDataPresent(kind: string): boolean;
  89593. /**
  89594. * Returns an array of indices (IndicesArray).
  89595. */
  89596. getIndices(): Nullable<IndicesArray>;
  89597. get _positions(): Nullable<Vector3[]>;
  89598. /**
  89599. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89600. * This means the mesh underlying bounding box and sphere are recomputed.
  89601. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89602. * @returns the current mesh
  89603. */
  89604. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89605. /** @hidden */
  89606. _preActivate(): InstancedMesh;
  89607. /** @hidden */
  89608. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89609. /** @hidden */
  89610. _postActivate(): void;
  89611. getWorldMatrix(): Matrix;
  89612. get isAnInstance(): boolean;
  89613. /**
  89614. * Returns the current associated LOD AbstractMesh.
  89615. */
  89616. getLOD(camera: Camera): AbstractMesh;
  89617. /** @hidden */
  89618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89619. /** @hidden */
  89620. _syncSubMeshes(): InstancedMesh;
  89621. /** @hidden */
  89622. _generatePointsArray(): boolean;
  89623. /**
  89624. * Creates a new InstancedMesh from the current mesh.
  89625. * - name (string) : the cloned mesh name
  89626. * - newParent (optional Node) : the optional Node to parent the clone to.
  89627. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89628. *
  89629. * Returns the clone.
  89630. */
  89631. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89632. /**
  89633. * Disposes the InstancedMesh.
  89634. * Returns nothing.
  89635. */
  89636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89637. }
  89638. interface Mesh {
  89639. /**
  89640. * Register a custom buffer that will be instanced
  89641. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89642. * @param kind defines the buffer kind
  89643. * @param stride defines the stride in floats
  89644. */
  89645. registerInstancedBuffer(kind: string, stride: number): void;
  89646. /** @hidden */
  89647. _userInstancedBuffersStorage: {
  89648. data: {
  89649. [key: string]: Float32Array;
  89650. };
  89651. sizes: {
  89652. [key: string]: number;
  89653. };
  89654. vertexBuffers: {
  89655. [key: string]: Nullable<VertexBuffer>;
  89656. };
  89657. strides: {
  89658. [key: string]: number;
  89659. };
  89660. };
  89661. }
  89662. interface AbstractMesh {
  89663. /**
  89664. * Object used to store instanced buffers defined by user
  89665. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89666. */
  89667. instancedBuffers: {
  89668. [key: string]: any;
  89669. };
  89670. }
  89671. }
  89672. declare module BABYLON {
  89673. /**
  89674. * Defines the options associated with the creation of a shader material.
  89675. */
  89676. export interface IShaderMaterialOptions {
  89677. /**
  89678. * Does the material work in alpha blend mode
  89679. */
  89680. needAlphaBlending: boolean;
  89681. /**
  89682. * Does the material work in alpha test mode
  89683. */
  89684. needAlphaTesting: boolean;
  89685. /**
  89686. * The list of attribute names used in the shader
  89687. */
  89688. attributes: string[];
  89689. /**
  89690. * The list of unifrom names used in the shader
  89691. */
  89692. uniforms: string[];
  89693. /**
  89694. * The list of UBO names used in the shader
  89695. */
  89696. uniformBuffers: string[];
  89697. /**
  89698. * The list of sampler names used in the shader
  89699. */
  89700. samplers: string[];
  89701. /**
  89702. * The list of defines used in the shader
  89703. */
  89704. defines: string[];
  89705. }
  89706. /**
  89707. * 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.
  89708. *
  89709. * This returned material effects how the mesh will look based on the code in the shaders.
  89710. *
  89711. * @see http://doc.babylonjs.com/how_to/shader_material
  89712. */
  89713. export class ShaderMaterial extends Material {
  89714. private _shaderPath;
  89715. private _options;
  89716. private _textures;
  89717. private _textureArrays;
  89718. private _floats;
  89719. private _ints;
  89720. private _floatsArrays;
  89721. private _colors3;
  89722. private _colors3Arrays;
  89723. private _colors4;
  89724. private _colors4Arrays;
  89725. private _vectors2;
  89726. private _vectors3;
  89727. private _vectors4;
  89728. private _matrices;
  89729. private _matrixArrays;
  89730. private _matrices3x3;
  89731. private _matrices2x2;
  89732. private _vectors2Arrays;
  89733. private _vectors3Arrays;
  89734. private _vectors4Arrays;
  89735. private _cachedWorldViewMatrix;
  89736. private _cachedWorldViewProjectionMatrix;
  89737. private _renderId;
  89738. private _multiview;
  89739. /**
  89740. * Instantiate a new shader material.
  89741. * 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.
  89742. * This returned material effects how the mesh will look based on the code in the shaders.
  89743. * @see http://doc.babylonjs.com/how_to/shader_material
  89744. * @param name Define the name of the material in the scene
  89745. * @param scene Define the scene the material belongs to
  89746. * @param shaderPath Defines the route to the shader code in one of three ways:
  89747. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89748. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89749. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89750. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89751. * @param options Define the options used to create the shader
  89752. */
  89753. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89754. /**
  89755. * Gets the shader path used to define the shader code
  89756. * It can be modified to trigger a new compilation
  89757. */
  89758. get shaderPath(): any;
  89759. /**
  89760. * Sets the shader path used to define the shader code
  89761. * It can be modified to trigger a new compilation
  89762. */
  89763. set shaderPath(shaderPath: any);
  89764. /**
  89765. * Gets the options used to compile the shader.
  89766. * They can be modified to trigger a new compilation
  89767. */
  89768. get options(): IShaderMaterialOptions;
  89769. /**
  89770. * Gets the current class name of the material e.g. "ShaderMaterial"
  89771. * Mainly use in serialization.
  89772. * @returns the class name
  89773. */
  89774. getClassName(): string;
  89775. /**
  89776. * Specifies if the material will require alpha blending
  89777. * @returns a boolean specifying if alpha blending is needed
  89778. */
  89779. needAlphaBlending(): boolean;
  89780. /**
  89781. * Specifies if this material should be rendered in alpha test mode
  89782. * @returns a boolean specifying if an alpha test is needed.
  89783. */
  89784. needAlphaTesting(): boolean;
  89785. private _checkUniform;
  89786. /**
  89787. * Set a texture in the shader.
  89788. * @param name Define the name of the uniform samplers as defined in the shader
  89789. * @param texture Define the texture to bind to this sampler
  89790. * @return the material itself allowing "fluent" like uniform updates
  89791. */
  89792. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89793. /**
  89794. * Set a texture array in the shader.
  89795. * @param name Define the name of the uniform sampler array as defined in the shader
  89796. * @param textures Define the list of textures to bind to this sampler
  89797. * @return the material itself allowing "fluent" like uniform updates
  89798. */
  89799. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89800. /**
  89801. * Set a float in the shader.
  89802. * @param name Define the name of the uniform as defined in the shader
  89803. * @param value Define the value to give to the uniform
  89804. * @return the material itself allowing "fluent" like uniform updates
  89805. */
  89806. setFloat(name: string, value: number): ShaderMaterial;
  89807. /**
  89808. * Set a int in the shader.
  89809. * @param name Define the name of the uniform as defined in the shader
  89810. * @param value Define the value to give to the uniform
  89811. * @return the material itself allowing "fluent" like uniform updates
  89812. */
  89813. setInt(name: string, value: number): ShaderMaterial;
  89814. /**
  89815. * Set an array of floats in the shader.
  89816. * @param name Define the name of the uniform as defined in the shader
  89817. * @param value Define the value to give to the uniform
  89818. * @return the material itself allowing "fluent" like uniform updates
  89819. */
  89820. setFloats(name: string, value: number[]): ShaderMaterial;
  89821. /**
  89822. * Set a vec3 in the shader from a Color3.
  89823. * @param name Define the name of the uniform as defined in the shader
  89824. * @param value Define the value to give to the uniform
  89825. * @return the material itself allowing "fluent" like uniform updates
  89826. */
  89827. setColor3(name: string, value: Color3): ShaderMaterial;
  89828. /**
  89829. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89835. /**
  89836. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  89842. /**
  89843. * Set a vec4 array in the shader from a Color4 array.
  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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89849. /**
  89850. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  89856. /**
  89857. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  89863. /**
  89864. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  89870. /**
  89871. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89877. /**
  89878. * Set a float32Array in the shader from a matrix array.
  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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89884. /**
  89885. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89891. /**
  89892. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89898. /**
  89899. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  89905. /**
  89906. * Set a vec3 array in the shader from a number 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. setArray3(name: string, value: number[]): ShaderMaterial;
  89912. /**
  89913. * Set a vec4 array in the shader from a number array.
  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. setArray4(name: string, value: number[]): ShaderMaterial;
  89919. private _checkCache;
  89920. /**
  89921. * Specifies that the submesh is ready to be used
  89922. * @param mesh defines the mesh to check
  89923. * @param subMesh defines which submesh to check
  89924. * @param useInstances specifies that instances should be used
  89925. * @returns a boolean indicating that the submesh is ready or not
  89926. */
  89927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89928. /**
  89929. * Checks if the material is ready to render the requested mesh
  89930. * @param mesh Define the mesh to render
  89931. * @param useInstances Define whether or not the material is used with instances
  89932. * @returns true if ready, otherwise false
  89933. */
  89934. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89935. /**
  89936. * Binds the world matrix to the material
  89937. * @param world defines the world transformation matrix
  89938. */
  89939. bindOnlyWorldMatrix(world: Matrix): void;
  89940. /**
  89941. * Binds the material to the mesh
  89942. * @param world defines the world transformation matrix
  89943. * @param mesh defines the mesh to bind the material to
  89944. */
  89945. bind(world: Matrix, mesh?: Mesh): void;
  89946. /**
  89947. * Gets the active textures from the material
  89948. * @returns an array of textures
  89949. */
  89950. getActiveTextures(): BaseTexture[];
  89951. /**
  89952. * Specifies if the material uses a texture
  89953. * @param texture defines the texture to check against the material
  89954. * @returns a boolean specifying if the material uses the texture
  89955. */
  89956. hasTexture(texture: BaseTexture): boolean;
  89957. /**
  89958. * Makes a duplicate of the material, and gives it a new name
  89959. * @param name defines the new name for the duplicated material
  89960. * @returns the cloned material
  89961. */
  89962. clone(name: string): ShaderMaterial;
  89963. /**
  89964. * Disposes the material
  89965. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89966. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89967. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89968. */
  89969. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89970. /**
  89971. * Serializes this material in a JSON representation
  89972. * @returns the serialized material object
  89973. */
  89974. serialize(): any;
  89975. /**
  89976. * Creates a shader material from parsed shader material data
  89977. * @param source defines the JSON represnetation of the material
  89978. * @param scene defines the hosting scene
  89979. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89980. * @returns a new material
  89981. */
  89982. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89983. }
  89984. }
  89985. declare module BABYLON {
  89986. /** @hidden */
  89987. export var colorPixelShader: {
  89988. name: string;
  89989. shader: string;
  89990. };
  89991. }
  89992. declare module BABYLON {
  89993. /** @hidden */
  89994. export var colorVertexShader: {
  89995. name: string;
  89996. shader: string;
  89997. };
  89998. }
  89999. declare module BABYLON {
  90000. /**
  90001. * Line mesh
  90002. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90003. */
  90004. export class LinesMesh extends Mesh {
  90005. /**
  90006. * If vertex color should be applied to the mesh
  90007. */
  90008. readonly useVertexColor?: boolean | undefined;
  90009. /**
  90010. * If vertex alpha should be applied to the mesh
  90011. */
  90012. readonly useVertexAlpha?: boolean | undefined;
  90013. /**
  90014. * Color of the line (Default: White)
  90015. */
  90016. color: Color3;
  90017. /**
  90018. * Alpha of the line (Default: 1)
  90019. */
  90020. alpha: number;
  90021. /**
  90022. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90023. * This margin is expressed in world space coordinates, so its value may vary.
  90024. * Default value is 0.1
  90025. */
  90026. intersectionThreshold: number;
  90027. private _colorShader;
  90028. private color4;
  90029. /**
  90030. * Creates a new LinesMesh
  90031. * @param name defines the name
  90032. * @param scene defines the hosting scene
  90033. * @param parent defines the parent mesh if any
  90034. * @param source defines the optional source LinesMesh used to clone data from
  90035. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90036. * When false, achieved by calling a clone(), also passing False.
  90037. * This will make creation of children, recursive.
  90038. * @param useVertexColor defines if this LinesMesh supports vertex color
  90039. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90040. */
  90041. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90042. /**
  90043. * If vertex color should be applied to the mesh
  90044. */
  90045. useVertexColor?: boolean | undefined,
  90046. /**
  90047. * If vertex alpha should be applied to the mesh
  90048. */
  90049. useVertexAlpha?: boolean | undefined);
  90050. private _addClipPlaneDefine;
  90051. private _removeClipPlaneDefine;
  90052. isReady(): boolean;
  90053. /**
  90054. * Returns the string "LineMesh"
  90055. */
  90056. getClassName(): string;
  90057. /**
  90058. * @hidden
  90059. */
  90060. get material(): Material;
  90061. /**
  90062. * @hidden
  90063. */
  90064. set material(value: Material);
  90065. /**
  90066. * @hidden
  90067. */
  90068. get checkCollisions(): boolean;
  90069. /** @hidden */
  90070. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90071. /** @hidden */
  90072. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90073. /**
  90074. * Disposes of the line mesh
  90075. * @param doNotRecurse If children should be disposed
  90076. */
  90077. dispose(doNotRecurse?: boolean): void;
  90078. /**
  90079. * Returns a new LineMesh object cloned from the current one.
  90080. */
  90081. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90082. /**
  90083. * Creates a new InstancedLinesMesh object from the mesh model.
  90084. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90085. * @param name defines the name of the new instance
  90086. * @returns a new InstancedLinesMesh
  90087. */
  90088. createInstance(name: string): InstancedLinesMesh;
  90089. }
  90090. /**
  90091. * Creates an instance based on a source LinesMesh
  90092. */
  90093. export class InstancedLinesMesh extends InstancedMesh {
  90094. /**
  90095. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90096. * This margin is expressed in world space coordinates, so its value may vary.
  90097. * Initilized with the intersectionThreshold value of the source LinesMesh
  90098. */
  90099. intersectionThreshold: number;
  90100. constructor(name: string, source: LinesMesh);
  90101. /**
  90102. * Returns the string "InstancedLinesMesh".
  90103. */
  90104. getClassName(): string;
  90105. }
  90106. }
  90107. declare module BABYLON {
  90108. /** @hidden */
  90109. export var linePixelShader: {
  90110. name: string;
  90111. shader: string;
  90112. };
  90113. }
  90114. declare module BABYLON {
  90115. /** @hidden */
  90116. export var lineVertexShader: {
  90117. name: string;
  90118. shader: string;
  90119. };
  90120. }
  90121. declare module BABYLON {
  90122. interface AbstractMesh {
  90123. /**
  90124. * Gets the edgesRenderer associated with the mesh
  90125. */
  90126. edgesRenderer: Nullable<EdgesRenderer>;
  90127. }
  90128. interface LinesMesh {
  90129. /**
  90130. * Enables the edge rendering mode on the mesh.
  90131. * This mode makes the mesh edges visible
  90132. * @param epsilon defines the maximal distance between two angles to detect a face
  90133. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90134. * @returns the currentAbstractMesh
  90135. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90136. */
  90137. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90138. }
  90139. interface InstancedLinesMesh {
  90140. /**
  90141. * Enables the edge rendering mode on the mesh.
  90142. * This mode makes the mesh edges visible
  90143. * @param epsilon defines the maximal distance between two angles to detect a face
  90144. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90145. * @returns the current InstancedLinesMesh
  90146. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90147. */
  90148. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90149. }
  90150. /**
  90151. * Defines the minimum contract an Edges renderer should follow.
  90152. */
  90153. export interface IEdgesRenderer extends IDisposable {
  90154. /**
  90155. * Gets or sets a boolean indicating if the edgesRenderer is active
  90156. */
  90157. isEnabled: boolean;
  90158. /**
  90159. * Renders the edges of the attached mesh,
  90160. */
  90161. render(): void;
  90162. /**
  90163. * Checks wether or not the edges renderer is ready to render.
  90164. * @return true if ready, otherwise false.
  90165. */
  90166. isReady(): boolean;
  90167. }
  90168. /**
  90169. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90170. */
  90171. export class EdgesRenderer implements IEdgesRenderer {
  90172. /**
  90173. * Define the size of the edges with an orthographic camera
  90174. */
  90175. edgesWidthScalerForOrthographic: number;
  90176. /**
  90177. * Define the size of the edges with a perspective camera
  90178. */
  90179. edgesWidthScalerForPerspective: number;
  90180. protected _source: AbstractMesh;
  90181. protected _linesPositions: number[];
  90182. protected _linesNormals: number[];
  90183. protected _linesIndices: number[];
  90184. protected _epsilon: number;
  90185. protected _indicesCount: number;
  90186. protected _lineShader: ShaderMaterial;
  90187. protected _ib: DataBuffer;
  90188. protected _buffers: {
  90189. [key: string]: Nullable<VertexBuffer>;
  90190. };
  90191. protected _checkVerticesInsteadOfIndices: boolean;
  90192. private _meshRebuildObserver;
  90193. private _meshDisposeObserver;
  90194. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90195. isEnabled: boolean;
  90196. /**
  90197. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90198. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90199. * @param source Mesh used to create edges
  90200. * @param epsilon sum of angles in adjacency to check for edge
  90201. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90202. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90203. */
  90204. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90205. protected _prepareRessources(): void;
  90206. /** @hidden */
  90207. _rebuild(): void;
  90208. /**
  90209. * Releases the required resources for the edges renderer
  90210. */
  90211. dispose(): void;
  90212. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90213. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90214. /**
  90215. * Checks if the pair of p0 and p1 is en edge
  90216. * @param faceIndex
  90217. * @param edge
  90218. * @param faceNormals
  90219. * @param p0
  90220. * @param p1
  90221. * @private
  90222. */
  90223. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90224. /**
  90225. * push line into the position, normal and index buffer
  90226. * @protected
  90227. */
  90228. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90229. /**
  90230. * Generates lines edges from adjacencjes
  90231. * @private
  90232. */
  90233. _generateEdgesLines(): void;
  90234. /**
  90235. * Checks wether or not the edges renderer is ready to render.
  90236. * @return true if ready, otherwise false.
  90237. */
  90238. isReady(): boolean;
  90239. /**
  90240. * Renders the edges of the attached mesh,
  90241. */
  90242. render(): void;
  90243. }
  90244. /**
  90245. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90246. */
  90247. export class LineEdgesRenderer extends EdgesRenderer {
  90248. /**
  90249. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90250. * @param source LineMesh used to generate edges
  90251. * @param epsilon not important (specified angle for edge detection)
  90252. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90253. */
  90254. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90255. /**
  90256. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90257. */
  90258. _generateEdgesLines(): void;
  90259. }
  90260. }
  90261. declare module BABYLON {
  90262. /**
  90263. * This represents the object necessary to create a rendering group.
  90264. * This is exclusively used and created by the rendering manager.
  90265. * To modify the behavior, you use the available helpers in your scene or meshes.
  90266. * @hidden
  90267. */
  90268. export class RenderingGroup {
  90269. index: number;
  90270. private static _zeroVector;
  90271. private _scene;
  90272. private _opaqueSubMeshes;
  90273. private _transparentSubMeshes;
  90274. private _alphaTestSubMeshes;
  90275. private _depthOnlySubMeshes;
  90276. private _particleSystems;
  90277. private _spriteManagers;
  90278. private _opaqueSortCompareFn;
  90279. private _alphaTestSortCompareFn;
  90280. private _transparentSortCompareFn;
  90281. private _renderOpaque;
  90282. private _renderAlphaTest;
  90283. private _renderTransparent;
  90284. /** @hidden */
  90285. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90286. onBeforeTransparentRendering: () => void;
  90287. /**
  90288. * Set the opaque sort comparison function.
  90289. * If null the sub meshes will be render in the order they were created
  90290. */
  90291. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90292. /**
  90293. * Set the alpha test sort comparison function.
  90294. * If null the sub meshes will be render in the order they were created
  90295. */
  90296. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90297. /**
  90298. * Set the transparent sort comparison function.
  90299. * If null the sub meshes will be render in the order they were created
  90300. */
  90301. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90302. /**
  90303. * Creates a new rendering group.
  90304. * @param index The rendering group index
  90305. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90306. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90307. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90308. */
  90309. 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>);
  90310. /**
  90311. * Render all the sub meshes contained in the group.
  90312. * @param customRenderFunction Used to override the default render behaviour of the group.
  90313. * @returns true if rendered some submeshes.
  90314. */
  90315. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90316. /**
  90317. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90318. * @param subMeshes The submeshes to render
  90319. */
  90320. private renderOpaqueSorted;
  90321. /**
  90322. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90323. * @param subMeshes The submeshes to render
  90324. */
  90325. private renderAlphaTestSorted;
  90326. /**
  90327. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90328. * @param subMeshes The submeshes to render
  90329. */
  90330. private renderTransparentSorted;
  90331. /**
  90332. * Renders the submeshes in a specified order.
  90333. * @param subMeshes The submeshes to sort before render
  90334. * @param sortCompareFn The comparison function use to sort
  90335. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90336. * @param transparent Specifies to activate blending if true
  90337. */
  90338. private static renderSorted;
  90339. /**
  90340. * Renders the submeshes in the order they were dispatched (no sort applied).
  90341. * @param subMeshes The submeshes to render
  90342. */
  90343. private static renderUnsorted;
  90344. /**
  90345. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90346. * are rendered back to front if in the same alpha index.
  90347. *
  90348. * @param a The first submesh
  90349. * @param b The second submesh
  90350. * @returns The result of the comparison
  90351. */
  90352. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90353. /**
  90354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90355. * are rendered back to front.
  90356. *
  90357. * @param a The first submesh
  90358. * @param b The second submesh
  90359. * @returns The result of the comparison
  90360. */
  90361. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90362. /**
  90363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90364. * are rendered front to back (prevent overdraw).
  90365. *
  90366. * @param a The first submesh
  90367. * @param b The second submesh
  90368. * @returns The result of the comparison
  90369. */
  90370. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90371. /**
  90372. * Resets the different lists of submeshes to prepare a new frame.
  90373. */
  90374. prepare(): void;
  90375. dispose(): void;
  90376. /**
  90377. * Inserts the submesh in its correct queue depending on its material.
  90378. * @param subMesh The submesh to dispatch
  90379. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90380. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90381. */
  90382. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90383. dispatchSprites(spriteManager: ISpriteManager): void;
  90384. dispatchParticles(particleSystem: IParticleSystem): void;
  90385. private _renderParticles;
  90386. private _renderSprites;
  90387. }
  90388. }
  90389. declare module BABYLON {
  90390. /**
  90391. * Interface describing the different options available in the rendering manager
  90392. * regarding Auto Clear between groups.
  90393. */
  90394. export interface IRenderingManagerAutoClearSetup {
  90395. /**
  90396. * Defines whether or not autoclear is enable.
  90397. */
  90398. autoClear: boolean;
  90399. /**
  90400. * Defines whether or not to autoclear the depth buffer.
  90401. */
  90402. depth: boolean;
  90403. /**
  90404. * Defines whether or not to autoclear the stencil buffer.
  90405. */
  90406. stencil: boolean;
  90407. }
  90408. /**
  90409. * This class is used by the onRenderingGroupObservable
  90410. */
  90411. export class RenderingGroupInfo {
  90412. /**
  90413. * The Scene that being rendered
  90414. */
  90415. scene: Scene;
  90416. /**
  90417. * The camera currently used for the rendering pass
  90418. */
  90419. camera: Nullable<Camera>;
  90420. /**
  90421. * The ID of the renderingGroup being processed
  90422. */
  90423. renderingGroupId: number;
  90424. }
  90425. /**
  90426. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90427. * It is enable to manage the different groups as well as the different necessary sort functions.
  90428. * This should not be used directly aside of the few static configurations
  90429. */
  90430. export class RenderingManager {
  90431. /**
  90432. * The max id used for rendering groups (not included)
  90433. */
  90434. static MAX_RENDERINGGROUPS: number;
  90435. /**
  90436. * The min id used for rendering groups (included)
  90437. */
  90438. static MIN_RENDERINGGROUPS: number;
  90439. /**
  90440. * Used to globally prevent autoclearing scenes.
  90441. */
  90442. static AUTOCLEAR: boolean;
  90443. /**
  90444. * @hidden
  90445. */
  90446. _useSceneAutoClearSetup: boolean;
  90447. private _scene;
  90448. private _renderingGroups;
  90449. private _depthStencilBufferAlreadyCleaned;
  90450. private _autoClearDepthStencil;
  90451. private _customOpaqueSortCompareFn;
  90452. private _customAlphaTestSortCompareFn;
  90453. private _customTransparentSortCompareFn;
  90454. private _renderingGroupInfo;
  90455. /**
  90456. * Instantiates a new rendering group for a particular scene
  90457. * @param scene Defines the scene the groups belongs to
  90458. */
  90459. constructor(scene: Scene);
  90460. private _clearDepthStencilBuffer;
  90461. /**
  90462. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90463. * @hidden
  90464. */
  90465. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90466. /**
  90467. * Resets the different information of the group to prepare a new frame
  90468. * @hidden
  90469. */
  90470. reset(): void;
  90471. /**
  90472. * Dispose and release the group and its associated resources.
  90473. * @hidden
  90474. */
  90475. dispose(): void;
  90476. /**
  90477. * Clear the info related to rendering groups preventing retention points during dispose.
  90478. */
  90479. freeRenderingGroups(): void;
  90480. private _prepareRenderingGroup;
  90481. /**
  90482. * Add a sprite manager to the rendering manager in order to render it this frame.
  90483. * @param spriteManager Define the sprite manager to render
  90484. */
  90485. dispatchSprites(spriteManager: ISpriteManager): void;
  90486. /**
  90487. * Add a particle system to the rendering manager in order to render it this frame.
  90488. * @param particleSystem Define the particle system to render
  90489. */
  90490. dispatchParticles(particleSystem: IParticleSystem): void;
  90491. /**
  90492. * Add a submesh to the manager in order to render it this frame
  90493. * @param subMesh The submesh to dispatch
  90494. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90495. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90496. */
  90497. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90498. /**
  90499. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90500. * This allowed control for front to back rendering or reversly depending of the special needs.
  90501. *
  90502. * @param renderingGroupId The rendering group id corresponding to its index
  90503. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90504. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90505. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90506. */
  90507. 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;
  90508. /**
  90509. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90510. *
  90511. * @param renderingGroupId The rendering group id corresponding to its index
  90512. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90513. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90514. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90515. */
  90516. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90517. /**
  90518. * Gets the current auto clear configuration for one rendering group of the rendering
  90519. * manager.
  90520. * @param index the rendering group index to get the information for
  90521. * @returns The auto clear setup for the requested rendering group
  90522. */
  90523. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90524. }
  90525. }
  90526. declare module BABYLON {
  90527. /**
  90528. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90529. */
  90530. export interface ICustomShaderOptions {
  90531. /**
  90532. * Gets or sets the custom shader name to use
  90533. */
  90534. shaderName: string;
  90535. /**
  90536. * The list of attribute names used in the shader
  90537. */
  90538. attributes?: string[];
  90539. /**
  90540. * The list of unifrom names used in the shader
  90541. */
  90542. uniforms?: string[];
  90543. /**
  90544. * The list of sampler names used in the shader
  90545. */
  90546. samplers?: string[];
  90547. /**
  90548. * The list of defines used in the shader
  90549. */
  90550. defines?: string[];
  90551. }
  90552. /**
  90553. * Interface to implement to create a shadow generator compatible with BJS.
  90554. */
  90555. export interface IShadowGenerator {
  90556. /**
  90557. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90558. * @returns The render target texture if present otherwise, null
  90559. */
  90560. getShadowMap(): Nullable<RenderTargetTexture>;
  90561. /**
  90562. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90563. * @param subMesh The submesh we want to render in the shadow map
  90564. * @param useInstances Defines wether will draw in the map using instances
  90565. * @returns true if ready otherwise, false
  90566. */
  90567. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90568. /**
  90569. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90570. * @param defines Defines of the material we want to update
  90571. * @param lightIndex Index of the light in the enabled light list of the material
  90572. */
  90573. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90574. /**
  90575. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90576. * defined in the generator but impacting the effect).
  90577. * It implies the unifroms available on the materials are the standard BJS ones.
  90578. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90579. * @param effect The effect we are binfing the information for
  90580. */
  90581. bindShadowLight(lightIndex: string, effect: Effect): void;
  90582. /**
  90583. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90584. * (eq to shadow prjection matrix * light transform matrix)
  90585. * @returns The transform matrix used to create the shadow map
  90586. */
  90587. getTransformMatrix(): Matrix;
  90588. /**
  90589. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90590. * Cube and 2D textures for instance.
  90591. */
  90592. recreateShadowMap(): void;
  90593. /**
  90594. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90595. * @param onCompiled Callback triggered at the and of the effects compilation
  90596. * @param options Sets of optional options forcing the compilation with different modes
  90597. */
  90598. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90599. useInstances: boolean;
  90600. }>): void;
  90601. /**
  90602. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90603. * @param options Sets of optional options forcing the compilation with different modes
  90604. * @returns A promise that resolves when the compilation completes
  90605. */
  90606. forceCompilationAsync(options?: Partial<{
  90607. useInstances: boolean;
  90608. }>): Promise<void>;
  90609. /**
  90610. * Serializes the shadow generator setup to a json object.
  90611. * @returns The serialized JSON object
  90612. */
  90613. serialize(): any;
  90614. /**
  90615. * Disposes the Shadow map and related Textures and effects.
  90616. */
  90617. dispose(): void;
  90618. }
  90619. /**
  90620. * Default implementation IShadowGenerator.
  90621. * This is the main object responsible of generating shadows in the framework.
  90622. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90623. */
  90624. export class ShadowGenerator implements IShadowGenerator {
  90625. /**
  90626. * Name of the shadow generator class
  90627. */
  90628. static CLASSNAME: string;
  90629. /**
  90630. * Shadow generator mode None: no filtering applied.
  90631. */
  90632. static readonly FILTER_NONE: number;
  90633. /**
  90634. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90635. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90636. */
  90637. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90638. /**
  90639. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90640. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90641. */
  90642. static readonly FILTER_POISSONSAMPLING: number;
  90643. /**
  90644. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90645. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90646. */
  90647. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90648. /**
  90649. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90650. * edge artifacts on steep falloff.
  90651. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90652. */
  90653. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90654. /**
  90655. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90656. * edge artifacts on steep falloff.
  90657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90658. */
  90659. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90660. /**
  90661. * Shadow generator mode PCF: Percentage Closer Filtering
  90662. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90663. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90664. */
  90665. static readonly FILTER_PCF: number;
  90666. /**
  90667. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90668. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90669. * Contact Hardening
  90670. */
  90671. static readonly FILTER_PCSS: number;
  90672. /**
  90673. * Reserved for PCF and PCSS
  90674. * Highest Quality.
  90675. *
  90676. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90677. *
  90678. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90679. */
  90680. static readonly QUALITY_HIGH: number;
  90681. /**
  90682. * Reserved for PCF and PCSS
  90683. * Good tradeoff for quality/perf cross devices
  90684. *
  90685. * Execute PCF on a 3*3 kernel.
  90686. *
  90687. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90688. */
  90689. static readonly QUALITY_MEDIUM: number;
  90690. /**
  90691. * Reserved for PCF and PCSS
  90692. * The lowest quality but the fastest.
  90693. *
  90694. * Execute PCF on a 1*1 kernel.
  90695. *
  90696. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90697. */
  90698. static readonly QUALITY_LOW: number;
  90699. /** Gets or sets the custom shader name to use */
  90700. customShaderOptions: ICustomShaderOptions;
  90701. /**
  90702. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90703. */
  90704. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90705. /**
  90706. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90707. */
  90708. onAfterShadowMapRenderObservable: Observable<Effect>;
  90709. /**
  90710. * Observable triggered before a mesh is rendered in the shadow map.
  90711. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90712. */
  90713. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90714. /**
  90715. * Observable triggered after a mesh is rendered in the shadow map.
  90716. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90717. */
  90718. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90719. protected _bias: number;
  90720. /**
  90721. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90722. */
  90723. get bias(): number;
  90724. /**
  90725. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90726. */
  90727. set bias(bias: number);
  90728. protected _normalBias: number;
  90729. /**
  90730. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90731. */
  90732. get normalBias(): number;
  90733. /**
  90734. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90735. */
  90736. set normalBias(normalBias: number);
  90737. protected _blurBoxOffset: number;
  90738. /**
  90739. * Gets the blur box offset: offset applied during the blur pass.
  90740. * Only useful if useKernelBlur = false
  90741. */
  90742. get blurBoxOffset(): number;
  90743. /**
  90744. * Sets the blur box offset: offset applied during the blur pass.
  90745. * Only useful if useKernelBlur = false
  90746. */
  90747. set blurBoxOffset(value: number);
  90748. protected _blurScale: number;
  90749. /**
  90750. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90751. * 2 means half of the size.
  90752. */
  90753. get blurScale(): number;
  90754. /**
  90755. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90756. * 2 means half of the size.
  90757. */
  90758. set blurScale(value: number);
  90759. protected _blurKernel: number;
  90760. /**
  90761. * Gets the blur kernel: kernel size of the blur pass.
  90762. * Only useful if useKernelBlur = true
  90763. */
  90764. get blurKernel(): number;
  90765. /**
  90766. * Sets the blur kernel: kernel size of the blur pass.
  90767. * Only useful if useKernelBlur = true
  90768. */
  90769. set blurKernel(value: number);
  90770. protected _useKernelBlur: boolean;
  90771. /**
  90772. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90773. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90774. */
  90775. get useKernelBlur(): boolean;
  90776. /**
  90777. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90778. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90779. */
  90780. set useKernelBlur(value: boolean);
  90781. protected _depthScale: number;
  90782. /**
  90783. * Gets the depth scale used in ESM mode.
  90784. */
  90785. get depthScale(): number;
  90786. /**
  90787. * Sets the depth scale used in ESM mode.
  90788. * This can override the scale stored on the light.
  90789. */
  90790. set depthScale(value: number);
  90791. protected _validateFilter(filter: number): number;
  90792. protected _filter: number;
  90793. /**
  90794. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90795. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90796. */
  90797. get filter(): number;
  90798. /**
  90799. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90800. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90801. */
  90802. set filter(value: number);
  90803. /**
  90804. * Gets if the current filter is set to Poisson Sampling.
  90805. */
  90806. get usePoissonSampling(): boolean;
  90807. /**
  90808. * Sets the current filter to Poisson Sampling.
  90809. */
  90810. set usePoissonSampling(value: boolean);
  90811. /**
  90812. * Gets if the current filter is set to ESM.
  90813. */
  90814. get useExponentialShadowMap(): boolean;
  90815. /**
  90816. * Sets the current filter is to ESM.
  90817. */
  90818. set useExponentialShadowMap(value: boolean);
  90819. /**
  90820. * Gets if the current filter is set to filtered ESM.
  90821. */
  90822. get useBlurExponentialShadowMap(): boolean;
  90823. /**
  90824. * Gets if the current filter is set to filtered ESM.
  90825. */
  90826. set useBlurExponentialShadowMap(value: boolean);
  90827. /**
  90828. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90829. * exponential to prevent steep falloff artifacts).
  90830. */
  90831. get useCloseExponentialShadowMap(): boolean;
  90832. /**
  90833. * Sets the current filter to "close ESM" (using the inverse of the
  90834. * exponential to prevent steep falloff artifacts).
  90835. */
  90836. set useCloseExponentialShadowMap(value: boolean);
  90837. /**
  90838. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90839. * exponential to prevent steep falloff artifacts).
  90840. */
  90841. get useBlurCloseExponentialShadowMap(): boolean;
  90842. /**
  90843. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90844. * exponential to prevent steep falloff artifacts).
  90845. */
  90846. set useBlurCloseExponentialShadowMap(value: boolean);
  90847. /**
  90848. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90849. */
  90850. get usePercentageCloserFiltering(): boolean;
  90851. /**
  90852. * Sets the current filter to "PCF" (percentage closer filtering).
  90853. */
  90854. set usePercentageCloserFiltering(value: boolean);
  90855. protected _filteringQuality: number;
  90856. /**
  90857. * Gets the PCF or PCSS Quality.
  90858. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90859. */
  90860. get filteringQuality(): number;
  90861. /**
  90862. * Sets the PCF or PCSS Quality.
  90863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90864. */
  90865. set filteringQuality(filteringQuality: number);
  90866. /**
  90867. * Gets if the current filter is set to "PCSS" (contact hardening).
  90868. */
  90869. get useContactHardeningShadow(): boolean;
  90870. /**
  90871. * Sets the current filter to "PCSS" (contact hardening).
  90872. */
  90873. set useContactHardeningShadow(value: boolean);
  90874. protected _contactHardeningLightSizeUVRatio: number;
  90875. /**
  90876. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90877. * Using a ratio helps keeping shape stability independently of the map size.
  90878. *
  90879. * It does not account for the light projection as it was having too much
  90880. * instability during the light setup or during light position changes.
  90881. *
  90882. * Only valid if useContactHardeningShadow is true.
  90883. */
  90884. get contactHardeningLightSizeUVRatio(): number;
  90885. /**
  90886. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90887. * Using a ratio helps keeping shape stability independently of the map size.
  90888. *
  90889. * It does not account for the light projection as it was having too much
  90890. * instability during the light setup or during light position changes.
  90891. *
  90892. * Only valid if useContactHardeningShadow is true.
  90893. */
  90894. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90895. protected _darkness: number;
  90896. /** Gets or sets the actual darkness of a shadow */
  90897. get darkness(): number;
  90898. set darkness(value: number);
  90899. /**
  90900. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90901. * 0 means strongest and 1 would means no shadow.
  90902. * @returns the darkness.
  90903. */
  90904. getDarkness(): number;
  90905. /**
  90906. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90907. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90908. * @returns the shadow generator allowing fluent coding.
  90909. */
  90910. setDarkness(darkness: number): ShadowGenerator;
  90911. protected _transparencyShadow: boolean;
  90912. /** Gets or sets the ability to have transparent shadow */
  90913. get transparencyShadow(): boolean;
  90914. set transparencyShadow(value: boolean);
  90915. /**
  90916. * Sets the ability to have transparent shadow (boolean).
  90917. * @param transparent True if transparent else False
  90918. * @returns the shadow generator allowing fluent coding
  90919. */
  90920. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90921. protected _shadowMap: Nullable<RenderTargetTexture>;
  90922. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90923. /**
  90924. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90925. * @returns The render target texture if present otherwise, null
  90926. */
  90927. getShadowMap(): Nullable<RenderTargetTexture>;
  90928. /**
  90929. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90930. * @returns The render target texture if the shadow map is present otherwise, null
  90931. */
  90932. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90933. /**
  90934. * Gets the class name of that object
  90935. * @returns "ShadowGenerator"
  90936. */
  90937. getClassName(): string;
  90938. /**
  90939. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90940. * @param mesh Mesh to add
  90941. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90942. * @returns the Shadow Generator itself
  90943. */
  90944. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90945. /**
  90946. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90947. * @param mesh Mesh to remove
  90948. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90949. * @returns the Shadow Generator itself
  90950. */
  90951. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90952. /**
  90953. * Controls the extent to which the shadows fade out at the edge of the frustum
  90954. */
  90955. frustumEdgeFalloff: number;
  90956. protected _light: IShadowLight;
  90957. /**
  90958. * Returns the associated light object.
  90959. * @returns the light generating the shadow
  90960. */
  90961. getLight(): IShadowLight;
  90962. /**
  90963. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90964. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90965. * It might on the other hand introduce peter panning.
  90966. */
  90967. forceBackFacesOnly: boolean;
  90968. protected _scene: Scene;
  90969. protected _lightDirection: Vector3;
  90970. protected _effect: Effect;
  90971. protected _viewMatrix: Matrix;
  90972. protected _projectionMatrix: Matrix;
  90973. protected _transformMatrix: Matrix;
  90974. protected _cachedPosition: Vector3;
  90975. protected _cachedDirection: Vector3;
  90976. protected _cachedDefines: string;
  90977. protected _currentRenderID: number;
  90978. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90979. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90980. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90981. protected _blurPostProcesses: PostProcess[];
  90982. protected _mapSize: number;
  90983. protected _currentFaceIndex: number;
  90984. protected _currentFaceIndexCache: number;
  90985. protected _textureType: number;
  90986. protected _defaultTextureMatrix: Matrix;
  90987. protected _storedUniqueId: Nullable<number>;
  90988. /** @hidden */
  90989. static _SceneComponentInitialization: (scene: Scene) => void;
  90990. /**
  90991. * Creates a ShadowGenerator object.
  90992. * A ShadowGenerator is the required tool to use the shadows.
  90993. * Each light casting shadows needs to use its own ShadowGenerator.
  90994. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90995. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90996. * @param light The light object generating the shadows.
  90997. * @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.
  90998. */
  90999. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91000. protected _initializeGenerator(): void;
  91001. protected _createTargetRenderTexture(): void;
  91002. protected _initializeShadowMap(): void;
  91003. protected _initializeBlurRTTAndPostProcesses(): void;
  91004. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91005. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91006. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91007. protected _applyFilterValues(): void;
  91008. /**
  91009. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91010. * @param onCompiled Callback triggered at the and of the effects compilation
  91011. * @param options Sets of optional options forcing the compilation with different modes
  91012. */
  91013. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91014. useInstances: boolean;
  91015. }>): void;
  91016. /**
  91017. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91018. * @param options Sets of optional options forcing the compilation with different modes
  91019. * @returns A promise that resolves when the compilation completes
  91020. */
  91021. forceCompilationAsync(options?: Partial<{
  91022. useInstances: boolean;
  91023. }>): Promise<void>;
  91024. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91025. /**
  91026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91027. * @param subMesh The submesh we want to render in the shadow map
  91028. * @param useInstances Defines wether will draw in the map using instances
  91029. * @returns true if ready otherwise, false
  91030. */
  91031. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91032. /**
  91033. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91034. * @param defines Defines of the material we want to update
  91035. * @param lightIndex Index of the light in the enabled light list of the material
  91036. */
  91037. prepareDefines(defines: any, lightIndex: number): void;
  91038. /**
  91039. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91040. * defined in the generator but impacting the effect).
  91041. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91042. * @param effect The effect we are binfing the information for
  91043. */
  91044. bindShadowLight(lightIndex: string, effect: Effect): void;
  91045. /**
  91046. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91047. * (eq to shadow prjection matrix * light transform matrix)
  91048. * @returns The transform matrix used to create the shadow map
  91049. */
  91050. getTransformMatrix(): Matrix;
  91051. /**
  91052. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91053. * Cube and 2D textures for instance.
  91054. */
  91055. recreateShadowMap(): void;
  91056. protected _disposeBlurPostProcesses(): void;
  91057. protected _disposeRTTandPostProcesses(): void;
  91058. /**
  91059. * Disposes the ShadowGenerator.
  91060. * Returns nothing.
  91061. */
  91062. dispose(): void;
  91063. /**
  91064. * Serializes the shadow generator setup to a json object.
  91065. * @returns The serialized JSON object
  91066. */
  91067. serialize(): any;
  91068. /**
  91069. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91070. * @param parsedShadowGenerator The JSON object to parse
  91071. * @param scene The scene to create the shadow map for
  91072. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91073. * @returns The parsed shadow generator
  91074. */
  91075. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91076. }
  91077. }
  91078. declare module BABYLON {
  91079. /**
  91080. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91081. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91082. * 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.
  91083. */
  91084. export abstract class Light extends Node {
  91085. /**
  91086. * Falloff Default: light is falling off following the material specification:
  91087. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91088. */
  91089. static readonly FALLOFF_DEFAULT: number;
  91090. /**
  91091. * Falloff Physical: light is falling off following the inverse squared distance law.
  91092. */
  91093. static readonly FALLOFF_PHYSICAL: number;
  91094. /**
  91095. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91096. * to enhance interoperability with other engines.
  91097. */
  91098. static readonly FALLOFF_GLTF: number;
  91099. /**
  91100. * Falloff Standard: light is falling off like in the standard material
  91101. * to enhance interoperability with other materials.
  91102. */
  91103. static readonly FALLOFF_STANDARD: number;
  91104. /**
  91105. * If every light affecting the material is in this lightmapMode,
  91106. * material.lightmapTexture adds or multiplies
  91107. * (depends on material.useLightmapAsShadowmap)
  91108. * after every other light calculations.
  91109. */
  91110. static readonly LIGHTMAP_DEFAULT: number;
  91111. /**
  91112. * material.lightmapTexture as only diffuse lighting from this light
  91113. * adds only specular lighting from this light
  91114. * adds dynamic shadows
  91115. */
  91116. static readonly LIGHTMAP_SPECULAR: number;
  91117. /**
  91118. * material.lightmapTexture as only lighting
  91119. * no light calculation from this light
  91120. * only adds dynamic shadows from this light
  91121. */
  91122. static readonly LIGHTMAP_SHADOWSONLY: number;
  91123. /**
  91124. * Each light type uses the default quantity according to its type:
  91125. * point/spot lights use luminous intensity
  91126. * directional lights use illuminance
  91127. */
  91128. static readonly INTENSITYMODE_AUTOMATIC: number;
  91129. /**
  91130. * lumen (lm)
  91131. */
  91132. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91133. /**
  91134. * candela (lm/sr)
  91135. */
  91136. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91137. /**
  91138. * lux (lm/m^2)
  91139. */
  91140. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91141. /**
  91142. * nit (cd/m^2)
  91143. */
  91144. static readonly INTENSITYMODE_LUMINANCE: number;
  91145. /**
  91146. * Light type const id of the point light.
  91147. */
  91148. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91149. /**
  91150. * Light type const id of the directional light.
  91151. */
  91152. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91153. /**
  91154. * Light type const id of the spot light.
  91155. */
  91156. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91157. /**
  91158. * Light type const id of the hemispheric light.
  91159. */
  91160. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91161. /**
  91162. * Diffuse gives the basic color to an object.
  91163. */
  91164. diffuse: Color3;
  91165. /**
  91166. * Specular produces a highlight color on an object.
  91167. * Note: This is note affecting PBR materials.
  91168. */
  91169. specular: Color3;
  91170. /**
  91171. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91172. * falling off base on range or angle.
  91173. * This can be set to any values in Light.FALLOFF_x.
  91174. *
  91175. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91176. * other types of materials.
  91177. */
  91178. falloffType: number;
  91179. /**
  91180. * Strength of the light.
  91181. * Note: By default it is define in the framework own unit.
  91182. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91183. */
  91184. intensity: number;
  91185. private _range;
  91186. protected _inverseSquaredRange: number;
  91187. /**
  91188. * Defines how far from the source the light is impacting in scene units.
  91189. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91190. */
  91191. get range(): number;
  91192. /**
  91193. * Defines how far from the source the light is impacting in scene units.
  91194. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91195. */
  91196. set range(value: number);
  91197. /**
  91198. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91199. * of light.
  91200. */
  91201. private _photometricScale;
  91202. private _intensityMode;
  91203. /**
  91204. * Gets the photometric scale used to interpret the intensity.
  91205. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91206. */
  91207. get intensityMode(): number;
  91208. /**
  91209. * Sets the photometric scale used to interpret the intensity.
  91210. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91211. */
  91212. set intensityMode(value: number);
  91213. private _radius;
  91214. /**
  91215. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91216. */
  91217. get radius(): number;
  91218. /**
  91219. * sets the light radius used by PBR Materials to simulate soft area lights.
  91220. */
  91221. set radius(value: number);
  91222. private _renderPriority;
  91223. /**
  91224. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91225. * exceeding the number allowed of the materials.
  91226. */
  91227. renderPriority: number;
  91228. private _shadowEnabled;
  91229. /**
  91230. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91231. * the current shadow generator.
  91232. */
  91233. get shadowEnabled(): boolean;
  91234. /**
  91235. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91236. * the current shadow generator.
  91237. */
  91238. set shadowEnabled(value: boolean);
  91239. private _includedOnlyMeshes;
  91240. /**
  91241. * Gets the only meshes impacted by this light.
  91242. */
  91243. get includedOnlyMeshes(): AbstractMesh[];
  91244. /**
  91245. * Sets the only meshes impacted by this light.
  91246. */
  91247. set includedOnlyMeshes(value: AbstractMesh[]);
  91248. private _excludedMeshes;
  91249. /**
  91250. * Gets the meshes not impacted by this light.
  91251. */
  91252. get excludedMeshes(): AbstractMesh[];
  91253. /**
  91254. * Sets the meshes not impacted by this light.
  91255. */
  91256. set excludedMeshes(value: AbstractMesh[]);
  91257. private _excludeWithLayerMask;
  91258. /**
  91259. * Gets the layer id use to find what meshes are not impacted by the light.
  91260. * Inactive if 0
  91261. */
  91262. get excludeWithLayerMask(): number;
  91263. /**
  91264. * Sets the layer id use to find what meshes are not impacted by the light.
  91265. * Inactive if 0
  91266. */
  91267. set excludeWithLayerMask(value: number);
  91268. private _includeOnlyWithLayerMask;
  91269. /**
  91270. * Gets the layer id use to find what meshes are impacted by the light.
  91271. * Inactive if 0
  91272. */
  91273. get includeOnlyWithLayerMask(): number;
  91274. /**
  91275. * Sets the layer id use to find what meshes are impacted by the light.
  91276. * Inactive if 0
  91277. */
  91278. set includeOnlyWithLayerMask(value: number);
  91279. private _lightmapMode;
  91280. /**
  91281. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91282. */
  91283. get lightmapMode(): number;
  91284. /**
  91285. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91286. */
  91287. set lightmapMode(value: number);
  91288. /**
  91289. * Shadow generator associted to the light.
  91290. * @hidden Internal use only.
  91291. */
  91292. _shadowGenerator: Nullable<IShadowGenerator>;
  91293. /**
  91294. * @hidden Internal use only.
  91295. */
  91296. _excludedMeshesIds: string[];
  91297. /**
  91298. * @hidden Internal use only.
  91299. */
  91300. _includedOnlyMeshesIds: string[];
  91301. /**
  91302. * The current light unifom buffer.
  91303. * @hidden Internal use only.
  91304. */
  91305. _uniformBuffer: UniformBuffer;
  91306. /** @hidden */
  91307. _renderId: number;
  91308. /**
  91309. * Creates a Light object in the scene.
  91310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91311. * @param name The firendly name of the light
  91312. * @param scene The scene the light belongs too
  91313. */
  91314. constructor(name: string, scene: Scene);
  91315. protected abstract _buildUniformLayout(): void;
  91316. /**
  91317. * Sets the passed Effect "effect" with the Light information.
  91318. * @param effect The effect to update
  91319. * @param lightIndex The index of the light in the effect to update
  91320. * @returns The light
  91321. */
  91322. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91323. /**
  91324. * Sets the passed Effect "effect" with the Light textures.
  91325. * @param effect The effect to update
  91326. * @param lightIndex The index of the light in the effect to update
  91327. * @returns The light
  91328. */
  91329. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91330. /**
  91331. * Binds the lights information from the scene to the effect for the given mesh.
  91332. * @param lightIndex Light index
  91333. * @param scene The scene where the light belongs to
  91334. * @param effect The effect we are binding the data to
  91335. * @param useSpecular Defines if specular is supported
  91336. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91337. */
  91338. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91339. /**
  91340. * Sets the passed Effect "effect" with the Light information.
  91341. * @param effect The effect to update
  91342. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91343. * @returns The light
  91344. */
  91345. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91346. /**
  91347. * Returns the string "Light".
  91348. * @returns the class name
  91349. */
  91350. getClassName(): string;
  91351. /** @hidden */
  91352. readonly _isLight: boolean;
  91353. /**
  91354. * Converts the light information to a readable string for debug purpose.
  91355. * @param fullDetails Supports for multiple levels of logging within scene loading
  91356. * @returns the human readable light info
  91357. */
  91358. toString(fullDetails?: boolean): string;
  91359. /** @hidden */
  91360. protected _syncParentEnabledState(): void;
  91361. /**
  91362. * Set the enabled state of this node.
  91363. * @param value - the new enabled state
  91364. */
  91365. setEnabled(value: boolean): void;
  91366. /**
  91367. * Returns the Light associated shadow generator if any.
  91368. * @return the associated shadow generator.
  91369. */
  91370. getShadowGenerator(): Nullable<IShadowGenerator>;
  91371. /**
  91372. * Returns a Vector3, the absolute light position in the World.
  91373. * @returns the world space position of the light
  91374. */
  91375. getAbsolutePosition(): Vector3;
  91376. /**
  91377. * Specifies if the light will affect the passed mesh.
  91378. * @param mesh The mesh to test against the light
  91379. * @return true the mesh is affected otherwise, false.
  91380. */
  91381. canAffectMesh(mesh: AbstractMesh): boolean;
  91382. /**
  91383. * Sort function to order lights for rendering.
  91384. * @param a First Light object to compare to second.
  91385. * @param b Second Light object to compare first.
  91386. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91387. */
  91388. static CompareLightsPriority(a: Light, b: Light): number;
  91389. /**
  91390. * Releases resources associated with this node.
  91391. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91392. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91393. */
  91394. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91395. /**
  91396. * Returns the light type ID (integer).
  91397. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91398. */
  91399. getTypeID(): number;
  91400. /**
  91401. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91402. * @returns the scaled intensity in intensity mode unit
  91403. */
  91404. getScaledIntensity(): number;
  91405. /**
  91406. * Returns a new Light object, named "name", from the current one.
  91407. * @param name The name of the cloned light
  91408. * @returns the new created light
  91409. */
  91410. clone(name: string): Nullable<Light>;
  91411. /**
  91412. * Serializes the current light into a Serialization object.
  91413. * @returns the serialized object.
  91414. */
  91415. serialize(): any;
  91416. /**
  91417. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91418. * This new light is named "name" and added to the passed scene.
  91419. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91420. * @param name The friendly name of the light
  91421. * @param scene The scene the new light will belong to
  91422. * @returns the constructor function
  91423. */
  91424. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91425. /**
  91426. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91427. * @param parsedLight The JSON representation of the light
  91428. * @param scene The scene to create the parsed light in
  91429. * @returns the created light after parsing
  91430. */
  91431. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91432. private _hookArrayForExcluded;
  91433. private _hookArrayForIncludedOnly;
  91434. private _resyncMeshes;
  91435. /**
  91436. * Forces the meshes to update their light related information in their rendering used effects
  91437. * @hidden Internal Use Only
  91438. */
  91439. _markMeshesAsLightDirty(): void;
  91440. /**
  91441. * Recomputes the cached photometric scale if needed.
  91442. */
  91443. private _computePhotometricScale;
  91444. /**
  91445. * Returns the Photometric Scale according to the light type and intensity mode.
  91446. */
  91447. private _getPhotometricScale;
  91448. /**
  91449. * Reorder the light in the scene according to their defined priority.
  91450. * @hidden Internal Use Only
  91451. */
  91452. _reorderLightsInScene(): void;
  91453. /**
  91454. * Prepares the list of defines specific to the light type.
  91455. * @param defines the list of defines
  91456. * @param lightIndex defines the index of the light for the effect
  91457. */
  91458. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91459. }
  91460. }
  91461. declare module BABYLON {
  91462. /**
  91463. * Interface used to define Action
  91464. */
  91465. export interface IAction {
  91466. /**
  91467. * Trigger for the action
  91468. */
  91469. trigger: number;
  91470. /** Options of the trigger */
  91471. triggerOptions: any;
  91472. /**
  91473. * Gets the trigger parameters
  91474. * @returns the trigger parameters
  91475. */
  91476. getTriggerParameter(): any;
  91477. /**
  91478. * Internal only - executes current action event
  91479. * @hidden
  91480. */
  91481. _executeCurrent(evt?: ActionEvent): void;
  91482. /**
  91483. * Serialize placeholder for child classes
  91484. * @param parent of child
  91485. * @returns the serialized object
  91486. */
  91487. serialize(parent: any): any;
  91488. /**
  91489. * Internal only
  91490. * @hidden
  91491. */
  91492. _prepare(): void;
  91493. /**
  91494. * Internal only - manager for action
  91495. * @hidden
  91496. */
  91497. _actionManager: AbstractActionManager;
  91498. /**
  91499. * Adds action to chain of actions, may be a DoNothingAction
  91500. * @param action defines the next action to execute
  91501. * @returns The action passed in
  91502. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91503. */
  91504. then(action: IAction): IAction;
  91505. }
  91506. /**
  91507. * The action to be carried out following a trigger
  91508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91509. */
  91510. export class Action implements IAction {
  91511. /** the trigger, with or without parameters, for the action */
  91512. triggerOptions: any;
  91513. /**
  91514. * Trigger for the action
  91515. */
  91516. trigger: number;
  91517. /**
  91518. * Internal only - manager for action
  91519. * @hidden
  91520. */
  91521. _actionManager: ActionManager;
  91522. private _nextActiveAction;
  91523. private _child;
  91524. private _condition?;
  91525. private _triggerParameter;
  91526. /**
  91527. * An event triggered prior to action being executed.
  91528. */
  91529. onBeforeExecuteObservable: Observable<Action>;
  91530. /**
  91531. * Creates a new Action
  91532. * @param triggerOptions the trigger, with or without parameters, for the action
  91533. * @param condition an optional determinant of action
  91534. */
  91535. constructor(
  91536. /** the trigger, with or without parameters, for the action */
  91537. triggerOptions: any, condition?: Condition);
  91538. /**
  91539. * Internal only
  91540. * @hidden
  91541. */
  91542. _prepare(): void;
  91543. /**
  91544. * Gets the trigger parameters
  91545. * @returns the trigger parameters
  91546. */
  91547. getTriggerParameter(): any;
  91548. /**
  91549. * Internal only - executes current action event
  91550. * @hidden
  91551. */
  91552. _executeCurrent(evt?: ActionEvent): void;
  91553. /**
  91554. * Execute placeholder for child classes
  91555. * @param evt optional action event
  91556. */
  91557. execute(evt?: ActionEvent): void;
  91558. /**
  91559. * Skips to next active action
  91560. */
  91561. skipToNextActiveAction(): void;
  91562. /**
  91563. * Adds action to chain of actions, may be a DoNothingAction
  91564. * @param action defines the next action to execute
  91565. * @returns The action passed in
  91566. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91567. */
  91568. then(action: Action): Action;
  91569. /**
  91570. * Internal only
  91571. * @hidden
  91572. */
  91573. _getProperty(propertyPath: string): string;
  91574. /**
  91575. * Internal only
  91576. * @hidden
  91577. */
  91578. _getEffectiveTarget(target: any, propertyPath: string): any;
  91579. /**
  91580. * Serialize placeholder for child classes
  91581. * @param parent of child
  91582. * @returns the serialized object
  91583. */
  91584. serialize(parent: any): any;
  91585. /**
  91586. * Internal only called by serialize
  91587. * @hidden
  91588. */
  91589. protected _serialize(serializedAction: any, parent?: any): any;
  91590. /**
  91591. * Internal only
  91592. * @hidden
  91593. */
  91594. static _SerializeValueAsString: (value: any) => string;
  91595. /**
  91596. * Internal only
  91597. * @hidden
  91598. */
  91599. static _GetTargetProperty: (target: Node | Scene) => {
  91600. name: string;
  91601. targetType: string;
  91602. value: string;
  91603. };
  91604. }
  91605. }
  91606. declare module BABYLON {
  91607. /**
  91608. * A Condition applied to an Action
  91609. */
  91610. export class Condition {
  91611. /**
  91612. * Internal only - manager for action
  91613. * @hidden
  91614. */
  91615. _actionManager: ActionManager;
  91616. /**
  91617. * Internal only
  91618. * @hidden
  91619. */
  91620. _evaluationId: number;
  91621. /**
  91622. * Internal only
  91623. * @hidden
  91624. */
  91625. _currentResult: boolean;
  91626. /**
  91627. * Creates a new Condition
  91628. * @param actionManager the manager of the action the condition is applied to
  91629. */
  91630. constructor(actionManager: ActionManager);
  91631. /**
  91632. * Check if the current condition is valid
  91633. * @returns a boolean
  91634. */
  91635. isValid(): boolean;
  91636. /**
  91637. * Internal only
  91638. * @hidden
  91639. */
  91640. _getProperty(propertyPath: string): string;
  91641. /**
  91642. * Internal only
  91643. * @hidden
  91644. */
  91645. _getEffectiveTarget(target: any, propertyPath: string): any;
  91646. /**
  91647. * Serialize placeholder for child classes
  91648. * @returns the serialized object
  91649. */
  91650. serialize(): any;
  91651. /**
  91652. * Internal only
  91653. * @hidden
  91654. */
  91655. protected _serialize(serializedCondition: any): any;
  91656. }
  91657. /**
  91658. * Defines specific conditional operators as extensions of Condition
  91659. */
  91660. export class ValueCondition extends Condition {
  91661. /** path to specify the property of the target the conditional operator uses */
  91662. propertyPath: string;
  91663. /** the value compared by the conditional operator against the current value of the property */
  91664. value: any;
  91665. /** the conditional operator, default ValueCondition.IsEqual */
  91666. operator: number;
  91667. /**
  91668. * Internal only
  91669. * @hidden
  91670. */
  91671. private static _IsEqual;
  91672. /**
  91673. * Internal only
  91674. * @hidden
  91675. */
  91676. private static _IsDifferent;
  91677. /**
  91678. * Internal only
  91679. * @hidden
  91680. */
  91681. private static _IsGreater;
  91682. /**
  91683. * Internal only
  91684. * @hidden
  91685. */
  91686. private static _IsLesser;
  91687. /**
  91688. * returns the number for IsEqual
  91689. */
  91690. static get IsEqual(): number;
  91691. /**
  91692. * Returns the number for IsDifferent
  91693. */
  91694. static get IsDifferent(): number;
  91695. /**
  91696. * Returns the number for IsGreater
  91697. */
  91698. static get IsGreater(): number;
  91699. /**
  91700. * Returns the number for IsLesser
  91701. */
  91702. static get IsLesser(): number;
  91703. /**
  91704. * Internal only The action manager for the condition
  91705. * @hidden
  91706. */
  91707. _actionManager: ActionManager;
  91708. /**
  91709. * Internal only
  91710. * @hidden
  91711. */
  91712. private _target;
  91713. /**
  91714. * Internal only
  91715. * @hidden
  91716. */
  91717. private _effectiveTarget;
  91718. /**
  91719. * Internal only
  91720. * @hidden
  91721. */
  91722. private _property;
  91723. /**
  91724. * Creates a new ValueCondition
  91725. * @param actionManager manager for the action the condition applies to
  91726. * @param target for the action
  91727. * @param propertyPath path to specify the property of the target the conditional operator uses
  91728. * @param value the value compared by the conditional operator against the current value of the property
  91729. * @param operator the conditional operator, default ValueCondition.IsEqual
  91730. */
  91731. constructor(actionManager: ActionManager, target: any,
  91732. /** path to specify the property of the target the conditional operator uses */
  91733. propertyPath: string,
  91734. /** the value compared by the conditional operator against the current value of the property */
  91735. value: any,
  91736. /** the conditional operator, default ValueCondition.IsEqual */
  91737. operator?: number);
  91738. /**
  91739. * Compares the given value with the property value for the specified conditional operator
  91740. * @returns the result of the comparison
  91741. */
  91742. isValid(): boolean;
  91743. /**
  91744. * Serialize the ValueCondition into a JSON compatible object
  91745. * @returns serialization object
  91746. */
  91747. serialize(): any;
  91748. /**
  91749. * Gets the name of the conditional operator for the ValueCondition
  91750. * @param operator the conditional operator
  91751. * @returns the name
  91752. */
  91753. static GetOperatorName(operator: number): string;
  91754. }
  91755. /**
  91756. * Defines a predicate condition as an extension of Condition
  91757. */
  91758. export class PredicateCondition extends Condition {
  91759. /** defines the predicate function used to validate the condition */
  91760. predicate: () => boolean;
  91761. /**
  91762. * Internal only - manager for action
  91763. * @hidden
  91764. */
  91765. _actionManager: ActionManager;
  91766. /**
  91767. * Creates a new PredicateCondition
  91768. * @param actionManager manager for the action the condition applies to
  91769. * @param predicate defines the predicate function used to validate the condition
  91770. */
  91771. constructor(actionManager: ActionManager,
  91772. /** defines the predicate function used to validate the condition */
  91773. predicate: () => boolean);
  91774. /**
  91775. * @returns the validity of the predicate condition
  91776. */
  91777. isValid(): boolean;
  91778. }
  91779. /**
  91780. * Defines a state condition as an extension of Condition
  91781. */
  91782. export class StateCondition extends Condition {
  91783. /** Value to compare with target state */
  91784. value: string;
  91785. /**
  91786. * Internal only - manager for action
  91787. * @hidden
  91788. */
  91789. _actionManager: ActionManager;
  91790. /**
  91791. * Internal only
  91792. * @hidden
  91793. */
  91794. private _target;
  91795. /**
  91796. * Creates a new StateCondition
  91797. * @param actionManager manager for the action the condition applies to
  91798. * @param target of the condition
  91799. * @param value to compare with target state
  91800. */
  91801. constructor(actionManager: ActionManager, target: any,
  91802. /** Value to compare with target state */
  91803. value: string);
  91804. /**
  91805. * Gets a boolean indicating if the current condition is met
  91806. * @returns the validity of the state
  91807. */
  91808. isValid(): boolean;
  91809. /**
  91810. * Serialize the StateCondition into a JSON compatible object
  91811. * @returns serialization object
  91812. */
  91813. serialize(): any;
  91814. }
  91815. }
  91816. declare module BABYLON {
  91817. /**
  91818. * This defines an action responsible to toggle a boolean once triggered.
  91819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91820. */
  91821. export class SwitchBooleanAction extends Action {
  91822. /**
  91823. * The path to the boolean property in the target object
  91824. */
  91825. propertyPath: string;
  91826. private _target;
  91827. private _effectiveTarget;
  91828. private _property;
  91829. /**
  91830. * Instantiate the action
  91831. * @param triggerOptions defines the trigger options
  91832. * @param target defines the object containing the boolean
  91833. * @param propertyPath defines the path to the boolean property in the target object
  91834. * @param condition defines the trigger related conditions
  91835. */
  91836. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91837. /** @hidden */
  91838. _prepare(): void;
  91839. /**
  91840. * Execute the action toggle the boolean value.
  91841. */
  91842. execute(): void;
  91843. /**
  91844. * Serializes the actions and its related information.
  91845. * @param parent defines the object to serialize in
  91846. * @returns the serialized object
  91847. */
  91848. serialize(parent: any): any;
  91849. }
  91850. /**
  91851. * This defines an action responsible to set a the state field of the target
  91852. * to a desired value once triggered.
  91853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91854. */
  91855. export class SetStateAction extends Action {
  91856. /**
  91857. * The value to store in the state field.
  91858. */
  91859. value: string;
  91860. private _target;
  91861. /**
  91862. * Instantiate the action
  91863. * @param triggerOptions defines the trigger options
  91864. * @param target defines the object containing the state property
  91865. * @param value defines the value to store in the state field
  91866. * @param condition defines the trigger related conditions
  91867. */
  91868. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91869. /**
  91870. * Execute the action and store the value on the target state property.
  91871. */
  91872. execute(): void;
  91873. /**
  91874. * Serializes the actions and its related information.
  91875. * @param parent defines the object to serialize in
  91876. * @returns the serialized object
  91877. */
  91878. serialize(parent: any): any;
  91879. }
  91880. /**
  91881. * This defines an action responsible to set a property of the target
  91882. * to a desired value once triggered.
  91883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91884. */
  91885. export class SetValueAction extends Action {
  91886. /**
  91887. * The path of the property to set in the target.
  91888. */
  91889. propertyPath: string;
  91890. /**
  91891. * The value to set in the property
  91892. */
  91893. value: any;
  91894. private _target;
  91895. private _effectiveTarget;
  91896. private _property;
  91897. /**
  91898. * Instantiate the action
  91899. * @param triggerOptions defines the trigger options
  91900. * @param target defines the object containing the property
  91901. * @param propertyPath defines the path of the property to set in the target
  91902. * @param value defines the value to set in the property
  91903. * @param condition defines the trigger related conditions
  91904. */
  91905. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91906. /** @hidden */
  91907. _prepare(): void;
  91908. /**
  91909. * Execute the action and set the targetted property to the desired value.
  91910. */
  91911. execute(): void;
  91912. /**
  91913. * Serializes the actions and its related information.
  91914. * @param parent defines the object to serialize in
  91915. * @returns the serialized object
  91916. */
  91917. serialize(parent: any): any;
  91918. }
  91919. /**
  91920. * This defines an action responsible to increment the target value
  91921. * to a desired value once triggered.
  91922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91923. */
  91924. export class IncrementValueAction extends Action {
  91925. /**
  91926. * The path of the property to increment in the target.
  91927. */
  91928. propertyPath: string;
  91929. /**
  91930. * The value we should increment the property by.
  91931. */
  91932. value: any;
  91933. private _target;
  91934. private _effectiveTarget;
  91935. private _property;
  91936. /**
  91937. * Instantiate the action
  91938. * @param triggerOptions defines the trigger options
  91939. * @param target defines the object containing the property
  91940. * @param propertyPath defines the path of the property to increment in the target
  91941. * @param value defines the value value we should increment the property by
  91942. * @param condition defines the trigger related conditions
  91943. */
  91944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91945. /** @hidden */
  91946. _prepare(): void;
  91947. /**
  91948. * Execute the action and increment the target of the value amount.
  91949. */
  91950. execute(): void;
  91951. /**
  91952. * Serializes the actions and its related information.
  91953. * @param parent defines the object to serialize in
  91954. * @returns the serialized object
  91955. */
  91956. serialize(parent: any): any;
  91957. }
  91958. /**
  91959. * This defines an action responsible to start an animation once triggered.
  91960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91961. */
  91962. export class PlayAnimationAction extends Action {
  91963. /**
  91964. * Where the animation should start (animation frame)
  91965. */
  91966. from: number;
  91967. /**
  91968. * Where the animation should stop (animation frame)
  91969. */
  91970. to: number;
  91971. /**
  91972. * Define if the animation should loop or stop after the first play.
  91973. */
  91974. loop?: boolean;
  91975. private _target;
  91976. /**
  91977. * Instantiate the action
  91978. * @param triggerOptions defines the trigger options
  91979. * @param target defines the target animation or animation name
  91980. * @param from defines from where the animation should start (animation frame)
  91981. * @param end defines where the animation should stop (animation frame)
  91982. * @param loop defines if the animation should loop or stop after the first play
  91983. * @param condition defines the trigger related conditions
  91984. */
  91985. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91986. /** @hidden */
  91987. _prepare(): void;
  91988. /**
  91989. * Execute the action and play the animation.
  91990. */
  91991. execute(): void;
  91992. /**
  91993. * Serializes the actions and its related information.
  91994. * @param parent defines the object to serialize in
  91995. * @returns the serialized object
  91996. */
  91997. serialize(parent: any): any;
  91998. }
  91999. /**
  92000. * This defines an action responsible to stop an animation once triggered.
  92001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92002. */
  92003. export class StopAnimationAction extends Action {
  92004. private _target;
  92005. /**
  92006. * Instantiate the action
  92007. * @param triggerOptions defines the trigger options
  92008. * @param target defines the target animation or animation name
  92009. * @param condition defines the trigger related conditions
  92010. */
  92011. constructor(triggerOptions: any, target: any, condition?: Condition);
  92012. /** @hidden */
  92013. _prepare(): void;
  92014. /**
  92015. * Execute the action and stop the animation.
  92016. */
  92017. execute(): void;
  92018. /**
  92019. * Serializes the actions and its related information.
  92020. * @param parent defines the object to serialize in
  92021. * @returns the serialized object
  92022. */
  92023. serialize(parent: any): any;
  92024. }
  92025. /**
  92026. * This defines an action responsible that does nothing once triggered.
  92027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92028. */
  92029. export class DoNothingAction extends Action {
  92030. /**
  92031. * Instantiate the action
  92032. * @param triggerOptions defines the trigger options
  92033. * @param condition defines the trigger related conditions
  92034. */
  92035. constructor(triggerOptions?: any, condition?: Condition);
  92036. /**
  92037. * Execute the action and do nothing.
  92038. */
  92039. execute(): void;
  92040. /**
  92041. * Serializes the actions and its related information.
  92042. * @param parent defines the object to serialize in
  92043. * @returns the serialized object
  92044. */
  92045. serialize(parent: any): any;
  92046. }
  92047. /**
  92048. * This defines an action responsible to trigger several actions once triggered.
  92049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92050. */
  92051. export class CombineAction extends Action {
  92052. /**
  92053. * The list of aggregated animations to run.
  92054. */
  92055. children: Action[];
  92056. /**
  92057. * Instantiate the action
  92058. * @param triggerOptions defines the trigger options
  92059. * @param children defines the list of aggregated animations to run
  92060. * @param condition defines the trigger related conditions
  92061. */
  92062. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92063. /** @hidden */
  92064. _prepare(): void;
  92065. /**
  92066. * Execute the action and executes all the aggregated actions.
  92067. */
  92068. execute(evt: ActionEvent): void;
  92069. /**
  92070. * Serializes the actions and its related information.
  92071. * @param parent defines the object to serialize in
  92072. * @returns the serialized object
  92073. */
  92074. serialize(parent: any): any;
  92075. }
  92076. /**
  92077. * This defines an action responsible to run code (external event) once triggered.
  92078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92079. */
  92080. export class ExecuteCodeAction extends Action {
  92081. /**
  92082. * The callback function to run.
  92083. */
  92084. func: (evt: ActionEvent) => void;
  92085. /**
  92086. * Instantiate the action
  92087. * @param triggerOptions defines the trigger options
  92088. * @param func defines the callback function to run
  92089. * @param condition defines the trigger related conditions
  92090. */
  92091. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92092. /**
  92093. * Execute the action and run the attached code.
  92094. */
  92095. execute(evt: ActionEvent): void;
  92096. }
  92097. /**
  92098. * This defines an action responsible to set the parent property of the target once triggered.
  92099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92100. */
  92101. export class SetParentAction extends Action {
  92102. private _parent;
  92103. private _target;
  92104. /**
  92105. * Instantiate the action
  92106. * @param triggerOptions defines the trigger options
  92107. * @param target defines the target containing the parent property
  92108. * @param parent defines from where the animation should start (animation frame)
  92109. * @param condition defines the trigger related conditions
  92110. */
  92111. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92112. /** @hidden */
  92113. _prepare(): void;
  92114. /**
  92115. * Execute the action and set the parent property.
  92116. */
  92117. execute(): void;
  92118. /**
  92119. * Serializes the actions and its related information.
  92120. * @param parent defines the object to serialize in
  92121. * @returns the serialized object
  92122. */
  92123. serialize(parent: any): any;
  92124. }
  92125. }
  92126. declare module BABYLON {
  92127. /**
  92128. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92129. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92131. */
  92132. export class ActionManager extends AbstractActionManager {
  92133. /**
  92134. * Nothing
  92135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92136. */
  92137. static readonly NothingTrigger: number;
  92138. /**
  92139. * On pick
  92140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92141. */
  92142. static readonly OnPickTrigger: number;
  92143. /**
  92144. * On left pick
  92145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92146. */
  92147. static readonly OnLeftPickTrigger: number;
  92148. /**
  92149. * On right pick
  92150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92151. */
  92152. static readonly OnRightPickTrigger: number;
  92153. /**
  92154. * On center pick
  92155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92156. */
  92157. static readonly OnCenterPickTrigger: number;
  92158. /**
  92159. * On pick down
  92160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92161. */
  92162. static readonly OnPickDownTrigger: number;
  92163. /**
  92164. * On double pick
  92165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92166. */
  92167. static readonly OnDoublePickTrigger: number;
  92168. /**
  92169. * On pick up
  92170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92171. */
  92172. static readonly OnPickUpTrigger: number;
  92173. /**
  92174. * On pick out.
  92175. * This trigger will only be raised if you also declared a OnPickDown
  92176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92177. */
  92178. static readonly OnPickOutTrigger: number;
  92179. /**
  92180. * On long press
  92181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92182. */
  92183. static readonly OnLongPressTrigger: number;
  92184. /**
  92185. * On pointer over
  92186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92187. */
  92188. static readonly OnPointerOverTrigger: number;
  92189. /**
  92190. * On pointer out
  92191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92192. */
  92193. static readonly OnPointerOutTrigger: number;
  92194. /**
  92195. * On every frame
  92196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92197. */
  92198. static readonly OnEveryFrameTrigger: number;
  92199. /**
  92200. * On intersection enter
  92201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92202. */
  92203. static readonly OnIntersectionEnterTrigger: number;
  92204. /**
  92205. * On intersection exit
  92206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92207. */
  92208. static readonly OnIntersectionExitTrigger: number;
  92209. /**
  92210. * On key down
  92211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92212. */
  92213. static readonly OnKeyDownTrigger: number;
  92214. /**
  92215. * On key up
  92216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92217. */
  92218. static readonly OnKeyUpTrigger: number;
  92219. private _scene;
  92220. /**
  92221. * Creates a new action manager
  92222. * @param scene defines the hosting scene
  92223. */
  92224. constructor(scene: Scene);
  92225. /**
  92226. * Releases all associated resources
  92227. */
  92228. dispose(): void;
  92229. /**
  92230. * Gets hosting scene
  92231. * @returns the hosting scene
  92232. */
  92233. getScene(): Scene;
  92234. /**
  92235. * Does this action manager handles actions of any of the given triggers
  92236. * @param triggers defines the triggers to be tested
  92237. * @return a boolean indicating whether one (or more) of the triggers is handled
  92238. */
  92239. hasSpecificTriggers(triggers: number[]): boolean;
  92240. /**
  92241. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92242. * speed.
  92243. * @param triggerA defines the trigger to be tested
  92244. * @param triggerB defines the trigger to be tested
  92245. * @return a boolean indicating whether one (or more) of the triggers is handled
  92246. */
  92247. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92248. /**
  92249. * Does this action manager handles actions of a given trigger
  92250. * @param trigger defines the trigger to be tested
  92251. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92252. * @return whether the trigger is handled
  92253. */
  92254. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92255. /**
  92256. * Does this action manager has pointer triggers
  92257. */
  92258. get hasPointerTriggers(): boolean;
  92259. /**
  92260. * Does this action manager has pick triggers
  92261. */
  92262. get hasPickTriggers(): boolean;
  92263. /**
  92264. * Registers an action to this action manager
  92265. * @param action defines the action to be registered
  92266. * @return the action amended (prepared) after registration
  92267. */
  92268. registerAction(action: IAction): Nullable<IAction>;
  92269. /**
  92270. * Unregisters an action to this action manager
  92271. * @param action defines the action to be unregistered
  92272. * @return a boolean indicating whether the action has been unregistered
  92273. */
  92274. unregisterAction(action: IAction): Boolean;
  92275. /**
  92276. * Process a specific trigger
  92277. * @param trigger defines the trigger to process
  92278. * @param evt defines the event details to be processed
  92279. */
  92280. processTrigger(trigger: number, evt?: IActionEvent): void;
  92281. /** @hidden */
  92282. _getEffectiveTarget(target: any, propertyPath: string): any;
  92283. /** @hidden */
  92284. _getProperty(propertyPath: string): string;
  92285. /**
  92286. * Serialize this manager to a JSON object
  92287. * @param name defines the property name to store this manager
  92288. * @returns a JSON representation of this manager
  92289. */
  92290. serialize(name: string): any;
  92291. /**
  92292. * Creates a new ActionManager from a JSON data
  92293. * @param parsedActions defines the JSON data to read from
  92294. * @param object defines the hosting mesh
  92295. * @param scene defines the hosting scene
  92296. */
  92297. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92298. /**
  92299. * Get a trigger name by index
  92300. * @param trigger defines the trigger index
  92301. * @returns a trigger name
  92302. */
  92303. static GetTriggerName(trigger: number): string;
  92304. }
  92305. }
  92306. declare module BABYLON {
  92307. /**
  92308. * Class used to represent a sprite
  92309. * @see http://doc.babylonjs.com/babylon101/sprites
  92310. */
  92311. export class Sprite {
  92312. /** defines the name */
  92313. name: string;
  92314. /** Gets or sets the current world position */
  92315. position: Vector3;
  92316. /** Gets or sets the main color */
  92317. color: Color4;
  92318. /** Gets or sets the width */
  92319. width: number;
  92320. /** Gets or sets the height */
  92321. height: number;
  92322. /** Gets or sets rotation angle */
  92323. angle: number;
  92324. /** Gets or sets the cell index in the sprite sheet */
  92325. cellIndex: number;
  92326. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92327. cellRef: string;
  92328. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92329. invertU: number;
  92330. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92331. invertV: number;
  92332. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92333. disposeWhenFinishedAnimating: boolean;
  92334. /** Gets the list of attached animations */
  92335. animations: Animation[];
  92336. /** Gets or sets a boolean indicating if the sprite can be picked */
  92337. isPickable: boolean;
  92338. /**
  92339. * Gets or sets the associated action manager
  92340. */
  92341. actionManager: Nullable<ActionManager>;
  92342. private _animationStarted;
  92343. private _loopAnimation;
  92344. private _fromIndex;
  92345. private _toIndex;
  92346. private _delay;
  92347. private _direction;
  92348. private _manager;
  92349. private _time;
  92350. private _onAnimationEnd;
  92351. /**
  92352. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92353. */
  92354. isVisible: boolean;
  92355. /**
  92356. * Gets or sets the sprite size
  92357. */
  92358. get size(): number;
  92359. set size(value: number);
  92360. /**
  92361. * Creates a new Sprite
  92362. * @param name defines the name
  92363. * @param manager defines the manager
  92364. */
  92365. constructor(
  92366. /** defines the name */
  92367. name: string, manager: ISpriteManager);
  92368. /**
  92369. * Starts an animation
  92370. * @param from defines the initial key
  92371. * @param to defines the end key
  92372. * @param loop defines if the animation must loop
  92373. * @param delay defines the start delay (in ms)
  92374. * @param onAnimationEnd defines a callback to call when animation ends
  92375. */
  92376. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92377. /** Stops current animation (if any) */
  92378. stopAnimation(): void;
  92379. /** @hidden */
  92380. _animate(deltaTime: number): void;
  92381. /** Release associated resources */
  92382. dispose(): void;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /**
  92387. * Information about the result of picking within a scene
  92388. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92389. */
  92390. export class PickingInfo {
  92391. /** @hidden */
  92392. _pickingUnavailable: boolean;
  92393. /**
  92394. * If the pick collided with an object
  92395. */
  92396. hit: boolean;
  92397. /**
  92398. * Distance away where the pick collided
  92399. */
  92400. distance: number;
  92401. /**
  92402. * The location of pick collision
  92403. */
  92404. pickedPoint: Nullable<Vector3>;
  92405. /**
  92406. * The mesh corresponding the the pick collision
  92407. */
  92408. pickedMesh: Nullable<AbstractMesh>;
  92409. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92410. bu: number;
  92411. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92412. bv: number;
  92413. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92414. faceId: number;
  92415. /** Id of the the submesh that was picked */
  92416. subMeshId: number;
  92417. /** If a sprite was picked, this will be the sprite the pick collided with */
  92418. pickedSprite: Nullable<Sprite>;
  92419. /**
  92420. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92421. */
  92422. originMesh: Nullable<AbstractMesh>;
  92423. /**
  92424. * The ray that was used to perform the picking.
  92425. */
  92426. ray: Nullable<Ray>;
  92427. /**
  92428. * Gets the normal correspodning to the face the pick collided with
  92429. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92430. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92431. * @returns The normal correspodning to the face the pick collided with
  92432. */
  92433. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92434. /**
  92435. * Gets the texture coordinates of where the pick occured
  92436. * @returns the vector containing the coordnates of the texture
  92437. */
  92438. getTextureCoordinates(): Nullable<Vector2>;
  92439. }
  92440. }
  92441. declare module BABYLON {
  92442. /**
  92443. * Gather the list of pointer event types as constants.
  92444. */
  92445. export class PointerEventTypes {
  92446. /**
  92447. * 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.
  92448. */
  92449. static readonly POINTERDOWN: number;
  92450. /**
  92451. * The pointerup event is fired when a pointer is no longer active.
  92452. */
  92453. static readonly POINTERUP: number;
  92454. /**
  92455. * The pointermove event is fired when a pointer changes coordinates.
  92456. */
  92457. static readonly POINTERMOVE: number;
  92458. /**
  92459. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92460. */
  92461. static readonly POINTERWHEEL: number;
  92462. /**
  92463. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92464. */
  92465. static readonly POINTERPICK: number;
  92466. /**
  92467. * The pointertap event is fired when a the object has been touched and released without drag.
  92468. */
  92469. static readonly POINTERTAP: number;
  92470. /**
  92471. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92472. */
  92473. static readonly POINTERDOUBLETAP: number;
  92474. }
  92475. /**
  92476. * Base class of pointer info types.
  92477. */
  92478. export class PointerInfoBase {
  92479. /**
  92480. * Defines the type of event (PointerEventTypes)
  92481. */
  92482. type: number;
  92483. /**
  92484. * Defines the related dom event
  92485. */
  92486. event: PointerEvent | MouseWheelEvent;
  92487. /**
  92488. * Instantiates the base class of pointers info.
  92489. * @param type Defines the type of event (PointerEventTypes)
  92490. * @param event Defines the related dom event
  92491. */
  92492. constructor(
  92493. /**
  92494. * Defines the type of event (PointerEventTypes)
  92495. */
  92496. type: number,
  92497. /**
  92498. * Defines the related dom event
  92499. */
  92500. event: PointerEvent | MouseWheelEvent);
  92501. }
  92502. /**
  92503. * This class is used to store pointer related info for the onPrePointerObservable event.
  92504. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92505. */
  92506. export class PointerInfoPre extends PointerInfoBase {
  92507. /**
  92508. * Ray from a pointer if availible (eg. 6dof controller)
  92509. */
  92510. ray: Nullable<Ray>;
  92511. /**
  92512. * Defines the local position of the pointer on the canvas.
  92513. */
  92514. localPosition: Vector2;
  92515. /**
  92516. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92517. */
  92518. skipOnPointerObservable: boolean;
  92519. /**
  92520. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92521. * @param type Defines the type of event (PointerEventTypes)
  92522. * @param event Defines the related dom event
  92523. * @param localX Defines the local x coordinates of the pointer when the event occured
  92524. * @param localY Defines the local y coordinates of the pointer when the event occured
  92525. */
  92526. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92527. }
  92528. /**
  92529. * This type contains all the data related to a pointer event in Babylon.js.
  92530. * 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.
  92531. */
  92532. export class PointerInfo extends PointerInfoBase {
  92533. /**
  92534. * Defines the picking info associated to the info (if any)\
  92535. */
  92536. pickInfo: Nullable<PickingInfo>;
  92537. /**
  92538. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92539. * @param type Defines the type of event (PointerEventTypes)
  92540. * @param event Defines the related dom event
  92541. * @param pickInfo Defines the picking info associated to the info (if any)\
  92542. */
  92543. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92544. /**
  92545. * Defines the picking info associated to the info (if any)\
  92546. */
  92547. pickInfo: Nullable<PickingInfo>);
  92548. }
  92549. /**
  92550. * Data relating to a touch event on the screen.
  92551. */
  92552. export interface PointerTouch {
  92553. /**
  92554. * X coordinate of touch.
  92555. */
  92556. x: number;
  92557. /**
  92558. * Y coordinate of touch.
  92559. */
  92560. y: number;
  92561. /**
  92562. * Id of touch. Unique for each finger.
  92563. */
  92564. pointerId: number;
  92565. /**
  92566. * Event type passed from DOM.
  92567. */
  92568. type: any;
  92569. }
  92570. }
  92571. declare module BABYLON {
  92572. /**
  92573. * Manage the mouse inputs to control the movement of a free camera.
  92574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92575. */
  92576. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92577. /**
  92578. * Define if touch is enabled in the mouse input
  92579. */
  92580. touchEnabled: boolean;
  92581. /**
  92582. * Defines the camera the input is attached to.
  92583. */
  92584. camera: FreeCamera;
  92585. /**
  92586. * Defines the buttons associated with the input to handle camera move.
  92587. */
  92588. buttons: number[];
  92589. /**
  92590. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92591. */
  92592. angularSensibility: number;
  92593. private _pointerInput;
  92594. private _onMouseMove;
  92595. private _observer;
  92596. private previousPosition;
  92597. /**
  92598. * Observable for when a pointer move event occurs containing the move offset
  92599. */
  92600. onPointerMovedObservable: Observable<{
  92601. offsetX: number;
  92602. offsetY: number;
  92603. }>;
  92604. /**
  92605. * @hidden
  92606. * If the camera should be rotated automatically based on pointer movement
  92607. */
  92608. _allowCameraRotation: boolean;
  92609. /**
  92610. * Manage the mouse inputs to control the movement of a free camera.
  92611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92612. * @param touchEnabled Defines if touch is enabled or not
  92613. */
  92614. constructor(
  92615. /**
  92616. * Define if touch is enabled in the mouse input
  92617. */
  92618. touchEnabled?: boolean);
  92619. /**
  92620. * Attach the input controls to a specific dom element to get the input from.
  92621. * @param element Defines the element the controls should be listened from
  92622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92623. */
  92624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92625. /**
  92626. * Called on JS contextmenu event.
  92627. * Override this method to provide functionality.
  92628. */
  92629. protected onContextMenu(evt: PointerEvent): void;
  92630. /**
  92631. * Detach the current controls from the specified dom element.
  92632. * @param element Defines the element to stop listening the inputs from
  92633. */
  92634. detachControl(element: Nullable<HTMLElement>): void;
  92635. /**
  92636. * Gets the class name of the current intput.
  92637. * @returns the class name
  92638. */
  92639. getClassName(): string;
  92640. /**
  92641. * Get the friendly name associated with the input class.
  92642. * @returns the input friendly name
  92643. */
  92644. getSimpleName(): string;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * Manage the touch inputs to control the movement of a free camera.
  92650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92651. */
  92652. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92653. /**
  92654. * Defines the camera the input is attached to.
  92655. */
  92656. camera: FreeCamera;
  92657. /**
  92658. * Defines the touch sensibility for rotation.
  92659. * The higher the faster.
  92660. */
  92661. touchAngularSensibility: number;
  92662. /**
  92663. * Defines the touch sensibility for move.
  92664. * The higher the faster.
  92665. */
  92666. touchMoveSensibility: number;
  92667. private _offsetX;
  92668. private _offsetY;
  92669. private _pointerPressed;
  92670. private _pointerInput;
  92671. private _observer;
  92672. private _onLostFocus;
  92673. /**
  92674. * Attach the input controls to a specific dom element to get the input from.
  92675. * @param element Defines the element the controls should be listened from
  92676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92677. */
  92678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92679. /**
  92680. * Detach the current controls from the specified dom element.
  92681. * @param element Defines the element to stop listening the inputs from
  92682. */
  92683. detachControl(element: Nullable<HTMLElement>): void;
  92684. /**
  92685. * Update the current camera state depending on the inputs that have been used this frame.
  92686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92687. */
  92688. checkInputs(): void;
  92689. /**
  92690. * Gets the class name of the current intput.
  92691. * @returns the class name
  92692. */
  92693. getClassName(): string;
  92694. /**
  92695. * Get the friendly name associated with the input class.
  92696. * @returns the input friendly name
  92697. */
  92698. getSimpleName(): string;
  92699. }
  92700. }
  92701. declare module BABYLON {
  92702. /**
  92703. * Default Inputs manager for the FreeCamera.
  92704. * It groups all the default supported inputs for ease of use.
  92705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92706. */
  92707. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92708. /**
  92709. * @hidden
  92710. */
  92711. _mouseInput: Nullable<FreeCameraMouseInput>;
  92712. /**
  92713. * Instantiates a new FreeCameraInputsManager.
  92714. * @param camera Defines the camera the inputs belong to
  92715. */
  92716. constructor(camera: FreeCamera);
  92717. /**
  92718. * Add keyboard input support to the input manager.
  92719. * @returns the current input manager
  92720. */
  92721. addKeyboard(): FreeCameraInputsManager;
  92722. /**
  92723. * Add mouse input support to the input manager.
  92724. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92725. * @returns the current input manager
  92726. */
  92727. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92728. /**
  92729. * Removes the mouse input support from the manager
  92730. * @returns the current input manager
  92731. */
  92732. removeMouse(): FreeCameraInputsManager;
  92733. /**
  92734. * Add touch input support to the input manager.
  92735. * @returns the current input manager
  92736. */
  92737. addTouch(): FreeCameraInputsManager;
  92738. /**
  92739. * Remove all attached input methods from a camera
  92740. */
  92741. clear(): void;
  92742. }
  92743. }
  92744. declare module BABYLON {
  92745. /**
  92746. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92747. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92749. */
  92750. export class FreeCamera extends TargetCamera {
  92751. /**
  92752. * Define the collision ellipsoid of the camera.
  92753. * This is helpful to simulate a camera body like the player body around the camera
  92754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92755. */
  92756. ellipsoid: Vector3;
  92757. /**
  92758. * Define an offset for the position of the ellipsoid around the camera.
  92759. * This can be helpful to determine the center of the body near the gravity center of the body
  92760. * instead of its head.
  92761. */
  92762. ellipsoidOffset: Vector3;
  92763. /**
  92764. * Enable or disable collisions of the camera with the rest of the scene objects.
  92765. */
  92766. checkCollisions: boolean;
  92767. /**
  92768. * Enable or disable gravity on the camera.
  92769. */
  92770. applyGravity: boolean;
  92771. /**
  92772. * Define the input manager associated to the camera.
  92773. */
  92774. inputs: FreeCameraInputsManager;
  92775. /**
  92776. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92777. * Higher values reduce sensitivity.
  92778. */
  92779. get angularSensibility(): number;
  92780. /**
  92781. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92782. * Higher values reduce sensitivity.
  92783. */
  92784. set angularSensibility(value: number);
  92785. /**
  92786. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92787. */
  92788. get keysUp(): number[];
  92789. set keysUp(value: number[]);
  92790. /**
  92791. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92792. */
  92793. get keysUpward(): number[];
  92794. set keysUpward(value: number[]);
  92795. /**
  92796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92797. */
  92798. get keysDown(): number[];
  92799. set keysDown(value: number[]);
  92800. /**
  92801. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92802. */
  92803. get keysDownward(): number[];
  92804. set keysDownward(value: number[]);
  92805. /**
  92806. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92807. */
  92808. get keysLeft(): number[];
  92809. set keysLeft(value: number[]);
  92810. /**
  92811. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92812. */
  92813. get keysRight(): number[];
  92814. set keysRight(value: number[]);
  92815. /**
  92816. * Event raised when the camera collide with a mesh in the scene.
  92817. */
  92818. onCollide: (collidedMesh: AbstractMesh) => void;
  92819. private _collider;
  92820. private _needMoveForGravity;
  92821. private _oldPosition;
  92822. private _diffPosition;
  92823. private _newPosition;
  92824. /** @hidden */
  92825. _localDirection: Vector3;
  92826. /** @hidden */
  92827. _transformedDirection: Vector3;
  92828. /**
  92829. * Instantiates a Free Camera.
  92830. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92831. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92832. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92833. * @param name Define the name of the camera in the scene
  92834. * @param position Define the start position of the camera in the scene
  92835. * @param scene Define the scene the camera belongs to
  92836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92837. */
  92838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92839. /**
  92840. * Attached controls to the current camera.
  92841. * @param element Defines the element the controls should be listened from
  92842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92843. */
  92844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92845. /**
  92846. * Detach the current controls from the camera.
  92847. * The camera will stop reacting to inputs.
  92848. * @param element Defines the element to stop listening the inputs from
  92849. */
  92850. detachControl(element: HTMLElement): void;
  92851. private _collisionMask;
  92852. /**
  92853. * Define a collision mask to limit the list of object the camera can collide with
  92854. */
  92855. get collisionMask(): number;
  92856. set collisionMask(mask: number);
  92857. /** @hidden */
  92858. _collideWithWorld(displacement: Vector3): void;
  92859. private _onCollisionPositionChange;
  92860. /** @hidden */
  92861. _checkInputs(): void;
  92862. /** @hidden */
  92863. _decideIfNeedsToMove(): boolean;
  92864. /** @hidden */
  92865. _updatePosition(): void;
  92866. /**
  92867. * Destroy the camera and release the current resources hold by it.
  92868. */
  92869. dispose(): void;
  92870. /**
  92871. * Gets the current object class name.
  92872. * @return the class name
  92873. */
  92874. getClassName(): string;
  92875. }
  92876. }
  92877. declare module BABYLON {
  92878. /**
  92879. * Represents a gamepad control stick position
  92880. */
  92881. export class StickValues {
  92882. /**
  92883. * The x component of the control stick
  92884. */
  92885. x: number;
  92886. /**
  92887. * The y component of the control stick
  92888. */
  92889. y: number;
  92890. /**
  92891. * Initializes the gamepad x and y control stick values
  92892. * @param x The x component of the gamepad control stick value
  92893. * @param y The y component of the gamepad control stick value
  92894. */
  92895. constructor(
  92896. /**
  92897. * The x component of the control stick
  92898. */
  92899. x: number,
  92900. /**
  92901. * The y component of the control stick
  92902. */
  92903. y: number);
  92904. }
  92905. /**
  92906. * An interface which manages callbacks for gamepad button changes
  92907. */
  92908. export interface GamepadButtonChanges {
  92909. /**
  92910. * Called when a gamepad has been changed
  92911. */
  92912. changed: boolean;
  92913. /**
  92914. * Called when a gamepad press event has been triggered
  92915. */
  92916. pressChanged: boolean;
  92917. /**
  92918. * Called when a touch event has been triggered
  92919. */
  92920. touchChanged: boolean;
  92921. /**
  92922. * Called when a value has changed
  92923. */
  92924. valueChanged: boolean;
  92925. }
  92926. /**
  92927. * Represents a gamepad
  92928. */
  92929. export class Gamepad {
  92930. /**
  92931. * The id of the gamepad
  92932. */
  92933. id: string;
  92934. /**
  92935. * The index of the gamepad
  92936. */
  92937. index: number;
  92938. /**
  92939. * The browser gamepad
  92940. */
  92941. browserGamepad: any;
  92942. /**
  92943. * Specifies what type of gamepad this represents
  92944. */
  92945. type: number;
  92946. private _leftStick;
  92947. private _rightStick;
  92948. /** @hidden */
  92949. _isConnected: boolean;
  92950. private _leftStickAxisX;
  92951. private _leftStickAxisY;
  92952. private _rightStickAxisX;
  92953. private _rightStickAxisY;
  92954. /**
  92955. * Triggered when the left control stick has been changed
  92956. */
  92957. private _onleftstickchanged;
  92958. /**
  92959. * Triggered when the right control stick has been changed
  92960. */
  92961. private _onrightstickchanged;
  92962. /**
  92963. * Represents a gamepad controller
  92964. */
  92965. static GAMEPAD: number;
  92966. /**
  92967. * Represents a generic controller
  92968. */
  92969. static GENERIC: number;
  92970. /**
  92971. * Represents an XBox controller
  92972. */
  92973. static XBOX: number;
  92974. /**
  92975. * Represents a pose-enabled controller
  92976. */
  92977. static POSE_ENABLED: number;
  92978. /**
  92979. * Represents an Dual Shock controller
  92980. */
  92981. static DUALSHOCK: number;
  92982. /**
  92983. * Specifies whether the left control stick should be Y-inverted
  92984. */
  92985. protected _invertLeftStickY: boolean;
  92986. /**
  92987. * Specifies if the gamepad has been connected
  92988. */
  92989. get isConnected(): boolean;
  92990. /**
  92991. * Initializes the gamepad
  92992. * @param id The id of the gamepad
  92993. * @param index The index of the gamepad
  92994. * @param browserGamepad The browser gamepad
  92995. * @param leftStickX The x component of the left joystick
  92996. * @param leftStickY The y component of the left joystick
  92997. * @param rightStickX The x component of the right joystick
  92998. * @param rightStickY The y component of the right joystick
  92999. */
  93000. constructor(
  93001. /**
  93002. * The id of the gamepad
  93003. */
  93004. id: string,
  93005. /**
  93006. * The index of the gamepad
  93007. */
  93008. index: number,
  93009. /**
  93010. * The browser gamepad
  93011. */
  93012. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93013. /**
  93014. * Callback triggered when the left joystick has changed
  93015. * @param callback
  93016. */
  93017. onleftstickchanged(callback: (values: StickValues) => void): void;
  93018. /**
  93019. * Callback triggered when the right joystick has changed
  93020. * @param callback
  93021. */
  93022. onrightstickchanged(callback: (values: StickValues) => void): void;
  93023. /**
  93024. * Gets the left joystick
  93025. */
  93026. get leftStick(): StickValues;
  93027. /**
  93028. * Sets the left joystick values
  93029. */
  93030. set leftStick(newValues: StickValues);
  93031. /**
  93032. * Gets the right joystick
  93033. */
  93034. get rightStick(): StickValues;
  93035. /**
  93036. * Sets the right joystick value
  93037. */
  93038. set rightStick(newValues: StickValues);
  93039. /**
  93040. * Updates the gamepad joystick positions
  93041. */
  93042. update(): void;
  93043. /**
  93044. * Disposes the gamepad
  93045. */
  93046. dispose(): void;
  93047. }
  93048. /**
  93049. * Represents a generic gamepad
  93050. */
  93051. export class GenericPad extends Gamepad {
  93052. private _buttons;
  93053. private _onbuttondown;
  93054. private _onbuttonup;
  93055. /**
  93056. * Observable triggered when a button has been pressed
  93057. */
  93058. onButtonDownObservable: Observable<number>;
  93059. /**
  93060. * Observable triggered when a button has been released
  93061. */
  93062. onButtonUpObservable: Observable<number>;
  93063. /**
  93064. * Callback triggered when a button has been pressed
  93065. * @param callback Called when a button has been pressed
  93066. */
  93067. onbuttondown(callback: (buttonPressed: number) => void): void;
  93068. /**
  93069. * Callback triggered when a button has been released
  93070. * @param callback Called when a button has been released
  93071. */
  93072. onbuttonup(callback: (buttonReleased: number) => void): void;
  93073. /**
  93074. * Initializes the generic gamepad
  93075. * @param id The id of the generic gamepad
  93076. * @param index The index of the generic gamepad
  93077. * @param browserGamepad The browser gamepad
  93078. */
  93079. constructor(id: string, index: number, browserGamepad: any);
  93080. private _setButtonValue;
  93081. /**
  93082. * Updates the generic gamepad
  93083. */
  93084. update(): void;
  93085. /**
  93086. * Disposes the generic gamepad
  93087. */
  93088. dispose(): void;
  93089. }
  93090. }
  93091. declare module BABYLON {
  93092. /**
  93093. * Defines the types of pose enabled controllers that are supported
  93094. */
  93095. export enum PoseEnabledControllerType {
  93096. /**
  93097. * HTC Vive
  93098. */
  93099. VIVE = 0,
  93100. /**
  93101. * Oculus Rift
  93102. */
  93103. OCULUS = 1,
  93104. /**
  93105. * Windows mixed reality
  93106. */
  93107. WINDOWS = 2,
  93108. /**
  93109. * Samsung gear VR
  93110. */
  93111. GEAR_VR = 3,
  93112. /**
  93113. * Google Daydream
  93114. */
  93115. DAYDREAM = 4,
  93116. /**
  93117. * Generic
  93118. */
  93119. GENERIC = 5
  93120. }
  93121. /**
  93122. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93123. */
  93124. export interface MutableGamepadButton {
  93125. /**
  93126. * Value of the button/trigger
  93127. */
  93128. value: number;
  93129. /**
  93130. * If the button/trigger is currently touched
  93131. */
  93132. touched: boolean;
  93133. /**
  93134. * If the button/trigger is currently pressed
  93135. */
  93136. pressed: boolean;
  93137. }
  93138. /**
  93139. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93140. * @hidden
  93141. */
  93142. export interface ExtendedGamepadButton extends GamepadButton {
  93143. /**
  93144. * If the button/trigger is currently pressed
  93145. */
  93146. readonly pressed: boolean;
  93147. /**
  93148. * If the button/trigger is currently touched
  93149. */
  93150. readonly touched: boolean;
  93151. /**
  93152. * Value of the button/trigger
  93153. */
  93154. readonly value: number;
  93155. }
  93156. /** @hidden */
  93157. export interface _GamePadFactory {
  93158. /**
  93159. * Returns whether or not the current gamepad can be created for this type of controller.
  93160. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93161. * @returns true if it can be created, otherwise false
  93162. */
  93163. canCreate(gamepadInfo: any): boolean;
  93164. /**
  93165. * Creates a new instance of the Gamepad.
  93166. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93167. * @returns the new gamepad instance
  93168. */
  93169. create(gamepadInfo: any): Gamepad;
  93170. }
  93171. /**
  93172. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93173. */
  93174. export class PoseEnabledControllerHelper {
  93175. /** @hidden */
  93176. static _ControllerFactories: _GamePadFactory[];
  93177. /** @hidden */
  93178. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93179. /**
  93180. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93181. * @param vrGamepad the gamepad to initialized
  93182. * @returns a vr controller of the type the gamepad identified as
  93183. */
  93184. static InitiateController(vrGamepad: any): Gamepad;
  93185. }
  93186. /**
  93187. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93188. */
  93189. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93190. /**
  93191. * If the controller is used in a webXR session
  93192. */
  93193. isXR: boolean;
  93194. private _deviceRoomPosition;
  93195. private _deviceRoomRotationQuaternion;
  93196. /**
  93197. * The device position in babylon space
  93198. */
  93199. devicePosition: Vector3;
  93200. /**
  93201. * The device rotation in babylon space
  93202. */
  93203. deviceRotationQuaternion: Quaternion;
  93204. /**
  93205. * The scale factor of the device in babylon space
  93206. */
  93207. deviceScaleFactor: number;
  93208. /**
  93209. * (Likely devicePosition should be used instead) The device position in its room space
  93210. */
  93211. position: Vector3;
  93212. /**
  93213. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93214. */
  93215. rotationQuaternion: Quaternion;
  93216. /**
  93217. * The type of controller (Eg. Windows mixed reality)
  93218. */
  93219. controllerType: PoseEnabledControllerType;
  93220. protected _calculatedPosition: Vector3;
  93221. private _calculatedRotation;
  93222. /**
  93223. * The raw pose from the device
  93224. */
  93225. rawPose: DevicePose;
  93226. private _trackPosition;
  93227. private _maxRotationDistFromHeadset;
  93228. private _draggedRoomRotation;
  93229. /**
  93230. * @hidden
  93231. */
  93232. _disableTrackPosition(fixedPosition: Vector3): void;
  93233. /**
  93234. * Internal, the mesh attached to the controller
  93235. * @hidden
  93236. */
  93237. _mesh: Nullable<AbstractMesh>;
  93238. private _poseControlledCamera;
  93239. private _leftHandSystemQuaternion;
  93240. /**
  93241. * Internal, matrix used to convert room space to babylon space
  93242. * @hidden
  93243. */
  93244. _deviceToWorld: Matrix;
  93245. /**
  93246. * Node to be used when casting a ray from the controller
  93247. * @hidden
  93248. */
  93249. _pointingPoseNode: Nullable<TransformNode>;
  93250. /**
  93251. * Name of the child mesh that can be used to cast a ray from the controller
  93252. */
  93253. static readonly POINTING_POSE: string;
  93254. /**
  93255. * Creates a new PoseEnabledController from a gamepad
  93256. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93257. */
  93258. constructor(browserGamepad: any);
  93259. private _workingMatrix;
  93260. /**
  93261. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93262. */
  93263. update(): void;
  93264. /**
  93265. * Updates only the pose device and mesh without doing any button event checking
  93266. */
  93267. protected _updatePoseAndMesh(): void;
  93268. /**
  93269. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93270. * @param poseData raw pose fromthe device
  93271. */
  93272. updateFromDevice(poseData: DevicePose): void;
  93273. /**
  93274. * @hidden
  93275. */
  93276. _meshAttachedObservable: Observable<AbstractMesh>;
  93277. /**
  93278. * Attaches a mesh to the controller
  93279. * @param mesh the mesh to be attached
  93280. */
  93281. attachToMesh(mesh: AbstractMesh): void;
  93282. /**
  93283. * Attaches the controllers mesh to a camera
  93284. * @param camera the camera the mesh should be attached to
  93285. */
  93286. attachToPoseControlledCamera(camera: TargetCamera): void;
  93287. /**
  93288. * Disposes of the controller
  93289. */
  93290. dispose(): void;
  93291. /**
  93292. * The mesh that is attached to the controller
  93293. */
  93294. get mesh(): Nullable<AbstractMesh>;
  93295. /**
  93296. * Gets the ray of the controller in the direction the controller is pointing
  93297. * @param length the length the resulting ray should be
  93298. * @returns a ray in the direction the controller is pointing
  93299. */
  93300. getForwardRay(length?: number): Ray;
  93301. }
  93302. }
  93303. declare module BABYLON {
  93304. /**
  93305. * Defines the WebVRController object that represents controllers tracked in 3D space
  93306. */
  93307. export abstract class WebVRController extends PoseEnabledController {
  93308. /**
  93309. * Internal, the default controller model for the controller
  93310. */
  93311. protected _defaultModel: Nullable<AbstractMesh>;
  93312. /**
  93313. * Fired when the trigger state has changed
  93314. */
  93315. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93316. /**
  93317. * Fired when the main button state has changed
  93318. */
  93319. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93320. /**
  93321. * Fired when the secondary button state has changed
  93322. */
  93323. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93324. /**
  93325. * Fired when the pad state has changed
  93326. */
  93327. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93328. /**
  93329. * Fired when controllers stick values have changed
  93330. */
  93331. onPadValuesChangedObservable: Observable<StickValues>;
  93332. /**
  93333. * Array of button availible on the controller
  93334. */
  93335. protected _buttons: Array<MutableGamepadButton>;
  93336. private _onButtonStateChange;
  93337. /**
  93338. * Fired when a controller button's state has changed
  93339. * @param callback the callback containing the button that was modified
  93340. */
  93341. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93342. /**
  93343. * X and Y axis corresponding to the controllers joystick
  93344. */
  93345. pad: StickValues;
  93346. /**
  93347. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93348. */
  93349. hand: string;
  93350. /**
  93351. * The default controller model for the controller
  93352. */
  93353. get defaultModel(): Nullable<AbstractMesh>;
  93354. /**
  93355. * Creates a new WebVRController from a gamepad
  93356. * @param vrGamepad the gamepad that the WebVRController should be created from
  93357. */
  93358. constructor(vrGamepad: any);
  93359. /**
  93360. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93361. */
  93362. update(): void;
  93363. /**
  93364. * Function to be called when a button is modified
  93365. */
  93366. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93367. /**
  93368. * Loads a mesh and attaches it to the controller
  93369. * @param scene the scene the mesh should be added to
  93370. * @param meshLoaded callback for when the mesh has been loaded
  93371. */
  93372. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93373. private _setButtonValue;
  93374. private _changes;
  93375. private _checkChanges;
  93376. /**
  93377. * Disposes of th webVRCOntroller
  93378. */
  93379. dispose(): void;
  93380. }
  93381. }
  93382. declare module BABYLON {
  93383. /**
  93384. * The HemisphericLight simulates the ambient environment light,
  93385. * so the passed direction is the light reflection direction, not the incoming direction.
  93386. */
  93387. export class HemisphericLight extends Light {
  93388. /**
  93389. * The groundColor is the light in the opposite direction to the one specified during creation.
  93390. * 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.
  93391. */
  93392. groundColor: Color3;
  93393. /**
  93394. * The light reflection direction, not the incoming direction.
  93395. */
  93396. direction: Vector3;
  93397. /**
  93398. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93399. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93400. * The HemisphericLight can't cast shadows.
  93401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93402. * @param name The friendly name of the light
  93403. * @param direction The direction of the light reflection
  93404. * @param scene The scene the light belongs to
  93405. */
  93406. constructor(name: string, direction: Vector3, scene: Scene);
  93407. protected _buildUniformLayout(): void;
  93408. /**
  93409. * Returns the string "HemisphericLight".
  93410. * @return The class name
  93411. */
  93412. getClassName(): string;
  93413. /**
  93414. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93415. * Returns the updated direction.
  93416. * @param target The target the direction should point to
  93417. * @return The computed direction
  93418. */
  93419. setDirectionToTarget(target: Vector3): Vector3;
  93420. /**
  93421. * Returns the shadow generator associated to the light.
  93422. * @returns Always null for hemispheric lights because it does not support shadows.
  93423. */
  93424. getShadowGenerator(): Nullable<IShadowGenerator>;
  93425. /**
  93426. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93427. * @param effect The effect to update
  93428. * @param lightIndex The index of the light in the effect to update
  93429. * @returns The hemispheric light
  93430. */
  93431. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93433. /**
  93434. * Computes the world matrix of the node
  93435. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93436. * @param useWasUpdatedFlag defines a reserved property
  93437. * @returns the world matrix
  93438. */
  93439. computeWorldMatrix(): Matrix;
  93440. /**
  93441. * Returns the integer 3.
  93442. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93443. */
  93444. getTypeID(): number;
  93445. /**
  93446. * Prepares the list of defines specific to the light type.
  93447. * @param defines the list of defines
  93448. * @param lightIndex defines the index of the light for the effect
  93449. */
  93450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93451. }
  93452. }
  93453. declare module BABYLON {
  93454. /** @hidden */
  93455. export var vrMultiviewToSingleviewPixelShader: {
  93456. name: string;
  93457. shader: string;
  93458. };
  93459. }
  93460. declare module BABYLON {
  93461. /**
  93462. * Renders to multiple views with a single draw call
  93463. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93464. */
  93465. export class MultiviewRenderTarget extends RenderTargetTexture {
  93466. /**
  93467. * Creates a multiview render target
  93468. * @param scene scene used with the render target
  93469. * @param size the size of the render target (used for each view)
  93470. */
  93471. constructor(scene: Scene, size?: number | {
  93472. width: number;
  93473. height: number;
  93474. } | {
  93475. ratio: number;
  93476. });
  93477. /**
  93478. * @hidden
  93479. * @param faceIndex the face index, if its a cube texture
  93480. */
  93481. _bindFrameBuffer(faceIndex?: number): void;
  93482. /**
  93483. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93484. * @returns the view count
  93485. */
  93486. getViewCount(): number;
  93487. }
  93488. }
  93489. declare module BABYLON {
  93490. /**
  93491. * Represents a camera frustum
  93492. */
  93493. export class Frustum {
  93494. /**
  93495. * Gets the planes representing the frustum
  93496. * @param transform matrix to be applied to the returned planes
  93497. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93498. */
  93499. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93500. /**
  93501. * Gets the near frustum plane transformed by the transform matrix
  93502. * @param transform transformation matrix to be applied to the resulting frustum plane
  93503. * @param frustumPlane the resuling frustum plane
  93504. */
  93505. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93506. /**
  93507. * Gets the far frustum plane transformed by the transform matrix
  93508. * @param transform transformation matrix to be applied to the resulting frustum plane
  93509. * @param frustumPlane the resuling frustum plane
  93510. */
  93511. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93512. /**
  93513. * Gets the left frustum plane transformed by the transform matrix
  93514. * @param transform transformation matrix to be applied to the resulting frustum plane
  93515. * @param frustumPlane the resuling frustum plane
  93516. */
  93517. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93518. /**
  93519. * Gets the right frustum plane transformed by the transform matrix
  93520. * @param transform transformation matrix to be applied to the resulting frustum plane
  93521. * @param frustumPlane the resuling frustum plane
  93522. */
  93523. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93524. /**
  93525. * Gets the top frustum plane transformed by the transform matrix
  93526. * @param transform transformation matrix to be applied to the resulting frustum plane
  93527. * @param frustumPlane the resuling frustum plane
  93528. */
  93529. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93530. /**
  93531. * Gets the bottom frustum plane transformed by the transform matrix
  93532. * @param transform transformation matrix to be applied to the resulting frustum plane
  93533. * @param frustumPlane the resuling frustum plane
  93534. */
  93535. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93536. /**
  93537. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93538. * @param transform transformation matrix to be applied to the resulting frustum planes
  93539. * @param frustumPlanes the resuling frustum planes
  93540. */
  93541. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93542. }
  93543. }
  93544. declare module BABYLON {
  93545. interface Engine {
  93546. /**
  93547. * Creates a new multiview render target
  93548. * @param width defines the width of the texture
  93549. * @param height defines the height of the texture
  93550. * @returns the created multiview texture
  93551. */
  93552. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93553. /**
  93554. * Binds a multiview framebuffer to be drawn to
  93555. * @param multiviewTexture texture to bind
  93556. */
  93557. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93558. }
  93559. interface Camera {
  93560. /**
  93561. * @hidden
  93562. * 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)
  93563. */
  93564. _useMultiviewToSingleView: boolean;
  93565. /**
  93566. * @hidden
  93567. * 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)
  93568. */
  93569. _multiviewTexture: Nullable<RenderTargetTexture>;
  93570. /**
  93571. * @hidden
  93572. * ensures the multiview texture of the camera exists and has the specified width/height
  93573. * @param width height to set on the multiview texture
  93574. * @param height width to set on the multiview texture
  93575. */
  93576. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93577. }
  93578. interface Scene {
  93579. /** @hidden */
  93580. _transformMatrixR: Matrix;
  93581. /** @hidden */
  93582. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93583. /** @hidden */
  93584. _createMultiviewUbo(): void;
  93585. /** @hidden */
  93586. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93587. /** @hidden */
  93588. _renderMultiviewToSingleView(camera: Camera): void;
  93589. }
  93590. }
  93591. declare module BABYLON {
  93592. /**
  93593. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93594. * This will not be used for webXR as it supports displaying texture arrays directly
  93595. */
  93596. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93597. /**
  93598. * Initializes a VRMultiviewToSingleview
  93599. * @param name name of the post process
  93600. * @param camera camera to be applied to
  93601. * @param scaleFactor scaling factor to the size of the output texture
  93602. */
  93603. constructor(name: string, camera: Camera, scaleFactor: number);
  93604. }
  93605. }
  93606. declare module BABYLON {
  93607. /**
  93608. * Interface used to define additional presentation attributes
  93609. */
  93610. export interface IVRPresentationAttributes {
  93611. /**
  93612. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93613. */
  93614. highRefreshRate: boolean;
  93615. /**
  93616. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93617. */
  93618. foveationLevel: number;
  93619. }
  93620. interface Engine {
  93621. /** @hidden */
  93622. _vrDisplay: any;
  93623. /** @hidden */
  93624. _vrSupported: boolean;
  93625. /** @hidden */
  93626. _oldSize: Size;
  93627. /** @hidden */
  93628. _oldHardwareScaleFactor: number;
  93629. /** @hidden */
  93630. _vrExclusivePointerMode: boolean;
  93631. /** @hidden */
  93632. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93633. /** @hidden */
  93634. _onVRDisplayPointerRestricted: () => void;
  93635. /** @hidden */
  93636. _onVRDisplayPointerUnrestricted: () => void;
  93637. /** @hidden */
  93638. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93639. /** @hidden */
  93640. _onVrDisplayDisconnect: Nullable<() => void>;
  93641. /** @hidden */
  93642. _onVrDisplayPresentChange: Nullable<() => void>;
  93643. /**
  93644. * Observable signaled when VR display mode changes
  93645. */
  93646. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93647. /**
  93648. * Observable signaled when VR request present is complete
  93649. */
  93650. onVRRequestPresentComplete: Observable<boolean>;
  93651. /**
  93652. * Observable signaled when VR request present starts
  93653. */
  93654. onVRRequestPresentStart: Observable<Engine>;
  93655. /**
  93656. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93657. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93658. */
  93659. isInVRExclusivePointerMode: boolean;
  93660. /**
  93661. * Gets a boolean indicating if a webVR device was detected
  93662. * @returns true if a webVR device was detected
  93663. */
  93664. isVRDevicePresent(): boolean;
  93665. /**
  93666. * Gets the current webVR device
  93667. * @returns the current webVR device (or null)
  93668. */
  93669. getVRDevice(): any;
  93670. /**
  93671. * Initializes a webVR display and starts listening to display change events
  93672. * The onVRDisplayChangedObservable will be notified upon these changes
  93673. * @returns A promise containing a VRDisplay and if vr is supported
  93674. */
  93675. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93676. /** @hidden */
  93677. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93678. /**
  93679. * Gets or sets the presentation attributes used to configure VR rendering
  93680. */
  93681. vrPresentationAttributes?: IVRPresentationAttributes;
  93682. /**
  93683. * Call this function to switch to webVR mode
  93684. * Will do nothing if webVR is not supported or if there is no webVR device
  93685. * @param options the webvr options provided to the camera. mainly used for multiview
  93686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93687. */
  93688. enableVR(options: WebVROptions): void;
  93689. /** @hidden */
  93690. _onVRFullScreenTriggered(): void;
  93691. }
  93692. }
  93693. declare module BABYLON {
  93694. /**
  93695. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93696. * IMPORTANT!! The data is right-hand data.
  93697. * @export
  93698. * @interface DevicePose
  93699. */
  93700. export interface DevicePose {
  93701. /**
  93702. * The position of the device, values in array are [x,y,z].
  93703. */
  93704. readonly position: Nullable<Float32Array>;
  93705. /**
  93706. * The linearVelocity of the device, values in array are [x,y,z].
  93707. */
  93708. readonly linearVelocity: Nullable<Float32Array>;
  93709. /**
  93710. * The linearAcceleration of the device, values in array are [x,y,z].
  93711. */
  93712. readonly linearAcceleration: Nullable<Float32Array>;
  93713. /**
  93714. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93715. */
  93716. readonly orientation: Nullable<Float32Array>;
  93717. /**
  93718. * The angularVelocity of the device, values in array are [x,y,z].
  93719. */
  93720. readonly angularVelocity: Nullable<Float32Array>;
  93721. /**
  93722. * The angularAcceleration of the device, values in array are [x,y,z].
  93723. */
  93724. readonly angularAcceleration: Nullable<Float32Array>;
  93725. }
  93726. /**
  93727. * Interface representing a pose controlled object in Babylon.
  93728. * A pose controlled object has both regular pose values as well as pose values
  93729. * from an external device such as a VR head mounted display
  93730. */
  93731. export interface PoseControlled {
  93732. /**
  93733. * The position of the object in babylon space.
  93734. */
  93735. position: Vector3;
  93736. /**
  93737. * The rotation quaternion of the object in babylon space.
  93738. */
  93739. rotationQuaternion: Quaternion;
  93740. /**
  93741. * The position of the device in babylon space.
  93742. */
  93743. devicePosition?: Vector3;
  93744. /**
  93745. * The rotation quaternion of the device in babylon space.
  93746. */
  93747. deviceRotationQuaternion: Quaternion;
  93748. /**
  93749. * The raw pose coming from the device.
  93750. */
  93751. rawPose: Nullable<DevicePose>;
  93752. /**
  93753. * The scale of the device to be used when translating from device space to babylon space.
  93754. */
  93755. deviceScaleFactor: number;
  93756. /**
  93757. * Updates the poseControlled values based on the input device pose.
  93758. * @param poseData the pose data to update the object with
  93759. */
  93760. updateFromDevice(poseData: DevicePose): void;
  93761. }
  93762. /**
  93763. * Set of options to customize the webVRCamera
  93764. */
  93765. export interface WebVROptions {
  93766. /**
  93767. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93768. */
  93769. trackPosition?: boolean;
  93770. /**
  93771. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93772. */
  93773. positionScale?: number;
  93774. /**
  93775. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93776. */
  93777. displayName?: string;
  93778. /**
  93779. * Should the native controller meshes be initialized. (default: true)
  93780. */
  93781. controllerMeshes?: boolean;
  93782. /**
  93783. * Creating a default HemiLight only on controllers. (default: true)
  93784. */
  93785. defaultLightingOnControllers?: boolean;
  93786. /**
  93787. * If you don't want to use the default VR button of the helper. (default: false)
  93788. */
  93789. useCustomVRButton?: boolean;
  93790. /**
  93791. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93792. */
  93793. customVRButton?: HTMLButtonElement;
  93794. /**
  93795. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93796. */
  93797. rayLength?: number;
  93798. /**
  93799. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93800. */
  93801. defaultHeight?: number;
  93802. /**
  93803. * If multiview should be used if availible (default: false)
  93804. */
  93805. useMultiview?: boolean;
  93806. }
  93807. /**
  93808. * This represents a WebVR camera.
  93809. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93810. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93811. */
  93812. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93813. private webVROptions;
  93814. /**
  93815. * @hidden
  93816. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93817. */
  93818. _vrDevice: any;
  93819. /**
  93820. * The rawPose of the vrDevice.
  93821. */
  93822. rawPose: Nullable<DevicePose>;
  93823. private _onVREnabled;
  93824. private _specsVersion;
  93825. private _attached;
  93826. private _frameData;
  93827. protected _descendants: Array<Node>;
  93828. private _deviceRoomPosition;
  93829. /** @hidden */
  93830. _deviceRoomRotationQuaternion: Quaternion;
  93831. private _standingMatrix;
  93832. /**
  93833. * Represents device position in babylon space.
  93834. */
  93835. devicePosition: Vector3;
  93836. /**
  93837. * Represents device rotation in babylon space.
  93838. */
  93839. deviceRotationQuaternion: Quaternion;
  93840. /**
  93841. * The scale of the device to be used when translating from device space to babylon space.
  93842. */
  93843. deviceScaleFactor: number;
  93844. private _deviceToWorld;
  93845. private _worldToDevice;
  93846. /**
  93847. * References to the webVR controllers for the vrDevice.
  93848. */
  93849. controllers: Array<WebVRController>;
  93850. /**
  93851. * Emits an event when a controller is attached.
  93852. */
  93853. onControllersAttachedObservable: Observable<WebVRController[]>;
  93854. /**
  93855. * Emits an event when a controller's mesh has been loaded;
  93856. */
  93857. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93858. /**
  93859. * Emits an event when the HMD's pose has been updated.
  93860. */
  93861. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93862. private _poseSet;
  93863. /**
  93864. * If the rig cameras be used as parent instead of this camera.
  93865. */
  93866. rigParenting: boolean;
  93867. private _lightOnControllers;
  93868. private _defaultHeight?;
  93869. /**
  93870. * Instantiates a WebVRFreeCamera.
  93871. * @param name The name of the WebVRFreeCamera
  93872. * @param position The starting anchor position for the camera
  93873. * @param scene The scene the camera belongs to
  93874. * @param webVROptions a set of customizable options for the webVRCamera
  93875. */
  93876. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93877. /**
  93878. * Gets the device distance from the ground in meters.
  93879. * @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.
  93880. */
  93881. deviceDistanceToRoomGround(): number;
  93882. /**
  93883. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93884. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93885. */
  93886. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93887. /**
  93888. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93889. * @returns A promise with a boolean set to if the standing matrix is supported.
  93890. */
  93891. useStandingMatrixAsync(): Promise<boolean>;
  93892. /**
  93893. * Disposes the camera
  93894. */
  93895. dispose(): void;
  93896. /**
  93897. * Gets a vrController by name.
  93898. * @param name The name of the controller to retreive
  93899. * @returns the controller matching the name specified or null if not found
  93900. */
  93901. getControllerByName(name: string): Nullable<WebVRController>;
  93902. private _leftController;
  93903. /**
  93904. * The controller corresponding to the users left hand.
  93905. */
  93906. get leftController(): Nullable<WebVRController>;
  93907. private _rightController;
  93908. /**
  93909. * The controller corresponding to the users right hand.
  93910. */
  93911. get rightController(): Nullable<WebVRController>;
  93912. /**
  93913. * Casts a ray forward from the vrCamera's gaze.
  93914. * @param length Length of the ray (default: 100)
  93915. * @returns the ray corresponding to the gaze
  93916. */
  93917. getForwardRay(length?: number): Ray;
  93918. /**
  93919. * @hidden
  93920. * Updates the camera based on device's frame data
  93921. */
  93922. _checkInputs(): void;
  93923. /**
  93924. * Updates the poseControlled values based on the input device pose.
  93925. * @param poseData Pose coming from the device
  93926. */
  93927. updateFromDevice(poseData: DevicePose): void;
  93928. private _htmlElementAttached;
  93929. private _detachIfAttached;
  93930. /**
  93931. * WebVR's attach control will start broadcasting frames to the device.
  93932. * Note that in certain browsers (chrome for example) this function must be called
  93933. * within a user-interaction callback. Example:
  93934. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93935. *
  93936. * @param element html element to attach the vrDevice to
  93937. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93938. */
  93939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93940. /**
  93941. * Detaches the camera from the html element and disables VR
  93942. *
  93943. * @param element html element to detach from
  93944. */
  93945. detachControl(element: HTMLElement): void;
  93946. /**
  93947. * @returns the name of this class
  93948. */
  93949. getClassName(): string;
  93950. /**
  93951. * Calls resetPose on the vrDisplay
  93952. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93953. */
  93954. resetToCurrentRotation(): void;
  93955. /**
  93956. * @hidden
  93957. * Updates the rig cameras (left and right eye)
  93958. */
  93959. _updateRigCameras(): void;
  93960. private _workingVector;
  93961. private _oneVector;
  93962. private _workingMatrix;
  93963. private updateCacheCalled;
  93964. private _correctPositionIfNotTrackPosition;
  93965. /**
  93966. * @hidden
  93967. * Updates the cached values of the camera
  93968. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93969. */
  93970. _updateCache(ignoreParentClass?: boolean): void;
  93971. /**
  93972. * @hidden
  93973. * Get current device position in babylon world
  93974. */
  93975. _computeDevicePosition(): void;
  93976. /**
  93977. * Updates the current device position and rotation in the babylon world
  93978. */
  93979. update(): void;
  93980. /**
  93981. * @hidden
  93982. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93983. * @returns an identity matrix
  93984. */
  93985. _getViewMatrix(): Matrix;
  93986. private _tmpMatrix;
  93987. /**
  93988. * This function is called by the two RIG cameras.
  93989. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93990. * @hidden
  93991. */
  93992. _getWebVRViewMatrix(): Matrix;
  93993. /** @hidden */
  93994. _getWebVRProjectionMatrix(): Matrix;
  93995. private _onGamepadConnectedObserver;
  93996. private _onGamepadDisconnectedObserver;
  93997. private _updateCacheWhenTrackingDisabledObserver;
  93998. /**
  93999. * Initializes the controllers and their meshes
  94000. */
  94001. initControllers(): void;
  94002. }
  94003. }
  94004. declare module BABYLON {
  94005. /**
  94006. * Size options for a post process
  94007. */
  94008. export type PostProcessOptions = {
  94009. width: number;
  94010. height: number;
  94011. };
  94012. /**
  94013. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94014. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94015. */
  94016. export class PostProcess {
  94017. /** Name of the PostProcess. */
  94018. name: string;
  94019. /**
  94020. * Gets or sets the unique id of the post process
  94021. */
  94022. uniqueId: number;
  94023. /**
  94024. * Width of the texture to apply the post process on
  94025. */
  94026. width: number;
  94027. /**
  94028. * Height of the texture to apply the post process on
  94029. */
  94030. height: number;
  94031. /**
  94032. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94033. * @hidden
  94034. */
  94035. _outputTexture: Nullable<InternalTexture>;
  94036. /**
  94037. * Sampling mode used by the shader
  94038. * See https://doc.babylonjs.com/classes/3.1/texture
  94039. */
  94040. renderTargetSamplingMode: number;
  94041. /**
  94042. * Clear color to use when screen clearing
  94043. */
  94044. clearColor: Color4;
  94045. /**
  94046. * If the buffer needs to be cleared before applying the post process. (default: true)
  94047. * Should be set to false if shader will overwrite all previous pixels.
  94048. */
  94049. autoClear: boolean;
  94050. /**
  94051. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94052. */
  94053. alphaMode: number;
  94054. /**
  94055. * Sets the setAlphaBlendConstants of the babylon engine
  94056. */
  94057. alphaConstants: Color4;
  94058. /**
  94059. * Animations to be used for the post processing
  94060. */
  94061. animations: Animation[];
  94062. /**
  94063. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94064. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94065. */
  94066. enablePixelPerfectMode: boolean;
  94067. /**
  94068. * Force the postprocess to be applied without taking in account viewport
  94069. */
  94070. forceFullscreenViewport: boolean;
  94071. /**
  94072. * List of inspectable custom properties (used by the Inspector)
  94073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94074. */
  94075. inspectableCustomProperties: IInspectable[];
  94076. /**
  94077. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94078. *
  94079. * | Value | Type | Description |
  94080. * | ----- | ----------------------------------- | ----------- |
  94081. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94082. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94083. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94084. *
  94085. */
  94086. scaleMode: number;
  94087. /**
  94088. * Force textures to be a power of two (default: false)
  94089. */
  94090. alwaysForcePOT: boolean;
  94091. private _samples;
  94092. /**
  94093. * Number of sample textures (default: 1)
  94094. */
  94095. get samples(): number;
  94096. set samples(n: number);
  94097. /**
  94098. * Modify the scale of the post process to be the same as the viewport (default: false)
  94099. */
  94100. adaptScaleToCurrentViewport: boolean;
  94101. private _camera;
  94102. private _scene;
  94103. private _engine;
  94104. private _options;
  94105. private _reusable;
  94106. private _textureType;
  94107. private _textureFormat;
  94108. /**
  94109. * Smart array of input and output textures for the post process.
  94110. * @hidden
  94111. */
  94112. _textures: SmartArray<InternalTexture>;
  94113. /**
  94114. * The index in _textures that corresponds to the output texture.
  94115. * @hidden
  94116. */
  94117. _currentRenderTextureInd: number;
  94118. private _effect;
  94119. private _samplers;
  94120. private _fragmentUrl;
  94121. private _vertexUrl;
  94122. private _parameters;
  94123. private _scaleRatio;
  94124. protected _indexParameters: any;
  94125. private _shareOutputWithPostProcess;
  94126. private _texelSize;
  94127. private _forcedOutputTexture;
  94128. /**
  94129. * Returns the fragment url or shader name used in the post process.
  94130. * @returns the fragment url or name in the shader store.
  94131. */
  94132. getEffectName(): string;
  94133. /**
  94134. * An event triggered when the postprocess is activated.
  94135. */
  94136. onActivateObservable: Observable<Camera>;
  94137. private _onActivateObserver;
  94138. /**
  94139. * A function that is added to the onActivateObservable
  94140. */
  94141. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94142. /**
  94143. * An event triggered when the postprocess changes its size.
  94144. */
  94145. onSizeChangedObservable: Observable<PostProcess>;
  94146. private _onSizeChangedObserver;
  94147. /**
  94148. * A function that is added to the onSizeChangedObservable
  94149. */
  94150. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94151. /**
  94152. * An event triggered when the postprocess applies its effect.
  94153. */
  94154. onApplyObservable: Observable<Effect>;
  94155. private _onApplyObserver;
  94156. /**
  94157. * A function that is added to the onApplyObservable
  94158. */
  94159. set onApply(callback: (effect: Effect) => void);
  94160. /**
  94161. * An event triggered before rendering the postprocess
  94162. */
  94163. onBeforeRenderObservable: Observable<Effect>;
  94164. private _onBeforeRenderObserver;
  94165. /**
  94166. * A function that is added to the onBeforeRenderObservable
  94167. */
  94168. set onBeforeRender(callback: (effect: Effect) => void);
  94169. /**
  94170. * An event triggered after rendering the postprocess
  94171. */
  94172. onAfterRenderObservable: Observable<Effect>;
  94173. private _onAfterRenderObserver;
  94174. /**
  94175. * A function that is added to the onAfterRenderObservable
  94176. */
  94177. set onAfterRender(callback: (efect: Effect) => void);
  94178. /**
  94179. * 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
  94180. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94181. */
  94182. get inputTexture(): InternalTexture;
  94183. set inputTexture(value: InternalTexture);
  94184. /**
  94185. * Gets the camera which post process is applied to.
  94186. * @returns The camera the post process is applied to.
  94187. */
  94188. getCamera(): Camera;
  94189. /**
  94190. * Gets the texel size of the postprocess.
  94191. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94192. */
  94193. get texelSize(): Vector2;
  94194. /**
  94195. * Creates a new instance PostProcess
  94196. * @param name The name of the PostProcess.
  94197. * @param fragmentUrl The url of the fragment shader to be used.
  94198. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94199. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94200. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94201. * @param camera The camera to apply the render pass to.
  94202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94203. * @param engine The engine which the post process will be applied. (default: current engine)
  94204. * @param reusable If the post process can be reused on the same frame. (default: false)
  94205. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94206. * @param textureType Type of textures used when performing the post process. (default: 0)
  94207. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94208. * @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
  94209. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94210. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94211. */
  94212. constructor(
  94213. /** Name of the PostProcess. */
  94214. 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);
  94215. /**
  94216. * Gets a string idenfifying the name of the class
  94217. * @returns "PostProcess" string
  94218. */
  94219. getClassName(): string;
  94220. /**
  94221. * Gets the engine which this post process belongs to.
  94222. * @returns The engine the post process was enabled with.
  94223. */
  94224. getEngine(): Engine;
  94225. /**
  94226. * The effect that is created when initializing the post process.
  94227. * @returns The created effect corresponding the the postprocess.
  94228. */
  94229. getEffect(): Effect;
  94230. /**
  94231. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94232. * @param postProcess The post process to share the output with.
  94233. * @returns This post process.
  94234. */
  94235. shareOutputWith(postProcess: PostProcess): PostProcess;
  94236. /**
  94237. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94238. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94239. */
  94240. useOwnOutput(): void;
  94241. /**
  94242. * Updates the effect with the current post process compile time values and recompiles the shader.
  94243. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94244. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94245. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94246. * @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
  94247. * @param onCompiled Called when the shader has been compiled.
  94248. * @param onError Called if there is an error when compiling a shader.
  94249. */
  94250. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94251. /**
  94252. * The post process is reusable if it can be used multiple times within one frame.
  94253. * @returns If the post process is reusable
  94254. */
  94255. isReusable(): boolean;
  94256. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94257. markTextureDirty(): void;
  94258. /**
  94259. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94260. * 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.
  94261. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94262. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94263. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94264. * @returns The target texture that was bound to be written to.
  94265. */
  94266. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94267. /**
  94268. * If the post process is supported.
  94269. */
  94270. get isSupported(): boolean;
  94271. /**
  94272. * The aspect ratio of the output texture.
  94273. */
  94274. get aspectRatio(): number;
  94275. /**
  94276. * Get a value indicating if the post-process is ready to be used
  94277. * @returns true if the post-process is ready (shader is compiled)
  94278. */
  94279. isReady(): boolean;
  94280. /**
  94281. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94282. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94283. */
  94284. apply(): Nullable<Effect>;
  94285. private _disposeTextures;
  94286. /**
  94287. * Disposes the post process.
  94288. * @param camera The camera to dispose the post process on.
  94289. */
  94290. dispose(camera?: Camera): void;
  94291. }
  94292. }
  94293. declare module BABYLON {
  94294. /** @hidden */
  94295. export var kernelBlurVaryingDeclaration: {
  94296. name: string;
  94297. shader: string;
  94298. };
  94299. }
  94300. declare module BABYLON {
  94301. /** @hidden */
  94302. export var kernelBlurFragment: {
  94303. name: string;
  94304. shader: string;
  94305. };
  94306. }
  94307. declare module BABYLON {
  94308. /** @hidden */
  94309. export var kernelBlurFragment2: {
  94310. name: string;
  94311. shader: string;
  94312. };
  94313. }
  94314. declare module BABYLON {
  94315. /** @hidden */
  94316. export var kernelBlurPixelShader: {
  94317. name: string;
  94318. shader: string;
  94319. };
  94320. }
  94321. declare module BABYLON {
  94322. /** @hidden */
  94323. export var kernelBlurVertex: {
  94324. name: string;
  94325. shader: string;
  94326. };
  94327. }
  94328. declare module BABYLON {
  94329. /** @hidden */
  94330. export var kernelBlurVertexShader: {
  94331. name: string;
  94332. shader: string;
  94333. };
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * The Blur Post Process which blurs an image based on a kernel and direction.
  94338. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94339. */
  94340. export class BlurPostProcess extends PostProcess {
  94341. /** The direction in which to blur the image. */
  94342. direction: Vector2;
  94343. private blockCompilation;
  94344. protected _kernel: number;
  94345. protected _idealKernel: number;
  94346. protected _packedFloat: boolean;
  94347. private _staticDefines;
  94348. /**
  94349. * Sets the length in pixels of the blur sample region
  94350. */
  94351. set kernel(v: number);
  94352. /**
  94353. * Gets the length in pixels of the blur sample region
  94354. */
  94355. get kernel(): number;
  94356. /**
  94357. * Sets wether or not the blur needs to unpack/repack floats
  94358. */
  94359. set packedFloat(v: boolean);
  94360. /**
  94361. * Gets wether or not the blur is unpacking/repacking floats
  94362. */
  94363. get packedFloat(): boolean;
  94364. /**
  94365. * Creates a new instance BlurPostProcess
  94366. * @param name The name of the effect.
  94367. * @param direction The direction in which to blur the image.
  94368. * @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.
  94369. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94370. * @param camera The camera to apply the render pass to.
  94371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94372. * @param engine The engine which the post process will be applied. (default: current engine)
  94373. * @param reusable If the post process can be reused on the same frame. (default: false)
  94374. * @param textureType Type of textures used when performing the post process. (default: 0)
  94375. * @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)
  94376. */
  94377. constructor(name: string,
  94378. /** The direction in which to blur the image. */
  94379. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94380. /**
  94381. * Updates the effect with the current post process compile time values and recompiles the shader.
  94382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94385. * @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
  94386. * @param onCompiled Called when the shader has been compiled.
  94387. * @param onError Called if there is an error when compiling a shader.
  94388. */
  94389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94390. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94391. /**
  94392. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94393. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94394. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94395. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94396. * The gaps between physical kernels are compensated for in the weighting of the samples
  94397. * @param idealKernel Ideal blur kernel.
  94398. * @return Nearest best kernel.
  94399. */
  94400. protected _nearestBestKernel(idealKernel: number): number;
  94401. /**
  94402. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94403. * @param x The point on the Gaussian distribution to sample.
  94404. * @return the value of the Gaussian function at x.
  94405. */
  94406. protected _gaussianWeight(x: number): number;
  94407. /**
  94408. * Generates a string that can be used as a floating point number in GLSL.
  94409. * @param x Value to print.
  94410. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94411. * @return GLSL float string.
  94412. */
  94413. protected _glslFloat(x: number, decimalFigures?: number): string;
  94414. }
  94415. }
  94416. declare module BABYLON {
  94417. /**
  94418. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94419. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94420. * You can then easily use it as a reflectionTexture on a flat surface.
  94421. * In case the surface is not a plane, please consider relying on reflection probes.
  94422. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94423. */
  94424. export class MirrorTexture extends RenderTargetTexture {
  94425. private scene;
  94426. /**
  94427. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94428. * 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.
  94429. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94430. */
  94431. mirrorPlane: Plane;
  94432. /**
  94433. * Define the blur ratio used to blur the reflection if needed.
  94434. */
  94435. set blurRatio(value: number);
  94436. get blurRatio(): number;
  94437. /**
  94438. * Define the adaptive blur kernel used to blur the reflection if needed.
  94439. * This will autocompute the closest best match for the `blurKernel`
  94440. */
  94441. set adaptiveBlurKernel(value: number);
  94442. /**
  94443. * Define the blur kernel used to blur the reflection if needed.
  94444. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94445. */
  94446. set blurKernel(value: number);
  94447. /**
  94448. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94449. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94450. */
  94451. set blurKernelX(value: number);
  94452. get blurKernelX(): number;
  94453. /**
  94454. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94455. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94456. */
  94457. set blurKernelY(value: number);
  94458. get blurKernelY(): number;
  94459. private _autoComputeBlurKernel;
  94460. protected _onRatioRescale(): void;
  94461. private _updateGammaSpace;
  94462. private _imageProcessingConfigChangeObserver;
  94463. private _transformMatrix;
  94464. private _mirrorMatrix;
  94465. private _savedViewMatrix;
  94466. private _blurX;
  94467. private _blurY;
  94468. private _adaptiveBlurKernel;
  94469. private _blurKernelX;
  94470. private _blurKernelY;
  94471. private _blurRatio;
  94472. /**
  94473. * Instantiates a Mirror Texture.
  94474. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94475. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94476. * You can then easily use it as a reflectionTexture on a flat surface.
  94477. * In case the surface is not a plane, please consider relying on reflection probes.
  94478. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94479. * @param name
  94480. * @param size
  94481. * @param scene
  94482. * @param generateMipMaps
  94483. * @param type
  94484. * @param samplingMode
  94485. * @param generateDepthBuffer
  94486. */
  94487. constructor(name: string, size: number | {
  94488. width: number;
  94489. height: number;
  94490. } | {
  94491. ratio: number;
  94492. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94493. private _preparePostProcesses;
  94494. /**
  94495. * Clone the mirror texture.
  94496. * @returns the cloned texture
  94497. */
  94498. clone(): MirrorTexture;
  94499. /**
  94500. * Serialize the texture to a JSON representation you could use in Parse later on
  94501. * @returns the serialized JSON representation
  94502. */
  94503. serialize(): any;
  94504. /**
  94505. * Dispose the texture and release its associated resources.
  94506. */
  94507. dispose(): void;
  94508. }
  94509. }
  94510. declare module BABYLON {
  94511. /**
  94512. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94513. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94514. */
  94515. export class Texture extends BaseTexture {
  94516. /**
  94517. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94518. */
  94519. static SerializeBuffers: boolean;
  94520. /** @hidden */
  94521. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94522. /** @hidden */
  94523. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94524. /** @hidden */
  94525. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94526. /** nearest is mag = nearest and min = nearest and mip = linear */
  94527. static readonly NEAREST_SAMPLINGMODE: number;
  94528. /** nearest is mag = nearest and min = nearest and mip = linear */
  94529. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94530. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94531. static readonly BILINEAR_SAMPLINGMODE: number;
  94532. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94533. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94534. /** Trilinear is mag = linear and min = linear and mip = linear */
  94535. static readonly TRILINEAR_SAMPLINGMODE: number;
  94536. /** Trilinear is mag = linear and min = linear and mip = linear */
  94537. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94538. /** mag = nearest and min = nearest and mip = nearest */
  94539. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94540. /** mag = nearest and min = linear and mip = nearest */
  94541. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94542. /** mag = nearest and min = linear and mip = linear */
  94543. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94544. /** mag = nearest and min = linear and mip = none */
  94545. static readonly NEAREST_LINEAR: number;
  94546. /** mag = nearest and min = nearest and mip = none */
  94547. static readonly NEAREST_NEAREST: number;
  94548. /** mag = linear and min = nearest and mip = nearest */
  94549. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94550. /** mag = linear and min = nearest and mip = linear */
  94551. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94552. /** mag = linear and min = linear and mip = none */
  94553. static readonly LINEAR_LINEAR: number;
  94554. /** mag = linear and min = nearest and mip = none */
  94555. static readonly LINEAR_NEAREST: number;
  94556. /** Explicit coordinates mode */
  94557. static readonly EXPLICIT_MODE: number;
  94558. /** Spherical coordinates mode */
  94559. static readonly SPHERICAL_MODE: number;
  94560. /** Planar coordinates mode */
  94561. static readonly PLANAR_MODE: number;
  94562. /** Cubic coordinates mode */
  94563. static readonly CUBIC_MODE: number;
  94564. /** Projection coordinates mode */
  94565. static readonly PROJECTION_MODE: number;
  94566. /** Inverse Cubic coordinates mode */
  94567. static readonly SKYBOX_MODE: number;
  94568. /** Inverse Cubic coordinates mode */
  94569. static readonly INVCUBIC_MODE: number;
  94570. /** Equirectangular coordinates mode */
  94571. static readonly EQUIRECTANGULAR_MODE: number;
  94572. /** Equirectangular Fixed coordinates mode */
  94573. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94574. /** Equirectangular Fixed Mirrored coordinates mode */
  94575. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94576. /** Texture is not repeating outside of 0..1 UVs */
  94577. static readonly CLAMP_ADDRESSMODE: number;
  94578. /** Texture is repeating outside of 0..1 UVs */
  94579. static readonly WRAP_ADDRESSMODE: number;
  94580. /** Texture is repeating and mirrored */
  94581. static readonly MIRROR_ADDRESSMODE: number;
  94582. /**
  94583. * 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
  94584. */
  94585. static UseSerializedUrlIfAny: boolean;
  94586. /**
  94587. * Define the url of the texture.
  94588. */
  94589. url: Nullable<string>;
  94590. /**
  94591. * Define an offset on the texture to offset the u coordinates of the UVs
  94592. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94593. */
  94594. uOffset: number;
  94595. /**
  94596. * Define an offset on the texture to offset the v coordinates of the UVs
  94597. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94598. */
  94599. vOffset: number;
  94600. /**
  94601. * Define an offset on the texture to scale the u coordinates of the UVs
  94602. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94603. */
  94604. uScale: number;
  94605. /**
  94606. * Define an offset on the texture to scale the v coordinates of the UVs
  94607. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94608. */
  94609. vScale: number;
  94610. /**
  94611. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94612. * @see http://doc.babylonjs.com/how_to/more_materials
  94613. */
  94614. uAng: number;
  94615. /**
  94616. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94617. * @see http://doc.babylonjs.com/how_to/more_materials
  94618. */
  94619. vAng: number;
  94620. /**
  94621. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94622. * @see http://doc.babylonjs.com/how_to/more_materials
  94623. */
  94624. wAng: number;
  94625. /**
  94626. * Defines the center of rotation (U)
  94627. */
  94628. uRotationCenter: number;
  94629. /**
  94630. * Defines the center of rotation (V)
  94631. */
  94632. vRotationCenter: number;
  94633. /**
  94634. * Defines the center of rotation (W)
  94635. */
  94636. wRotationCenter: number;
  94637. /**
  94638. * Are mip maps generated for this texture or not.
  94639. */
  94640. get noMipmap(): boolean;
  94641. /**
  94642. * List of inspectable custom properties (used by the Inspector)
  94643. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94644. */
  94645. inspectableCustomProperties: Nullable<IInspectable[]>;
  94646. private _noMipmap;
  94647. /** @hidden */
  94648. _invertY: boolean;
  94649. private _rowGenerationMatrix;
  94650. private _cachedTextureMatrix;
  94651. private _projectionModeMatrix;
  94652. private _t0;
  94653. private _t1;
  94654. private _t2;
  94655. private _cachedUOffset;
  94656. private _cachedVOffset;
  94657. private _cachedUScale;
  94658. private _cachedVScale;
  94659. private _cachedUAng;
  94660. private _cachedVAng;
  94661. private _cachedWAng;
  94662. private _cachedProjectionMatrixId;
  94663. private _cachedCoordinatesMode;
  94664. /** @hidden */
  94665. protected _initialSamplingMode: number;
  94666. /** @hidden */
  94667. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94668. private _deleteBuffer;
  94669. protected _format: Nullable<number>;
  94670. private _delayedOnLoad;
  94671. private _delayedOnError;
  94672. private _mimeType?;
  94673. /**
  94674. * Observable triggered once the texture has been loaded.
  94675. */
  94676. onLoadObservable: Observable<Texture>;
  94677. protected _isBlocking: boolean;
  94678. /**
  94679. * Is the texture preventing material to render while loading.
  94680. * If false, a default texture will be used instead of the loading one during the preparation step.
  94681. */
  94682. set isBlocking(value: boolean);
  94683. get isBlocking(): boolean;
  94684. /**
  94685. * Get the current sampling mode associated with the texture.
  94686. */
  94687. get samplingMode(): number;
  94688. /**
  94689. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94690. */
  94691. get invertY(): boolean;
  94692. /**
  94693. * Instantiates a new texture.
  94694. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94695. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94696. * @param url defines the url of the picture to load as a texture
  94697. * @param scene defines the scene or engine the texture will belong to
  94698. * @param noMipmap defines if the texture will require mip maps or not
  94699. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94700. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94701. * @param onLoad defines a callback triggered when the texture has been loaded
  94702. * @param onError defines a callback triggered when an error occurred during the loading session
  94703. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94704. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94705. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94706. * @param mimeType defines an optional mime type information
  94707. */
  94708. 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);
  94709. /**
  94710. * Update the url (and optional buffer) of this texture if url was null during construction.
  94711. * @param url the url of the texture
  94712. * @param buffer the buffer of the texture (defaults to null)
  94713. * @param onLoad callback called when the texture is loaded (defaults to null)
  94714. */
  94715. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94716. /**
  94717. * Finish the loading sequence of a texture flagged as delayed load.
  94718. * @hidden
  94719. */
  94720. delayLoad(): void;
  94721. private _prepareRowForTextureGeneration;
  94722. /**
  94723. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94724. * @returns the transform matrix of the texture.
  94725. */
  94726. getTextureMatrix(uBase?: number): Matrix;
  94727. /**
  94728. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94729. * @returns The reflection texture transform
  94730. */
  94731. getReflectionTextureMatrix(): Matrix;
  94732. /**
  94733. * Clones the texture.
  94734. * @returns the cloned texture
  94735. */
  94736. clone(): Texture;
  94737. /**
  94738. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94739. * @returns The JSON representation of the texture
  94740. */
  94741. serialize(): any;
  94742. /**
  94743. * Get the current class name of the texture useful for serialization or dynamic coding.
  94744. * @returns "Texture"
  94745. */
  94746. getClassName(): string;
  94747. /**
  94748. * Dispose the texture and release its associated resources.
  94749. */
  94750. dispose(): void;
  94751. /**
  94752. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94753. * @param parsedTexture Define the JSON representation of the texture
  94754. * @param scene Define the scene the parsed texture should be instantiated in
  94755. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94756. * @returns The parsed texture if successful
  94757. */
  94758. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94759. /**
  94760. * Creates a texture from its base 64 representation.
  94761. * @param data Define the base64 payload without the data: prefix
  94762. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94763. * @param scene Define the scene the texture should belong to
  94764. * @param noMipmap Forces the texture to not create mip map information if true
  94765. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94766. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94767. * @param onLoad define a callback triggered when the texture has been loaded
  94768. * @param onError define a callback triggered when an error occurred during the loading session
  94769. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94770. * @returns the created texture
  94771. */
  94772. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94773. /**
  94774. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94775. * @param data Define the base64 payload without the data: prefix
  94776. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94777. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94778. * @param scene Define the scene the texture should belong to
  94779. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94780. * @param noMipmap Forces the texture to not create mip map information if true
  94781. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94782. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94783. * @param onLoad define a callback triggered when the texture has been loaded
  94784. * @param onError define a callback triggered when an error occurred during the loading session
  94785. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94786. * @returns the created texture
  94787. */
  94788. 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;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94794. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94795. */
  94796. export class PostProcessManager {
  94797. private _scene;
  94798. private _indexBuffer;
  94799. private _vertexBuffers;
  94800. /**
  94801. * Creates a new instance PostProcess
  94802. * @param scene The scene that the post process is associated with.
  94803. */
  94804. constructor(scene: Scene);
  94805. private _prepareBuffers;
  94806. private _buildIndexBuffer;
  94807. /**
  94808. * Rebuilds the vertex buffers of the manager.
  94809. * @hidden
  94810. */
  94811. _rebuild(): void;
  94812. /**
  94813. * Prepares a frame to be run through a post process.
  94814. * @param sourceTexture The input texture to the post procesess. (default: null)
  94815. * @param postProcesses An array of post processes to be run. (default: null)
  94816. * @returns True if the post processes were able to be run.
  94817. * @hidden
  94818. */
  94819. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94820. /**
  94821. * Manually render a set of post processes to a texture.
  94822. * @param postProcesses An array of post processes to be run.
  94823. * @param targetTexture The target texture to render to.
  94824. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94825. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94826. * @param lodLevel defines which lod of the texture to render to
  94827. */
  94828. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94829. /**
  94830. * Finalize the result of the output of the postprocesses.
  94831. * @param doNotPresent If true the result will not be displayed to the screen.
  94832. * @param targetTexture The target texture to render to.
  94833. * @param faceIndex The index of the face to bind the target texture to.
  94834. * @param postProcesses The array of post processes to render.
  94835. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94836. * @hidden
  94837. */
  94838. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94839. /**
  94840. * Disposes of the post process manager.
  94841. */
  94842. dispose(): void;
  94843. }
  94844. }
  94845. declare module BABYLON {
  94846. /**
  94847. * This Helps creating a texture that will be created from a camera in your scene.
  94848. * It is basically a dynamic texture that could be used to create special effects for instance.
  94849. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94850. */
  94851. export class RenderTargetTexture extends Texture {
  94852. isCube: boolean;
  94853. /**
  94854. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94855. */
  94856. static readonly REFRESHRATE_RENDER_ONCE: number;
  94857. /**
  94858. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94859. */
  94860. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94861. /**
  94862. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94863. * the central point of your effect and can save a lot of performances.
  94864. */
  94865. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94866. /**
  94867. * Use this predicate to dynamically define the list of mesh you want to render.
  94868. * If set, the renderList property will be overwritten.
  94869. */
  94870. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94871. private _renderList;
  94872. /**
  94873. * Use this list to define the list of mesh you want to render.
  94874. */
  94875. get renderList(): Nullable<Array<AbstractMesh>>;
  94876. set renderList(value: Nullable<Array<AbstractMesh>>);
  94877. /**
  94878. * Use this function to overload the renderList array at rendering time.
  94879. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94880. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94881. * the cube (if the RTT is a cube, else layerOrFace=0).
  94882. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94883. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94884. * hold dummy elements!
  94885. */
  94886. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94887. private _hookArray;
  94888. /**
  94889. * Define if particles should be rendered in your texture.
  94890. */
  94891. renderParticles: boolean;
  94892. /**
  94893. * Define if sprites should be rendered in your texture.
  94894. */
  94895. renderSprites: boolean;
  94896. /**
  94897. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94898. */
  94899. coordinatesMode: number;
  94900. /**
  94901. * Define the camera used to render the texture.
  94902. */
  94903. activeCamera: Nullable<Camera>;
  94904. /**
  94905. * Override the mesh isReady function with your own one.
  94906. */
  94907. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94908. /**
  94909. * Override the render function of the texture with your own one.
  94910. */
  94911. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94912. /**
  94913. * Define if camera post processes should be use while rendering the texture.
  94914. */
  94915. useCameraPostProcesses: boolean;
  94916. /**
  94917. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94918. */
  94919. ignoreCameraViewport: boolean;
  94920. private _postProcessManager;
  94921. private _postProcesses;
  94922. private _resizeObserver;
  94923. /**
  94924. * An event triggered when the texture is unbind.
  94925. */
  94926. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94927. /**
  94928. * An event triggered when the texture is unbind.
  94929. */
  94930. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94931. private _onAfterUnbindObserver;
  94932. /**
  94933. * Set a after unbind callback in the texture.
  94934. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94935. */
  94936. set onAfterUnbind(callback: () => void);
  94937. /**
  94938. * An event triggered before rendering the texture
  94939. */
  94940. onBeforeRenderObservable: Observable<number>;
  94941. private _onBeforeRenderObserver;
  94942. /**
  94943. * Set a before render callback in the texture.
  94944. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94945. */
  94946. set onBeforeRender(callback: (faceIndex: number) => void);
  94947. /**
  94948. * An event triggered after rendering the texture
  94949. */
  94950. onAfterRenderObservable: Observable<number>;
  94951. private _onAfterRenderObserver;
  94952. /**
  94953. * Set a after render callback in the texture.
  94954. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94955. */
  94956. set onAfterRender(callback: (faceIndex: number) => void);
  94957. /**
  94958. * An event triggered after the texture clear
  94959. */
  94960. onClearObservable: Observable<Engine>;
  94961. private _onClearObserver;
  94962. /**
  94963. * Set a clear callback in the texture.
  94964. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94965. */
  94966. set onClear(callback: (Engine: Engine) => void);
  94967. /**
  94968. * An event triggered when the texture is resized.
  94969. */
  94970. onResizeObservable: Observable<RenderTargetTexture>;
  94971. /**
  94972. * Define the clear color of the Render Target if it should be different from the scene.
  94973. */
  94974. clearColor: Color4;
  94975. protected _size: number | {
  94976. width: number;
  94977. height: number;
  94978. layers?: number;
  94979. };
  94980. protected _initialSizeParameter: number | {
  94981. width: number;
  94982. height: number;
  94983. } | {
  94984. ratio: number;
  94985. };
  94986. protected _sizeRatio: Nullable<number>;
  94987. /** @hidden */
  94988. _generateMipMaps: boolean;
  94989. protected _renderingManager: RenderingManager;
  94990. /** @hidden */
  94991. _waitingRenderList: string[];
  94992. protected _doNotChangeAspectRatio: boolean;
  94993. protected _currentRefreshId: number;
  94994. protected _refreshRate: number;
  94995. protected _textureMatrix: Matrix;
  94996. protected _samples: number;
  94997. protected _renderTargetOptions: RenderTargetCreationOptions;
  94998. /**
  94999. * Gets render target creation options that were used.
  95000. */
  95001. get renderTargetOptions(): RenderTargetCreationOptions;
  95002. protected _engine: Engine;
  95003. protected _onRatioRescale(): void;
  95004. /**
  95005. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95006. * It must define where the camera used to render the texture is set
  95007. */
  95008. boundingBoxPosition: Vector3;
  95009. private _boundingBoxSize;
  95010. /**
  95011. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95012. * When defined, the cubemap will switch to local mode
  95013. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95014. * @example https://www.babylonjs-playground.com/#RNASML
  95015. */
  95016. set boundingBoxSize(value: Vector3);
  95017. get boundingBoxSize(): Vector3;
  95018. /**
  95019. * In case the RTT has been created with a depth texture, get the associated
  95020. * depth texture.
  95021. * Otherwise, return null.
  95022. */
  95023. get depthStencilTexture(): Nullable<InternalTexture>;
  95024. /**
  95025. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95026. * or used a shadow, depth texture...
  95027. * @param name The friendly name of the texture
  95028. * @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)
  95029. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95030. * @param generateMipMaps True if mip maps need to be generated after render.
  95031. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95032. * @param type The type of the buffer in the RTT (int, half float, float...)
  95033. * @param isCube True if a cube texture needs to be created
  95034. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95035. * @param generateDepthBuffer True to generate a depth buffer
  95036. * @param generateStencilBuffer True to generate a stencil buffer
  95037. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95038. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95039. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95040. */
  95041. constructor(name: string, size: number | {
  95042. width: number;
  95043. height: number;
  95044. layers?: number;
  95045. } | {
  95046. ratio: number;
  95047. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95048. /**
  95049. * Creates a depth stencil texture.
  95050. * This is only available in WebGL 2 or with the depth texture extension available.
  95051. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95052. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95053. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95054. */
  95055. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95056. private _processSizeParameter;
  95057. /**
  95058. * Define the number of samples to use in case of MSAA.
  95059. * It defaults to one meaning no MSAA has been enabled.
  95060. */
  95061. get samples(): number;
  95062. set samples(value: number);
  95063. /**
  95064. * Resets the refresh counter of the texture and start bak from scratch.
  95065. * Could be useful to regenerate the texture if it is setup to render only once.
  95066. */
  95067. resetRefreshCounter(): void;
  95068. /**
  95069. * Define the refresh rate of the texture or the rendering frequency.
  95070. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95071. */
  95072. get refreshRate(): number;
  95073. set refreshRate(value: number);
  95074. /**
  95075. * Adds a post process to the render target rendering passes.
  95076. * @param postProcess define the post process to add
  95077. */
  95078. addPostProcess(postProcess: PostProcess): void;
  95079. /**
  95080. * Clear all the post processes attached to the render target
  95081. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95082. */
  95083. clearPostProcesses(dispose?: boolean): void;
  95084. /**
  95085. * Remove one of the post process from the list of attached post processes to the texture
  95086. * @param postProcess define the post process to remove from the list
  95087. */
  95088. removePostProcess(postProcess: PostProcess): void;
  95089. /** @hidden */
  95090. _shouldRender(): boolean;
  95091. /**
  95092. * Gets the actual render size of the texture.
  95093. * @returns the width of the render size
  95094. */
  95095. getRenderSize(): number;
  95096. /**
  95097. * Gets the actual render width of the texture.
  95098. * @returns the width of the render size
  95099. */
  95100. getRenderWidth(): number;
  95101. /**
  95102. * Gets the actual render height of the texture.
  95103. * @returns the height of the render size
  95104. */
  95105. getRenderHeight(): number;
  95106. /**
  95107. * Gets the actual number of layers of the texture.
  95108. * @returns the number of layers
  95109. */
  95110. getRenderLayers(): number;
  95111. /**
  95112. * Get if the texture can be rescaled or not.
  95113. */
  95114. get canRescale(): boolean;
  95115. /**
  95116. * Resize the texture using a ratio.
  95117. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95118. */
  95119. scale(ratio: number): void;
  95120. /**
  95121. * Get the texture reflection matrix used to rotate/transform the reflection.
  95122. * @returns the reflection matrix
  95123. */
  95124. getReflectionTextureMatrix(): Matrix;
  95125. /**
  95126. * Resize the texture to a new desired size.
  95127. * Be carrefull as it will recreate all the data in the new texture.
  95128. * @param size Define the new size. It can be:
  95129. * - a number for squared texture,
  95130. * - an object containing { width: number, height: number }
  95131. * - or an object containing a ratio { ratio: number }
  95132. */
  95133. resize(size: number | {
  95134. width: number;
  95135. height: number;
  95136. } | {
  95137. ratio: number;
  95138. }): void;
  95139. private _defaultRenderListPrepared;
  95140. /**
  95141. * Renders all the objects from the render list into the texture.
  95142. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95143. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95144. */
  95145. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95146. private _bestReflectionRenderTargetDimension;
  95147. private _prepareRenderingManager;
  95148. /**
  95149. * @hidden
  95150. * @param faceIndex face index to bind to if this is a cubetexture
  95151. * @param layer defines the index of the texture to bind in the array
  95152. */
  95153. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95154. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95155. private renderToTarget;
  95156. /**
  95157. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95158. * This allowed control for front to back rendering or reversly depending of the special needs.
  95159. *
  95160. * @param renderingGroupId The rendering group id corresponding to its index
  95161. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95162. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95163. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95164. */
  95165. 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;
  95166. /**
  95167. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95168. *
  95169. * @param renderingGroupId The rendering group id corresponding to its index
  95170. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95171. */
  95172. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95173. /**
  95174. * Clones the texture.
  95175. * @returns the cloned texture
  95176. */
  95177. clone(): RenderTargetTexture;
  95178. /**
  95179. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95180. * @returns The JSON representation of the texture
  95181. */
  95182. serialize(): any;
  95183. /**
  95184. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95185. */
  95186. disposeFramebufferObjects(): void;
  95187. /**
  95188. * Dispose the texture and release its associated resources.
  95189. */
  95190. dispose(): void;
  95191. /** @hidden */
  95192. _rebuild(): void;
  95193. /**
  95194. * Clear the info related to rendering groups preventing retention point in material dispose.
  95195. */
  95196. freeRenderingGroups(): void;
  95197. /**
  95198. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95199. * @returns the view count
  95200. */
  95201. getViewCount(): number;
  95202. }
  95203. }
  95204. declare module BABYLON {
  95205. /**
  95206. * Options for compiling materials.
  95207. */
  95208. export interface IMaterialCompilationOptions {
  95209. /**
  95210. * Defines whether clip planes are enabled.
  95211. */
  95212. clipPlane: boolean;
  95213. /**
  95214. * Defines whether instances are enabled.
  95215. */
  95216. useInstances: boolean;
  95217. }
  95218. /**
  95219. * Base class for the main features of a material in Babylon.js
  95220. */
  95221. export class Material implements IAnimatable {
  95222. /**
  95223. * Returns the triangle fill mode
  95224. */
  95225. static readonly TriangleFillMode: number;
  95226. /**
  95227. * Returns the wireframe mode
  95228. */
  95229. static readonly WireFrameFillMode: number;
  95230. /**
  95231. * Returns the point fill mode
  95232. */
  95233. static readonly PointFillMode: number;
  95234. /**
  95235. * Returns the point list draw mode
  95236. */
  95237. static readonly PointListDrawMode: number;
  95238. /**
  95239. * Returns the line list draw mode
  95240. */
  95241. static readonly LineListDrawMode: number;
  95242. /**
  95243. * Returns the line loop draw mode
  95244. */
  95245. static readonly LineLoopDrawMode: number;
  95246. /**
  95247. * Returns the line strip draw mode
  95248. */
  95249. static readonly LineStripDrawMode: number;
  95250. /**
  95251. * Returns the triangle strip draw mode
  95252. */
  95253. static readonly TriangleStripDrawMode: number;
  95254. /**
  95255. * Returns the triangle fan draw mode
  95256. */
  95257. static readonly TriangleFanDrawMode: number;
  95258. /**
  95259. * Stores the clock-wise side orientation
  95260. */
  95261. static readonly ClockWiseSideOrientation: number;
  95262. /**
  95263. * Stores the counter clock-wise side orientation
  95264. */
  95265. static readonly CounterClockWiseSideOrientation: number;
  95266. /**
  95267. * The dirty texture flag value
  95268. */
  95269. static readonly TextureDirtyFlag: number;
  95270. /**
  95271. * The dirty light flag value
  95272. */
  95273. static readonly LightDirtyFlag: number;
  95274. /**
  95275. * The dirty fresnel flag value
  95276. */
  95277. static readonly FresnelDirtyFlag: number;
  95278. /**
  95279. * The dirty attribute flag value
  95280. */
  95281. static readonly AttributesDirtyFlag: number;
  95282. /**
  95283. * The dirty misc flag value
  95284. */
  95285. static readonly MiscDirtyFlag: number;
  95286. /**
  95287. * The all dirty flag value
  95288. */
  95289. static readonly AllDirtyFlag: number;
  95290. /**
  95291. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95292. */
  95293. static readonly MATERIAL_OPAQUE: number;
  95294. /**
  95295. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95296. */
  95297. static readonly MATERIAL_ALPHATEST: number;
  95298. /**
  95299. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95300. */
  95301. static readonly MATERIAL_ALPHABLEND: number;
  95302. /**
  95303. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95304. * They are also discarded below the alpha cutoff threshold to improve performances.
  95305. */
  95306. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95307. /**
  95308. * The ID of the material
  95309. */
  95310. id: string;
  95311. /**
  95312. * Gets or sets the unique id of the material
  95313. */
  95314. uniqueId: number;
  95315. /**
  95316. * The name of the material
  95317. */
  95318. name: string;
  95319. /**
  95320. * Gets or sets user defined metadata
  95321. */
  95322. metadata: any;
  95323. /**
  95324. * For internal use only. Please do not use.
  95325. */
  95326. reservedDataStore: any;
  95327. /**
  95328. * Specifies if the ready state should be checked on each call
  95329. */
  95330. checkReadyOnEveryCall: boolean;
  95331. /**
  95332. * Specifies if the ready state should be checked once
  95333. */
  95334. checkReadyOnlyOnce: boolean;
  95335. /**
  95336. * The state of the material
  95337. */
  95338. state: string;
  95339. /**
  95340. * The alpha value of the material
  95341. */
  95342. protected _alpha: number;
  95343. /**
  95344. * List of inspectable custom properties (used by the Inspector)
  95345. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95346. */
  95347. inspectableCustomProperties: IInspectable[];
  95348. /**
  95349. * Sets the alpha value of the material
  95350. */
  95351. set alpha(value: number);
  95352. /**
  95353. * Gets the alpha value of the material
  95354. */
  95355. get alpha(): number;
  95356. /**
  95357. * Specifies if back face culling is enabled
  95358. */
  95359. protected _backFaceCulling: boolean;
  95360. /**
  95361. * Sets the back-face culling state
  95362. */
  95363. set backFaceCulling(value: boolean);
  95364. /**
  95365. * Gets the back-face culling state
  95366. */
  95367. get backFaceCulling(): boolean;
  95368. /**
  95369. * Stores the value for side orientation
  95370. */
  95371. sideOrientation: number;
  95372. /**
  95373. * Callback triggered when the material is compiled
  95374. */
  95375. onCompiled: Nullable<(effect: Effect) => void>;
  95376. /**
  95377. * Callback triggered when an error occurs
  95378. */
  95379. onError: Nullable<(effect: Effect, errors: string) => void>;
  95380. /**
  95381. * Callback triggered to get the render target textures
  95382. */
  95383. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95384. /**
  95385. * Gets a boolean indicating that current material needs to register RTT
  95386. */
  95387. get hasRenderTargetTextures(): boolean;
  95388. /**
  95389. * Specifies if the material should be serialized
  95390. */
  95391. doNotSerialize: boolean;
  95392. /**
  95393. * @hidden
  95394. */
  95395. _storeEffectOnSubMeshes: boolean;
  95396. /**
  95397. * Stores the animations for the material
  95398. */
  95399. animations: Nullable<Array<Animation>>;
  95400. /**
  95401. * An event triggered when the material is disposed
  95402. */
  95403. onDisposeObservable: Observable<Material>;
  95404. /**
  95405. * An observer which watches for dispose events
  95406. */
  95407. private _onDisposeObserver;
  95408. private _onUnBindObservable;
  95409. /**
  95410. * Called during a dispose event
  95411. */
  95412. set onDispose(callback: () => void);
  95413. private _onBindObservable;
  95414. /**
  95415. * An event triggered when the material is bound
  95416. */
  95417. get onBindObservable(): Observable<AbstractMesh>;
  95418. /**
  95419. * An observer which watches for bind events
  95420. */
  95421. private _onBindObserver;
  95422. /**
  95423. * Called during a bind event
  95424. */
  95425. set onBind(callback: (Mesh: AbstractMesh) => void);
  95426. /**
  95427. * An event triggered when the material is unbound
  95428. */
  95429. get onUnBindObservable(): Observable<Material>;
  95430. /**
  95431. * Stores the value of the alpha mode
  95432. */
  95433. private _alphaMode;
  95434. /**
  95435. * Sets the value of the alpha mode.
  95436. *
  95437. * | Value | Type | Description |
  95438. * | --- | --- | --- |
  95439. * | 0 | ALPHA_DISABLE | |
  95440. * | 1 | ALPHA_ADD | |
  95441. * | 2 | ALPHA_COMBINE | |
  95442. * | 3 | ALPHA_SUBTRACT | |
  95443. * | 4 | ALPHA_MULTIPLY | |
  95444. * | 5 | ALPHA_MAXIMIZED | |
  95445. * | 6 | ALPHA_ONEONE | |
  95446. * | 7 | ALPHA_PREMULTIPLIED | |
  95447. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95448. * | 9 | ALPHA_INTERPOLATE | |
  95449. * | 10 | ALPHA_SCREENMODE | |
  95450. *
  95451. */
  95452. set alphaMode(value: number);
  95453. /**
  95454. * Gets the value of the alpha mode
  95455. */
  95456. get alphaMode(): number;
  95457. /**
  95458. * Stores the state of the need depth pre-pass value
  95459. */
  95460. private _needDepthPrePass;
  95461. /**
  95462. * Sets the need depth pre-pass value
  95463. */
  95464. set needDepthPrePass(value: boolean);
  95465. /**
  95466. * Gets the depth pre-pass value
  95467. */
  95468. get needDepthPrePass(): boolean;
  95469. /**
  95470. * Specifies if depth writing should be disabled
  95471. */
  95472. disableDepthWrite: boolean;
  95473. /**
  95474. * Specifies if depth writing should be forced
  95475. */
  95476. forceDepthWrite: boolean;
  95477. /**
  95478. * Specifies the depth function that should be used. 0 means the default engine function
  95479. */
  95480. depthFunction: number;
  95481. /**
  95482. * Specifies if there should be a separate pass for culling
  95483. */
  95484. separateCullingPass: boolean;
  95485. /**
  95486. * Stores the state specifing if fog should be enabled
  95487. */
  95488. private _fogEnabled;
  95489. /**
  95490. * Sets the state for enabling fog
  95491. */
  95492. set fogEnabled(value: boolean);
  95493. /**
  95494. * Gets the value of the fog enabled state
  95495. */
  95496. get fogEnabled(): boolean;
  95497. /**
  95498. * Stores the size of points
  95499. */
  95500. pointSize: number;
  95501. /**
  95502. * Stores the z offset value
  95503. */
  95504. zOffset: number;
  95505. /**
  95506. * Gets a value specifying if wireframe mode is enabled
  95507. */
  95508. get wireframe(): boolean;
  95509. /**
  95510. * Sets the state of wireframe mode
  95511. */
  95512. set wireframe(value: boolean);
  95513. /**
  95514. * Gets the value specifying if point clouds are enabled
  95515. */
  95516. get pointsCloud(): boolean;
  95517. /**
  95518. * Sets the state of point cloud mode
  95519. */
  95520. set pointsCloud(value: boolean);
  95521. /**
  95522. * Gets the material fill mode
  95523. */
  95524. get fillMode(): number;
  95525. /**
  95526. * Sets the material fill mode
  95527. */
  95528. set fillMode(value: number);
  95529. /**
  95530. * @hidden
  95531. * Stores the effects for the material
  95532. */
  95533. _effect: Nullable<Effect>;
  95534. /**
  95535. * Specifies if uniform buffers should be used
  95536. */
  95537. private _useUBO;
  95538. /**
  95539. * Stores a reference to the scene
  95540. */
  95541. private _scene;
  95542. /**
  95543. * Stores the fill mode state
  95544. */
  95545. private _fillMode;
  95546. /**
  95547. * Specifies if the depth write state should be cached
  95548. */
  95549. private _cachedDepthWriteState;
  95550. /**
  95551. * Specifies if the depth function state should be cached
  95552. */
  95553. private _cachedDepthFunctionState;
  95554. /**
  95555. * Stores the uniform buffer
  95556. */
  95557. protected _uniformBuffer: UniformBuffer;
  95558. /** @hidden */
  95559. _indexInSceneMaterialArray: number;
  95560. /** @hidden */
  95561. meshMap: Nullable<{
  95562. [id: string]: AbstractMesh | undefined;
  95563. }>;
  95564. /**
  95565. * Creates a material instance
  95566. * @param name defines the name of the material
  95567. * @param scene defines the scene to reference
  95568. * @param doNotAdd specifies if the material should be added to the scene
  95569. */
  95570. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95571. /**
  95572. * Returns a string representation of the current material
  95573. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95574. * @returns a string with material information
  95575. */
  95576. toString(fullDetails?: boolean): string;
  95577. /**
  95578. * Gets the class name of the material
  95579. * @returns a string with the class name of the material
  95580. */
  95581. getClassName(): string;
  95582. /**
  95583. * Specifies if updates for the material been locked
  95584. */
  95585. get isFrozen(): boolean;
  95586. /**
  95587. * Locks updates for the material
  95588. */
  95589. freeze(): void;
  95590. /**
  95591. * Unlocks updates for the material
  95592. */
  95593. unfreeze(): void;
  95594. /**
  95595. * Specifies if the material is ready to be used
  95596. * @param mesh defines the mesh to check
  95597. * @param useInstances specifies if instances should be used
  95598. * @returns a boolean indicating if the material is ready to be used
  95599. */
  95600. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95601. /**
  95602. * Specifies that the submesh is ready to be used
  95603. * @param mesh defines the mesh to check
  95604. * @param subMesh defines which submesh to check
  95605. * @param useInstances specifies that instances should be used
  95606. * @returns a boolean indicating that the submesh is ready or not
  95607. */
  95608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95609. /**
  95610. * Returns the material effect
  95611. * @returns the effect associated with the material
  95612. */
  95613. getEffect(): Nullable<Effect>;
  95614. /**
  95615. * Returns the current scene
  95616. * @returns a Scene
  95617. */
  95618. getScene(): Scene;
  95619. /**
  95620. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95621. */
  95622. protected _forceAlphaTest: boolean;
  95623. /**
  95624. * The transparency mode of the material.
  95625. */
  95626. protected _transparencyMode: Nullable<number>;
  95627. /**
  95628. * Gets the current transparency mode.
  95629. */
  95630. get transparencyMode(): Nullable<number>;
  95631. /**
  95632. * Sets the transparency mode of the material.
  95633. *
  95634. * | Value | Type | Description |
  95635. * | ----- | ----------------------------------- | ----------- |
  95636. * | 0 | OPAQUE | |
  95637. * | 1 | ALPHATEST | |
  95638. * | 2 | ALPHABLEND | |
  95639. * | 3 | ALPHATESTANDBLEND | |
  95640. *
  95641. */
  95642. set transparencyMode(value: Nullable<number>);
  95643. /**
  95644. * Returns true if alpha blending should be disabled.
  95645. */
  95646. protected get _disableAlphaBlending(): boolean;
  95647. /**
  95648. * Specifies whether or not this material should be rendered in alpha blend mode.
  95649. * @returns a boolean specifying if alpha blending is needed
  95650. */
  95651. needAlphaBlending(): boolean;
  95652. /**
  95653. * Specifies if the mesh will require alpha blending
  95654. * @param mesh defines the mesh to check
  95655. * @returns a boolean specifying if alpha blending is needed for the mesh
  95656. */
  95657. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95658. /**
  95659. * Specifies whether or not this material should be rendered in alpha test mode.
  95660. * @returns a boolean specifying if an alpha test is needed.
  95661. */
  95662. needAlphaTesting(): boolean;
  95663. /**
  95664. * Specifies if material alpha testing should be turned on for the mesh
  95665. * @param mesh defines the mesh to check
  95666. */
  95667. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95668. /**
  95669. * Gets the texture used for the alpha test
  95670. * @returns the texture to use for alpha testing
  95671. */
  95672. getAlphaTestTexture(): Nullable<BaseTexture>;
  95673. /**
  95674. * Marks the material to indicate that it needs to be re-calculated
  95675. */
  95676. markDirty(): void;
  95677. /** @hidden */
  95678. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95679. /**
  95680. * Binds the material to the mesh
  95681. * @param world defines the world transformation matrix
  95682. * @param mesh defines the mesh to bind the material to
  95683. */
  95684. bind(world: Matrix, mesh?: Mesh): void;
  95685. /**
  95686. * Binds the submesh to the material
  95687. * @param world defines the world transformation matrix
  95688. * @param mesh defines the mesh containing the submesh
  95689. * @param subMesh defines the submesh to bind the material to
  95690. */
  95691. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95692. /**
  95693. * Binds the world matrix to the material
  95694. * @param world defines the world transformation matrix
  95695. */
  95696. bindOnlyWorldMatrix(world: Matrix): void;
  95697. /**
  95698. * Binds the scene's uniform buffer to the effect.
  95699. * @param effect defines the effect to bind to the scene uniform buffer
  95700. * @param sceneUbo defines the uniform buffer storing scene data
  95701. */
  95702. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95703. /**
  95704. * Binds the view matrix to the effect
  95705. * @param effect defines the effect to bind the view matrix to
  95706. */
  95707. bindView(effect: Effect): void;
  95708. /**
  95709. * Binds the view projection matrix to the effect
  95710. * @param effect defines the effect to bind the view projection matrix to
  95711. */
  95712. bindViewProjection(effect: Effect): void;
  95713. /**
  95714. * Processes to execute after binding the material to a mesh
  95715. * @param mesh defines the rendered mesh
  95716. */
  95717. protected _afterBind(mesh?: Mesh): void;
  95718. /**
  95719. * Unbinds the material from the mesh
  95720. */
  95721. unbind(): void;
  95722. /**
  95723. * Gets the active textures from the material
  95724. * @returns an array of textures
  95725. */
  95726. getActiveTextures(): BaseTexture[];
  95727. /**
  95728. * Specifies if the material uses a texture
  95729. * @param texture defines the texture to check against the material
  95730. * @returns a boolean specifying if the material uses the texture
  95731. */
  95732. hasTexture(texture: BaseTexture): boolean;
  95733. /**
  95734. * Makes a duplicate of the material, and gives it a new name
  95735. * @param name defines the new name for the duplicated material
  95736. * @returns the cloned material
  95737. */
  95738. clone(name: string): Nullable<Material>;
  95739. /**
  95740. * Gets the meshes bound to the material
  95741. * @returns an array of meshes bound to the material
  95742. */
  95743. getBindedMeshes(): AbstractMesh[];
  95744. /**
  95745. * Force shader compilation
  95746. * @param mesh defines the mesh associated with this material
  95747. * @param onCompiled defines a function to execute once the material is compiled
  95748. * @param options defines the options to configure the compilation
  95749. * @param onError defines a function to execute if the material fails compiling
  95750. */
  95751. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95752. /**
  95753. * Force shader compilation
  95754. * @param mesh defines the mesh that will use this material
  95755. * @param options defines additional options for compiling the shaders
  95756. * @returns a promise that resolves when the compilation completes
  95757. */
  95758. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95759. private static readonly _AllDirtyCallBack;
  95760. private static readonly _ImageProcessingDirtyCallBack;
  95761. private static readonly _TextureDirtyCallBack;
  95762. private static readonly _FresnelDirtyCallBack;
  95763. private static readonly _MiscDirtyCallBack;
  95764. private static readonly _LightsDirtyCallBack;
  95765. private static readonly _AttributeDirtyCallBack;
  95766. private static _FresnelAndMiscDirtyCallBack;
  95767. private static _TextureAndMiscDirtyCallBack;
  95768. private static readonly _DirtyCallbackArray;
  95769. private static readonly _RunDirtyCallBacks;
  95770. /**
  95771. * Marks a define in the material to indicate that it needs to be re-computed
  95772. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95773. */
  95774. markAsDirty(flag: number): void;
  95775. /**
  95776. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95777. * @param func defines a function which checks material defines against the submeshes
  95778. */
  95779. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95780. /**
  95781. * Indicates that we need to re-calculated for all submeshes
  95782. */
  95783. protected _markAllSubMeshesAsAllDirty(): void;
  95784. /**
  95785. * Indicates that image processing needs to be re-calculated for all submeshes
  95786. */
  95787. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95788. /**
  95789. * Indicates that textures need to be re-calculated for all submeshes
  95790. */
  95791. protected _markAllSubMeshesAsTexturesDirty(): void;
  95792. /**
  95793. * Indicates that fresnel needs to be re-calculated for all submeshes
  95794. */
  95795. protected _markAllSubMeshesAsFresnelDirty(): void;
  95796. /**
  95797. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95798. */
  95799. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95800. /**
  95801. * Indicates that lights need to be re-calculated for all submeshes
  95802. */
  95803. protected _markAllSubMeshesAsLightsDirty(): void;
  95804. /**
  95805. * Indicates that attributes need to be re-calculated for all submeshes
  95806. */
  95807. protected _markAllSubMeshesAsAttributesDirty(): void;
  95808. /**
  95809. * Indicates that misc needs to be re-calculated for all submeshes
  95810. */
  95811. protected _markAllSubMeshesAsMiscDirty(): void;
  95812. /**
  95813. * Indicates that textures and misc need to be re-calculated for all submeshes
  95814. */
  95815. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95816. /**
  95817. * Disposes the material
  95818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95819. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95820. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95821. */
  95822. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95823. /** @hidden */
  95824. private releaseVertexArrayObject;
  95825. /**
  95826. * Serializes this material
  95827. * @returns the serialized material object
  95828. */
  95829. serialize(): any;
  95830. /**
  95831. * Creates a material from parsed material data
  95832. * @param parsedMaterial defines parsed material data
  95833. * @param scene defines the hosting scene
  95834. * @param rootUrl defines the root URL to use to load textures
  95835. * @returns a new material
  95836. */
  95837. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95838. }
  95839. }
  95840. declare module BABYLON {
  95841. /**
  95842. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95843. * separate meshes. This can be use to improve performances.
  95844. * @see http://doc.babylonjs.com/how_to/multi_materials
  95845. */
  95846. export class MultiMaterial extends Material {
  95847. private _subMaterials;
  95848. /**
  95849. * Gets or Sets the list of Materials used within the multi material.
  95850. * They need to be ordered according to the submeshes order in the associated mesh
  95851. */
  95852. get subMaterials(): Nullable<Material>[];
  95853. set subMaterials(value: Nullable<Material>[]);
  95854. /**
  95855. * Function used to align with Node.getChildren()
  95856. * @returns the list of Materials used within the multi material
  95857. */
  95858. getChildren(): Nullable<Material>[];
  95859. /**
  95860. * Instantiates a new Multi Material
  95861. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95862. * separate meshes. This can be use to improve performances.
  95863. * @see http://doc.babylonjs.com/how_to/multi_materials
  95864. * @param name Define the name in the scene
  95865. * @param scene Define the scene the material belongs to
  95866. */
  95867. constructor(name: string, scene: Scene);
  95868. private _hookArray;
  95869. /**
  95870. * Get one of the submaterial by its index in the submaterials array
  95871. * @param index The index to look the sub material at
  95872. * @returns The Material if the index has been defined
  95873. */
  95874. getSubMaterial(index: number): Nullable<Material>;
  95875. /**
  95876. * Get the list of active textures for the whole sub materials list.
  95877. * @returns All the textures that will be used during the rendering
  95878. */
  95879. getActiveTextures(): BaseTexture[];
  95880. /**
  95881. * Gets the current class name of the material e.g. "MultiMaterial"
  95882. * Mainly use in serialization.
  95883. * @returns the class name
  95884. */
  95885. getClassName(): string;
  95886. /**
  95887. * Checks if the material is ready to render the requested sub mesh
  95888. * @param mesh Define the mesh the submesh belongs to
  95889. * @param subMesh Define the sub mesh to look readyness for
  95890. * @param useInstances Define whether or not the material is used with instances
  95891. * @returns true if ready, otherwise false
  95892. */
  95893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95894. /**
  95895. * Clones the current material and its related sub materials
  95896. * @param name Define the name of the newly cloned material
  95897. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95898. * @returns the cloned material
  95899. */
  95900. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95901. /**
  95902. * Serializes the materials into a JSON representation.
  95903. * @returns the JSON representation
  95904. */
  95905. serialize(): any;
  95906. /**
  95907. * Dispose the material and release its associated resources
  95908. * @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)
  95909. * @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)
  95910. * @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)
  95911. */
  95912. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95913. /**
  95914. * Creates a MultiMaterial from parsed MultiMaterial data.
  95915. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95916. * @param scene defines the hosting scene
  95917. * @returns a new MultiMaterial
  95918. */
  95919. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95920. }
  95921. }
  95922. declare module BABYLON {
  95923. /**
  95924. * Base class for submeshes
  95925. */
  95926. export class BaseSubMesh {
  95927. /** @hidden */
  95928. _materialDefines: Nullable<MaterialDefines>;
  95929. /** @hidden */
  95930. _materialEffect: Nullable<Effect>;
  95931. /**
  95932. * Gets material defines used by the effect associated to the sub mesh
  95933. */
  95934. get materialDefines(): Nullable<MaterialDefines>;
  95935. /**
  95936. * Sets material defines used by the effect associated to the sub mesh
  95937. */
  95938. set materialDefines(defines: Nullable<MaterialDefines>);
  95939. /**
  95940. * Gets associated effect
  95941. */
  95942. get effect(): Nullable<Effect>;
  95943. /**
  95944. * Sets associated effect (effect used to render this submesh)
  95945. * @param effect defines the effect to associate with
  95946. * @param defines defines the set of defines used to compile this effect
  95947. */
  95948. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95949. }
  95950. /**
  95951. * Defines a subdivision inside a mesh
  95952. */
  95953. export class SubMesh extends BaseSubMesh implements ICullable {
  95954. /** the material index to use */
  95955. materialIndex: number;
  95956. /** vertex index start */
  95957. verticesStart: number;
  95958. /** vertices count */
  95959. verticesCount: number;
  95960. /** index start */
  95961. indexStart: number;
  95962. /** indices count */
  95963. indexCount: number;
  95964. /** @hidden */
  95965. _linesIndexCount: number;
  95966. private _mesh;
  95967. private _renderingMesh;
  95968. private _boundingInfo;
  95969. private _linesIndexBuffer;
  95970. /** @hidden */
  95971. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95972. /** @hidden */
  95973. _trianglePlanes: Plane[];
  95974. /** @hidden */
  95975. _lastColliderTransformMatrix: Nullable<Matrix>;
  95976. /** @hidden */
  95977. _renderId: number;
  95978. /** @hidden */
  95979. _alphaIndex: number;
  95980. /** @hidden */
  95981. _distanceToCamera: number;
  95982. /** @hidden */
  95983. _id: number;
  95984. private _currentMaterial;
  95985. /**
  95986. * Add a new submesh to a mesh
  95987. * @param materialIndex defines the material index to use
  95988. * @param verticesStart defines vertex index start
  95989. * @param verticesCount defines vertices count
  95990. * @param indexStart defines index start
  95991. * @param indexCount defines indices count
  95992. * @param mesh defines the parent mesh
  95993. * @param renderingMesh defines an optional rendering mesh
  95994. * @param createBoundingBox defines if bounding box should be created for this submesh
  95995. * @returns the new submesh
  95996. */
  95997. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  95998. /**
  95999. * Creates a new submesh
  96000. * @param materialIndex defines the material index to use
  96001. * @param verticesStart defines vertex index start
  96002. * @param verticesCount defines vertices count
  96003. * @param indexStart defines index start
  96004. * @param indexCount defines indices count
  96005. * @param mesh defines the parent mesh
  96006. * @param renderingMesh defines an optional rendering mesh
  96007. * @param createBoundingBox defines if bounding box should be created for this submesh
  96008. */
  96009. constructor(
  96010. /** the material index to use */
  96011. materialIndex: number,
  96012. /** vertex index start */
  96013. verticesStart: number,
  96014. /** vertices count */
  96015. verticesCount: number,
  96016. /** index start */
  96017. indexStart: number,
  96018. /** indices count */
  96019. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96020. /**
  96021. * Returns true if this submesh covers the entire parent mesh
  96022. * @ignorenaming
  96023. */
  96024. get IsGlobal(): boolean;
  96025. /**
  96026. * Returns the submesh BoudingInfo object
  96027. * @returns current bounding info (or mesh's one if the submesh is global)
  96028. */
  96029. getBoundingInfo(): BoundingInfo;
  96030. /**
  96031. * Sets the submesh BoundingInfo
  96032. * @param boundingInfo defines the new bounding info to use
  96033. * @returns the SubMesh
  96034. */
  96035. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96036. /**
  96037. * Returns the mesh of the current submesh
  96038. * @return the parent mesh
  96039. */
  96040. getMesh(): AbstractMesh;
  96041. /**
  96042. * Returns the rendering mesh of the submesh
  96043. * @returns the rendering mesh (could be different from parent mesh)
  96044. */
  96045. getRenderingMesh(): Mesh;
  96046. /**
  96047. * Returns the submesh material
  96048. * @returns null or the current material
  96049. */
  96050. getMaterial(): Nullable<Material>;
  96051. /**
  96052. * Sets a new updated BoundingInfo object to the submesh
  96053. * @param data defines an optional position array to use to determine the bounding info
  96054. * @returns the SubMesh
  96055. */
  96056. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96057. /** @hidden */
  96058. _checkCollision(collider: Collider): boolean;
  96059. /**
  96060. * Updates the submesh BoundingInfo
  96061. * @param world defines the world matrix to use to update the bounding info
  96062. * @returns the submesh
  96063. */
  96064. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96065. /**
  96066. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96067. * @param frustumPlanes defines the frustum planes
  96068. * @returns true if the submesh is intersecting with the frustum
  96069. */
  96070. isInFrustum(frustumPlanes: Plane[]): boolean;
  96071. /**
  96072. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96073. * @param frustumPlanes defines the frustum planes
  96074. * @returns true if the submesh is inside the frustum
  96075. */
  96076. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96077. /**
  96078. * Renders the submesh
  96079. * @param enableAlphaMode defines if alpha needs to be used
  96080. * @returns the submesh
  96081. */
  96082. render(enableAlphaMode: boolean): SubMesh;
  96083. /**
  96084. * @hidden
  96085. */
  96086. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96087. /**
  96088. * Checks if the submesh intersects with a ray
  96089. * @param ray defines the ray to test
  96090. * @returns true is the passed ray intersects the submesh bounding box
  96091. */
  96092. canIntersects(ray: Ray): boolean;
  96093. /**
  96094. * Intersects current submesh with a ray
  96095. * @param ray defines the ray to test
  96096. * @param positions defines mesh's positions array
  96097. * @param indices defines mesh's indices array
  96098. * @param fastCheck defines if only bounding info should be used
  96099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96100. * @returns intersection info or null if no intersection
  96101. */
  96102. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96103. /** @hidden */
  96104. private _intersectLines;
  96105. /** @hidden */
  96106. private _intersectUnIndexedLines;
  96107. /** @hidden */
  96108. private _intersectTriangles;
  96109. /** @hidden */
  96110. private _intersectUnIndexedTriangles;
  96111. /** @hidden */
  96112. _rebuild(): void;
  96113. /**
  96114. * Creates a new submesh from the passed mesh
  96115. * @param newMesh defines the new hosting mesh
  96116. * @param newRenderingMesh defines an optional rendering mesh
  96117. * @returns the new submesh
  96118. */
  96119. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96120. /**
  96121. * Release associated resources
  96122. */
  96123. dispose(): void;
  96124. /**
  96125. * Gets the class name
  96126. * @returns the string "SubMesh".
  96127. */
  96128. getClassName(): string;
  96129. /**
  96130. * Creates a new submesh from indices data
  96131. * @param materialIndex the index of the main mesh material
  96132. * @param startIndex the index where to start the copy in the mesh indices array
  96133. * @param indexCount the number of indices to copy then from the startIndex
  96134. * @param mesh the main mesh to create the submesh from
  96135. * @param renderingMesh the optional rendering mesh
  96136. * @returns a new submesh
  96137. */
  96138. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96139. }
  96140. }
  96141. declare module BABYLON {
  96142. /**
  96143. * Class used to represent data loading progression
  96144. */
  96145. export class SceneLoaderFlags {
  96146. private static _ForceFullSceneLoadingForIncremental;
  96147. private static _ShowLoadingScreen;
  96148. private static _CleanBoneMatrixWeights;
  96149. private static _loggingLevel;
  96150. /**
  96151. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96152. */
  96153. static get ForceFullSceneLoadingForIncremental(): boolean;
  96154. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96155. /**
  96156. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96157. */
  96158. static get ShowLoadingScreen(): boolean;
  96159. static set ShowLoadingScreen(value: boolean);
  96160. /**
  96161. * Defines the current logging level (while loading the scene)
  96162. * @ignorenaming
  96163. */
  96164. static get loggingLevel(): number;
  96165. static set loggingLevel(value: number);
  96166. /**
  96167. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96168. */
  96169. static get CleanBoneMatrixWeights(): boolean;
  96170. static set CleanBoneMatrixWeights(value: boolean);
  96171. }
  96172. }
  96173. declare module BABYLON {
  96174. /**
  96175. * Class used to store geometry data (vertex buffers + index buffer)
  96176. */
  96177. export class Geometry implements IGetSetVerticesData {
  96178. /**
  96179. * Gets or sets the ID of the geometry
  96180. */
  96181. id: string;
  96182. /**
  96183. * Gets or sets the unique ID of the geometry
  96184. */
  96185. uniqueId: number;
  96186. /**
  96187. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96188. */
  96189. delayLoadState: number;
  96190. /**
  96191. * Gets the file containing the data to load when running in delay load state
  96192. */
  96193. delayLoadingFile: Nullable<string>;
  96194. /**
  96195. * Callback called when the geometry is updated
  96196. */
  96197. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96198. private _scene;
  96199. private _engine;
  96200. private _meshes;
  96201. private _totalVertices;
  96202. /** @hidden */
  96203. _indices: IndicesArray;
  96204. /** @hidden */
  96205. _vertexBuffers: {
  96206. [key: string]: VertexBuffer;
  96207. };
  96208. private _isDisposed;
  96209. private _extend;
  96210. private _boundingBias;
  96211. /** @hidden */
  96212. _delayInfo: Array<string>;
  96213. private _indexBuffer;
  96214. private _indexBufferIsUpdatable;
  96215. /** @hidden */
  96216. _boundingInfo: Nullable<BoundingInfo>;
  96217. /** @hidden */
  96218. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96219. /** @hidden */
  96220. _softwareSkinningFrameId: number;
  96221. private _vertexArrayObjects;
  96222. private _updatable;
  96223. /** @hidden */
  96224. _positions: Nullable<Vector3[]>;
  96225. /**
  96226. * 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
  96227. */
  96228. get boundingBias(): Vector2;
  96229. /**
  96230. * 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
  96231. */
  96232. set boundingBias(value: Vector2);
  96233. /**
  96234. * Static function used to attach a new empty geometry to a mesh
  96235. * @param mesh defines the mesh to attach the geometry to
  96236. * @returns the new Geometry
  96237. */
  96238. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96239. /**
  96240. * Creates a new geometry
  96241. * @param id defines the unique ID
  96242. * @param scene defines the hosting scene
  96243. * @param vertexData defines the VertexData used to get geometry data
  96244. * @param updatable defines if geometry must be updatable (false by default)
  96245. * @param mesh defines the mesh that will be associated with the geometry
  96246. */
  96247. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96248. /**
  96249. * Gets the current extend of the geometry
  96250. */
  96251. get extend(): {
  96252. minimum: Vector3;
  96253. maximum: Vector3;
  96254. };
  96255. /**
  96256. * Gets the hosting scene
  96257. * @returns the hosting Scene
  96258. */
  96259. getScene(): Scene;
  96260. /**
  96261. * Gets the hosting engine
  96262. * @returns the hosting Engine
  96263. */
  96264. getEngine(): Engine;
  96265. /**
  96266. * Defines if the geometry is ready to use
  96267. * @returns true if the geometry is ready to be used
  96268. */
  96269. isReady(): boolean;
  96270. /**
  96271. * Gets a value indicating that the geometry should not be serialized
  96272. */
  96273. get doNotSerialize(): boolean;
  96274. /** @hidden */
  96275. _rebuild(): void;
  96276. /**
  96277. * Affects all geometry data in one call
  96278. * @param vertexData defines the geometry data
  96279. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96280. */
  96281. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96282. /**
  96283. * Set specific vertex data
  96284. * @param kind defines the data kind (Position, normal, etc...)
  96285. * @param data defines the vertex data to use
  96286. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96287. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96288. */
  96289. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96290. /**
  96291. * Removes a specific vertex data
  96292. * @param kind defines the data kind (Position, normal, etc...)
  96293. */
  96294. removeVerticesData(kind: string): void;
  96295. /**
  96296. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96297. * @param buffer defines the vertex buffer to use
  96298. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96299. */
  96300. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96301. /**
  96302. * Update a specific vertex buffer
  96303. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96304. * It will do nothing if the buffer is not updatable
  96305. * @param kind defines the data kind (Position, normal, etc...)
  96306. * @param data defines the data to use
  96307. * @param offset defines the offset in the target buffer where to store the data
  96308. * @param useBytes set to true if the offset is in bytes
  96309. */
  96310. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96311. /**
  96312. * Update a specific vertex buffer
  96313. * This function will create a new buffer if the current one is not updatable
  96314. * @param kind defines the data kind (Position, normal, etc...)
  96315. * @param data defines the data to use
  96316. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96317. */
  96318. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96319. private _updateBoundingInfo;
  96320. /** @hidden */
  96321. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96322. /**
  96323. * Gets total number of vertices
  96324. * @returns the total number of vertices
  96325. */
  96326. getTotalVertices(): number;
  96327. /**
  96328. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96329. * @param kind defines the data kind (Position, normal, etc...)
  96330. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96331. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96332. * @returns a float array containing vertex data
  96333. */
  96334. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96335. /**
  96336. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96337. * @param kind defines the data kind (Position, normal, etc...)
  96338. * @returns true if the vertex buffer with the specified kind is updatable
  96339. */
  96340. isVertexBufferUpdatable(kind: string): boolean;
  96341. /**
  96342. * Gets a specific vertex buffer
  96343. * @param kind defines the data kind (Position, normal, etc...)
  96344. * @returns a VertexBuffer
  96345. */
  96346. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96347. /**
  96348. * Returns all vertex buffers
  96349. * @return an object holding all vertex buffers indexed by kind
  96350. */
  96351. getVertexBuffers(): Nullable<{
  96352. [key: string]: VertexBuffer;
  96353. }>;
  96354. /**
  96355. * Gets a boolean indicating if specific vertex buffer is present
  96356. * @param kind defines the data kind (Position, normal, etc...)
  96357. * @returns true if data is present
  96358. */
  96359. isVerticesDataPresent(kind: string): boolean;
  96360. /**
  96361. * Gets a list of all attached data kinds (Position, normal, etc...)
  96362. * @returns a list of string containing all kinds
  96363. */
  96364. getVerticesDataKinds(): string[];
  96365. /**
  96366. * Update index buffer
  96367. * @param indices defines the indices to store in the index buffer
  96368. * @param offset defines the offset in the target buffer where to store the data
  96369. * @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)
  96370. */
  96371. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96372. /**
  96373. * Creates a new index buffer
  96374. * @param indices defines the indices to store in the index buffer
  96375. * @param totalVertices defines the total number of vertices (could be null)
  96376. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96377. */
  96378. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96379. /**
  96380. * Return the total number of indices
  96381. * @returns the total number of indices
  96382. */
  96383. getTotalIndices(): number;
  96384. /**
  96385. * Gets the index buffer array
  96386. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96387. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96388. * @returns the index buffer array
  96389. */
  96390. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96391. /**
  96392. * Gets the index buffer
  96393. * @return the index buffer
  96394. */
  96395. getIndexBuffer(): Nullable<DataBuffer>;
  96396. /** @hidden */
  96397. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96398. /**
  96399. * Release the associated resources for a specific mesh
  96400. * @param mesh defines the source mesh
  96401. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96402. */
  96403. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96404. /**
  96405. * Apply current geometry to a given mesh
  96406. * @param mesh defines the mesh to apply geometry to
  96407. */
  96408. applyToMesh(mesh: Mesh): void;
  96409. private _updateExtend;
  96410. private _applyToMesh;
  96411. private notifyUpdate;
  96412. /**
  96413. * Load the geometry if it was flagged as delay loaded
  96414. * @param scene defines the hosting scene
  96415. * @param onLoaded defines a callback called when the geometry is loaded
  96416. */
  96417. load(scene: Scene, onLoaded?: () => void): void;
  96418. private _queueLoad;
  96419. /**
  96420. * Invert the geometry to move from a right handed system to a left handed one.
  96421. */
  96422. toLeftHanded(): void;
  96423. /** @hidden */
  96424. _resetPointsArrayCache(): void;
  96425. /** @hidden */
  96426. _generatePointsArray(): boolean;
  96427. /**
  96428. * Gets a value indicating if the geometry is disposed
  96429. * @returns true if the geometry was disposed
  96430. */
  96431. isDisposed(): boolean;
  96432. private _disposeVertexArrayObjects;
  96433. /**
  96434. * Free all associated resources
  96435. */
  96436. dispose(): void;
  96437. /**
  96438. * Clone the current geometry into a new geometry
  96439. * @param id defines the unique ID of the new geometry
  96440. * @returns a new geometry object
  96441. */
  96442. copy(id: string): Geometry;
  96443. /**
  96444. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96445. * @return a JSON representation of the current geometry data (without the vertices data)
  96446. */
  96447. serialize(): any;
  96448. private toNumberArray;
  96449. /**
  96450. * Serialize all vertices data into a JSON oject
  96451. * @returns a JSON representation of the current geometry data
  96452. */
  96453. serializeVerticeData(): any;
  96454. /**
  96455. * Extracts a clone of a mesh geometry
  96456. * @param mesh defines the source mesh
  96457. * @param id defines the unique ID of the new geometry object
  96458. * @returns the new geometry object
  96459. */
  96460. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96461. /**
  96462. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96464. * Be aware Math.random() could cause collisions, but:
  96465. * "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"
  96466. * @returns a string containing a new GUID
  96467. */
  96468. static RandomId(): string;
  96469. /** @hidden */
  96470. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96471. private static _CleanMatricesWeights;
  96472. /**
  96473. * Create a new geometry from persisted data (Using .babylon file format)
  96474. * @param parsedVertexData defines the persisted data
  96475. * @param scene defines the hosting scene
  96476. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96477. * @returns the new geometry object
  96478. */
  96479. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96480. }
  96481. }
  96482. declare module BABYLON {
  96483. /**
  96484. * Define an interface for all classes that will get and set the data on vertices
  96485. */
  96486. export interface IGetSetVerticesData {
  96487. /**
  96488. * Gets a boolean indicating if specific vertex data is present
  96489. * @param kind defines the vertex data kind to use
  96490. * @returns true is data kind is present
  96491. */
  96492. isVerticesDataPresent(kind: string): boolean;
  96493. /**
  96494. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96495. * @param kind defines the data kind (Position, normal, etc...)
  96496. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96497. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96498. * @returns a float array containing vertex data
  96499. */
  96500. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96501. /**
  96502. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96503. * @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.
  96504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96505. * @returns the indices array or an empty array if the mesh has no geometry
  96506. */
  96507. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96508. /**
  96509. * Set specific vertex data
  96510. * @param kind defines the data kind (Position, normal, etc...)
  96511. * @param data defines the vertex data to use
  96512. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96513. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96514. */
  96515. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96516. /**
  96517. * Update a specific associated vertex buffer
  96518. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96519. * - VertexBuffer.PositionKind
  96520. * - VertexBuffer.UVKind
  96521. * - VertexBuffer.UV2Kind
  96522. * - VertexBuffer.UV3Kind
  96523. * - VertexBuffer.UV4Kind
  96524. * - VertexBuffer.UV5Kind
  96525. * - VertexBuffer.UV6Kind
  96526. * - VertexBuffer.ColorKind
  96527. * - VertexBuffer.MatricesIndicesKind
  96528. * - VertexBuffer.MatricesIndicesExtraKind
  96529. * - VertexBuffer.MatricesWeightsKind
  96530. * - VertexBuffer.MatricesWeightsExtraKind
  96531. * @param data defines the data source
  96532. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96533. * @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)
  96534. */
  96535. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96536. /**
  96537. * Creates a new index buffer
  96538. * @param indices defines the indices to store in the index buffer
  96539. * @param totalVertices defines the total number of vertices (could be null)
  96540. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96541. */
  96542. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96543. }
  96544. /**
  96545. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96546. */
  96547. export class VertexData {
  96548. /**
  96549. * Mesh side orientation : usually the external or front surface
  96550. */
  96551. static readonly FRONTSIDE: number;
  96552. /**
  96553. * Mesh side orientation : usually the internal or back surface
  96554. */
  96555. static readonly BACKSIDE: number;
  96556. /**
  96557. * Mesh side orientation : both internal and external or front and back surfaces
  96558. */
  96559. static readonly DOUBLESIDE: number;
  96560. /**
  96561. * Mesh side orientation : by default, `FRONTSIDE`
  96562. */
  96563. static readonly DEFAULTSIDE: number;
  96564. /**
  96565. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96566. */
  96567. positions: Nullable<FloatArray>;
  96568. /**
  96569. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96570. */
  96571. normals: Nullable<FloatArray>;
  96572. /**
  96573. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96574. */
  96575. tangents: Nullable<FloatArray>;
  96576. /**
  96577. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96578. */
  96579. uvs: Nullable<FloatArray>;
  96580. /**
  96581. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96582. */
  96583. uvs2: Nullable<FloatArray>;
  96584. /**
  96585. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96586. */
  96587. uvs3: Nullable<FloatArray>;
  96588. /**
  96589. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96590. */
  96591. uvs4: Nullable<FloatArray>;
  96592. /**
  96593. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96594. */
  96595. uvs5: Nullable<FloatArray>;
  96596. /**
  96597. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96598. */
  96599. uvs6: Nullable<FloatArray>;
  96600. /**
  96601. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96602. */
  96603. colors: Nullable<FloatArray>;
  96604. /**
  96605. * 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).
  96606. */
  96607. matricesIndices: Nullable<FloatArray>;
  96608. /**
  96609. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96610. */
  96611. matricesWeights: Nullable<FloatArray>;
  96612. /**
  96613. * An array extending the number of possible indices
  96614. */
  96615. matricesIndicesExtra: Nullable<FloatArray>;
  96616. /**
  96617. * An array extending the number of possible weights when the number of indices is extended
  96618. */
  96619. matricesWeightsExtra: Nullable<FloatArray>;
  96620. /**
  96621. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96622. */
  96623. indices: Nullable<IndicesArray>;
  96624. /**
  96625. * Uses the passed data array to set the set the values for the specified kind of data
  96626. * @param data a linear array of floating numbers
  96627. * @param kind the type of data that is being set, eg positions, colors etc
  96628. */
  96629. set(data: FloatArray, kind: string): void;
  96630. /**
  96631. * Associates the vertexData to the passed Mesh.
  96632. * Sets it as updatable or not (default `false`)
  96633. * @param mesh the mesh the vertexData is applied to
  96634. * @param updatable when used and having the value true allows new data to update the vertexData
  96635. * @returns the VertexData
  96636. */
  96637. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96638. /**
  96639. * Associates the vertexData to the passed Geometry.
  96640. * Sets it as updatable or not (default `false`)
  96641. * @param geometry the geometry the vertexData is applied to
  96642. * @param updatable when used and having the value true allows new data to update the vertexData
  96643. * @returns VertexData
  96644. */
  96645. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96646. /**
  96647. * Updates the associated mesh
  96648. * @param mesh the mesh to be updated
  96649. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96650. * @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
  96651. * @returns VertexData
  96652. */
  96653. updateMesh(mesh: Mesh): VertexData;
  96654. /**
  96655. * Updates the associated geometry
  96656. * @param geometry the geometry to be updated
  96657. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96658. * @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
  96659. * @returns VertexData.
  96660. */
  96661. updateGeometry(geometry: Geometry): VertexData;
  96662. private _applyTo;
  96663. private _update;
  96664. /**
  96665. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96666. * @param matrix the transforming matrix
  96667. * @returns the VertexData
  96668. */
  96669. transform(matrix: Matrix): VertexData;
  96670. /**
  96671. * Merges the passed VertexData into the current one
  96672. * @param other the VertexData to be merged into the current one
  96673. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96674. * @returns the modified VertexData
  96675. */
  96676. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96677. private _mergeElement;
  96678. private _validate;
  96679. /**
  96680. * Serializes the VertexData
  96681. * @returns a serialized object
  96682. */
  96683. serialize(): any;
  96684. /**
  96685. * Extracts the vertexData from a mesh
  96686. * @param mesh the mesh from which to extract the VertexData
  96687. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96688. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96689. * @returns the object VertexData associated to the passed mesh
  96690. */
  96691. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96692. /**
  96693. * Extracts the vertexData from the geometry
  96694. * @param geometry the geometry from which to extract the VertexData
  96695. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96696. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96697. * @returns the object VertexData associated to the passed mesh
  96698. */
  96699. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96700. private static _ExtractFrom;
  96701. /**
  96702. * Creates the VertexData for a Ribbon
  96703. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96704. * * pathArray array of paths, each of which an array of successive Vector3
  96705. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96706. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96707. * * 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
  96708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96709. * * 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)
  96710. * * 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)
  96711. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96712. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96713. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96714. * @returns the VertexData of the ribbon
  96715. */
  96716. static CreateRibbon(options: {
  96717. pathArray: Vector3[][];
  96718. closeArray?: boolean;
  96719. closePath?: boolean;
  96720. offset?: number;
  96721. sideOrientation?: number;
  96722. frontUVs?: Vector4;
  96723. backUVs?: Vector4;
  96724. invertUV?: boolean;
  96725. uvs?: Vector2[];
  96726. colors?: Color4[];
  96727. }): VertexData;
  96728. /**
  96729. * Creates the VertexData for a box
  96730. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96731. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96732. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96733. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96734. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96735. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96736. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96738. * * 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)
  96739. * * 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)
  96740. * @returns the VertexData of the box
  96741. */
  96742. static CreateBox(options: {
  96743. size?: number;
  96744. width?: number;
  96745. height?: number;
  96746. depth?: number;
  96747. faceUV?: Vector4[];
  96748. faceColors?: Color4[];
  96749. sideOrientation?: number;
  96750. frontUVs?: Vector4;
  96751. backUVs?: Vector4;
  96752. }): VertexData;
  96753. /**
  96754. * Creates the VertexData for a tiled box
  96755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96756. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96757. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96758. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96760. * @returns the VertexData of the box
  96761. */
  96762. static CreateTiledBox(options: {
  96763. pattern?: number;
  96764. width?: number;
  96765. height?: number;
  96766. depth?: number;
  96767. tileSize?: number;
  96768. tileWidth?: number;
  96769. tileHeight?: number;
  96770. alignHorizontal?: number;
  96771. alignVertical?: number;
  96772. faceUV?: Vector4[];
  96773. faceColors?: Color4[];
  96774. sideOrientation?: number;
  96775. }): VertexData;
  96776. /**
  96777. * Creates the VertexData for a tiled plane
  96778. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96779. * * pattern a limited pattern arrangement depending on the number
  96780. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96781. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96782. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96784. * * 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)
  96785. * * 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)
  96786. * @returns the VertexData of the tiled plane
  96787. */
  96788. static CreateTiledPlane(options: {
  96789. pattern?: number;
  96790. tileSize?: number;
  96791. tileWidth?: number;
  96792. tileHeight?: number;
  96793. size?: number;
  96794. width?: number;
  96795. height?: number;
  96796. alignHorizontal?: number;
  96797. alignVertical?: number;
  96798. sideOrientation?: number;
  96799. frontUVs?: Vector4;
  96800. backUVs?: Vector4;
  96801. }): VertexData;
  96802. /**
  96803. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96805. * * segments sets the number of horizontal strips optional, default 32
  96806. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96807. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96808. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96809. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96810. * * 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
  96811. * * 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
  96812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96813. * * 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)
  96814. * * 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)
  96815. * @returns the VertexData of the ellipsoid
  96816. */
  96817. static CreateSphere(options: {
  96818. segments?: number;
  96819. diameter?: number;
  96820. diameterX?: number;
  96821. diameterY?: number;
  96822. diameterZ?: number;
  96823. arc?: number;
  96824. slice?: number;
  96825. sideOrientation?: number;
  96826. frontUVs?: Vector4;
  96827. backUVs?: Vector4;
  96828. }): VertexData;
  96829. /**
  96830. * Creates the VertexData for a cylinder, cone or prism
  96831. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96832. * * height sets the height (y direction) of the cylinder, optional, default 2
  96833. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96834. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96835. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96836. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96837. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96838. * * 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
  96839. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96841. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96842. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96844. * * 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)
  96845. * * 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)
  96846. * @returns the VertexData of the cylinder, cone or prism
  96847. */
  96848. static CreateCylinder(options: {
  96849. height?: number;
  96850. diameterTop?: number;
  96851. diameterBottom?: number;
  96852. diameter?: number;
  96853. tessellation?: number;
  96854. subdivisions?: number;
  96855. arc?: number;
  96856. faceColors?: Color4[];
  96857. faceUV?: Vector4[];
  96858. hasRings?: boolean;
  96859. enclose?: boolean;
  96860. sideOrientation?: number;
  96861. frontUVs?: Vector4;
  96862. backUVs?: Vector4;
  96863. }): VertexData;
  96864. /**
  96865. * Creates the VertexData for a torus
  96866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96867. * * diameter the diameter of the torus, optional default 1
  96868. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96869. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96871. * * 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)
  96872. * * 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)
  96873. * @returns the VertexData of the torus
  96874. */
  96875. static CreateTorus(options: {
  96876. diameter?: number;
  96877. thickness?: number;
  96878. tessellation?: number;
  96879. sideOrientation?: number;
  96880. frontUVs?: Vector4;
  96881. backUVs?: Vector4;
  96882. }): VertexData;
  96883. /**
  96884. * Creates the VertexData of the LineSystem
  96885. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96886. * - lines an array of lines, each line being an array of successive Vector3
  96887. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96888. * @returns the VertexData of the LineSystem
  96889. */
  96890. static CreateLineSystem(options: {
  96891. lines: Vector3[][];
  96892. colors?: Nullable<Color4[][]>;
  96893. }): VertexData;
  96894. /**
  96895. * Create the VertexData for a DashedLines
  96896. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96897. * - points an array successive Vector3
  96898. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96899. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96900. * - dashNb the intended total number of dashes, optional, default 200
  96901. * @returns the VertexData for the DashedLines
  96902. */
  96903. static CreateDashedLines(options: {
  96904. points: Vector3[];
  96905. dashSize?: number;
  96906. gapSize?: number;
  96907. dashNb?: number;
  96908. }): VertexData;
  96909. /**
  96910. * Creates the VertexData for a Ground
  96911. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96912. * - width the width (x direction) of the ground, optional, default 1
  96913. * - height the height (z direction) of the ground, optional, default 1
  96914. * - subdivisions the number of subdivisions per side, optional, default 1
  96915. * @returns the VertexData of the Ground
  96916. */
  96917. static CreateGround(options: {
  96918. width?: number;
  96919. height?: number;
  96920. subdivisions?: number;
  96921. subdivisionsX?: number;
  96922. subdivisionsY?: number;
  96923. }): VertexData;
  96924. /**
  96925. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96927. * * xmin the ground minimum X coordinate, optional, default -1
  96928. * * zmin the ground minimum Z coordinate, optional, default -1
  96929. * * xmax the ground maximum X coordinate, optional, default 1
  96930. * * zmax the ground maximum Z coordinate, optional, default 1
  96931. * * 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}
  96932. * * 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}
  96933. * @returns the VertexData of the TiledGround
  96934. */
  96935. static CreateTiledGround(options: {
  96936. xmin: number;
  96937. zmin: number;
  96938. xmax: number;
  96939. zmax: number;
  96940. subdivisions?: {
  96941. w: number;
  96942. h: number;
  96943. };
  96944. precision?: {
  96945. w: number;
  96946. h: number;
  96947. };
  96948. }): VertexData;
  96949. /**
  96950. * Creates the VertexData of the Ground designed from a heightmap
  96951. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96952. * * width the width (x direction) of the ground
  96953. * * height the height (z direction) of the ground
  96954. * * subdivisions the number of subdivisions per side
  96955. * * minHeight the minimum altitude on the ground, optional, default 0
  96956. * * maxHeight the maximum altitude on the ground, optional default 1
  96957. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96958. * * buffer the array holding the image color data
  96959. * * bufferWidth the width of image
  96960. * * bufferHeight the height of image
  96961. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96962. * @returns the VertexData of the Ground designed from a heightmap
  96963. */
  96964. static CreateGroundFromHeightMap(options: {
  96965. width: number;
  96966. height: number;
  96967. subdivisions: number;
  96968. minHeight: number;
  96969. maxHeight: number;
  96970. colorFilter: Color3;
  96971. buffer: Uint8Array;
  96972. bufferWidth: number;
  96973. bufferHeight: number;
  96974. alphaFilter: number;
  96975. }): VertexData;
  96976. /**
  96977. * Creates the VertexData for a Plane
  96978. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96979. * * size sets the width and height of the plane to the value of size, optional default 1
  96980. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96981. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96983. * * 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)
  96984. * * 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)
  96985. * @returns the VertexData of the box
  96986. */
  96987. static CreatePlane(options: {
  96988. size?: number;
  96989. width?: number;
  96990. height?: number;
  96991. sideOrientation?: number;
  96992. frontUVs?: Vector4;
  96993. backUVs?: Vector4;
  96994. }): VertexData;
  96995. /**
  96996. * Creates the VertexData of the Disc or regular Polygon
  96997. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  96998. * * radius the radius of the disc, optional default 0.5
  96999. * * tessellation the number of polygon sides, optional, default 64
  97000. * * 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
  97001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97002. * * 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)
  97003. * * 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)
  97004. * @returns the VertexData of the box
  97005. */
  97006. static CreateDisc(options: {
  97007. radius?: number;
  97008. tessellation?: number;
  97009. arc?: number;
  97010. sideOrientation?: number;
  97011. frontUVs?: Vector4;
  97012. backUVs?: Vector4;
  97013. }): VertexData;
  97014. /**
  97015. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97016. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97017. * @param polygon a mesh built from polygonTriangulation.build()
  97018. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97019. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97020. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97021. * @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)
  97022. * @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)
  97023. * @returns the VertexData of the Polygon
  97024. */
  97025. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97026. /**
  97027. * Creates the VertexData of the IcoSphere
  97028. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97029. * * radius the radius of the IcoSphere, optional default 1
  97030. * * radiusX allows stretching in the x direction, optional, default radius
  97031. * * radiusY allows stretching in the y direction, optional, default radius
  97032. * * radiusZ allows stretching in the z direction, optional, default radius
  97033. * * flat when true creates a flat shaded mesh, optional, default true
  97034. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97036. * * 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)
  97037. * * 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)
  97038. * @returns the VertexData of the IcoSphere
  97039. */
  97040. static CreateIcoSphere(options: {
  97041. radius?: number;
  97042. radiusX?: number;
  97043. radiusY?: number;
  97044. radiusZ?: number;
  97045. flat?: boolean;
  97046. subdivisions?: number;
  97047. sideOrientation?: number;
  97048. frontUVs?: Vector4;
  97049. backUVs?: Vector4;
  97050. }): VertexData;
  97051. /**
  97052. * Creates the VertexData for a Polyhedron
  97053. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97054. * * type provided types are:
  97055. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97056. * * 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)
  97057. * * size the size of the IcoSphere, optional default 1
  97058. * * sizeX allows stretching in the x direction, optional, default size
  97059. * * sizeY allows stretching in the y direction, optional, default size
  97060. * * sizeZ allows stretching in the z direction, optional, default size
  97061. * * 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
  97062. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97063. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97064. * * flat when true creates a flat shaded mesh, optional, default true
  97065. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97067. * * 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)
  97068. * * 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)
  97069. * @returns the VertexData of the Polyhedron
  97070. */
  97071. static CreatePolyhedron(options: {
  97072. type?: number;
  97073. size?: number;
  97074. sizeX?: number;
  97075. sizeY?: number;
  97076. sizeZ?: number;
  97077. custom?: any;
  97078. faceUV?: Vector4[];
  97079. faceColors?: Color4[];
  97080. flat?: boolean;
  97081. sideOrientation?: number;
  97082. frontUVs?: Vector4;
  97083. backUVs?: Vector4;
  97084. }): VertexData;
  97085. /**
  97086. * Creates the VertexData for a TorusKnot
  97087. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97088. * * radius the radius of the torus knot, optional, default 2
  97089. * * tube the thickness of the tube, optional, default 0.5
  97090. * * radialSegments the number of sides on each tube segments, optional, default 32
  97091. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97092. * * p the number of windings around the z axis, optional, default 2
  97093. * * q the number of windings around the x axis, optional, default 3
  97094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97095. * * 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)
  97096. * * 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)
  97097. * @returns the VertexData of the Torus Knot
  97098. */
  97099. static CreateTorusKnot(options: {
  97100. radius?: number;
  97101. tube?: number;
  97102. radialSegments?: number;
  97103. tubularSegments?: number;
  97104. p?: number;
  97105. q?: number;
  97106. sideOrientation?: number;
  97107. frontUVs?: Vector4;
  97108. backUVs?: Vector4;
  97109. }): VertexData;
  97110. /**
  97111. * Compute normals for given positions and indices
  97112. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97113. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97114. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97115. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97116. * * facetNormals : optional array of facet normals (vector3)
  97117. * * facetPositions : optional array of facet positions (vector3)
  97118. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97119. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97120. * * bInfo : optional bounding info, required for facetPartitioning computation
  97121. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97122. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97123. * * useRightHandedSystem: optional boolean to for right handed system computation
  97124. * * depthSort : optional boolean to enable the facet depth sort computation
  97125. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97126. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97127. */
  97128. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97129. facetNormals?: any;
  97130. facetPositions?: any;
  97131. facetPartitioning?: any;
  97132. ratio?: number;
  97133. bInfo?: any;
  97134. bbSize?: Vector3;
  97135. subDiv?: any;
  97136. useRightHandedSystem?: boolean;
  97137. depthSort?: boolean;
  97138. distanceTo?: Vector3;
  97139. depthSortedFacets?: any;
  97140. }): void;
  97141. /** @hidden */
  97142. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97143. /**
  97144. * Applies VertexData created from the imported parameters to the geometry
  97145. * @param parsedVertexData the parsed data from an imported file
  97146. * @param geometry the geometry to apply the VertexData to
  97147. */
  97148. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97149. }
  97150. }
  97151. declare module BABYLON {
  97152. /**
  97153. * Defines a target to use with MorphTargetManager
  97154. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97155. */
  97156. export class MorphTarget implements IAnimatable {
  97157. /** defines the name of the target */
  97158. name: string;
  97159. /**
  97160. * Gets or sets the list of animations
  97161. */
  97162. animations: Animation[];
  97163. private _scene;
  97164. private _positions;
  97165. private _normals;
  97166. private _tangents;
  97167. private _uvs;
  97168. private _influence;
  97169. private _uniqueId;
  97170. /**
  97171. * Observable raised when the influence changes
  97172. */
  97173. onInfluenceChanged: Observable<boolean>;
  97174. /** @hidden */
  97175. _onDataLayoutChanged: Observable<void>;
  97176. /**
  97177. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97178. */
  97179. get influence(): number;
  97180. set influence(influence: number);
  97181. /**
  97182. * Gets or sets the id of the morph Target
  97183. */
  97184. id: string;
  97185. private _animationPropertiesOverride;
  97186. /**
  97187. * Gets or sets the animation properties override
  97188. */
  97189. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97190. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97191. /**
  97192. * Creates a new MorphTarget
  97193. * @param name defines the name of the target
  97194. * @param influence defines the influence to use
  97195. * @param scene defines the scene the morphtarget belongs to
  97196. */
  97197. constructor(
  97198. /** defines the name of the target */
  97199. name: string, influence?: number, scene?: Nullable<Scene>);
  97200. /**
  97201. * Gets the unique ID of this manager
  97202. */
  97203. get uniqueId(): number;
  97204. /**
  97205. * Gets a boolean defining if the target contains position data
  97206. */
  97207. get hasPositions(): boolean;
  97208. /**
  97209. * Gets a boolean defining if the target contains normal data
  97210. */
  97211. get hasNormals(): boolean;
  97212. /**
  97213. * Gets a boolean defining if the target contains tangent data
  97214. */
  97215. get hasTangents(): boolean;
  97216. /**
  97217. * Gets a boolean defining if the target contains texture coordinates data
  97218. */
  97219. get hasUVs(): boolean;
  97220. /**
  97221. * Affects position data to this target
  97222. * @param data defines the position data to use
  97223. */
  97224. setPositions(data: Nullable<FloatArray>): void;
  97225. /**
  97226. * Gets the position data stored in this target
  97227. * @returns a FloatArray containing the position data (or null if not present)
  97228. */
  97229. getPositions(): Nullable<FloatArray>;
  97230. /**
  97231. * Affects normal data to this target
  97232. * @param data defines the normal data to use
  97233. */
  97234. setNormals(data: Nullable<FloatArray>): void;
  97235. /**
  97236. * Gets the normal data stored in this target
  97237. * @returns a FloatArray containing the normal data (or null if not present)
  97238. */
  97239. getNormals(): Nullable<FloatArray>;
  97240. /**
  97241. * Affects tangent data to this target
  97242. * @param data defines the tangent data to use
  97243. */
  97244. setTangents(data: Nullable<FloatArray>): void;
  97245. /**
  97246. * Gets the tangent data stored in this target
  97247. * @returns a FloatArray containing the tangent data (or null if not present)
  97248. */
  97249. getTangents(): Nullable<FloatArray>;
  97250. /**
  97251. * Affects texture coordinates data to this target
  97252. * @param data defines the texture coordinates data to use
  97253. */
  97254. setUVs(data: Nullable<FloatArray>): void;
  97255. /**
  97256. * Gets the texture coordinates data stored in this target
  97257. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97258. */
  97259. getUVs(): Nullable<FloatArray>;
  97260. /**
  97261. * Clone the current target
  97262. * @returns a new MorphTarget
  97263. */
  97264. clone(): MorphTarget;
  97265. /**
  97266. * Serializes the current target into a Serialization object
  97267. * @returns the serialized object
  97268. */
  97269. serialize(): any;
  97270. /**
  97271. * Returns the string "MorphTarget"
  97272. * @returns "MorphTarget"
  97273. */
  97274. getClassName(): string;
  97275. /**
  97276. * Creates a new target from serialized data
  97277. * @param serializationObject defines the serialized data to use
  97278. * @returns a new MorphTarget
  97279. */
  97280. static Parse(serializationObject: any): MorphTarget;
  97281. /**
  97282. * Creates a MorphTarget from mesh data
  97283. * @param mesh defines the source mesh
  97284. * @param name defines the name to use for the new target
  97285. * @param influence defines the influence to attach to the target
  97286. * @returns a new MorphTarget
  97287. */
  97288. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97289. }
  97290. }
  97291. declare module BABYLON {
  97292. /**
  97293. * This class is used to deform meshes using morphing between different targets
  97294. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97295. */
  97296. export class MorphTargetManager {
  97297. private _targets;
  97298. private _targetInfluenceChangedObservers;
  97299. private _targetDataLayoutChangedObservers;
  97300. private _activeTargets;
  97301. private _scene;
  97302. private _influences;
  97303. private _supportsNormals;
  97304. private _supportsTangents;
  97305. private _supportsUVs;
  97306. private _vertexCount;
  97307. private _uniqueId;
  97308. private _tempInfluences;
  97309. /**
  97310. * Gets or sets a boolean indicating if normals must be morphed
  97311. */
  97312. enableNormalMorphing: boolean;
  97313. /**
  97314. * Gets or sets a boolean indicating if tangents must be morphed
  97315. */
  97316. enableTangentMorphing: boolean;
  97317. /**
  97318. * Gets or sets a boolean indicating if UV must be morphed
  97319. */
  97320. enableUVMorphing: boolean;
  97321. /**
  97322. * Creates a new MorphTargetManager
  97323. * @param scene defines the current scene
  97324. */
  97325. constructor(scene?: Nullable<Scene>);
  97326. /**
  97327. * Gets the unique ID of this manager
  97328. */
  97329. get uniqueId(): number;
  97330. /**
  97331. * Gets the number of vertices handled by this manager
  97332. */
  97333. get vertexCount(): number;
  97334. /**
  97335. * Gets a boolean indicating if this manager supports morphing of normals
  97336. */
  97337. get supportsNormals(): boolean;
  97338. /**
  97339. * Gets a boolean indicating if this manager supports morphing of tangents
  97340. */
  97341. get supportsTangents(): boolean;
  97342. /**
  97343. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97344. */
  97345. get supportsUVs(): boolean;
  97346. /**
  97347. * Gets the number of targets stored in this manager
  97348. */
  97349. get numTargets(): number;
  97350. /**
  97351. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97352. */
  97353. get numInfluencers(): number;
  97354. /**
  97355. * Gets the list of influences (one per target)
  97356. */
  97357. get influences(): Float32Array;
  97358. /**
  97359. * Gets the active target at specified index. An active target is a target with an influence > 0
  97360. * @param index defines the index to check
  97361. * @returns the requested target
  97362. */
  97363. getActiveTarget(index: number): MorphTarget;
  97364. /**
  97365. * Gets the target at specified index
  97366. * @param index defines the index to check
  97367. * @returns the requested target
  97368. */
  97369. getTarget(index: number): MorphTarget;
  97370. /**
  97371. * Add a new target to this manager
  97372. * @param target defines the target to add
  97373. */
  97374. addTarget(target: MorphTarget): void;
  97375. /**
  97376. * Removes a target from the manager
  97377. * @param target defines the target to remove
  97378. */
  97379. removeTarget(target: MorphTarget): void;
  97380. /**
  97381. * Clone the current manager
  97382. * @returns a new MorphTargetManager
  97383. */
  97384. clone(): MorphTargetManager;
  97385. /**
  97386. * Serializes the current manager into a Serialization object
  97387. * @returns the serialized object
  97388. */
  97389. serialize(): any;
  97390. private _syncActiveTargets;
  97391. /**
  97392. * Syncrhonize the targets with all the meshes using this morph target manager
  97393. */
  97394. synchronize(): void;
  97395. /**
  97396. * Creates a new MorphTargetManager from serialized data
  97397. * @param serializationObject defines the serialized data
  97398. * @param scene defines the hosting scene
  97399. * @returns the new MorphTargetManager
  97400. */
  97401. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97402. }
  97403. }
  97404. declare module BABYLON {
  97405. /**
  97406. * Class used to represent a specific level of detail of a mesh
  97407. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97408. */
  97409. export class MeshLODLevel {
  97410. /** Defines the distance where this level should start being displayed */
  97411. distance: number;
  97412. /** Defines the mesh to use to render this level */
  97413. mesh: Nullable<Mesh>;
  97414. /**
  97415. * Creates a new LOD level
  97416. * @param distance defines the distance where this level should star being displayed
  97417. * @param mesh defines the mesh to use to render this level
  97418. */
  97419. constructor(
  97420. /** Defines the distance where this level should start being displayed */
  97421. distance: number,
  97422. /** Defines the mesh to use to render this level */
  97423. mesh: Nullable<Mesh>);
  97424. }
  97425. }
  97426. declare module BABYLON {
  97427. /**
  97428. * Mesh representing the gorund
  97429. */
  97430. export class GroundMesh extends Mesh {
  97431. /** If octree should be generated */
  97432. generateOctree: boolean;
  97433. private _heightQuads;
  97434. /** @hidden */
  97435. _subdivisionsX: number;
  97436. /** @hidden */
  97437. _subdivisionsY: number;
  97438. /** @hidden */
  97439. _width: number;
  97440. /** @hidden */
  97441. _height: number;
  97442. /** @hidden */
  97443. _minX: number;
  97444. /** @hidden */
  97445. _maxX: number;
  97446. /** @hidden */
  97447. _minZ: number;
  97448. /** @hidden */
  97449. _maxZ: number;
  97450. constructor(name: string, scene: Scene);
  97451. /**
  97452. * "GroundMesh"
  97453. * @returns "GroundMesh"
  97454. */
  97455. getClassName(): string;
  97456. /**
  97457. * The minimum of x and y subdivisions
  97458. */
  97459. get subdivisions(): number;
  97460. /**
  97461. * X subdivisions
  97462. */
  97463. get subdivisionsX(): number;
  97464. /**
  97465. * Y subdivisions
  97466. */
  97467. get subdivisionsY(): number;
  97468. /**
  97469. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97470. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97471. * @param chunksCount the number of subdivisions for x and y
  97472. * @param octreeBlocksSize (Default: 32)
  97473. */
  97474. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97475. /**
  97476. * Returns a height (y) value in the Worl system :
  97477. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97478. * @param x x coordinate
  97479. * @param z z coordinate
  97480. * @returns the ground y position if (x, z) are outside the ground surface.
  97481. */
  97482. getHeightAtCoordinates(x: number, z: number): number;
  97483. /**
  97484. * Returns a normalized vector (Vector3) orthogonal to the ground
  97485. * at the ground coordinates (x, z) expressed in the World system.
  97486. * @param x x coordinate
  97487. * @param z z coordinate
  97488. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97489. */
  97490. getNormalAtCoordinates(x: number, z: number): Vector3;
  97491. /**
  97492. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97493. * at the ground coordinates (x, z) expressed in the World system.
  97494. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97495. * @param x x coordinate
  97496. * @param z z coordinate
  97497. * @param ref vector to store the result
  97498. * @returns the GroundMesh.
  97499. */
  97500. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97501. /**
  97502. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97503. * if the ground has been updated.
  97504. * This can be used in the render loop.
  97505. * @returns the GroundMesh.
  97506. */
  97507. updateCoordinateHeights(): GroundMesh;
  97508. private _getFacetAt;
  97509. private _initHeightQuads;
  97510. private _computeHeightQuads;
  97511. /**
  97512. * Serializes this ground mesh
  97513. * @param serializationObject object to write serialization to
  97514. */
  97515. serialize(serializationObject: any): void;
  97516. /**
  97517. * Parses a serialized ground mesh
  97518. * @param parsedMesh the serialized mesh
  97519. * @param scene the scene to create the ground mesh in
  97520. * @returns the created ground mesh
  97521. */
  97522. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97523. }
  97524. }
  97525. declare module BABYLON {
  97526. /**
  97527. * Interface for Physics-Joint data
  97528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97529. */
  97530. export interface PhysicsJointData {
  97531. /**
  97532. * The main pivot of the joint
  97533. */
  97534. mainPivot?: Vector3;
  97535. /**
  97536. * The connected pivot of the joint
  97537. */
  97538. connectedPivot?: Vector3;
  97539. /**
  97540. * The main axis of the joint
  97541. */
  97542. mainAxis?: Vector3;
  97543. /**
  97544. * The connected axis of the joint
  97545. */
  97546. connectedAxis?: Vector3;
  97547. /**
  97548. * The collision of the joint
  97549. */
  97550. collision?: boolean;
  97551. /**
  97552. * Native Oimo/Cannon/Energy data
  97553. */
  97554. nativeParams?: any;
  97555. }
  97556. /**
  97557. * This is a holder class for the physics joint created by the physics plugin
  97558. * It holds a set of functions to control the underlying joint
  97559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97560. */
  97561. export class PhysicsJoint {
  97562. /**
  97563. * The type of the physics joint
  97564. */
  97565. type: number;
  97566. /**
  97567. * The data for the physics joint
  97568. */
  97569. jointData: PhysicsJointData;
  97570. private _physicsJoint;
  97571. protected _physicsPlugin: IPhysicsEnginePlugin;
  97572. /**
  97573. * Initializes the physics joint
  97574. * @param type The type of the physics joint
  97575. * @param jointData The data for the physics joint
  97576. */
  97577. constructor(
  97578. /**
  97579. * The type of the physics joint
  97580. */
  97581. type: number,
  97582. /**
  97583. * The data for the physics joint
  97584. */
  97585. jointData: PhysicsJointData);
  97586. /**
  97587. * Gets the physics joint
  97588. */
  97589. get physicsJoint(): any;
  97590. /**
  97591. * Sets the physics joint
  97592. */
  97593. set physicsJoint(newJoint: any);
  97594. /**
  97595. * Sets the physics plugin
  97596. */
  97597. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97598. /**
  97599. * Execute a function that is physics-plugin specific.
  97600. * @param {Function} func the function that will be executed.
  97601. * It accepts two parameters: the physics world and the physics joint
  97602. */
  97603. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97604. /**
  97605. * Distance-Joint type
  97606. */
  97607. static DistanceJoint: number;
  97608. /**
  97609. * Hinge-Joint type
  97610. */
  97611. static HingeJoint: number;
  97612. /**
  97613. * Ball-and-Socket joint type
  97614. */
  97615. static BallAndSocketJoint: number;
  97616. /**
  97617. * Wheel-Joint type
  97618. */
  97619. static WheelJoint: number;
  97620. /**
  97621. * Slider-Joint type
  97622. */
  97623. static SliderJoint: number;
  97624. /**
  97625. * Prismatic-Joint type
  97626. */
  97627. static PrismaticJoint: number;
  97628. /**
  97629. * Universal-Joint type
  97630. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97631. */
  97632. static UniversalJoint: number;
  97633. /**
  97634. * Hinge-Joint 2 type
  97635. */
  97636. static Hinge2Joint: number;
  97637. /**
  97638. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97639. */
  97640. static PointToPointJoint: number;
  97641. /**
  97642. * Spring-Joint type
  97643. */
  97644. static SpringJoint: number;
  97645. /**
  97646. * Lock-Joint type
  97647. */
  97648. static LockJoint: number;
  97649. }
  97650. /**
  97651. * A class representing a physics distance joint
  97652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97653. */
  97654. export class DistanceJoint extends PhysicsJoint {
  97655. /**
  97656. *
  97657. * @param jointData The data for the Distance-Joint
  97658. */
  97659. constructor(jointData: DistanceJointData);
  97660. /**
  97661. * Update the predefined distance.
  97662. * @param maxDistance The maximum preferred distance
  97663. * @param minDistance The minimum preferred distance
  97664. */
  97665. updateDistance(maxDistance: number, minDistance?: number): void;
  97666. }
  97667. /**
  97668. * Represents a Motor-Enabled Joint
  97669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97670. */
  97671. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97672. /**
  97673. * Initializes the Motor-Enabled Joint
  97674. * @param type The type of the joint
  97675. * @param jointData The physica joint data for the joint
  97676. */
  97677. constructor(type: number, jointData: PhysicsJointData);
  97678. /**
  97679. * Set the motor values.
  97680. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97681. * @param force the force to apply
  97682. * @param maxForce max force for this motor.
  97683. */
  97684. setMotor(force?: number, maxForce?: number): void;
  97685. /**
  97686. * Set the motor's limits.
  97687. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97688. * @param upperLimit The upper limit of the motor
  97689. * @param lowerLimit The lower limit of the motor
  97690. */
  97691. setLimit(upperLimit: number, lowerLimit?: number): void;
  97692. }
  97693. /**
  97694. * This class represents a single physics Hinge-Joint
  97695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97696. */
  97697. export class HingeJoint extends MotorEnabledJoint {
  97698. /**
  97699. * Initializes the Hinge-Joint
  97700. * @param jointData The joint data for the Hinge-Joint
  97701. */
  97702. constructor(jointData: PhysicsJointData);
  97703. /**
  97704. * Set the motor values.
  97705. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97706. * @param {number} force the force to apply
  97707. * @param {number} maxForce max force for this motor.
  97708. */
  97709. setMotor(force?: number, maxForce?: number): void;
  97710. /**
  97711. * Set the motor's limits.
  97712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97713. * @param upperLimit The upper limit of the motor
  97714. * @param lowerLimit The lower limit of the motor
  97715. */
  97716. setLimit(upperLimit: number, lowerLimit?: number): void;
  97717. }
  97718. /**
  97719. * This class represents a dual hinge physics joint (same as wheel joint)
  97720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97721. */
  97722. export class Hinge2Joint extends MotorEnabledJoint {
  97723. /**
  97724. * Initializes the Hinge2-Joint
  97725. * @param jointData The joint data for the Hinge2-Joint
  97726. */
  97727. constructor(jointData: PhysicsJointData);
  97728. /**
  97729. * Set the motor values.
  97730. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97731. * @param {number} targetSpeed the speed the motor is to reach
  97732. * @param {number} maxForce max force for this motor.
  97733. * @param {motorIndex} the motor's index, 0 or 1.
  97734. */
  97735. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97736. /**
  97737. * Set the motor limits.
  97738. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97739. * @param {number} upperLimit the upper limit
  97740. * @param {number} lowerLimit lower limit
  97741. * @param {motorIndex} the motor's index, 0 or 1.
  97742. */
  97743. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97744. }
  97745. /**
  97746. * Interface for a motor enabled joint
  97747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97748. */
  97749. export interface IMotorEnabledJoint {
  97750. /**
  97751. * Physics joint
  97752. */
  97753. physicsJoint: any;
  97754. /**
  97755. * Sets the motor of the motor-enabled joint
  97756. * @param force The force of the motor
  97757. * @param maxForce The maximum force of the motor
  97758. * @param motorIndex The index of the motor
  97759. */
  97760. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97761. /**
  97762. * Sets the limit of the motor
  97763. * @param upperLimit The upper limit of the motor
  97764. * @param lowerLimit The lower limit of the motor
  97765. * @param motorIndex The index of the motor
  97766. */
  97767. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97768. }
  97769. /**
  97770. * Joint data for a Distance-Joint
  97771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97772. */
  97773. export interface DistanceJointData extends PhysicsJointData {
  97774. /**
  97775. * Max distance the 2 joint objects can be apart
  97776. */
  97777. maxDistance: number;
  97778. }
  97779. /**
  97780. * Joint data from a spring joint
  97781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97782. */
  97783. export interface SpringJointData extends PhysicsJointData {
  97784. /**
  97785. * Length of the spring
  97786. */
  97787. length: number;
  97788. /**
  97789. * Stiffness of the spring
  97790. */
  97791. stiffness: number;
  97792. /**
  97793. * Damping of the spring
  97794. */
  97795. damping: number;
  97796. /** this callback will be called when applying the force to the impostors. */
  97797. forceApplicationCallback: () => void;
  97798. }
  97799. }
  97800. declare module BABYLON {
  97801. /**
  97802. * Holds the data for the raycast result
  97803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97804. */
  97805. export class PhysicsRaycastResult {
  97806. private _hasHit;
  97807. private _hitDistance;
  97808. private _hitNormalWorld;
  97809. private _hitPointWorld;
  97810. private _rayFromWorld;
  97811. private _rayToWorld;
  97812. /**
  97813. * Gets if there was a hit
  97814. */
  97815. get hasHit(): boolean;
  97816. /**
  97817. * Gets the distance from the hit
  97818. */
  97819. get hitDistance(): number;
  97820. /**
  97821. * Gets the hit normal/direction in the world
  97822. */
  97823. get hitNormalWorld(): Vector3;
  97824. /**
  97825. * Gets the hit point in the world
  97826. */
  97827. get hitPointWorld(): Vector3;
  97828. /**
  97829. * Gets the ray "start point" of the ray in the world
  97830. */
  97831. get rayFromWorld(): Vector3;
  97832. /**
  97833. * Gets the ray "end point" of the ray in the world
  97834. */
  97835. get rayToWorld(): Vector3;
  97836. /**
  97837. * Sets the hit data (normal & point in world space)
  97838. * @param hitNormalWorld defines the normal in world space
  97839. * @param hitPointWorld defines the point in world space
  97840. */
  97841. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97842. /**
  97843. * Sets the distance from the start point to the hit point
  97844. * @param distance
  97845. */
  97846. setHitDistance(distance: number): void;
  97847. /**
  97848. * Calculates the distance manually
  97849. */
  97850. calculateHitDistance(): void;
  97851. /**
  97852. * Resets all the values to default
  97853. * @param from The from point on world space
  97854. * @param to The to point on world space
  97855. */
  97856. reset(from?: Vector3, to?: Vector3): void;
  97857. }
  97858. /**
  97859. * Interface for the size containing width and height
  97860. */
  97861. interface IXYZ {
  97862. /**
  97863. * X
  97864. */
  97865. x: number;
  97866. /**
  97867. * Y
  97868. */
  97869. y: number;
  97870. /**
  97871. * Z
  97872. */
  97873. z: number;
  97874. }
  97875. }
  97876. declare module BABYLON {
  97877. /**
  97878. * Interface used to describe a physics joint
  97879. */
  97880. export interface PhysicsImpostorJoint {
  97881. /** Defines the main impostor to which the joint is linked */
  97882. mainImpostor: PhysicsImpostor;
  97883. /** Defines the impostor that is connected to the main impostor using this joint */
  97884. connectedImpostor: PhysicsImpostor;
  97885. /** Defines the joint itself */
  97886. joint: PhysicsJoint;
  97887. }
  97888. /** @hidden */
  97889. export interface IPhysicsEnginePlugin {
  97890. world: any;
  97891. name: string;
  97892. setGravity(gravity: Vector3): void;
  97893. setTimeStep(timeStep: number): void;
  97894. getTimeStep(): number;
  97895. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97899. removePhysicsBody(impostor: PhysicsImpostor): void;
  97900. generateJoint(joint: PhysicsImpostorJoint): void;
  97901. removeJoint(joint: PhysicsImpostorJoint): void;
  97902. isSupported(): boolean;
  97903. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97904. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97905. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97906. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97907. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97908. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97909. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97910. getBodyMass(impostor: PhysicsImpostor): number;
  97911. getBodyFriction(impostor: PhysicsImpostor): number;
  97912. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97913. getBodyRestitution(impostor: PhysicsImpostor): number;
  97914. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97915. getBodyPressure?(impostor: PhysicsImpostor): number;
  97916. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97917. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97918. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97919. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97920. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97921. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97922. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97923. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97924. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97925. sleepBody(impostor: PhysicsImpostor): void;
  97926. wakeUpBody(impostor: PhysicsImpostor): void;
  97927. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97928. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97929. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97930. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97931. getRadius(impostor: PhysicsImpostor): number;
  97932. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97933. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97934. dispose(): void;
  97935. }
  97936. /**
  97937. * Interface used to define a physics engine
  97938. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97939. */
  97940. export interface IPhysicsEngine {
  97941. /**
  97942. * Gets the gravity vector used by the simulation
  97943. */
  97944. gravity: Vector3;
  97945. /**
  97946. * Sets the gravity vector used by the simulation
  97947. * @param gravity defines the gravity vector to use
  97948. */
  97949. setGravity(gravity: Vector3): void;
  97950. /**
  97951. * Set the time step of the physics engine.
  97952. * Default is 1/60.
  97953. * To slow it down, enter 1/600 for example.
  97954. * To speed it up, 1/30
  97955. * @param newTimeStep the new timestep to apply to this world.
  97956. */
  97957. setTimeStep(newTimeStep: number): void;
  97958. /**
  97959. * Get the time step of the physics engine.
  97960. * @returns the current time step
  97961. */
  97962. getTimeStep(): number;
  97963. /**
  97964. * Set the sub time step of the physics engine.
  97965. * Default is 0 meaning there is no sub steps
  97966. * To increase physics resolution precision, set a small value (like 1 ms)
  97967. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97968. */
  97969. setSubTimeStep(subTimeStep: number): void;
  97970. /**
  97971. * Get the sub time step of the physics engine.
  97972. * @returns the current sub time step
  97973. */
  97974. getSubTimeStep(): number;
  97975. /**
  97976. * Release all resources
  97977. */
  97978. dispose(): void;
  97979. /**
  97980. * Gets the name of the current physics plugin
  97981. * @returns the name of the plugin
  97982. */
  97983. getPhysicsPluginName(): string;
  97984. /**
  97985. * Adding a new impostor for the impostor tracking.
  97986. * This will be done by the impostor itself.
  97987. * @param impostor the impostor to add
  97988. */
  97989. addImpostor(impostor: PhysicsImpostor): void;
  97990. /**
  97991. * Remove an impostor from the engine.
  97992. * This impostor and its mesh will not longer be updated by the physics engine.
  97993. * @param impostor the impostor to remove
  97994. */
  97995. removeImpostor(impostor: PhysicsImpostor): void;
  97996. /**
  97997. * Add a joint to the physics engine
  97998. * @param mainImpostor defines the main impostor to which the joint is added.
  97999. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98000. * @param joint defines the joint that will connect both impostors.
  98001. */
  98002. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98003. /**
  98004. * Removes a joint from the simulation
  98005. * @param mainImpostor defines the impostor used with the joint
  98006. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98007. * @param joint defines the joint to remove
  98008. */
  98009. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98010. /**
  98011. * Gets the current plugin used to run the simulation
  98012. * @returns current plugin
  98013. */
  98014. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98015. /**
  98016. * Gets the list of physic impostors
  98017. * @returns an array of PhysicsImpostor
  98018. */
  98019. getImpostors(): Array<PhysicsImpostor>;
  98020. /**
  98021. * Gets the impostor for a physics enabled object
  98022. * @param object defines the object impersonated by the impostor
  98023. * @returns the PhysicsImpostor or null if not found
  98024. */
  98025. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98026. /**
  98027. * Gets the impostor for a physics body object
  98028. * @param body defines physics body used by the impostor
  98029. * @returns the PhysicsImpostor or null if not found
  98030. */
  98031. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98032. /**
  98033. * Does a raycast in the physics world
  98034. * @param from when should the ray start?
  98035. * @param to when should the ray end?
  98036. * @returns PhysicsRaycastResult
  98037. */
  98038. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98039. /**
  98040. * Called by the scene. No need to call it.
  98041. * @param delta defines the timespam between frames
  98042. */
  98043. _step(delta: number): void;
  98044. }
  98045. }
  98046. declare module BABYLON {
  98047. /**
  98048. * The interface for the physics imposter parameters
  98049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98050. */
  98051. export interface PhysicsImpostorParameters {
  98052. /**
  98053. * The mass of the physics imposter
  98054. */
  98055. mass: number;
  98056. /**
  98057. * The friction of the physics imposter
  98058. */
  98059. friction?: number;
  98060. /**
  98061. * The coefficient of restitution of the physics imposter
  98062. */
  98063. restitution?: number;
  98064. /**
  98065. * The native options of the physics imposter
  98066. */
  98067. nativeOptions?: any;
  98068. /**
  98069. * Specifies if the parent should be ignored
  98070. */
  98071. ignoreParent?: boolean;
  98072. /**
  98073. * Specifies if bi-directional transformations should be disabled
  98074. */
  98075. disableBidirectionalTransformation?: boolean;
  98076. /**
  98077. * The pressure inside the physics imposter, soft object only
  98078. */
  98079. pressure?: number;
  98080. /**
  98081. * The stiffness the physics imposter, soft object only
  98082. */
  98083. stiffness?: number;
  98084. /**
  98085. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98086. */
  98087. velocityIterations?: number;
  98088. /**
  98089. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98090. */
  98091. positionIterations?: number;
  98092. /**
  98093. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98094. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98095. * Add to fix multiple points
  98096. */
  98097. fixedPoints?: number;
  98098. /**
  98099. * The collision margin around a soft object
  98100. */
  98101. margin?: number;
  98102. /**
  98103. * The collision margin around a soft object
  98104. */
  98105. damping?: number;
  98106. /**
  98107. * The path for a rope based on an extrusion
  98108. */
  98109. path?: any;
  98110. /**
  98111. * The shape of an extrusion used for a rope based on an extrusion
  98112. */
  98113. shape?: any;
  98114. }
  98115. /**
  98116. * Interface for a physics-enabled object
  98117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98118. */
  98119. export interface IPhysicsEnabledObject {
  98120. /**
  98121. * The position of the physics-enabled object
  98122. */
  98123. position: Vector3;
  98124. /**
  98125. * The rotation of the physics-enabled object
  98126. */
  98127. rotationQuaternion: Nullable<Quaternion>;
  98128. /**
  98129. * The scale of the physics-enabled object
  98130. */
  98131. scaling: Vector3;
  98132. /**
  98133. * The rotation of the physics-enabled object
  98134. */
  98135. rotation?: Vector3;
  98136. /**
  98137. * The parent of the physics-enabled object
  98138. */
  98139. parent?: any;
  98140. /**
  98141. * The bounding info of the physics-enabled object
  98142. * @returns The bounding info of the physics-enabled object
  98143. */
  98144. getBoundingInfo(): BoundingInfo;
  98145. /**
  98146. * Computes the world matrix
  98147. * @param force Specifies if the world matrix should be computed by force
  98148. * @returns A world matrix
  98149. */
  98150. computeWorldMatrix(force: boolean): Matrix;
  98151. /**
  98152. * Gets the world matrix
  98153. * @returns A world matrix
  98154. */
  98155. getWorldMatrix?(): Matrix;
  98156. /**
  98157. * Gets the child meshes
  98158. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98159. * @returns An array of abstract meshes
  98160. */
  98161. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98162. /**
  98163. * Gets the vertex data
  98164. * @param kind The type of vertex data
  98165. * @returns A nullable array of numbers, or a float32 array
  98166. */
  98167. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98168. /**
  98169. * Gets the indices from the mesh
  98170. * @returns A nullable array of index arrays
  98171. */
  98172. getIndices?(): Nullable<IndicesArray>;
  98173. /**
  98174. * Gets the scene from the mesh
  98175. * @returns the indices array or null
  98176. */
  98177. getScene?(): Scene;
  98178. /**
  98179. * Gets the absolute position from the mesh
  98180. * @returns the absolute position
  98181. */
  98182. getAbsolutePosition(): Vector3;
  98183. /**
  98184. * Gets the absolute pivot point from the mesh
  98185. * @returns the absolute pivot point
  98186. */
  98187. getAbsolutePivotPoint(): Vector3;
  98188. /**
  98189. * Rotates the mesh
  98190. * @param axis The axis of rotation
  98191. * @param amount The amount of rotation
  98192. * @param space The space of the rotation
  98193. * @returns The rotation transform node
  98194. */
  98195. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98196. /**
  98197. * Translates the mesh
  98198. * @param axis The axis of translation
  98199. * @param distance The distance of translation
  98200. * @param space The space of the translation
  98201. * @returns The transform node
  98202. */
  98203. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98204. /**
  98205. * Sets the absolute position of the mesh
  98206. * @param absolutePosition The absolute position of the mesh
  98207. * @returns The transform node
  98208. */
  98209. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98210. /**
  98211. * Gets the class name of the mesh
  98212. * @returns The class name
  98213. */
  98214. getClassName(): string;
  98215. }
  98216. /**
  98217. * Represents a physics imposter
  98218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98219. */
  98220. export class PhysicsImpostor {
  98221. /**
  98222. * The physics-enabled object used as the physics imposter
  98223. */
  98224. object: IPhysicsEnabledObject;
  98225. /**
  98226. * The type of the physics imposter
  98227. */
  98228. type: number;
  98229. private _options;
  98230. private _scene?;
  98231. /**
  98232. * The default object size of the imposter
  98233. */
  98234. static DEFAULT_OBJECT_SIZE: Vector3;
  98235. /**
  98236. * The identity quaternion of the imposter
  98237. */
  98238. static IDENTITY_QUATERNION: Quaternion;
  98239. /** @hidden */
  98240. _pluginData: any;
  98241. private _physicsEngine;
  98242. private _physicsBody;
  98243. private _bodyUpdateRequired;
  98244. private _onBeforePhysicsStepCallbacks;
  98245. private _onAfterPhysicsStepCallbacks;
  98246. /** @hidden */
  98247. _onPhysicsCollideCallbacks: Array<{
  98248. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98249. otherImpostors: Array<PhysicsImpostor>;
  98250. }>;
  98251. private _deltaPosition;
  98252. private _deltaRotation;
  98253. private _deltaRotationConjugated;
  98254. /** @hidden */
  98255. _isFromLine: boolean;
  98256. private _parent;
  98257. private _isDisposed;
  98258. private static _tmpVecs;
  98259. private static _tmpQuat;
  98260. /**
  98261. * Specifies if the physics imposter is disposed
  98262. */
  98263. get isDisposed(): boolean;
  98264. /**
  98265. * Gets the mass of the physics imposter
  98266. */
  98267. get mass(): number;
  98268. set mass(value: number);
  98269. /**
  98270. * Gets the coefficient of friction
  98271. */
  98272. get friction(): number;
  98273. /**
  98274. * Sets the coefficient of friction
  98275. */
  98276. set friction(value: number);
  98277. /**
  98278. * Gets the coefficient of restitution
  98279. */
  98280. get restitution(): number;
  98281. /**
  98282. * Sets the coefficient of restitution
  98283. */
  98284. set restitution(value: number);
  98285. /**
  98286. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98287. */
  98288. get pressure(): number;
  98289. /**
  98290. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98291. */
  98292. set pressure(value: number);
  98293. /**
  98294. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98295. */
  98296. get stiffness(): number;
  98297. /**
  98298. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98299. */
  98300. set stiffness(value: number);
  98301. /**
  98302. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98303. */
  98304. get velocityIterations(): number;
  98305. /**
  98306. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98307. */
  98308. set velocityIterations(value: number);
  98309. /**
  98310. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98311. */
  98312. get positionIterations(): number;
  98313. /**
  98314. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98315. */
  98316. set positionIterations(value: number);
  98317. /**
  98318. * The unique id of the physics imposter
  98319. * set by the physics engine when adding this impostor to the array
  98320. */
  98321. uniqueId: number;
  98322. /**
  98323. * @hidden
  98324. */
  98325. soft: boolean;
  98326. /**
  98327. * @hidden
  98328. */
  98329. segments: number;
  98330. private _joints;
  98331. /**
  98332. * Initializes the physics imposter
  98333. * @param object The physics-enabled object used as the physics imposter
  98334. * @param type The type of the physics imposter
  98335. * @param _options The options for the physics imposter
  98336. * @param _scene The Babylon scene
  98337. */
  98338. constructor(
  98339. /**
  98340. * The physics-enabled object used as the physics imposter
  98341. */
  98342. object: IPhysicsEnabledObject,
  98343. /**
  98344. * The type of the physics imposter
  98345. */
  98346. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98347. /**
  98348. * This function will completly initialize this impostor.
  98349. * It will create a new body - but only if this mesh has no parent.
  98350. * If it has, this impostor will not be used other than to define the impostor
  98351. * of the child mesh.
  98352. * @hidden
  98353. */
  98354. _init(): void;
  98355. private _getPhysicsParent;
  98356. /**
  98357. * Should a new body be generated.
  98358. * @returns boolean specifying if body initialization is required
  98359. */
  98360. isBodyInitRequired(): boolean;
  98361. /**
  98362. * Sets the updated scaling
  98363. * @param updated Specifies if the scaling is updated
  98364. */
  98365. setScalingUpdated(): void;
  98366. /**
  98367. * Force a regeneration of this or the parent's impostor's body.
  98368. * Use under cautious - This will remove all joints already implemented.
  98369. */
  98370. forceUpdate(): void;
  98371. /**
  98372. * Gets the body that holds this impostor. Either its own, or its parent.
  98373. */
  98374. get physicsBody(): any;
  98375. /**
  98376. * Get the parent of the physics imposter
  98377. * @returns Physics imposter or null
  98378. */
  98379. get parent(): Nullable<PhysicsImpostor>;
  98380. /**
  98381. * Sets the parent of the physics imposter
  98382. */
  98383. set parent(value: Nullable<PhysicsImpostor>);
  98384. /**
  98385. * Set the physics body. Used mainly by the physics engine/plugin
  98386. */
  98387. set physicsBody(physicsBody: any);
  98388. /**
  98389. * Resets the update flags
  98390. */
  98391. resetUpdateFlags(): void;
  98392. /**
  98393. * Gets the object extend size
  98394. * @returns the object extend size
  98395. */
  98396. getObjectExtendSize(): Vector3;
  98397. /**
  98398. * Gets the object center
  98399. * @returns The object center
  98400. */
  98401. getObjectCenter(): Vector3;
  98402. /**
  98403. * Get a specific parameter from the options parameters
  98404. * @param paramName The object parameter name
  98405. * @returns The object parameter
  98406. */
  98407. getParam(paramName: string): any;
  98408. /**
  98409. * Sets a specific parameter in the options given to the physics plugin
  98410. * @param paramName The parameter name
  98411. * @param value The value of the parameter
  98412. */
  98413. setParam(paramName: string, value: number): void;
  98414. /**
  98415. * Specifically change the body's mass option. Won't recreate the physics body object
  98416. * @param mass The mass of the physics imposter
  98417. */
  98418. setMass(mass: number): void;
  98419. /**
  98420. * Gets the linear velocity
  98421. * @returns linear velocity or null
  98422. */
  98423. getLinearVelocity(): Nullable<Vector3>;
  98424. /**
  98425. * Sets the linear velocity
  98426. * @param velocity linear velocity or null
  98427. */
  98428. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98429. /**
  98430. * Gets the angular velocity
  98431. * @returns angular velocity or null
  98432. */
  98433. getAngularVelocity(): Nullable<Vector3>;
  98434. /**
  98435. * Sets the angular velocity
  98436. * @param velocity The velocity or null
  98437. */
  98438. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98439. /**
  98440. * Execute a function with the physics plugin native code
  98441. * Provide a function the will have two variables - the world object and the physics body object
  98442. * @param func The function to execute with the physics plugin native code
  98443. */
  98444. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98445. /**
  98446. * Register a function that will be executed before the physics world is stepping forward
  98447. * @param func The function to execute before the physics world is stepped forward
  98448. */
  98449. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98450. /**
  98451. * Unregister a function that will be executed before the physics world is stepping forward
  98452. * @param func The function to execute before the physics world is stepped forward
  98453. */
  98454. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98455. /**
  98456. * Register a function that will be executed after the physics step
  98457. * @param func The function to execute after physics step
  98458. */
  98459. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98460. /**
  98461. * Unregisters a function that will be executed after the physics step
  98462. * @param func The function to execute after physics step
  98463. */
  98464. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98465. /**
  98466. * register a function that will be executed when this impostor collides against a different body
  98467. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98468. * @param func Callback that is executed on collision
  98469. */
  98470. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98471. /**
  98472. * Unregisters the physics imposter on contact
  98473. * @param collideAgainst The physics object to collide against
  98474. * @param func Callback to execute on collision
  98475. */
  98476. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98477. private _tmpQuat;
  98478. private _tmpQuat2;
  98479. /**
  98480. * Get the parent rotation
  98481. * @returns The parent rotation
  98482. */
  98483. getParentsRotation(): Quaternion;
  98484. /**
  98485. * this function is executed by the physics engine.
  98486. */
  98487. beforeStep: () => void;
  98488. /**
  98489. * this function is executed by the physics engine
  98490. */
  98491. afterStep: () => void;
  98492. /**
  98493. * Legacy collision detection event support
  98494. */
  98495. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98496. /**
  98497. * event and body object due to cannon's event-based architecture.
  98498. */
  98499. onCollide: (e: {
  98500. body: any;
  98501. }) => void;
  98502. /**
  98503. * Apply a force
  98504. * @param force The force to apply
  98505. * @param contactPoint The contact point for the force
  98506. * @returns The physics imposter
  98507. */
  98508. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98509. /**
  98510. * Apply an impulse
  98511. * @param force The impulse force
  98512. * @param contactPoint The contact point for the impulse force
  98513. * @returns The physics imposter
  98514. */
  98515. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98516. /**
  98517. * A help function to create a joint
  98518. * @param otherImpostor A physics imposter used to create a joint
  98519. * @param jointType The type of joint
  98520. * @param jointData The data for the joint
  98521. * @returns The physics imposter
  98522. */
  98523. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98524. /**
  98525. * Add a joint to this impostor with a different impostor
  98526. * @param otherImpostor A physics imposter used to add a joint
  98527. * @param joint The joint to add
  98528. * @returns The physics imposter
  98529. */
  98530. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98531. /**
  98532. * Add an anchor to a cloth impostor
  98533. * @param otherImpostor rigid impostor to anchor to
  98534. * @param width ratio across width from 0 to 1
  98535. * @param height ratio up height from 0 to 1
  98536. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98537. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98538. * @returns impostor the soft imposter
  98539. */
  98540. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98541. /**
  98542. * Add a hook to a rope impostor
  98543. * @param otherImpostor rigid impostor to anchor to
  98544. * @param length ratio across rope from 0 to 1
  98545. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98546. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98547. * @returns impostor the rope imposter
  98548. */
  98549. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98550. /**
  98551. * Will keep this body still, in a sleep mode.
  98552. * @returns the physics imposter
  98553. */
  98554. sleep(): PhysicsImpostor;
  98555. /**
  98556. * Wake the body up.
  98557. * @returns The physics imposter
  98558. */
  98559. wakeUp(): PhysicsImpostor;
  98560. /**
  98561. * Clones the physics imposter
  98562. * @param newObject The physics imposter clones to this physics-enabled object
  98563. * @returns A nullable physics imposter
  98564. */
  98565. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98566. /**
  98567. * Disposes the physics imposter
  98568. */
  98569. dispose(): void;
  98570. /**
  98571. * Sets the delta position
  98572. * @param position The delta position amount
  98573. */
  98574. setDeltaPosition(position: Vector3): void;
  98575. /**
  98576. * Sets the delta rotation
  98577. * @param rotation The delta rotation amount
  98578. */
  98579. setDeltaRotation(rotation: Quaternion): void;
  98580. /**
  98581. * Gets the box size of the physics imposter and stores the result in the input parameter
  98582. * @param result Stores the box size
  98583. * @returns The physics imposter
  98584. */
  98585. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98586. /**
  98587. * Gets the radius of the physics imposter
  98588. * @returns Radius of the physics imposter
  98589. */
  98590. getRadius(): number;
  98591. /**
  98592. * Sync a bone with this impostor
  98593. * @param bone The bone to sync to the impostor.
  98594. * @param boneMesh The mesh that the bone is influencing.
  98595. * @param jointPivot The pivot of the joint / bone in local space.
  98596. * @param distToJoint Optional distance from the impostor to the joint.
  98597. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98598. */
  98599. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98600. /**
  98601. * Sync impostor to a bone
  98602. * @param bone The bone that the impostor will be synced to.
  98603. * @param boneMesh The mesh that the bone is influencing.
  98604. * @param jointPivot The pivot of the joint / bone in local space.
  98605. * @param distToJoint Optional distance from the impostor to the joint.
  98606. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98607. * @param boneAxis Optional vector3 axis the bone is aligned with
  98608. */
  98609. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98610. /**
  98611. * No-Imposter type
  98612. */
  98613. static NoImpostor: number;
  98614. /**
  98615. * Sphere-Imposter type
  98616. */
  98617. static SphereImpostor: number;
  98618. /**
  98619. * Box-Imposter type
  98620. */
  98621. static BoxImpostor: number;
  98622. /**
  98623. * Plane-Imposter type
  98624. */
  98625. static PlaneImpostor: number;
  98626. /**
  98627. * Mesh-imposter type
  98628. */
  98629. static MeshImpostor: number;
  98630. /**
  98631. * Capsule-Impostor type (Ammo.js plugin only)
  98632. */
  98633. static CapsuleImpostor: number;
  98634. /**
  98635. * Cylinder-Imposter type
  98636. */
  98637. static CylinderImpostor: number;
  98638. /**
  98639. * Particle-Imposter type
  98640. */
  98641. static ParticleImpostor: number;
  98642. /**
  98643. * Heightmap-Imposter type
  98644. */
  98645. static HeightmapImpostor: number;
  98646. /**
  98647. * ConvexHull-Impostor type (Ammo.js plugin only)
  98648. */
  98649. static ConvexHullImpostor: number;
  98650. /**
  98651. * Custom-Imposter type (Ammo.js plugin only)
  98652. */
  98653. static CustomImpostor: number;
  98654. /**
  98655. * Rope-Imposter type
  98656. */
  98657. static RopeImpostor: number;
  98658. /**
  98659. * Cloth-Imposter type
  98660. */
  98661. static ClothImpostor: number;
  98662. /**
  98663. * Softbody-Imposter type
  98664. */
  98665. static SoftbodyImpostor: number;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. /**
  98670. * @hidden
  98671. **/
  98672. export class _CreationDataStorage {
  98673. closePath?: boolean;
  98674. closeArray?: boolean;
  98675. idx: number[];
  98676. dashSize: number;
  98677. gapSize: number;
  98678. path3D: Path3D;
  98679. pathArray: Vector3[][];
  98680. arc: number;
  98681. radius: number;
  98682. cap: number;
  98683. tessellation: number;
  98684. }
  98685. /**
  98686. * @hidden
  98687. **/
  98688. class _InstanceDataStorage {
  98689. visibleInstances: any;
  98690. batchCache: _InstancesBatch;
  98691. instancesBufferSize: number;
  98692. instancesBuffer: Nullable<Buffer>;
  98693. instancesData: Float32Array;
  98694. overridenInstanceCount: number;
  98695. isFrozen: boolean;
  98696. previousBatch: Nullable<_InstancesBatch>;
  98697. hardwareInstancedRendering: boolean;
  98698. sideOrientation: number;
  98699. manualUpdate: boolean;
  98700. }
  98701. /**
  98702. * @hidden
  98703. **/
  98704. export class _InstancesBatch {
  98705. mustReturn: boolean;
  98706. visibleInstances: Nullable<InstancedMesh[]>[];
  98707. renderSelf: boolean[];
  98708. hardwareInstancedRendering: boolean[];
  98709. }
  98710. /**
  98711. * Class used to represent renderable models
  98712. */
  98713. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98714. /**
  98715. * Mesh side orientation : usually the external or front surface
  98716. */
  98717. static readonly FRONTSIDE: number;
  98718. /**
  98719. * Mesh side orientation : usually the internal or back surface
  98720. */
  98721. static readonly BACKSIDE: number;
  98722. /**
  98723. * Mesh side orientation : both internal and external or front and back surfaces
  98724. */
  98725. static readonly DOUBLESIDE: number;
  98726. /**
  98727. * Mesh side orientation : by default, `FRONTSIDE`
  98728. */
  98729. static readonly DEFAULTSIDE: number;
  98730. /**
  98731. * Mesh cap setting : no cap
  98732. */
  98733. static readonly NO_CAP: number;
  98734. /**
  98735. * Mesh cap setting : one cap at the beginning of the mesh
  98736. */
  98737. static readonly CAP_START: number;
  98738. /**
  98739. * Mesh cap setting : one cap at the end of the mesh
  98740. */
  98741. static readonly CAP_END: number;
  98742. /**
  98743. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98744. */
  98745. static readonly CAP_ALL: number;
  98746. /**
  98747. * Mesh pattern setting : no flip or rotate
  98748. */
  98749. static readonly NO_FLIP: number;
  98750. /**
  98751. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98752. */
  98753. static readonly FLIP_TILE: number;
  98754. /**
  98755. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98756. */
  98757. static readonly ROTATE_TILE: number;
  98758. /**
  98759. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98760. */
  98761. static readonly FLIP_ROW: number;
  98762. /**
  98763. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98764. */
  98765. static readonly ROTATE_ROW: number;
  98766. /**
  98767. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98768. */
  98769. static readonly FLIP_N_ROTATE_TILE: number;
  98770. /**
  98771. * Mesh pattern setting : rotate pattern and rotate
  98772. */
  98773. static readonly FLIP_N_ROTATE_ROW: number;
  98774. /**
  98775. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98776. */
  98777. static readonly CENTER: number;
  98778. /**
  98779. * Mesh tile positioning : part tiles on left
  98780. */
  98781. static readonly LEFT: number;
  98782. /**
  98783. * Mesh tile positioning : part tiles on right
  98784. */
  98785. static readonly RIGHT: number;
  98786. /**
  98787. * Mesh tile positioning : part tiles on top
  98788. */
  98789. static readonly TOP: number;
  98790. /**
  98791. * Mesh tile positioning : part tiles on bottom
  98792. */
  98793. static readonly BOTTOM: number;
  98794. /**
  98795. * Gets the default side orientation.
  98796. * @param orientation the orientation to value to attempt to get
  98797. * @returns the default orientation
  98798. * @hidden
  98799. */
  98800. static _GetDefaultSideOrientation(orientation?: number): number;
  98801. private _internalMeshDataInfo;
  98802. /**
  98803. * An event triggered before rendering the mesh
  98804. */
  98805. get onBeforeRenderObservable(): Observable<Mesh>;
  98806. /**
  98807. * An event triggered before binding the mesh
  98808. */
  98809. get onBeforeBindObservable(): Observable<Mesh>;
  98810. /**
  98811. * An event triggered after rendering the mesh
  98812. */
  98813. get onAfterRenderObservable(): Observable<Mesh>;
  98814. /**
  98815. * An event triggered before drawing the mesh
  98816. */
  98817. get onBeforeDrawObservable(): Observable<Mesh>;
  98818. private _onBeforeDrawObserver;
  98819. /**
  98820. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98821. */
  98822. set onBeforeDraw(callback: () => void);
  98823. get hasInstances(): boolean;
  98824. /**
  98825. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98826. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98827. */
  98828. delayLoadState: number;
  98829. /**
  98830. * Gets the list of instances created from this mesh
  98831. * it is not supposed to be modified manually.
  98832. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98833. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98834. */
  98835. instances: InstancedMesh[];
  98836. /**
  98837. * Gets the file containing delay loading data for this mesh
  98838. */
  98839. delayLoadingFile: string;
  98840. /** @hidden */
  98841. _binaryInfo: any;
  98842. /**
  98843. * User defined function used to change how LOD level selection is done
  98844. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98845. */
  98846. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98847. /**
  98848. * Gets or sets the morph target manager
  98849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98850. */
  98851. get morphTargetManager(): Nullable<MorphTargetManager>;
  98852. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98853. /** @hidden */
  98854. _creationDataStorage: Nullable<_CreationDataStorage>;
  98855. /** @hidden */
  98856. _geometry: Nullable<Geometry>;
  98857. /** @hidden */
  98858. _delayInfo: Array<string>;
  98859. /** @hidden */
  98860. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98861. /** @hidden */
  98862. _instanceDataStorage: _InstanceDataStorage;
  98863. private _effectiveMaterial;
  98864. /** @hidden */
  98865. _shouldGenerateFlatShading: boolean;
  98866. /** @hidden */
  98867. _originalBuilderSideOrientation: number;
  98868. /**
  98869. * Use this property to change the original side orientation defined at construction time
  98870. */
  98871. overrideMaterialSideOrientation: Nullable<number>;
  98872. /**
  98873. * Gets the source mesh (the one used to clone this one from)
  98874. */
  98875. get source(): Nullable<Mesh>;
  98876. /**
  98877. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98878. */
  98879. get isUnIndexed(): boolean;
  98880. set isUnIndexed(value: boolean);
  98881. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98882. get worldMatrixInstancedBuffer(): Float32Array;
  98883. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98884. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98885. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98886. /**
  98887. * @constructor
  98888. * @param name The value used by scene.getMeshByName() to do a lookup.
  98889. * @param scene The scene to add this mesh to.
  98890. * @param parent The parent of this mesh, if it has one
  98891. * @param source An optional Mesh from which geometry is shared, cloned.
  98892. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98893. * When false, achieved by calling a clone(), also passing False.
  98894. * This will make creation of children, recursive.
  98895. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98896. */
  98897. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98898. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98899. doNotInstantiate: boolean;
  98900. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98901. /**
  98902. * Gets the class name
  98903. * @returns the string "Mesh".
  98904. */
  98905. getClassName(): string;
  98906. /** @hidden */
  98907. get _isMesh(): boolean;
  98908. /**
  98909. * Returns a description of this mesh
  98910. * @param fullDetails define if full details about this mesh must be used
  98911. * @returns a descriptive string representing this mesh
  98912. */
  98913. toString(fullDetails?: boolean): string;
  98914. /** @hidden */
  98915. _unBindEffect(): void;
  98916. /**
  98917. * Gets a boolean indicating if this mesh has LOD
  98918. */
  98919. get hasLODLevels(): boolean;
  98920. /**
  98921. * Gets the list of MeshLODLevel associated with the current mesh
  98922. * @returns an array of MeshLODLevel
  98923. */
  98924. getLODLevels(): MeshLODLevel[];
  98925. private _sortLODLevels;
  98926. /**
  98927. * Add a mesh as LOD level triggered at the given distance.
  98928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98929. * @param distance The distance from the center of the object to show this level
  98930. * @param mesh The mesh to be added as LOD level (can be null)
  98931. * @return This mesh (for chaining)
  98932. */
  98933. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98934. /**
  98935. * Returns the LOD level mesh at the passed distance or null if not found.
  98936. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98937. * @param distance The distance from the center of the object to show this level
  98938. * @returns a Mesh or `null`
  98939. */
  98940. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98941. /**
  98942. * Remove a mesh from the LOD array
  98943. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98944. * @param mesh defines the mesh to be removed
  98945. * @return This mesh (for chaining)
  98946. */
  98947. removeLODLevel(mesh: Mesh): Mesh;
  98948. /**
  98949. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98950. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98951. * @param camera defines the camera to use to compute distance
  98952. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98953. * @return This mesh (for chaining)
  98954. */
  98955. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98956. /**
  98957. * Gets the mesh internal Geometry object
  98958. */
  98959. get geometry(): Nullable<Geometry>;
  98960. /**
  98961. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98962. * @returns the total number of vertices
  98963. */
  98964. getTotalVertices(): number;
  98965. /**
  98966. * Returns the content of an associated vertex buffer
  98967. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98968. * - VertexBuffer.PositionKind
  98969. * - VertexBuffer.UVKind
  98970. * - VertexBuffer.UV2Kind
  98971. * - VertexBuffer.UV3Kind
  98972. * - VertexBuffer.UV4Kind
  98973. * - VertexBuffer.UV5Kind
  98974. * - VertexBuffer.UV6Kind
  98975. * - VertexBuffer.ColorKind
  98976. * - VertexBuffer.MatricesIndicesKind
  98977. * - VertexBuffer.MatricesIndicesExtraKind
  98978. * - VertexBuffer.MatricesWeightsKind
  98979. * - VertexBuffer.MatricesWeightsExtraKind
  98980. * @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
  98981. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98982. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98983. */
  98984. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98985. /**
  98986. * Returns the mesh VertexBuffer object from the requested `kind`
  98987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98988. * - VertexBuffer.PositionKind
  98989. * - VertexBuffer.NormalKind
  98990. * - VertexBuffer.UVKind
  98991. * - VertexBuffer.UV2Kind
  98992. * - VertexBuffer.UV3Kind
  98993. * - VertexBuffer.UV4Kind
  98994. * - VertexBuffer.UV5Kind
  98995. * - VertexBuffer.UV6Kind
  98996. * - VertexBuffer.ColorKind
  98997. * - VertexBuffer.MatricesIndicesKind
  98998. * - VertexBuffer.MatricesIndicesExtraKind
  98999. * - VertexBuffer.MatricesWeightsKind
  99000. * - VertexBuffer.MatricesWeightsExtraKind
  99001. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99002. */
  99003. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99004. /**
  99005. * Tests if a specific vertex buffer is associated with this mesh
  99006. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99007. * - VertexBuffer.PositionKind
  99008. * - VertexBuffer.NormalKind
  99009. * - VertexBuffer.UVKind
  99010. * - VertexBuffer.UV2Kind
  99011. * - VertexBuffer.UV3Kind
  99012. * - VertexBuffer.UV4Kind
  99013. * - VertexBuffer.UV5Kind
  99014. * - VertexBuffer.UV6Kind
  99015. * - VertexBuffer.ColorKind
  99016. * - VertexBuffer.MatricesIndicesKind
  99017. * - VertexBuffer.MatricesIndicesExtraKind
  99018. * - VertexBuffer.MatricesWeightsKind
  99019. * - VertexBuffer.MatricesWeightsExtraKind
  99020. * @returns a boolean
  99021. */
  99022. isVerticesDataPresent(kind: string): boolean;
  99023. /**
  99024. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99026. * - VertexBuffer.PositionKind
  99027. * - VertexBuffer.UVKind
  99028. * - VertexBuffer.UV2Kind
  99029. * - VertexBuffer.UV3Kind
  99030. * - VertexBuffer.UV4Kind
  99031. * - VertexBuffer.UV5Kind
  99032. * - VertexBuffer.UV6Kind
  99033. * - VertexBuffer.ColorKind
  99034. * - VertexBuffer.MatricesIndicesKind
  99035. * - VertexBuffer.MatricesIndicesExtraKind
  99036. * - VertexBuffer.MatricesWeightsKind
  99037. * - VertexBuffer.MatricesWeightsExtraKind
  99038. * @returns a boolean
  99039. */
  99040. isVertexBufferUpdatable(kind: string): boolean;
  99041. /**
  99042. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99043. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99044. * - VertexBuffer.PositionKind
  99045. * - VertexBuffer.NormalKind
  99046. * - VertexBuffer.UVKind
  99047. * - VertexBuffer.UV2Kind
  99048. * - VertexBuffer.UV3Kind
  99049. * - VertexBuffer.UV4Kind
  99050. * - VertexBuffer.UV5Kind
  99051. * - VertexBuffer.UV6Kind
  99052. * - VertexBuffer.ColorKind
  99053. * - VertexBuffer.MatricesIndicesKind
  99054. * - VertexBuffer.MatricesIndicesExtraKind
  99055. * - VertexBuffer.MatricesWeightsKind
  99056. * - VertexBuffer.MatricesWeightsExtraKind
  99057. * @returns an array of strings
  99058. */
  99059. getVerticesDataKinds(): string[];
  99060. /**
  99061. * Returns a positive integer : the total number of indices in this mesh geometry.
  99062. * @returns the numner of indices or zero if the mesh has no geometry.
  99063. */
  99064. getTotalIndices(): number;
  99065. /**
  99066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99067. * @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.
  99068. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99069. * @returns the indices array or an empty array if the mesh has no geometry
  99070. */
  99071. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99072. get isBlocked(): boolean;
  99073. /**
  99074. * Determine if the current mesh is ready to be rendered
  99075. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99076. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99077. * @returns true if all associated assets are ready (material, textures, shaders)
  99078. */
  99079. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99080. /**
  99081. * 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.
  99082. */
  99083. get areNormalsFrozen(): boolean;
  99084. /**
  99085. * 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.
  99086. * @returns the current mesh
  99087. */
  99088. freezeNormals(): Mesh;
  99089. /**
  99090. * 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
  99091. * @returns the current mesh
  99092. */
  99093. unfreezeNormals(): Mesh;
  99094. /**
  99095. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99096. */
  99097. set overridenInstanceCount(count: number);
  99098. /** @hidden */
  99099. _preActivate(): Mesh;
  99100. /** @hidden */
  99101. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99102. /** @hidden */
  99103. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99104. /**
  99105. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99106. * This means the mesh underlying bounding box and sphere are recomputed.
  99107. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99108. * @returns the current mesh
  99109. */
  99110. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99111. /** @hidden */
  99112. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99113. /**
  99114. * This function will subdivide the mesh into multiple submeshes
  99115. * @param count defines the expected number of submeshes
  99116. */
  99117. subdivide(count: number): void;
  99118. /**
  99119. * Copy a FloatArray into a specific associated vertex buffer
  99120. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99121. * - VertexBuffer.PositionKind
  99122. * - VertexBuffer.UVKind
  99123. * - VertexBuffer.UV2Kind
  99124. * - VertexBuffer.UV3Kind
  99125. * - VertexBuffer.UV4Kind
  99126. * - VertexBuffer.UV5Kind
  99127. * - VertexBuffer.UV6Kind
  99128. * - VertexBuffer.ColorKind
  99129. * - VertexBuffer.MatricesIndicesKind
  99130. * - VertexBuffer.MatricesIndicesExtraKind
  99131. * - VertexBuffer.MatricesWeightsKind
  99132. * - VertexBuffer.MatricesWeightsExtraKind
  99133. * @param data defines the data source
  99134. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99135. * @param stride defines the data stride size (can be null)
  99136. * @returns the current mesh
  99137. */
  99138. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99139. /**
  99140. * Delete a vertex buffer associated with this mesh
  99141. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99142. * - VertexBuffer.PositionKind
  99143. * - VertexBuffer.UVKind
  99144. * - VertexBuffer.UV2Kind
  99145. * - VertexBuffer.UV3Kind
  99146. * - VertexBuffer.UV4Kind
  99147. * - VertexBuffer.UV5Kind
  99148. * - VertexBuffer.UV6Kind
  99149. * - VertexBuffer.ColorKind
  99150. * - VertexBuffer.MatricesIndicesKind
  99151. * - VertexBuffer.MatricesIndicesExtraKind
  99152. * - VertexBuffer.MatricesWeightsKind
  99153. * - VertexBuffer.MatricesWeightsExtraKind
  99154. */
  99155. removeVerticesData(kind: string): void;
  99156. /**
  99157. * Flags an associated vertex buffer as updatable
  99158. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99159. * - VertexBuffer.PositionKind
  99160. * - VertexBuffer.UVKind
  99161. * - VertexBuffer.UV2Kind
  99162. * - VertexBuffer.UV3Kind
  99163. * - VertexBuffer.UV4Kind
  99164. * - VertexBuffer.UV5Kind
  99165. * - VertexBuffer.UV6Kind
  99166. * - VertexBuffer.ColorKind
  99167. * - VertexBuffer.MatricesIndicesKind
  99168. * - VertexBuffer.MatricesIndicesExtraKind
  99169. * - VertexBuffer.MatricesWeightsKind
  99170. * - VertexBuffer.MatricesWeightsExtraKind
  99171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99172. */
  99173. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99174. /**
  99175. * Sets the mesh global Vertex Buffer
  99176. * @param buffer defines the buffer to use
  99177. * @returns the current mesh
  99178. */
  99179. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99180. /**
  99181. * Update a specific associated vertex buffer
  99182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99183. * - VertexBuffer.PositionKind
  99184. * - VertexBuffer.UVKind
  99185. * - VertexBuffer.UV2Kind
  99186. * - VertexBuffer.UV3Kind
  99187. * - VertexBuffer.UV4Kind
  99188. * - VertexBuffer.UV5Kind
  99189. * - VertexBuffer.UV6Kind
  99190. * - VertexBuffer.ColorKind
  99191. * - VertexBuffer.MatricesIndicesKind
  99192. * - VertexBuffer.MatricesIndicesExtraKind
  99193. * - VertexBuffer.MatricesWeightsKind
  99194. * - VertexBuffer.MatricesWeightsExtraKind
  99195. * @param data defines the data source
  99196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99197. * @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)
  99198. * @returns the current mesh
  99199. */
  99200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99201. /**
  99202. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99203. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99204. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99205. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99206. * @returns the current mesh
  99207. */
  99208. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99209. /**
  99210. * Creates a un-shared specific occurence of the geometry for the mesh.
  99211. * @returns the current mesh
  99212. */
  99213. makeGeometryUnique(): Mesh;
  99214. /**
  99215. * Set the index buffer of this mesh
  99216. * @param indices defines the source data
  99217. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99218. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99219. * @returns the current mesh
  99220. */
  99221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99222. /**
  99223. * Update the current index buffer
  99224. * @param indices defines the source data
  99225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99226. * @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)
  99227. * @returns the current mesh
  99228. */
  99229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99230. /**
  99231. * Invert the geometry to move from a right handed system to a left handed one.
  99232. * @returns the current mesh
  99233. */
  99234. toLeftHanded(): Mesh;
  99235. /** @hidden */
  99236. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99237. /** @hidden */
  99238. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99239. /**
  99240. * Registers for this mesh a javascript function called just before the rendering process
  99241. * @param func defines the function to call before rendering this mesh
  99242. * @returns the current mesh
  99243. */
  99244. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99245. /**
  99246. * Disposes a previously registered javascript function called before the rendering
  99247. * @param func defines the function to remove
  99248. * @returns the current mesh
  99249. */
  99250. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99251. /**
  99252. * Registers for this mesh a javascript function called just after the rendering is complete
  99253. * @param func defines the function to call after rendering this mesh
  99254. * @returns the current mesh
  99255. */
  99256. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99257. /**
  99258. * Disposes a previously registered javascript function called after the rendering.
  99259. * @param func defines the function to remove
  99260. * @returns the current mesh
  99261. */
  99262. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99263. /** @hidden */
  99264. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99265. /** @hidden */
  99266. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99267. /** @hidden */
  99268. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99269. /** @hidden */
  99270. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99271. /** @hidden */
  99272. _rebuild(): void;
  99273. /** @hidden */
  99274. _freeze(): void;
  99275. /** @hidden */
  99276. _unFreeze(): void;
  99277. /**
  99278. * 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
  99279. * @param subMesh defines the subMesh to render
  99280. * @param enableAlphaMode defines if alpha mode can be changed
  99281. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99282. * @returns the current mesh
  99283. */
  99284. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99285. private _onBeforeDraw;
  99286. /**
  99287. * Renormalize the mesh and patch it up if there are no weights
  99288. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99289. * However in the case of zero weights then we set just a single influence to 1.
  99290. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99291. */
  99292. cleanMatrixWeights(): void;
  99293. private normalizeSkinFourWeights;
  99294. private normalizeSkinWeightsAndExtra;
  99295. /**
  99296. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99297. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99298. * the user know there was an issue with importing the mesh
  99299. * @returns a validation object with skinned, valid and report string
  99300. */
  99301. validateSkinning(): {
  99302. skinned: boolean;
  99303. valid: boolean;
  99304. report: string;
  99305. };
  99306. /** @hidden */
  99307. _checkDelayState(): Mesh;
  99308. private _queueLoad;
  99309. /**
  99310. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99311. * A mesh is in the frustum if its bounding box intersects the frustum
  99312. * @param frustumPlanes defines the frustum to test
  99313. * @returns true if the mesh is in the frustum planes
  99314. */
  99315. isInFrustum(frustumPlanes: Plane[]): boolean;
  99316. /**
  99317. * Sets the mesh material by the material or multiMaterial `id` property
  99318. * @param id is a string identifying the material or the multiMaterial
  99319. * @returns the current mesh
  99320. */
  99321. setMaterialByID(id: string): Mesh;
  99322. /**
  99323. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99324. * @returns an array of IAnimatable
  99325. */
  99326. getAnimatables(): IAnimatable[];
  99327. /**
  99328. * Modifies the mesh geometry according to the passed transformation matrix.
  99329. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99330. * The mesh normals are modified using the same transformation.
  99331. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99332. * @param transform defines the transform matrix to use
  99333. * @see http://doc.babylonjs.com/resources/baking_transformations
  99334. * @returns the current mesh
  99335. */
  99336. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99337. /**
  99338. * Modifies the mesh geometry according to its own current World Matrix.
  99339. * The mesh World Matrix is then reset.
  99340. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99341. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99342. * @see http://doc.babylonjs.com/resources/baking_transformations
  99343. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99344. * @returns the current mesh
  99345. */
  99346. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99347. /** @hidden */
  99348. get _positions(): Nullable<Vector3[]>;
  99349. /** @hidden */
  99350. _resetPointsArrayCache(): Mesh;
  99351. /** @hidden */
  99352. _generatePointsArray(): boolean;
  99353. /**
  99354. * Returns a new Mesh object generated from the current mesh properties.
  99355. * This method must not get confused with createInstance()
  99356. * @param name is a string, the name given to the new mesh
  99357. * @param newParent can be any Node object (default `null`)
  99358. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99359. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99360. * @returns a new mesh
  99361. */
  99362. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99363. /**
  99364. * Releases resources associated with this mesh.
  99365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99367. */
  99368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99369. /** @hidden */
  99370. _disposeInstanceSpecificData(): void;
  99371. /**
  99372. * Modifies the mesh geometry according to a displacement map.
  99373. * 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.
  99374. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99375. * @param url is a string, the URL from the image file is to be downloaded.
  99376. * @param minHeight is the lower limit of the displacement.
  99377. * @param maxHeight is the upper limit of the displacement.
  99378. * @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.
  99379. * @param uvOffset is an optional vector2 used to offset UV.
  99380. * @param uvScale is an optional vector2 used to scale UV.
  99381. * @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.
  99382. * @returns the Mesh.
  99383. */
  99384. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99385. /**
  99386. * Modifies the mesh geometry according to a displacementMap buffer.
  99387. * 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.
  99388. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99389. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99390. * @param heightMapWidth is the width of the buffer image.
  99391. * @param heightMapHeight is the height of the buffer image.
  99392. * @param minHeight is the lower limit of the displacement.
  99393. * @param maxHeight is the upper limit of the displacement.
  99394. * @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.
  99395. * @param uvOffset is an optional vector2 used to offset UV.
  99396. * @param uvScale is an optional vector2 used to scale UV.
  99397. * @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.
  99398. * @returns the Mesh.
  99399. */
  99400. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99401. /**
  99402. * Modify the mesh to get a flat shading rendering.
  99403. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99404. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99405. * @returns current mesh
  99406. */
  99407. convertToFlatShadedMesh(): Mesh;
  99408. /**
  99409. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99410. * In other words, more vertices, no more indices and a single bigger VBO.
  99411. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99412. * @returns current mesh
  99413. */
  99414. convertToUnIndexedMesh(): Mesh;
  99415. /**
  99416. * Inverses facet orientations.
  99417. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99418. * @param flipNormals will also inverts the normals
  99419. * @returns current mesh
  99420. */
  99421. flipFaces(flipNormals?: boolean): Mesh;
  99422. /**
  99423. * Increase the number of facets and hence vertices in a mesh
  99424. * Vertex normals are interpolated from existing vertex normals
  99425. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99426. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99427. */
  99428. increaseVertices(numberPerEdge: number): void;
  99429. /**
  99430. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99431. * This will undo any application of covertToFlatShadedMesh
  99432. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99433. */
  99434. forceSharedVertices(): void;
  99435. /** @hidden */
  99436. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99437. /** @hidden */
  99438. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99439. /**
  99440. * Creates a new InstancedMesh object from the mesh model.
  99441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99442. * @param name defines the name of the new instance
  99443. * @returns a new InstancedMesh
  99444. */
  99445. createInstance(name: string): InstancedMesh;
  99446. /**
  99447. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99448. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99449. * @returns the current mesh
  99450. */
  99451. synchronizeInstances(): Mesh;
  99452. /**
  99453. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99454. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99455. * This should be used together with the simplification to avoid disappearing triangles.
  99456. * @param successCallback an optional success callback to be called after the optimization finished.
  99457. * @returns the current mesh
  99458. */
  99459. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99460. /**
  99461. * Serialize current mesh
  99462. * @param serializationObject defines the object which will receive the serialization data
  99463. */
  99464. serialize(serializationObject: any): void;
  99465. /** @hidden */
  99466. _syncGeometryWithMorphTargetManager(): void;
  99467. /** @hidden */
  99468. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99469. /**
  99470. * Returns a new Mesh object parsed from the source provided.
  99471. * @param parsedMesh is the source
  99472. * @param scene defines the hosting scene
  99473. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99474. * @returns a new Mesh
  99475. */
  99476. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99477. /**
  99478. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99479. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99480. * @param name defines the name of the mesh to create
  99481. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99482. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99483. * @param closePath creates a seam between the first and the last points of each path of the path array
  99484. * @param offset is taken in account only if the `pathArray` is containing a single path
  99485. * @param scene defines the hosting scene
  99486. * @param updatable defines if the mesh must be flagged as updatable
  99487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99488. * @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)
  99489. * @returns a new Mesh
  99490. */
  99491. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99492. /**
  99493. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99494. * @param name defines the name of the mesh to create
  99495. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99496. * @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
  99497. * @param scene defines the hosting scene
  99498. * @param updatable defines if the mesh must be flagged as updatable
  99499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99500. * @returns a new Mesh
  99501. */
  99502. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99503. /**
  99504. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99505. * @param name defines the name of the mesh to create
  99506. * @param size sets the size (float) of each box side (default 1)
  99507. * @param scene defines the hosting scene
  99508. * @param updatable defines if the mesh must be flagged as updatable
  99509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99510. * @returns a new Mesh
  99511. */
  99512. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99513. /**
  99514. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99515. * @param name defines the name of the mesh to create
  99516. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99517. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99518. * @param scene defines the hosting scene
  99519. * @param updatable defines if the mesh must be flagged as updatable
  99520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99521. * @returns a new Mesh
  99522. */
  99523. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99524. /**
  99525. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99526. * @param name defines the name of the mesh to create
  99527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99529. * @param scene defines the hosting scene
  99530. * @returns a new Mesh
  99531. */
  99532. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99533. /**
  99534. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  99537. * @param diameterTop set the top cap diameter (floats, default 1)
  99538. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99539. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99540. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99541. * @param scene defines the hosting scene
  99542. * @param updatable defines if the mesh must be flagged as updatable
  99543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99544. * @returns a new Mesh
  99545. */
  99546. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99547. /**
  99548. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99549. * @param name defines the name of the mesh to create
  99550. * @param diameter sets the diameter size (float) of the torus (default 1)
  99551. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99552. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99553. * @param scene defines the hosting scene
  99554. * @param updatable defines if the mesh must be flagged as updatable
  99555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99556. * @returns a new Mesh
  99557. */
  99558. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99559. /**
  99560. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99561. * @param name defines the name of the mesh to create
  99562. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99563. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99564. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99565. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99566. * @param p the number of windings on X axis (positive integers, default 2)
  99567. * @param q the number of windings on Y axis (positive integers, default 3)
  99568. * @param scene defines the hosting scene
  99569. * @param updatable defines if the mesh must be flagged as updatable
  99570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99571. * @returns a new Mesh
  99572. */
  99573. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99574. /**
  99575. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99576. * @param name defines the name of the mesh to create
  99577. * @param points is an array successive Vector3
  99578. * @param scene defines the hosting scene
  99579. * @param updatable defines if the mesh must be flagged as updatable
  99580. * @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).
  99581. * @returns a new Mesh
  99582. */
  99583. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99584. /**
  99585. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99586. * @param name defines the name of the mesh to create
  99587. * @param points is an array successive Vector3
  99588. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99589. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99590. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99591. * @param scene defines the hosting scene
  99592. * @param updatable defines if the mesh must be flagged as updatable
  99593. * @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)
  99594. * @returns a new Mesh
  99595. */
  99596. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99597. /**
  99598. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99599. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99600. * 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.
  99601. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99602. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99603. * Remember you can only change the shape positions, not their number when updating a polygon.
  99604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99605. * @param name defines the name of the mesh to create
  99606. * @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
  99607. * @param scene defines the hosting scene
  99608. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99609. * @param updatable defines if the mesh must be flagged as updatable
  99610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99611. * @param earcutInjection can be used to inject your own earcut reference
  99612. * @returns a new Mesh
  99613. */
  99614. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99615. /**
  99616. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99618. * @param name defines the name of the mesh to create
  99619. * @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
  99620. * @param depth defines the height of extrusion
  99621. * @param scene defines the hosting scene
  99622. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99623. * @param updatable defines if the mesh must be flagged as updatable
  99624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99625. * @param earcutInjection can be used to inject your own earcut reference
  99626. * @returns a new Mesh
  99627. */
  99628. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99629. /**
  99630. * Creates an extruded shape mesh.
  99631. * 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
  99632. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99633. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99634. * @param name defines the name of the mesh to create
  99635. * @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
  99636. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99637. * @param scale is the value to scale the shape
  99638. * @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
  99639. * @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
  99640. * @param scene defines the hosting scene
  99641. * @param updatable defines if the mesh must be flagged as updatable
  99642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99643. * @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)
  99644. * @returns a new Mesh
  99645. */
  99646. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99647. /**
  99648. * Creates an custom extruded shape mesh.
  99649. * The custom extrusion is a parametric shape.
  99650. * It has no predefined shape. Its final shape will depend on the input parameters.
  99651. * Please consider using the same method from the MeshBuilder class instead
  99652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99653. * @param name defines the name of the mesh to create
  99654. * @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
  99655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99656. * @param scaleFunction is a custom Javascript function called on each path point
  99657. * @param rotationFunction is a custom Javascript function called on each path point
  99658. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99659. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99660. * @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
  99661. * @param scene defines the hosting scene
  99662. * @param updatable defines if the mesh must be flagged as updatable
  99663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99664. * @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)
  99665. * @returns a new Mesh
  99666. */
  99667. 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;
  99668. /**
  99669. * Creates lathe mesh.
  99670. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99671. * Please consider using the same method from the MeshBuilder class instead
  99672. * @param name defines the name of the mesh to create
  99673. * @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
  99674. * @param radius is the radius value of the lathe
  99675. * @param tessellation is the side number of the lathe.
  99676. * @param scene defines the hosting scene
  99677. * @param updatable defines if the mesh must be flagged as updatable
  99678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99679. * @returns a new Mesh
  99680. */
  99681. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99682. /**
  99683. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99684. * @param name defines the name of the mesh to create
  99685. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99686. * @param scene defines the hosting scene
  99687. * @param updatable defines if the mesh must be flagged as updatable
  99688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99689. * @returns a new Mesh
  99690. */
  99691. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99692. /**
  99693. * Creates a ground mesh.
  99694. * Please consider using the same method from the MeshBuilder class instead
  99695. * @param name defines the name of the mesh to create
  99696. * @param width set the width of the ground
  99697. * @param height set the height of the ground
  99698. * @param subdivisions sets the number of subdivisions per side
  99699. * @param scene defines the hosting scene
  99700. * @param updatable defines if the mesh must be flagged as updatable
  99701. * @returns a new Mesh
  99702. */
  99703. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99704. /**
  99705. * Creates a tiled ground mesh.
  99706. * Please consider using the same method from the MeshBuilder class instead
  99707. * @param name defines the name of the mesh to create
  99708. * @param xmin set the ground minimum X coordinate
  99709. * @param zmin set the ground minimum Y coordinate
  99710. * @param xmax set the ground maximum X coordinate
  99711. * @param zmax set the ground maximum Z coordinate
  99712. * @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
  99713. * @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
  99714. * @param scene defines the hosting scene
  99715. * @param updatable defines if the mesh must be flagged as updatable
  99716. * @returns a new Mesh
  99717. */
  99718. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99719. w: number;
  99720. h: number;
  99721. }, precision: {
  99722. w: number;
  99723. h: number;
  99724. }, scene: Scene, updatable?: boolean): Mesh;
  99725. /**
  99726. * Creates a ground mesh from a height map.
  99727. * Please consider using the same method from the MeshBuilder class instead
  99728. * @see http://doc.babylonjs.com/babylon101/height_map
  99729. * @param name defines the name of the mesh to create
  99730. * @param url sets the URL of the height map image resource
  99731. * @param width set the ground width size
  99732. * @param height set the ground height size
  99733. * @param subdivisions sets the number of subdivision per side
  99734. * @param minHeight is the minimum altitude on the ground
  99735. * @param maxHeight is the maximum altitude on the ground
  99736. * @param scene defines the hosting scene
  99737. * @param updatable defines if the mesh must be flagged as updatable
  99738. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99739. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99740. * @returns a new Mesh
  99741. */
  99742. 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;
  99743. /**
  99744. * Creates a tube mesh.
  99745. * The tube is a parametric shape.
  99746. * It has no predefined shape. Its final shape will depend on the input parameters.
  99747. * Please consider using the same method from the MeshBuilder class instead
  99748. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99749. * @param name defines the name of the mesh to create
  99750. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99751. * @param radius sets the tube radius size
  99752. * @param tessellation is the number of sides on the tubular surface
  99753. * @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
  99754. * @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
  99755. * @param scene defines the hosting scene
  99756. * @param updatable defines if the mesh must be flagged as updatable
  99757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99758. * @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)
  99759. * @returns a new Mesh
  99760. */
  99761. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99762. (i: number, distance: number): number;
  99763. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99764. /**
  99765. * Creates a polyhedron mesh.
  99766. * Please consider using the same method from the MeshBuilder class instead.
  99767. * * 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
  99768. * * The parameter `size` (positive float, default 1) sets the polygon size
  99769. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99770. * * 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`
  99771. * * 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
  99772. * * 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)`)
  99773. * * 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
  99774. * * 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
  99775. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99776. * * If you create a double-sided mesh, you can choose what parts of 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
  99777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99778. * @param name defines the name of the mesh to create
  99779. * @param options defines the options used to create the mesh
  99780. * @param scene defines the hosting scene
  99781. * @returns a new Mesh
  99782. */
  99783. static CreatePolyhedron(name: string, options: {
  99784. type?: number;
  99785. size?: number;
  99786. sizeX?: number;
  99787. sizeY?: number;
  99788. sizeZ?: number;
  99789. custom?: any;
  99790. faceUV?: Vector4[];
  99791. faceColors?: Color4[];
  99792. updatable?: boolean;
  99793. sideOrientation?: number;
  99794. }, scene: Scene): Mesh;
  99795. /**
  99796. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99797. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99798. * * 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`)
  99799. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99800. * * 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
  99801. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99802. * * If you create a double-sided mesh, you can choose what parts of 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
  99803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99804. * @param name defines the name of the mesh
  99805. * @param options defines the options used to create the mesh
  99806. * @param scene defines the hosting scene
  99807. * @returns a new Mesh
  99808. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99809. */
  99810. static CreateIcoSphere(name: string, options: {
  99811. radius?: number;
  99812. flat?: boolean;
  99813. subdivisions?: number;
  99814. sideOrientation?: number;
  99815. updatable?: boolean;
  99816. }, scene: Scene): Mesh;
  99817. /**
  99818. * Creates a decal mesh.
  99819. * Please consider using the same method from the MeshBuilder class instead.
  99820. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99821. * @param name defines the name of the mesh
  99822. * @param sourceMesh defines the mesh receiving the decal
  99823. * @param position sets the position of the decal in world coordinates
  99824. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99825. * @param size sets the decal scaling
  99826. * @param angle sets the angle to rotate the decal
  99827. * @returns a new Mesh
  99828. */
  99829. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99830. /**
  99831. * Prepare internal position array for software CPU skinning
  99832. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99833. */
  99834. setPositionsForCPUSkinning(): Float32Array;
  99835. /**
  99836. * Prepare internal normal array for software CPU skinning
  99837. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99838. */
  99839. setNormalsForCPUSkinning(): Float32Array;
  99840. /**
  99841. * Updates the vertex buffer by applying transformation from the bones
  99842. * @param skeleton defines the skeleton to apply to current mesh
  99843. * @returns the current mesh
  99844. */
  99845. applySkeleton(skeleton: Skeleton): Mesh;
  99846. /**
  99847. * 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
  99848. * @param meshes defines the list of meshes to scan
  99849. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99850. */
  99851. static MinMax(meshes: AbstractMesh[]): {
  99852. min: Vector3;
  99853. max: Vector3;
  99854. };
  99855. /**
  99856. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99857. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99858. * @returns a vector3
  99859. */
  99860. static Center(meshesOrMinMaxVector: {
  99861. min: Vector3;
  99862. max: Vector3;
  99863. } | AbstractMesh[]): Vector3;
  99864. /**
  99865. * Merge the array of meshes into a single mesh for performance reasons.
  99866. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99867. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99868. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99869. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99870. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99871. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99872. * @returns a new mesh
  99873. */
  99874. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99875. /** @hidden */
  99876. addInstance(instance: InstancedMesh): void;
  99877. /** @hidden */
  99878. removeInstance(instance: InstancedMesh): void;
  99879. }
  99880. }
  99881. declare module BABYLON {
  99882. /**
  99883. * This is the base class of all the camera used in the application.
  99884. * @see http://doc.babylonjs.com/features/cameras
  99885. */
  99886. export class Camera extends Node {
  99887. /** @hidden */
  99888. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99889. /**
  99890. * This is the default projection mode used by the cameras.
  99891. * It helps recreating a feeling of perspective and better appreciate depth.
  99892. * This is the best way to simulate real life cameras.
  99893. */
  99894. static readonly PERSPECTIVE_CAMERA: number;
  99895. /**
  99896. * This helps creating camera with an orthographic mode.
  99897. * 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.
  99898. */
  99899. static readonly ORTHOGRAPHIC_CAMERA: number;
  99900. /**
  99901. * This is the default FOV mode for perspective cameras.
  99902. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99903. */
  99904. static readonly FOVMODE_VERTICAL_FIXED: number;
  99905. /**
  99906. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99907. */
  99908. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99909. /**
  99910. * This specifies ther is no need for a camera rig.
  99911. * Basically only one eye is rendered corresponding to the camera.
  99912. */
  99913. static readonly RIG_MODE_NONE: number;
  99914. /**
  99915. * Simulates a camera Rig with one blue eye and one red eye.
  99916. * This can be use with 3d blue and red glasses.
  99917. */
  99918. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99919. /**
  99920. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99921. */
  99922. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99923. /**
  99924. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99925. */
  99926. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99927. /**
  99928. * Defines that both eyes of the camera will be rendered over under each other.
  99929. */
  99930. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99931. /**
  99932. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99933. */
  99934. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99935. /**
  99936. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99937. */
  99938. static readonly RIG_MODE_VR: number;
  99939. /**
  99940. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99941. */
  99942. static readonly RIG_MODE_WEBVR: number;
  99943. /**
  99944. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99945. */
  99946. static readonly RIG_MODE_CUSTOM: number;
  99947. /**
  99948. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99949. */
  99950. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99951. /**
  99952. * Define the input manager associated with the camera.
  99953. */
  99954. inputs: CameraInputsManager<Camera>;
  99955. /** @hidden */
  99956. _position: Vector3;
  99957. /**
  99958. * Define the current local position of the camera in the scene
  99959. */
  99960. get position(): Vector3;
  99961. set position(newPosition: Vector3);
  99962. /**
  99963. * The vector the camera should consider as up.
  99964. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99965. */
  99966. upVector: Vector3;
  99967. /**
  99968. * Define the current limit on the left side for an orthographic camera
  99969. * In scene unit
  99970. */
  99971. orthoLeft: Nullable<number>;
  99972. /**
  99973. * Define the current limit on the right side for an orthographic camera
  99974. * In scene unit
  99975. */
  99976. orthoRight: Nullable<number>;
  99977. /**
  99978. * Define the current limit on the bottom side for an orthographic camera
  99979. * In scene unit
  99980. */
  99981. orthoBottom: Nullable<number>;
  99982. /**
  99983. * Define the current limit on the top side for an orthographic camera
  99984. * In scene unit
  99985. */
  99986. orthoTop: Nullable<number>;
  99987. /**
  99988. * Field Of View is set in Radians. (default is 0.8)
  99989. */
  99990. fov: number;
  99991. /**
  99992. * Define the minimum distance the camera can see from.
  99993. * This is important to note that the depth buffer are not infinite and the closer it starts
  99994. * the more your scene might encounter depth fighting issue.
  99995. */
  99996. minZ: number;
  99997. /**
  99998. * Define the maximum distance the camera can see to.
  99999. * This is important to note that the depth buffer are not infinite and the further it end
  100000. * the more your scene might encounter depth fighting issue.
  100001. */
  100002. maxZ: number;
  100003. /**
  100004. * Define the default inertia of the camera.
  100005. * This helps giving a smooth feeling to the camera movement.
  100006. */
  100007. inertia: number;
  100008. /**
  100009. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100010. */
  100011. mode: number;
  100012. /**
  100013. * Define whether the camera is intermediate.
  100014. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100015. */
  100016. isIntermediate: boolean;
  100017. /**
  100018. * Define the viewport of the camera.
  100019. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100020. */
  100021. viewport: Viewport;
  100022. /**
  100023. * Restricts the camera to viewing objects with the same layerMask.
  100024. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100025. */
  100026. layerMask: number;
  100027. /**
  100028. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100029. */
  100030. fovMode: number;
  100031. /**
  100032. * Rig mode of the camera.
  100033. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100034. * This is normally controlled byt the camera themselves as internal use.
  100035. */
  100036. cameraRigMode: number;
  100037. /**
  100038. * Defines the distance between both "eyes" in case of a RIG
  100039. */
  100040. interaxialDistance: number;
  100041. /**
  100042. * Defines if stereoscopic rendering is done side by side or over under.
  100043. */
  100044. isStereoscopicSideBySide: boolean;
  100045. /**
  100046. * 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
  100047. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100048. * else in the scene. (Eg. security camera)
  100049. *
  100050. * 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)
  100051. */
  100052. customRenderTargets: RenderTargetTexture[];
  100053. /**
  100054. * When set, the camera will render to this render target instead of the default canvas
  100055. *
  100056. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100057. */
  100058. outputRenderTarget: Nullable<RenderTargetTexture>;
  100059. /**
  100060. * Observable triggered when the camera view matrix has changed.
  100061. */
  100062. onViewMatrixChangedObservable: Observable<Camera>;
  100063. /**
  100064. * Observable triggered when the camera Projection matrix has changed.
  100065. */
  100066. onProjectionMatrixChangedObservable: Observable<Camera>;
  100067. /**
  100068. * Observable triggered when the inputs have been processed.
  100069. */
  100070. onAfterCheckInputsObservable: Observable<Camera>;
  100071. /**
  100072. * Observable triggered when reset has been called and applied to the camera.
  100073. */
  100074. onRestoreStateObservable: Observable<Camera>;
  100075. /**
  100076. * Is this camera a part of a rig system?
  100077. */
  100078. isRigCamera: boolean;
  100079. /**
  100080. * If isRigCamera set to true this will be set with the parent camera.
  100081. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100082. */
  100083. rigParent?: Camera;
  100084. /** @hidden */
  100085. _cameraRigParams: any;
  100086. /** @hidden */
  100087. _rigCameras: Camera[];
  100088. /** @hidden */
  100089. _rigPostProcess: Nullable<PostProcess>;
  100090. protected _webvrViewMatrix: Matrix;
  100091. /** @hidden */
  100092. _skipRendering: boolean;
  100093. /** @hidden */
  100094. _projectionMatrix: Matrix;
  100095. /** @hidden */
  100096. _postProcesses: Nullable<PostProcess>[];
  100097. /** @hidden */
  100098. _activeMeshes: SmartArray<AbstractMesh>;
  100099. protected _globalPosition: Vector3;
  100100. /** @hidden */
  100101. _computedViewMatrix: Matrix;
  100102. private _doNotComputeProjectionMatrix;
  100103. private _transformMatrix;
  100104. private _frustumPlanes;
  100105. private _refreshFrustumPlanes;
  100106. private _storedFov;
  100107. private _stateStored;
  100108. /**
  100109. * Instantiates a new camera object.
  100110. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100111. * @see http://doc.babylonjs.com/features/cameras
  100112. * @param name Defines the name of the camera in the scene
  100113. * @param position Defines the position of the camera
  100114. * @param scene Defines the scene the camera belongs too
  100115. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100116. */
  100117. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100118. /**
  100119. * Store current camera state (fov, position, etc..)
  100120. * @returns the camera
  100121. */
  100122. storeState(): Camera;
  100123. /**
  100124. * Restores the camera state values if it has been stored. You must call storeState() first
  100125. */
  100126. protected _restoreStateValues(): boolean;
  100127. /**
  100128. * Restored camera state. You must call storeState() first.
  100129. * @returns true if restored and false otherwise
  100130. */
  100131. restoreState(): boolean;
  100132. /**
  100133. * Gets the class name of the camera.
  100134. * @returns the class name
  100135. */
  100136. getClassName(): string;
  100137. /** @hidden */
  100138. readonly _isCamera: boolean;
  100139. /**
  100140. * Gets a string representation of the camera useful for debug purpose.
  100141. * @param fullDetails Defines that a more verboe level of logging is required
  100142. * @returns the string representation
  100143. */
  100144. toString(fullDetails?: boolean): string;
  100145. /**
  100146. * Gets the current world space position of the camera.
  100147. */
  100148. get globalPosition(): Vector3;
  100149. /**
  100150. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100151. * @returns the active meshe list
  100152. */
  100153. getActiveMeshes(): SmartArray<AbstractMesh>;
  100154. /**
  100155. * Check whether a mesh is part of the current active mesh list of the camera
  100156. * @param mesh Defines the mesh to check
  100157. * @returns true if active, false otherwise
  100158. */
  100159. isActiveMesh(mesh: Mesh): boolean;
  100160. /**
  100161. * Is this camera ready to be used/rendered
  100162. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100163. * @return true if the camera is ready
  100164. */
  100165. isReady(completeCheck?: boolean): boolean;
  100166. /** @hidden */
  100167. _initCache(): void;
  100168. /** @hidden */
  100169. _updateCache(ignoreParentClass?: boolean): void;
  100170. /** @hidden */
  100171. _isSynchronized(): boolean;
  100172. /** @hidden */
  100173. _isSynchronizedViewMatrix(): boolean;
  100174. /** @hidden */
  100175. _isSynchronizedProjectionMatrix(): boolean;
  100176. /**
  100177. * Attach the input controls to a specific dom element to get the input from.
  100178. * @param element Defines the element the controls should be listened from
  100179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100180. */
  100181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100182. /**
  100183. * Detach the current controls from the specified dom element.
  100184. * @param element Defines the element to stop listening the inputs from
  100185. */
  100186. detachControl(element: HTMLElement): void;
  100187. /**
  100188. * Update the camera state according to the different inputs gathered during the frame.
  100189. */
  100190. update(): void;
  100191. /** @hidden */
  100192. _checkInputs(): void;
  100193. /** @hidden */
  100194. get rigCameras(): Camera[];
  100195. /**
  100196. * Gets the post process used by the rig cameras
  100197. */
  100198. get rigPostProcess(): Nullable<PostProcess>;
  100199. /**
  100200. * Internal, gets the first post proces.
  100201. * @returns the first post process to be run on this camera.
  100202. */
  100203. _getFirstPostProcess(): Nullable<PostProcess>;
  100204. private _cascadePostProcessesToRigCams;
  100205. /**
  100206. * Attach a post process to the camera.
  100207. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100208. * @param postProcess The post process to attach to the camera
  100209. * @param insertAt The position of the post process in case several of them are in use in the scene
  100210. * @returns the position the post process has been inserted at
  100211. */
  100212. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100213. /**
  100214. * Detach a post process to the camera.
  100215. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100216. * @param postProcess The post process to detach from the camera
  100217. */
  100218. detachPostProcess(postProcess: PostProcess): void;
  100219. /**
  100220. * Gets the current world matrix of the camera
  100221. */
  100222. getWorldMatrix(): Matrix;
  100223. /** @hidden */
  100224. _getViewMatrix(): Matrix;
  100225. /**
  100226. * Gets the current view matrix of the camera.
  100227. * @param force forces the camera to recompute the matrix without looking at the cached state
  100228. * @returns the view matrix
  100229. */
  100230. getViewMatrix(force?: boolean): Matrix;
  100231. /**
  100232. * Freeze the projection matrix.
  100233. * It will prevent the cache check of the camera projection compute and can speed up perf
  100234. * if no parameter of the camera are meant to change
  100235. * @param projection Defines manually a projection if necessary
  100236. */
  100237. freezeProjectionMatrix(projection?: Matrix): void;
  100238. /**
  100239. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100240. */
  100241. unfreezeProjectionMatrix(): void;
  100242. /**
  100243. * Gets the current projection matrix of the camera.
  100244. * @param force forces the camera to recompute the matrix without looking at the cached state
  100245. * @returns the projection matrix
  100246. */
  100247. getProjectionMatrix(force?: boolean): Matrix;
  100248. /**
  100249. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100250. * @returns a Matrix
  100251. */
  100252. getTransformationMatrix(): Matrix;
  100253. private _updateFrustumPlanes;
  100254. /**
  100255. * Checks if a cullable object (mesh...) is in the camera frustum
  100256. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100257. * @param target The object to check
  100258. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100259. * @returns true if the object is in frustum otherwise false
  100260. */
  100261. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100262. /**
  100263. * Checks if a cullable object (mesh...) is in the camera frustum
  100264. * Unlike isInFrustum this cheks the full bounding box
  100265. * @param target The object to check
  100266. * @returns true if the object is in frustum otherwise false
  100267. */
  100268. isCompletelyInFrustum(target: ICullable): boolean;
  100269. /**
  100270. * Gets a ray in the forward direction from the camera.
  100271. * @param length Defines the length of the ray to create
  100272. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100273. * @param origin Defines the start point of the ray which defaults to the camera position
  100274. * @returns the forward ray
  100275. */
  100276. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100277. /**
  100278. * Releases resources associated with this node.
  100279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100281. */
  100282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100283. /** @hidden */
  100284. _isLeftCamera: boolean;
  100285. /**
  100286. * Gets the left camera of a rig setup in case of Rigged Camera
  100287. */
  100288. get isLeftCamera(): boolean;
  100289. /** @hidden */
  100290. _isRightCamera: boolean;
  100291. /**
  100292. * Gets the right camera of a rig setup in case of Rigged Camera
  100293. */
  100294. get isRightCamera(): boolean;
  100295. /**
  100296. * Gets the left camera of a rig setup in case of Rigged Camera
  100297. */
  100298. get leftCamera(): Nullable<FreeCamera>;
  100299. /**
  100300. * Gets the right camera of a rig setup in case of Rigged Camera
  100301. */
  100302. get rightCamera(): Nullable<FreeCamera>;
  100303. /**
  100304. * Gets the left camera target of a rig setup in case of Rigged Camera
  100305. * @returns the target position
  100306. */
  100307. getLeftTarget(): Nullable<Vector3>;
  100308. /**
  100309. * Gets the right camera target of a rig setup in case of Rigged Camera
  100310. * @returns the target position
  100311. */
  100312. getRightTarget(): Nullable<Vector3>;
  100313. /**
  100314. * @hidden
  100315. */
  100316. setCameraRigMode(mode: number, rigParams: any): void;
  100317. /** @hidden */
  100318. static _setStereoscopicRigMode(camera: Camera): void;
  100319. /** @hidden */
  100320. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100321. /** @hidden */
  100322. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100323. /** @hidden */
  100324. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100325. /** @hidden */
  100326. _getVRProjectionMatrix(): Matrix;
  100327. protected _updateCameraRotationMatrix(): void;
  100328. protected _updateWebVRCameraRotationMatrix(): void;
  100329. /**
  100330. * This function MUST be overwritten by the different WebVR cameras available.
  100331. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100332. * @hidden
  100333. */
  100334. _getWebVRProjectionMatrix(): Matrix;
  100335. /**
  100336. * This function MUST be overwritten by the different WebVR cameras available.
  100337. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100338. * @hidden
  100339. */
  100340. _getWebVRViewMatrix(): Matrix;
  100341. /** @hidden */
  100342. setCameraRigParameter(name: string, value: any): void;
  100343. /**
  100344. * needs to be overridden by children so sub has required properties to be copied
  100345. * @hidden
  100346. */
  100347. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100348. /**
  100349. * May need to be overridden by children
  100350. * @hidden
  100351. */
  100352. _updateRigCameras(): void;
  100353. /** @hidden */
  100354. _setupInputs(): void;
  100355. /**
  100356. * Serialiaze the camera setup to a json represention
  100357. * @returns the JSON representation
  100358. */
  100359. serialize(): any;
  100360. /**
  100361. * Clones the current camera.
  100362. * @param name The cloned camera name
  100363. * @returns the cloned camera
  100364. */
  100365. clone(name: string): Camera;
  100366. /**
  100367. * Gets the direction of the camera relative to a given local axis.
  100368. * @param localAxis Defines the reference axis to provide a relative direction.
  100369. * @return the direction
  100370. */
  100371. getDirection(localAxis: Vector3): Vector3;
  100372. /**
  100373. * Returns the current camera absolute rotation
  100374. */
  100375. get absoluteRotation(): Quaternion;
  100376. /**
  100377. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100378. * @param localAxis Defines the reference axis to provide a relative direction.
  100379. * @param result Defines the vector to store the result in
  100380. */
  100381. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100382. /**
  100383. * Gets a camera constructor for a given camera type
  100384. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100385. * @param name The name of the camera the result will be able to instantiate
  100386. * @param scene The scene the result will construct the camera in
  100387. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100388. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100389. * @returns a factory method to construc the camera
  100390. */
  100391. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100392. /**
  100393. * Compute the world matrix of the camera.
  100394. * @returns the camera world matrix
  100395. */
  100396. computeWorldMatrix(): Matrix;
  100397. /**
  100398. * Parse a JSON and creates the camera from the parsed information
  100399. * @param parsedCamera The JSON to parse
  100400. * @param scene The scene to instantiate the camera in
  100401. * @returns the newly constructed camera
  100402. */
  100403. static Parse(parsedCamera: any, scene: Scene): Camera;
  100404. }
  100405. }
  100406. declare module BABYLON {
  100407. /**
  100408. * Class containing static functions to help procedurally build meshes
  100409. */
  100410. export class DiscBuilder {
  100411. /**
  100412. * Creates a plane polygonal mesh. By default, this is a disc
  100413. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100414. * * 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
  100415. * * 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
  100416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100419. * @param name defines the name of the mesh
  100420. * @param options defines the options used to create the mesh
  100421. * @param scene defines the hosting scene
  100422. * @returns the plane polygonal mesh
  100423. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100424. */
  100425. static CreateDisc(name: string, options: {
  100426. radius?: number;
  100427. tessellation?: number;
  100428. arc?: number;
  100429. updatable?: boolean;
  100430. sideOrientation?: number;
  100431. frontUVs?: Vector4;
  100432. backUVs?: Vector4;
  100433. }, scene?: Nullable<Scene>): Mesh;
  100434. }
  100435. }
  100436. declare module BABYLON {
  100437. /**
  100438. * Options to be used when creating a FresnelParameters.
  100439. */
  100440. export type IFresnelParametersCreationOptions = {
  100441. /**
  100442. * Define the color used on edges (grazing angle)
  100443. */
  100444. leftColor?: Color3;
  100445. /**
  100446. * Define the color used on center
  100447. */
  100448. rightColor?: Color3;
  100449. /**
  100450. * Define bias applied to computed fresnel term
  100451. */
  100452. bias?: number;
  100453. /**
  100454. * Defined the power exponent applied to fresnel term
  100455. */
  100456. power?: number;
  100457. /**
  100458. * Define if the fresnel effect is enable or not.
  100459. */
  100460. isEnabled?: boolean;
  100461. };
  100462. /**
  100463. * Serialized format for FresnelParameters.
  100464. */
  100465. export type IFresnelParametersSerialized = {
  100466. /**
  100467. * Define the color used on edges (grazing angle) [as an array]
  100468. */
  100469. leftColor: number[];
  100470. /**
  100471. * Define the color used on center [as an array]
  100472. */
  100473. rightColor: number[];
  100474. /**
  100475. * Define bias applied to computed fresnel term
  100476. */
  100477. bias: number;
  100478. /**
  100479. * Defined the power exponent applied to fresnel term
  100480. */
  100481. power?: number;
  100482. /**
  100483. * Define if the fresnel effect is enable or not.
  100484. */
  100485. isEnabled: boolean;
  100486. };
  100487. /**
  100488. * This represents all the required information to add a fresnel effect on a material:
  100489. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100490. */
  100491. export class FresnelParameters {
  100492. private _isEnabled;
  100493. /**
  100494. * Define if the fresnel effect is enable or not.
  100495. */
  100496. get isEnabled(): boolean;
  100497. set isEnabled(value: boolean);
  100498. /**
  100499. * Define the color used on edges (grazing angle)
  100500. */
  100501. leftColor: Color3;
  100502. /**
  100503. * Define the color used on center
  100504. */
  100505. rightColor: Color3;
  100506. /**
  100507. * Define bias applied to computed fresnel term
  100508. */
  100509. bias: number;
  100510. /**
  100511. * Defined the power exponent applied to fresnel term
  100512. */
  100513. power: number;
  100514. /**
  100515. * Creates a new FresnelParameters object.
  100516. *
  100517. * @param options provide your own settings to optionally to override defaults
  100518. */
  100519. constructor(options?: IFresnelParametersCreationOptions);
  100520. /**
  100521. * Clones the current fresnel and its valuues
  100522. * @returns a clone fresnel configuration
  100523. */
  100524. clone(): FresnelParameters;
  100525. /**
  100526. * Determines equality between FresnelParameters objects
  100527. * @param otherFresnelParameters defines the second operand
  100528. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100529. */
  100530. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100531. /**
  100532. * Serializes the current fresnel parameters to a JSON representation.
  100533. * @return the JSON serialization
  100534. */
  100535. serialize(): IFresnelParametersSerialized;
  100536. /**
  100537. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100538. * @param parsedFresnelParameters Define the JSON representation
  100539. * @returns the parsed parameters
  100540. */
  100541. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100542. }
  100543. }
  100544. declare module BABYLON {
  100545. /**
  100546. * Base class of materials working in push mode in babylon JS
  100547. * @hidden
  100548. */
  100549. export class PushMaterial extends Material {
  100550. protected _activeEffect: Effect;
  100551. protected _normalMatrix: Matrix;
  100552. /**
  100553. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100554. * This means that the material can keep using a previous shader while a new one is being compiled.
  100555. * This is mostly used when shader parallel compilation is supported (true by default)
  100556. */
  100557. allowShaderHotSwapping: boolean;
  100558. constructor(name: string, scene: Scene);
  100559. getEffect(): Effect;
  100560. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100561. /**
  100562. * Binds the given world matrix to the active effect
  100563. *
  100564. * @param world the matrix to bind
  100565. */
  100566. bindOnlyWorldMatrix(world: Matrix): void;
  100567. /**
  100568. * Binds the given normal matrix to the active effect
  100569. *
  100570. * @param normalMatrix the matrix to bind
  100571. */
  100572. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100573. bind(world: Matrix, mesh?: Mesh): void;
  100574. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100575. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100576. }
  100577. }
  100578. declare module BABYLON {
  100579. /**
  100580. * This groups all the flags used to control the materials channel.
  100581. */
  100582. export class MaterialFlags {
  100583. private static _DiffuseTextureEnabled;
  100584. /**
  100585. * Are diffuse textures enabled in the application.
  100586. */
  100587. static get DiffuseTextureEnabled(): boolean;
  100588. static set DiffuseTextureEnabled(value: boolean);
  100589. private static _AmbientTextureEnabled;
  100590. /**
  100591. * Are ambient textures enabled in the application.
  100592. */
  100593. static get AmbientTextureEnabled(): boolean;
  100594. static set AmbientTextureEnabled(value: boolean);
  100595. private static _OpacityTextureEnabled;
  100596. /**
  100597. * Are opacity textures enabled in the application.
  100598. */
  100599. static get OpacityTextureEnabled(): boolean;
  100600. static set OpacityTextureEnabled(value: boolean);
  100601. private static _ReflectionTextureEnabled;
  100602. /**
  100603. * Are reflection textures enabled in the application.
  100604. */
  100605. static get ReflectionTextureEnabled(): boolean;
  100606. static set ReflectionTextureEnabled(value: boolean);
  100607. private static _EmissiveTextureEnabled;
  100608. /**
  100609. * Are emissive textures enabled in the application.
  100610. */
  100611. static get EmissiveTextureEnabled(): boolean;
  100612. static set EmissiveTextureEnabled(value: boolean);
  100613. private static _SpecularTextureEnabled;
  100614. /**
  100615. * Are specular textures enabled in the application.
  100616. */
  100617. static get SpecularTextureEnabled(): boolean;
  100618. static set SpecularTextureEnabled(value: boolean);
  100619. private static _BumpTextureEnabled;
  100620. /**
  100621. * Are bump textures enabled in the application.
  100622. */
  100623. static get BumpTextureEnabled(): boolean;
  100624. static set BumpTextureEnabled(value: boolean);
  100625. private static _LightmapTextureEnabled;
  100626. /**
  100627. * Are lightmap textures enabled in the application.
  100628. */
  100629. static get LightmapTextureEnabled(): boolean;
  100630. static set LightmapTextureEnabled(value: boolean);
  100631. private static _RefractionTextureEnabled;
  100632. /**
  100633. * Are refraction textures enabled in the application.
  100634. */
  100635. static get RefractionTextureEnabled(): boolean;
  100636. static set RefractionTextureEnabled(value: boolean);
  100637. private static _ColorGradingTextureEnabled;
  100638. /**
  100639. * Are color grading textures enabled in the application.
  100640. */
  100641. static get ColorGradingTextureEnabled(): boolean;
  100642. static set ColorGradingTextureEnabled(value: boolean);
  100643. private static _FresnelEnabled;
  100644. /**
  100645. * Are fresnels enabled in the application.
  100646. */
  100647. static get FresnelEnabled(): boolean;
  100648. static set FresnelEnabled(value: boolean);
  100649. private static _ClearCoatTextureEnabled;
  100650. /**
  100651. * Are clear coat textures enabled in the application.
  100652. */
  100653. static get ClearCoatTextureEnabled(): boolean;
  100654. static set ClearCoatTextureEnabled(value: boolean);
  100655. private static _ClearCoatBumpTextureEnabled;
  100656. /**
  100657. * Are clear coat bump textures enabled in the application.
  100658. */
  100659. static get ClearCoatBumpTextureEnabled(): boolean;
  100660. static set ClearCoatBumpTextureEnabled(value: boolean);
  100661. private static _ClearCoatTintTextureEnabled;
  100662. /**
  100663. * Are clear coat tint textures enabled in the application.
  100664. */
  100665. static get ClearCoatTintTextureEnabled(): boolean;
  100666. static set ClearCoatTintTextureEnabled(value: boolean);
  100667. private static _SheenTextureEnabled;
  100668. /**
  100669. * Are sheen textures enabled in the application.
  100670. */
  100671. static get SheenTextureEnabled(): boolean;
  100672. static set SheenTextureEnabled(value: boolean);
  100673. private static _AnisotropicTextureEnabled;
  100674. /**
  100675. * Are anisotropic textures enabled in the application.
  100676. */
  100677. static get AnisotropicTextureEnabled(): boolean;
  100678. static set AnisotropicTextureEnabled(value: boolean);
  100679. private static _ThicknessTextureEnabled;
  100680. /**
  100681. * Are thickness textures enabled in the application.
  100682. */
  100683. static get ThicknessTextureEnabled(): boolean;
  100684. static set ThicknessTextureEnabled(value: boolean);
  100685. }
  100686. }
  100687. declare module BABYLON {
  100688. /** @hidden */
  100689. export var defaultFragmentDeclaration: {
  100690. name: string;
  100691. shader: string;
  100692. };
  100693. }
  100694. declare module BABYLON {
  100695. /** @hidden */
  100696. export var defaultUboDeclaration: {
  100697. name: string;
  100698. shader: string;
  100699. };
  100700. }
  100701. declare module BABYLON {
  100702. /** @hidden */
  100703. export var lightFragmentDeclaration: {
  100704. name: string;
  100705. shader: string;
  100706. };
  100707. }
  100708. declare module BABYLON {
  100709. /** @hidden */
  100710. export var lightUboDeclaration: {
  100711. name: string;
  100712. shader: string;
  100713. };
  100714. }
  100715. declare module BABYLON {
  100716. /** @hidden */
  100717. export var lightsFragmentFunctions: {
  100718. name: string;
  100719. shader: string;
  100720. };
  100721. }
  100722. declare module BABYLON {
  100723. /** @hidden */
  100724. export var shadowsFragmentFunctions: {
  100725. name: string;
  100726. shader: string;
  100727. };
  100728. }
  100729. declare module BABYLON {
  100730. /** @hidden */
  100731. export var fresnelFunction: {
  100732. name: string;
  100733. shader: string;
  100734. };
  100735. }
  100736. declare module BABYLON {
  100737. /** @hidden */
  100738. export var reflectionFunction: {
  100739. name: string;
  100740. shader: string;
  100741. };
  100742. }
  100743. declare module BABYLON {
  100744. /** @hidden */
  100745. export var bumpFragmentFunctions: {
  100746. name: string;
  100747. shader: string;
  100748. };
  100749. }
  100750. declare module BABYLON {
  100751. /** @hidden */
  100752. export var logDepthDeclaration: {
  100753. name: string;
  100754. shader: string;
  100755. };
  100756. }
  100757. declare module BABYLON {
  100758. /** @hidden */
  100759. export var bumpFragment: {
  100760. name: string;
  100761. shader: string;
  100762. };
  100763. }
  100764. declare module BABYLON {
  100765. /** @hidden */
  100766. export var depthPrePass: {
  100767. name: string;
  100768. shader: string;
  100769. };
  100770. }
  100771. declare module BABYLON {
  100772. /** @hidden */
  100773. export var lightFragment: {
  100774. name: string;
  100775. shader: string;
  100776. };
  100777. }
  100778. declare module BABYLON {
  100779. /** @hidden */
  100780. export var logDepthFragment: {
  100781. name: string;
  100782. shader: string;
  100783. };
  100784. }
  100785. declare module BABYLON {
  100786. /** @hidden */
  100787. export var defaultPixelShader: {
  100788. name: string;
  100789. shader: string;
  100790. };
  100791. }
  100792. declare module BABYLON {
  100793. /** @hidden */
  100794. export var defaultVertexDeclaration: {
  100795. name: string;
  100796. shader: string;
  100797. };
  100798. }
  100799. declare module BABYLON {
  100800. /** @hidden */
  100801. export var bumpVertexDeclaration: {
  100802. name: string;
  100803. shader: string;
  100804. };
  100805. }
  100806. declare module BABYLON {
  100807. /** @hidden */
  100808. export var bumpVertex: {
  100809. name: string;
  100810. shader: string;
  100811. };
  100812. }
  100813. declare module BABYLON {
  100814. /** @hidden */
  100815. export var fogVertex: {
  100816. name: string;
  100817. shader: string;
  100818. };
  100819. }
  100820. declare module BABYLON {
  100821. /** @hidden */
  100822. export var shadowsVertex: {
  100823. name: string;
  100824. shader: string;
  100825. };
  100826. }
  100827. declare module BABYLON {
  100828. /** @hidden */
  100829. export var pointCloudVertex: {
  100830. name: string;
  100831. shader: string;
  100832. };
  100833. }
  100834. declare module BABYLON {
  100835. /** @hidden */
  100836. export var logDepthVertex: {
  100837. name: string;
  100838. shader: string;
  100839. };
  100840. }
  100841. declare module BABYLON {
  100842. /** @hidden */
  100843. export var defaultVertexShader: {
  100844. name: string;
  100845. shader: string;
  100846. };
  100847. }
  100848. declare module BABYLON {
  100849. /** @hidden */
  100850. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100851. MAINUV1: boolean;
  100852. MAINUV2: boolean;
  100853. DIFFUSE: boolean;
  100854. DIFFUSEDIRECTUV: number;
  100855. AMBIENT: boolean;
  100856. AMBIENTDIRECTUV: number;
  100857. OPACITY: boolean;
  100858. OPACITYDIRECTUV: number;
  100859. OPACITYRGB: boolean;
  100860. REFLECTION: boolean;
  100861. EMISSIVE: boolean;
  100862. EMISSIVEDIRECTUV: number;
  100863. SPECULAR: boolean;
  100864. SPECULARDIRECTUV: number;
  100865. BUMP: boolean;
  100866. BUMPDIRECTUV: number;
  100867. PARALLAX: boolean;
  100868. PARALLAXOCCLUSION: boolean;
  100869. SPECULAROVERALPHA: boolean;
  100870. CLIPPLANE: boolean;
  100871. CLIPPLANE2: boolean;
  100872. CLIPPLANE3: boolean;
  100873. CLIPPLANE4: boolean;
  100874. CLIPPLANE5: boolean;
  100875. CLIPPLANE6: boolean;
  100876. ALPHATEST: boolean;
  100877. DEPTHPREPASS: boolean;
  100878. ALPHAFROMDIFFUSE: boolean;
  100879. POINTSIZE: boolean;
  100880. FOG: boolean;
  100881. SPECULARTERM: boolean;
  100882. DIFFUSEFRESNEL: boolean;
  100883. OPACITYFRESNEL: boolean;
  100884. REFLECTIONFRESNEL: boolean;
  100885. REFRACTIONFRESNEL: boolean;
  100886. EMISSIVEFRESNEL: boolean;
  100887. FRESNEL: boolean;
  100888. NORMAL: boolean;
  100889. UV1: boolean;
  100890. UV2: boolean;
  100891. VERTEXCOLOR: boolean;
  100892. VERTEXALPHA: boolean;
  100893. NUM_BONE_INFLUENCERS: number;
  100894. BonesPerMesh: number;
  100895. BONETEXTURE: boolean;
  100896. INSTANCES: boolean;
  100897. GLOSSINESS: boolean;
  100898. ROUGHNESS: boolean;
  100899. EMISSIVEASILLUMINATION: boolean;
  100900. LINKEMISSIVEWITHDIFFUSE: boolean;
  100901. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100902. LIGHTMAP: boolean;
  100903. LIGHTMAPDIRECTUV: number;
  100904. OBJECTSPACE_NORMALMAP: boolean;
  100905. USELIGHTMAPASSHADOWMAP: boolean;
  100906. REFLECTIONMAP_3D: boolean;
  100907. REFLECTIONMAP_SPHERICAL: boolean;
  100908. REFLECTIONMAP_PLANAR: boolean;
  100909. REFLECTIONMAP_CUBIC: boolean;
  100910. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100911. REFLECTIONMAP_PROJECTION: boolean;
  100912. REFLECTIONMAP_SKYBOX: boolean;
  100913. REFLECTIONMAP_EXPLICIT: boolean;
  100914. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100915. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100916. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100917. INVERTCUBICMAP: boolean;
  100918. LOGARITHMICDEPTH: boolean;
  100919. REFRACTION: boolean;
  100920. REFRACTIONMAP_3D: boolean;
  100921. REFLECTIONOVERALPHA: boolean;
  100922. TWOSIDEDLIGHTING: boolean;
  100923. SHADOWFLOAT: boolean;
  100924. MORPHTARGETS: boolean;
  100925. MORPHTARGETS_NORMAL: boolean;
  100926. MORPHTARGETS_TANGENT: boolean;
  100927. MORPHTARGETS_UV: boolean;
  100928. NUM_MORPH_INFLUENCERS: number;
  100929. NONUNIFORMSCALING: boolean;
  100930. PREMULTIPLYALPHA: boolean;
  100931. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100932. ALPHABLEND: boolean;
  100933. IMAGEPROCESSING: boolean;
  100934. VIGNETTE: boolean;
  100935. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100936. VIGNETTEBLENDMODEOPAQUE: boolean;
  100937. TONEMAPPING: boolean;
  100938. TONEMAPPING_ACES: boolean;
  100939. CONTRAST: boolean;
  100940. COLORCURVES: boolean;
  100941. COLORGRADING: boolean;
  100942. COLORGRADING3D: boolean;
  100943. SAMPLER3DGREENDEPTH: boolean;
  100944. SAMPLER3DBGRMAP: boolean;
  100945. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100946. MULTIVIEW: boolean;
  100947. /**
  100948. * If the reflection texture on this material is in linear color space
  100949. * @hidden
  100950. */
  100951. IS_REFLECTION_LINEAR: boolean;
  100952. /**
  100953. * If the refraction texture on this material is in linear color space
  100954. * @hidden
  100955. */
  100956. IS_REFRACTION_LINEAR: boolean;
  100957. EXPOSURE: boolean;
  100958. constructor();
  100959. setReflectionMode(modeToEnable: string): void;
  100960. }
  100961. /**
  100962. * This is the default material used in Babylon. It is the best trade off between quality
  100963. * and performances.
  100964. * @see http://doc.babylonjs.com/babylon101/materials
  100965. */
  100966. export class StandardMaterial extends PushMaterial {
  100967. private _diffuseTexture;
  100968. /**
  100969. * The basic texture of the material as viewed under a light.
  100970. */
  100971. diffuseTexture: Nullable<BaseTexture>;
  100972. private _ambientTexture;
  100973. /**
  100974. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100975. */
  100976. ambientTexture: Nullable<BaseTexture>;
  100977. private _opacityTexture;
  100978. /**
  100979. * Define the transparency of the material from a texture.
  100980. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100981. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100982. */
  100983. opacityTexture: Nullable<BaseTexture>;
  100984. private _reflectionTexture;
  100985. /**
  100986. * Define the texture used to display the reflection.
  100987. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100988. */
  100989. reflectionTexture: Nullable<BaseTexture>;
  100990. private _emissiveTexture;
  100991. /**
  100992. * Define texture of the material as if self lit.
  100993. * This will be mixed in the final result even in the absence of light.
  100994. */
  100995. emissiveTexture: Nullable<BaseTexture>;
  100996. private _specularTexture;
  100997. /**
  100998. * Define how the color and intensity of the highlight given by the light in the material.
  100999. */
  101000. specularTexture: Nullable<BaseTexture>;
  101001. private _bumpTexture;
  101002. /**
  101003. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101004. * 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.
  101005. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101006. */
  101007. bumpTexture: Nullable<BaseTexture>;
  101008. private _lightmapTexture;
  101009. /**
  101010. * Complex lighting can be computationally expensive to compute at runtime.
  101011. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101012. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101013. */
  101014. lightmapTexture: Nullable<BaseTexture>;
  101015. private _refractionTexture;
  101016. /**
  101017. * Define the texture used to display the refraction.
  101018. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101019. */
  101020. refractionTexture: Nullable<BaseTexture>;
  101021. /**
  101022. * The color of the material lit by the environmental background lighting.
  101023. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101024. */
  101025. ambientColor: Color3;
  101026. /**
  101027. * The basic color of the material as viewed under a light.
  101028. */
  101029. diffuseColor: Color3;
  101030. /**
  101031. * Define how the color and intensity of the highlight given by the light in the material.
  101032. */
  101033. specularColor: Color3;
  101034. /**
  101035. * Define the color of the material as if self lit.
  101036. * This will be mixed in the final result even in the absence of light.
  101037. */
  101038. emissiveColor: Color3;
  101039. /**
  101040. * Defines how sharp are the highlights in the material.
  101041. * The bigger the value the sharper giving a more glossy feeling to the result.
  101042. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101043. */
  101044. specularPower: number;
  101045. private _useAlphaFromDiffuseTexture;
  101046. /**
  101047. * Does the transparency come from the diffuse texture alpha channel.
  101048. */
  101049. useAlphaFromDiffuseTexture: boolean;
  101050. private _useEmissiveAsIllumination;
  101051. /**
  101052. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101053. */
  101054. useEmissiveAsIllumination: boolean;
  101055. private _linkEmissiveWithDiffuse;
  101056. /**
  101057. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101058. * the emissive level when the final color is close to one.
  101059. */
  101060. linkEmissiveWithDiffuse: boolean;
  101061. private _useSpecularOverAlpha;
  101062. /**
  101063. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101064. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101065. */
  101066. useSpecularOverAlpha: boolean;
  101067. private _useReflectionOverAlpha;
  101068. /**
  101069. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101070. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101071. */
  101072. useReflectionOverAlpha: boolean;
  101073. private _disableLighting;
  101074. /**
  101075. * Does lights from the scene impacts this material.
  101076. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101077. */
  101078. disableLighting: boolean;
  101079. private _useObjectSpaceNormalMap;
  101080. /**
  101081. * Allows using an object space normal map (instead of tangent space).
  101082. */
  101083. useObjectSpaceNormalMap: boolean;
  101084. private _useParallax;
  101085. /**
  101086. * Is parallax enabled or not.
  101087. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101088. */
  101089. useParallax: boolean;
  101090. private _useParallaxOcclusion;
  101091. /**
  101092. * Is parallax occlusion enabled or not.
  101093. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101094. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101095. */
  101096. useParallaxOcclusion: boolean;
  101097. /**
  101098. * 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.
  101099. */
  101100. parallaxScaleBias: number;
  101101. private _roughness;
  101102. /**
  101103. * Helps to define how blurry the reflections should appears in the material.
  101104. */
  101105. roughness: number;
  101106. /**
  101107. * In case of refraction, define the value of the index of refraction.
  101108. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101109. */
  101110. indexOfRefraction: number;
  101111. /**
  101112. * Invert the refraction texture alongside the y axis.
  101113. * It can be useful with procedural textures or probe for instance.
  101114. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101115. */
  101116. invertRefractionY: boolean;
  101117. /**
  101118. * Defines the alpha limits in alpha test mode.
  101119. */
  101120. alphaCutOff: number;
  101121. private _useLightmapAsShadowmap;
  101122. /**
  101123. * In case of light mapping, define whether the map contains light or shadow informations.
  101124. */
  101125. useLightmapAsShadowmap: boolean;
  101126. private _diffuseFresnelParameters;
  101127. /**
  101128. * Define the diffuse fresnel parameters of the material.
  101129. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101130. */
  101131. diffuseFresnelParameters: FresnelParameters;
  101132. private _opacityFresnelParameters;
  101133. /**
  101134. * Define the opacity fresnel parameters of the material.
  101135. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101136. */
  101137. opacityFresnelParameters: FresnelParameters;
  101138. private _reflectionFresnelParameters;
  101139. /**
  101140. * Define the reflection fresnel parameters of the material.
  101141. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101142. */
  101143. reflectionFresnelParameters: FresnelParameters;
  101144. private _refractionFresnelParameters;
  101145. /**
  101146. * Define the refraction fresnel parameters of the material.
  101147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101148. */
  101149. refractionFresnelParameters: FresnelParameters;
  101150. private _emissiveFresnelParameters;
  101151. /**
  101152. * Define the emissive fresnel parameters of the material.
  101153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101154. */
  101155. emissiveFresnelParameters: FresnelParameters;
  101156. private _useReflectionFresnelFromSpecular;
  101157. /**
  101158. * If true automatically deducts the fresnels values from the material specularity.
  101159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101160. */
  101161. useReflectionFresnelFromSpecular: boolean;
  101162. private _useGlossinessFromSpecularMapAlpha;
  101163. /**
  101164. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101165. */
  101166. useGlossinessFromSpecularMapAlpha: boolean;
  101167. private _maxSimultaneousLights;
  101168. /**
  101169. * Defines the maximum number of lights that can be used in the material
  101170. */
  101171. maxSimultaneousLights: number;
  101172. private _invertNormalMapX;
  101173. /**
  101174. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101175. */
  101176. invertNormalMapX: boolean;
  101177. private _invertNormalMapY;
  101178. /**
  101179. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101180. */
  101181. invertNormalMapY: boolean;
  101182. private _twoSidedLighting;
  101183. /**
  101184. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101185. */
  101186. twoSidedLighting: boolean;
  101187. /**
  101188. * Default configuration related to image processing available in the standard Material.
  101189. */
  101190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101191. /**
  101192. * Gets the image processing configuration used either in this material.
  101193. */
  101194. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101195. /**
  101196. * Sets the Default image processing configuration used either in the this material.
  101197. *
  101198. * If sets to null, the scene one is in use.
  101199. */
  101200. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101201. /**
  101202. * Keep track of the image processing observer to allow dispose and replace.
  101203. */
  101204. private _imageProcessingObserver;
  101205. /**
  101206. * Attaches a new image processing configuration to the Standard Material.
  101207. * @param configuration
  101208. */
  101209. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101210. /**
  101211. * Gets wether the color curves effect is enabled.
  101212. */
  101213. get cameraColorCurvesEnabled(): boolean;
  101214. /**
  101215. * Sets wether the color curves effect is enabled.
  101216. */
  101217. set cameraColorCurvesEnabled(value: boolean);
  101218. /**
  101219. * Gets wether the color grading effect is enabled.
  101220. */
  101221. get cameraColorGradingEnabled(): boolean;
  101222. /**
  101223. * Gets wether the color grading effect is enabled.
  101224. */
  101225. set cameraColorGradingEnabled(value: boolean);
  101226. /**
  101227. * Gets wether tonemapping is enabled or not.
  101228. */
  101229. get cameraToneMappingEnabled(): boolean;
  101230. /**
  101231. * Sets wether tonemapping is enabled or not
  101232. */
  101233. set cameraToneMappingEnabled(value: boolean);
  101234. /**
  101235. * The camera exposure used on this material.
  101236. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101237. * This corresponds to a photographic exposure.
  101238. */
  101239. get cameraExposure(): number;
  101240. /**
  101241. * The camera exposure used on this material.
  101242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101243. * This corresponds to a photographic exposure.
  101244. */
  101245. set cameraExposure(value: number);
  101246. /**
  101247. * Gets The camera contrast used on this material.
  101248. */
  101249. get cameraContrast(): number;
  101250. /**
  101251. * Sets The camera contrast used on this material.
  101252. */
  101253. set cameraContrast(value: number);
  101254. /**
  101255. * Gets the Color Grading 2D Lookup Texture.
  101256. */
  101257. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101258. /**
  101259. * Sets the Color Grading 2D Lookup Texture.
  101260. */
  101261. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101262. /**
  101263. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101264. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101265. * 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;
  101266. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101267. */
  101268. get cameraColorCurves(): Nullable<ColorCurves>;
  101269. /**
  101270. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101271. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101272. * 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;
  101273. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101274. */
  101275. set cameraColorCurves(value: Nullable<ColorCurves>);
  101276. /**
  101277. * Custom callback helping to override the default shader used in the material.
  101278. */
  101279. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101280. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101281. protected _worldViewProjectionMatrix: Matrix;
  101282. protected _globalAmbientColor: Color3;
  101283. protected _useLogarithmicDepth: boolean;
  101284. protected _rebuildInParallel: boolean;
  101285. /**
  101286. * Instantiates a new standard material.
  101287. * This is the default material used in Babylon. It is the best trade off between quality
  101288. * and performances.
  101289. * @see http://doc.babylonjs.com/babylon101/materials
  101290. * @param name Define the name of the material in the scene
  101291. * @param scene Define the scene the material belong to
  101292. */
  101293. constructor(name: string, scene: Scene);
  101294. /**
  101295. * Gets a boolean indicating that current material needs to register RTT
  101296. */
  101297. get hasRenderTargetTextures(): boolean;
  101298. /**
  101299. * Gets the current class name of the material e.g. "StandardMaterial"
  101300. * Mainly use in serialization.
  101301. * @returns the class name
  101302. */
  101303. getClassName(): string;
  101304. /**
  101305. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101306. * You can try switching to logarithmic depth.
  101307. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101308. */
  101309. get useLogarithmicDepth(): boolean;
  101310. set useLogarithmicDepth(value: boolean);
  101311. /**
  101312. * Specifies if the material will require alpha blending
  101313. * @returns a boolean specifying if alpha blending is needed
  101314. */
  101315. needAlphaBlending(): boolean;
  101316. /**
  101317. * Specifies if this material should be rendered in alpha test mode
  101318. * @returns a boolean specifying if an alpha test is needed.
  101319. */
  101320. needAlphaTesting(): boolean;
  101321. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101322. /**
  101323. * Get the texture used for alpha test purpose.
  101324. * @returns the diffuse texture in case of the standard material.
  101325. */
  101326. getAlphaTestTexture(): Nullable<BaseTexture>;
  101327. /**
  101328. * Get if the submesh is ready to be used and all its information available.
  101329. * Child classes can use it to update shaders
  101330. * @param mesh defines the mesh to check
  101331. * @param subMesh defines which submesh to check
  101332. * @param useInstances specifies that instances should be used
  101333. * @returns a boolean indicating that the submesh is ready or not
  101334. */
  101335. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101336. /**
  101337. * Builds the material UBO layouts.
  101338. * Used internally during the effect preparation.
  101339. */
  101340. buildUniformLayout(): void;
  101341. /**
  101342. * Unbinds the material from the mesh
  101343. */
  101344. unbind(): void;
  101345. /**
  101346. * Binds the submesh to this material by preparing the effect and shader to draw
  101347. * @param world defines the world transformation matrix
  101348. * @param mesh defines the mesh containing the submesh
  101349. * @param subMesh defines the submesh to bind the material to
  101350. */
  101351. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101352. /**
  101353. * Get the list of animatables in the material.
  101354. * @returns the list of animatables object used in the material
  101355. */
  101356. getAnimatables(): IAnimatable[];
  101357. /**
  101358. * Gets the active textures from the material
  101359. * @returns an array of textures
  101360. */
  101361. getActiveTextures(): BaseTexture[];
  101362. /**
  101363. * Specifies if the material uses a texture
  101364. * @param texture defines the texture to check against the material
  101365. * @returns a boolean specifying if the material uses the texture
  101366. */
  101367. hasTexture(texture: BaseTexture): boolean;
  101368. /**
  101369. * Disposes the material
  101370. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101371. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101372. */
  101373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101374. /**
  101375. * Makes a duplicate of the material, and gives it a new name
  101376. * @param name defines the new name for the duplicated material
  101377. * @returns the cloned material
  101378. */
  101379. clone(name: string): StandardMaterial;
  101380. /**
  101381. * Serializes this material in a JSON representation
  101382. * @returns the serialized material object
  101383. */
  101384. serialize(): any;
  101385. /**
  101386. * Creates a standard material from parsed material data
  101387. * @param source defines the JSON representation of the material
  101388. * @param scene defines the hosting scene
  101389. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101390. * @returns a new standard material
  101391. */
  101392. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101393. /**
  101394. * Are diffuse textures enabled in the application.
  101395. */
  101396. static get DiffuseTextureEnabled(): boolean;
  101397. static set DiffuseTextureEnabled(value: boolean);
  101398. /**
  101399. * Are ambient textures enabled in the application.
  101400. */
  101401. static get AmbientTextureEnabled(): boolean;
  101402. static set AmbientTextureEnabled(value: boolean);
  101403. /**
  101404. * Are opacity textures enabled in the application.
  101405. */
  101406. static get OpacityTextureEnabled(): boolean;
  101407. static set OpacityTextureEnabled(value: boolean);
  101408. /**
  101409. * Are reflection textures enabled in the application.
  101410. */
  101411. static get ReflectionTextureEnabled(): boolean;
  101412. static set ReflectionTextureEnabled(value: boolean);
  101413. /**
  101414. * Are emissive textures enabled in the application.
  101415. */
  101416. static get EmissiveTextureEnabled(): boolean;
  101417. static set EmissiveTextureEnabled(value: boolean);
  101418. /**
  101419. * Are specular textures enabled in the application.
  101420. */
  101421. static get SpecularTextureEnabled(): boolean;
  101422. static set SpecularTextureEnabled(value: boolean);
  101423. /**
  101424. * Are bump textures enabled in the application.
  101425. */
  101426. static get BumpTextureEnabled(): boolean;
  101427. static set BumpTextureEnabled(value: boolean);
  101428. /**
  101429. * Are lightmap textures enabled in the application.
  101430. */
  101431. static get LightmapTextureEnabled(): boolean;
  101432. static set LightmapTextureEnabled(value: boolean);
  101433. /**
  101434. * Are refraction textures enabled in the application.
  101435. */
  101436. static get RefractionTextureEnabled(): boolean;
  101437. static set RefractionTextureEnabled(value: boolean);
  101438. /**
  101439. * Are color grading textures enabled in the application.
  101440. */
  101441. static get ColorGradingTextureEnabled(): boolean;
  101442. static set ColorGradingTextureEnabled(value: boolean);
  101443. /**
  101444. * Are fresnels enabled in the application.
  101445. */
  101446. static get FresnelEnabled(): boolean;
  101447. static set FresnelEnabled(value: boolean);
  101448. }
  101449. }
  101450. declare module BABYLON {
  101451. /**
  101452. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101453. *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.
  101454. * The SPS is also a particle system. It provides some methods to manage the particles.
  101455. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101456. *
  101457. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101458. */
  101459. export class SolidParticleSystem implements IDisposable {
  101460. /**
  101461. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101462. * Example : var p = SPS.particles[i];
  101463. */
  101464. particles: SolidParticle[];
  101465. /**
  101466. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101467. */
  101468. nbParticles: number;
  101469. /**
  101470. * If the particles must ever face the camera (default false). Useful for planar particles.
  101471. */
  101472. billboard: boolean;
  101473. /**
  101474. * Recompute normals when adding a shape
  101475. */
  101476. recomputeNormals: boolean;
  101477. /**
  101478. * This a counter ofr your own usage. It's not set by any SPS functions.
  101479. */
  101480. counter: number;
  101481. /**
  101482. * The SPS name. This name is also given to the underlying mesh.
  101483. */
  101484. name: string;
  101485. /**
  101486. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101487. */
  101488. mesh: Mesh;
  101489. /**
  101490. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101491. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101492. */
  101493. vars: any;
  101494. /**
  101495. * This array is populated when the SPS is set as 'pickable'.
  101496. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101497. * Each element of this array is an object `{idx: int, faceId: int}`.
  101498. * `idx` is the picked particle index in the `SPS.particles` array
  101499. * `faceId` is the picked face index counted within this particle.
  101500. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101501. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101502. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101503. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101504. */
  101505. pickedParticles: {
  101506. idx: number;
  101507. faceId: number;
  101508. }[];
  101509. /**
  101510. * This array is populated when the SPS is set as 'pickable'
  101511. * Each key of this array is a submesh index.
  101512. * Each element of this array is a second array defined like this :
  101513. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101514. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101515. * `idx` is the picked particle index in the `SPS.particles` array
  101516. * `faceId` is the picked face index counted within this particle.
  101517. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101518. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101519. */
  101520. pickedBySubMesh: {
  101521. idx: number;
  101522. faceId: number;
  101523. }[][];
  101524. /**
  101525. * This array is populated when `enableDepthSort` is set to true.
  101526. * Each element of this array is an instance of the class DepthSortedParticle.
  101527. */
  101528. depthSortedParticles: DepthSortedParticle[];
  101529. /**
  101530. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101531. * @hidden
  101532. */
  101533. _bSphereOnly: boolean;
  101534. /**
  101535. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101536. * @hidden
  101537. */
  101538. _bSphereRadiusFactor: number;
  101539. private _scene;
  101540. private _positions;
  101541. private _indices;
  101542. private _normals;
  101543. private _colors;
  101544. private _uvs;
  101545. private _indices32;
  101546. private _positions32;
  101547. private _normals32;
  101548. private _fixedNormal32;
  101549. private _colors32;
  101550. private _uvs32;
  101551. private _index;
  101552. private _updatable;
  101553. private _pickable;
  101554. private _isVisibilityBoxLocked;
  101555. private _alwaysVisible;
  101556. private _depthSort;
  101557. private _expandable;
  101558. private _shapeCounter;
  101559. private _copy;
  101560. private _color;
  101561. private _computeParticleColor;
  101562. private _computeParticleTexture;
  101563. private _computeParticleRotation;
  101564. private _computeParticleVertex;
  101565. private _computeBoundingBox;
  101566. private _depthSortParticles;
  101567. private _camera;
  101568. private _mustUnrotateFixedNormals;
  101569. private _particlesIntersect;
  101570. private _needs32Bits;
  101571. private _isNotBuilt;
  101572. private _lastParticleId;
  101573. private _idxOfId;
  101574. private _multimaterialEnabled;
  101575. private _useModelMaterial;
  101576. private _indicesByMaterial;
  101577. private _materialIndexes;
  101578. private _depthSortFunction;
  101579. private _materialSortFunction;
  101580. private _materials;
  101581. private _multimaterial;
  101582. private _materialIndexesById;
  101583. private _defaultMaterial;
  101584. private _autoUpdateSubMeshes;
  101585. /**
  101586. * Creates a SPS (Solid Particle System) object.
  101587. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101588. * @param scene (Scene) is the scene in which the SPS is added.
  101589. * @param options defines the options of the sps e.g.
  101590. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101591. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101592. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101593. * * 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.
  101594. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101595. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101596. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101597. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101598. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101599. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101600. */
  101601. constructor(name: string, scene: Scene, options?: {
  101602. updatable?: boolean;
  101603. isPickable?: boolean;
  101604. enableDepthSort?: boolean;
  101605. particleIntersection?: boolean;
  101606. boundingSphereOnly?: boolean;
  101607. bSphereRadiusFactor?: number;
  101608. expandable?: boolean;
  101609. useModelMaterial?: boolean;
  101610. enableMultiMaterial?: boolean;
  101611. });
  101612. /**
  101613. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101614. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101615. * @returns the created mesh
  101616. */
  101617. buildMesh(): Mesh;
  101618. /**
  101619. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101620. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101621. * Thus the particles generated from `digest()` have their property `position` set yet.
  101622. * @param mesh ( Mesh ) is the mesh to be digested
  101623. * @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
  101624. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101625. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101626. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101627. * @returns the current SPS
  101628. */
  101629. digest(mesh: Mesh, options?: {
  101630. facetNb?: number;
  101631. number?: number;
  101632. delta?: number;
  101633. storage?: [];
  101634. }): SolidParticleSystem;
  101635. /**
  101636. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101637. * @hidden
  101638. */
  101639. private _unrotateFixedNormals;
  101640. /**
  101641. * Resets the temporary working copy particle
  101642. * @hidden
  101643. */
  101644. private _resetCopy;
  101645. /**
  101646. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101647. * @param p the current index in the positions array to be updated
  101648. * @param ind the current index in the indices array
  101649. * @param shape a Vector3 array, the shape geometry
  101650. * @param positions the positions array to be updated
  101651. * @param meshInd the shape indices array
  101652. * @param indices the indices array to be updated
  101653. * @param meshUV the shape uv array
  101654. * @param uvs the uv array to be updated
  101655. * @param meshCol the shape color array
  101656. * @param colors the color array to be updated
  101657. * @param meshNor the shape normals array
  101658. * @param normals the normals array to be updated
  101659. * @param idx the particle index
  101660. * @param idxInShape the particle index in its shape
  101661. * @param options the addShape() method passed options
  101662. * @model the particle model
  101663. * @hidden
  101664. */
  101665. private _meshBuilder;
  101666. /**
  101667. * Returns a shape Vector3 array from positions float array
  101668. * @param positions float array
  101669. * @returns a vector3 array
  101670. * @hidden
  101671. */
  101672. private _posToShape;
  101673. /**
  101674. * Returns a shapeUV array from a float uvs (array deep copy)
  101675. * @param uvs as a float array
  101676. * @returns a shapeUV array
  101677. * @hidden
  101678. */
  101679. private _uvsToShapeUV;
  101680. /**
  101681. * Adds a new particle object in the particles array
  101682. * @param idx particle index in particles array
  101683. * @param id particle id
  101684. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101685. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101686. * @param model particle ModelShape object
  101687. * @param shapeId model shape identifier
  101688. * @param idxInShape index of the particle in the current model
  101689. * @param bInfo model bounding info object
  101690. * @param storage target storage array, if any
  101691. * @hidden
  101692. */
  101693. private _addParticle;
  101694. /**
  101695. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101696. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101697. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101698. * @param nb (positive integer) the number of particles to be created from this model
  101699. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101700. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101701. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101702. * @returns the number of shapes in the system
  101703. */
  101704. addShape(mesh: Mesh, nb: number, options?: {
  101705. positionFunction?: any;
  101706. vertexFunction?: any;
  101707. storage?: [];
  101708. }): number;
  101709. /**
  101710. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101711. * @hidden
  101712. */
  101713. private _rebuildParticle;
  101714. /**
  101715. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101716. * @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.
  101717. * @returns the SPS.
  101718. */
  101719. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101720. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101721. * Returns an array with the removed particles.
  101722. * 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.
  101723. * The SPS can't be empty so at least one particle needs to remain in place.
  101724. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101725. * @param start index of the first particle to remove
  101726. * @param end index of the last particle to remove (included)
  101727. * @returns an array populated with the removed particles
  101728. */
  101729. removeParticles(start: number, end: number): SolidParticle[];
  101730. /**
  101731. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101732. * @param solidParticleArray an array populated with Solid Particles objects
  101733. * @returns the SPS
  101734. */
  101735. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101736. /**
  101737. * Creates a new particle and modifies the SPS mesh geometry :
  101738. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101739. * - calls _addParticle() to populate the particle array
  101740. * factorized code from addShape() and insertParticlesFromArray()
  101741. * @param idx particle index in the particles array
  101742. * @param i particle index in its shape
  101743. * @param modelShape particle ModelShape object
  101744. * @param shape shape vertex array
  101745. * @param meshInd shape indices array
  101746. * @param meshUV shape uv array
  101747. * @param meshCol shape color array
  101748. * @param meshNor shape normals array
  101749. * @param bbInfo shape bounding info
  101750. * @param storage target particle storage
  101751. * @options addShape() passed options
  101752. * @hidden
  101753. */
  101754. private _insertNewParticle;
  101755. /**
  101756. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101757. * This method calls `updateParticle()` for each particle of the SPS.
  101758. * For an animated SPS, it is usually called within the render loop.
  101759. * 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.
  101760. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101761. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101762. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101763. * @returns the SPS.
  101764. */
  101765. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101766. /**
  101767. * Disposes the SPS.
  101768. */
  101769. dispose(): void;
  101770. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101771. * idx is the particle index in the SPS
  101772. * faceId is the picked face index counted within this particle.
  101773. * Returns null if the pickInfo can't identify a picked particle.
  101774. * @param pickingInfo (PickingInfo object)
  101775. * @returns {idx: number, faceId: number} or null
  101776. */
  101777. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101778. idx: number;
  101779. faceId: number;
  101780. }>;
  101781. /**
  101782. * Returns a SolidParticle object from its identifier : particle.id
  101783. * @param id (integer) the particle Id
  101784. * @returns the searched particle or null if not found in the SPS.
  101785. */
  101786. getParticleById(id: number): Nullable<SolidParticle>;
  101787. /**
  101788. * Returns a new array populated with the particles having the passed shapeId.
  101789. * @param shapeId (integer) the shape identifier
  101790. * @returns a new solid particle array
  101791. */
  101792. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101793. /**
  101794. * Populates the passed array "ref" with the particles having the passed shapeId.
  101795. * @param shapeId the shape identifier
  101796. * @returns the SPS
  101797. * @param ref
  101798. */
  101799. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101800. /**
  101801. * Computes the required SubMeshes according the materials assigned to the particles.
  101802. * @returns the solid particle system.
  101803. * Does nothing if called before the SPS mesh is built.
  101804. */
  101805. computeSubMeshes(): SolidParticleSystem;
  101806. /**
  101807. * Sorts the solid particles by material when MultiMaterial is enabled.
  101808. * Updates the indices32 array.
  101809. * Updates the indicesByMaterial array.
  101810. * Updates the mesh indices array.
  101811. * @returns the SPS
  101812. * @hidden
  101813. */
  101814. private _sortParticlesByMaterial;
  101815. /**
  101816. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101817. * @hidden
  101818. */
  101819. private _setMaterialIndexesById;
  101820. /**
  101821. * Returns an array with unique values of Materials from the passed array
  101822. * @param array the material array to be checked and filtered
  101823. * @hidden
  101824. */
  101825. private _filterUniqueMaterialId;
  101826. /**
  101827. * Sets a new Standard Material as _defaultMaterial if not already set.
  101828. * @hidden
  101829. */
  101830. private _setDefaultMaterial;
  101831. /**
  101832. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101833. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101834. * @returns the SPS.
  101835. */
  101836. refreshVisibleSize(): SolidParticleSystem;
  101837. /**
  101838. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101839. * @param size the size (float) of the visibility box
  101840. * note : this doesn't lock the SPS mesh bounding box.
  101841. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101842. */
  101843. setVisibilityBox(size: number): void;
  101844. /**
  101845. * Gets whether the SPS as always visible or not
  101846. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101847. */
  101848. get isAlwaysVisible(): boolean;
  101849. /**
  101850. * Sets the SPS as always visible or not
  101851. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101852. */
  101853. set isAlwaysVisible(val: boolean);
  101854. /**
  101855. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101856. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101857. */
  101858. set isVisibilityBoxLocked(val: boolean);
  101859. /**
  101860. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101861. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101862. */
  101863. get isVisibilityBoxLocked(): boolean;
  101864. /**
  101865. * Tells to `setParticles()` to compute the particle rotations or not.
  101866. * Default value : true. The SPS is faster when it's set to false.
  101867. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101868. */
  101869. set computeParticleRotation(val: boolean);
  101870. /**
  101871. * Tells to `setParticles()` to compute the particle colors or not.
  101872. * Default value : true. The SPS is faster when it's set to false.
  101873. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101874. */
  101875. set computeParticleColor(val: boolean);
  101876. set computeParticleTexture(val: boolean);
  101877. /**
  101878. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101879. * Default value : false. The SPS is faster when it's set to false.
  101880. * Note : the particle custom vertex positions aren't stored values.
  101881. */
  101882. set computeParticleVertex(val: boolean);
  101883. /**
  101884. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101885. */
  101886. set computeBoundingBox(val: boolean);
  101887. /**
  101888. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101889. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101890. * Default : `true`
  101891. */
  101892. set depthSortParticles(val: boolean);
  101893. /**
  101894. * Gets if `setParticles()` computes the particle rotations or not.
  101895. * Default value : true. The SPS is faster when it's set to false.
  101896. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101897. */
  101898. get computeParticleRotation(): boolean;
  101899. /**
  101900. * Gets if `setParticles()` computes the particle colors or not.
  101901. * Default value : true. The SPS is faster when it's set to false.
  101902. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101903. */
  101904. get computeParticleColor(): boolean;
  101905. /**
  101906. * Gets if `setParticles()` computes the particle textures or not.
  101907. * Default value : true. The SPS is faster when it's set to false.
  101908. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101909. */
  101910. get computeParticleTexture(): boolean;
  101911. /**
  101912. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101913. * Default value : false. The SPS is faster when it's set to false.
  101914. * Note : the particle custom vertex positions aren't stored values.
  101915. */
  101916. get computeParticleVertex(): boolean;
  101917. /**
  101918. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101919. */
  101920. get computeBoundingBox(): boolean;
  101921. /**
  101922. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101923. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101924. * Default : `true`
  101925. */
  101926. get depthSortParticles(): boolean;
  101927. /**
  101928. * Gets if the SPS is created as expandable at construction time.
  101929. * Default : `false`
  101930. */
  101931. get expandable(): boolean;
  101932. /**
  101933. * Gets if the SPS supports the Multi Materials
  101934. */
  101935. get multimaterialEnabled(): boolean;
  101936. /**
  101937. * Gets if the SPS uses the model materials for its own multimaterial.
  101938. */
  101939. get useModelMaterial(): boolean;
  101940. /**
  101941. * The SPS used material array.
  101942. */
  101943. get materials(): Material[];
  101944. /**
  101945. * Sets the SPS MultiMaterial from the passed materials.
  101946. * Note : the passed array is internally copied and not used then by reference.
  101947. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101948. */
  101949. setMultiMaterial(materials: Material[]): void;
  101950. /**
  101951. * The SPS computed multimaterial object
  101952. */
  101953. get multimaterial(): MultiMaterial;
  101954. set multimaterial(mm: MultiMaterial);
  101955. /**
  101956. * If the subMeshes must be updated on the next call to setParticles()
  101957. */
  101958. get autoUpdateSubMeshes(): boolean;
  101959. set autoUpdateSubMeshes(val: boolean);
  101960. /**
  101961. * This function does nothing. It may be overwritten to set all the particle first values.
  101962. * The SPS doesn't call this function, you may have to call it by your own.
  101963. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101964. */
  101965. initParticles(): void;
  101966. /**
  101967. * This function does nothing. It may be overwritten to recycle a particle.
  101968. * The SPS doesn't call this function, you may have to call it by your own.
  101969. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101970. * @param particle The particle to recycle
  101971. * @returns the recycled particle
  101972. */
  101973. recycleParticle(particle: SolidParticle): SolidParticle;
  101974. /**
  101975. * Updates a particle : this function should be overwritten by the user.
  101976. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101977. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101978. * @example : just set a particle position or velocity and recycle conditions
  101979. * @param particle The particle to update
  101980. * @returns the updated particle
  101981. */
  101982. updateParticle(particle: SolidParticle): SolidParticle;
  101983. /**
  101984. * Updates a vertex of a particle : it can be overwritten by the user.
  101985. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101986. * @param particle the current particle
  101987. * @param vertex the current index of the current particle
  101988. * @param pt the index of the current vertex in the particle shape
  101989. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101990. * @example : just set a vertex particle position
  101991. * @returns the updated vertex
  101992. */
  101993. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  101994. /**
  101995. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  101996. * This does nothing and may be overwritten by the user.
  101997. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101998. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101999. * @param update the boolean update value actually passed to setParticles()
  102000. */
  102001. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102002. /**
  102003. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102004. * This will be passed three parameters.
  102005. * This does nothing and may be overwritten by the user.
  102006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102008. * @param update the boolean update value actually passed to setParticles()
  102009. */
  102010. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102011. }
  102012. }
  102013. declare module BABYLON {
  102014. /**
  102015. * Represents one particle of a solid particle system.
  102016. */
  102017. export class SolidParticle {
  102018. /**
  102019. * particle global index
  102020. */
  102021. idx: number;
  102022. /**
  102023. * particle identifier
  102024. */
  102025. id: number;
  102026. /**
  102027. * The color of the particle
  102028. */
  102029. color: Nullable<Color4>;
  102030. /**
  102031. * The world space position of the particle.
  102032. */
  102033. position: Vector3;
  102034. /**
  102035. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102036. */
  102037. rotation: Vector3;
  102038. /**
  102039. * The world space rotation quaternion of the particle.
  102040. */
  102041. rotationQuaternion: Nullable<Quaternion>;
  102042. /**
  102043. * The scaling of the particle.
  102044. */
  102045. scaling: Vector3;
  102046. /**
  102047. * The uvs of the particle.
  102048. */
  102049. uvs: Vector4;
  102050. /**
  102051. * The current speed of the particle.
  102052. */
  102053. velocity: Vector3;
  102054. /**
  102055. * The pivot point in the particle local space.
  102056. */
  102057. pivot: Vector3;
  102058. /**
  102059. * Must the particle be translated from its pivot point in its local space ?
  102060. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102061. * Default : false
  102062. */
  102063. translateFromPivot: boolean;
  102064. /**
  102065. * Is the particle active or not ?
  102066. */
  102067. alive: boolean;
  102068. /**
  102069. * Is the particle visible or not ?
  102070. */
  102071. isVisible: boolean;
  102072. /**
  102073. * Index of this particle in the global "positions" array (Internal use)
  102074. * @hidden
  102075. */
  102076. _pos: number;
  102077. /**
  102078. * @hidden Index of this particle in the global "indices" array (Internal use)
  102079. */
  102080. _ind: number;
  102081. /**
  102082. * @hidden ModelShape of this particle (Internal use)
  102083. */
  102084. _model: ModelShape;
  102085. /**
  102086. * ModelShape id of this particle
  102087. */
  102088. shapeId: number;
  102089. /**
  102090. * Index of the particle in its shape id
  102091. */
  102092. idxInShape: number;
  102093. /**
  102094. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102095. */
  102096. _modelBoundingInfo: BoundingInfo;
  102097. /**
  102098. * @hidden Particle BoundingInfo object (Internal use)
  102099. */
  102100. _boundingInfo: BoundingInfo;
  102101. /**
  102102. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102103. */
  102104. _sps: SolidParticleSystem;
  102105. /**
  102106. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102107. */
  102108. _stillInvisible: boolean;
  102109. /**
  102110. * @hidden Last computed particle rotation matrix
  102111. */
  102112. _rotationMatrix: number[];
  102113. /**
  102114. * Parent particle Id, if any.
  102115. * Default null.
  102116. */
  102117. parentId: Nullable<number>;
  102118. /**
  102119. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102120. */
  102121. materialIndex: Nullable<number>;
  102122. /**
  102123. * Custom object or properties.
  102124. */
  102125. props: Nullable<any>;
  102126. /**
  102127. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102128. * The possible values are :
  102129. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102130. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102132. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102133. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102134. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102135. * */
  102136. cullingStrategy: number;
  102137. /**
  102138. * @hidden Internal global position in the SPS.
  102139. */
  102140. _globalPosition: Vector3;
  102141. /**
  102142. * Creates a Solid Particle object.
  102143. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102144. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102145. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102146. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102147. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102148. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102149. * @param shapeId (integer) is the model shape identifier in the SPS.
  102150. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102151. * @param sps defines the sps it is associated to
  102152. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102153. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102154. */
  102155. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102156. /**
  102157. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102158. * @param target the particle target
  102159. * @returns the current particle
  102160. */
  102161. copyToRef(target: SolidParticle): SolidParticle;
  102162. /**
  102163. * Legacy support, changed scale to scaling
  102164. */
  102165. get scale(): Vector3;
  102166. /**
  102167. * Legacy support, changed scale to scaling
  102168. */
  102169. set scale(scale: Vector3);
  102170. /**
  102171. * Legacy support, changed quaternion to rotationQuaternion
  102172. */
  102173. get quaternion(): Nullable<Quaternion>;
  102174. /**
  102175. * Legacy support, changed quaternion to rotationQuaternion
  102176. */
  102177. set quaternion(q: Nullable<Quaternion>);
  102178. /**
  102179. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102180. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102181. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102182. * @returns true if it intersects
  102183. */
  102184. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102185. /**
  102186. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102187. * A particle is in the frustum if its bounding box intersects the frustum
  102188. * @param frustumPlanes defines the frustum to test
  102189. * @returns true if the particle is in the frustum planes
  102190. */
  102191. isInFrustum(frustumPlanes: Plane[]): boolean;
  102192. /**
  102193. * get the rotation matrix of the particle
  102194. * @hidden
  102195. */
  102196. getRotationMatrix(m: Matrix): void;
  102197. }
  102198. /**
  102199. * Represents the shape of the model used by one particle of a solid particle system.
  102200. * SPS internal tool, don't use it manually.
  102201. */
  102202. export class ModelShape {
  102203. /**
  102204. * The shape id
  102205. * @hidden
  102206. */
  102207. shapeID: number;
  102208. /**
  102209. * flat array of model positions (internal use)
  102210. * @hidden
  102211. */
  102212. _shape: Vector3[];
  102213. /**
  102214. * flat array of model UVs (internal use)
  102215. * @hidden
  102216. */
  102217. _shapeUV: number[];
  102218. /**
  102219. * color array of the model
  102220. * @hidden
  102221. */
  102222. _shapeColors: number[];
  102223. /**
  102224. * indices array of the model
  102225. * @hidden
  102226. */
  102227. _indices: number[];
  102228. /**
  102229. * normals array of the model
  102230. * @hidden
  102231. */
  102232. _normals: number[];
  102233. /**
  102234. * length of the shape in the model indices array (internal use)
  102235. * @hidden
  102236. */
  102237. _indicesLength: number;
  102238. /**
  102239. * Custom position function (internal use)
  102240. * @hidden
  102241. */
  102242. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102243. /**
  102244. * Custom vertex function (internal use)
  102245. * @hidden
  102246. */
  102247. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102248. /**
  102249. * Model material (internal use)
  102250. * @hidden
  102251. */
  102252. _material: Nullable<Material>;
  102253. /**
  102254. * 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.
  102255. * SPS internal tool, don't use it manually.
  102256. * @hidden
  102257. */
  102258. 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>);
  102259. }
  102260. /**
  102261. * Represents a Depth Sorted Particle in the solid particle system.
  102262. * @hidden
  102263. */
  102264. export class DepthSortedParticle {
  102265. /**
  102266. * Particle index
  102267. */
  102268. idx: number;
  102269. /**
  102270. * Index of the particle in the "indices" array
  102271. */
  102272. ind: number;
  102273. /**
  102274. * Length of the particle shape in the "indices" array
  102275. */
  102276. indicesLength: number;
  102277. /**
  102278. * Squared distance from the particle to the camera
  102279. */
  102280. sqDistance: number;
  102281. /**
  102282. * Material index when used with MultiMaterials
  102283. */
  102284. materialIndex: number;
  102285. /**
  102286. * Creates a new sorted particle
  102287. * @param materialIndex
  102288. */
  102289. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102290. }
  102291. }
  102292. declare module BABYLON {
  102293. /**
  102294. * @hidden
  102295. */
  102296. export class _MeshCollisionData {
  102297. _checkCollisions: boolean;
  102298. _collisionMask: number;
  102299. _collisionGroup: number;
  102300. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102301. _collider: Nullable<Collider>;
  102302. _oldPositionForCollisions: Vector3;
  102303. _diffPositionForCollisions: Vector3;
  102304. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102305. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102306. }
  102307. }
  102308. declare module BABYLON {
  102309. /** @hidden */
  102310. class _FacetDataStorage {
  102311. facetPositions: Vector3[];
  102312. facetNormals: Vector3[];
  102313. facetPartitioning: number[][];
  102314. facetNb: number;
  102315. partitioningSubdivisions: number;
  102316. partitioningBBoxRatio: number;
  102317. facetDataEnabled: boolean;
  102318. facetParameters: any;
  102319. bbSize: Vector3;
  102320. subDiv: {
  102321. max: number;
  102322. X: number;
  102323. Y: number;
  102324. Z: number;
  102325. };
  102326. facetDepthSort: boolean;
  102327. facetDepthSortEnabled: boolean;
  102328. depthSortedIndices: IndicesArray;
  102329. depthSortedFacets: {
  102330. ind: number;
  102331. sqDistance: number;
  102332. }[];
  102333. facetDepthSortFunction: (f1: {
  102334. ind: number;
  102335. sqDistance: number;
  102336. }, f2: {
  102337. ind: number;
  102338. sqDistance: number;
  102339. }) => number;
  102340. facetDepthSortFrom: Vector3;
  102341. facetDepthSortOrigin: Vector3;
  102342. invertedMatrix: Matrix;
  102343. }
  102344. /**
  102345. * @hidden
  102346. **/
  102347. class _InternalAbstractMeshDataInfo {
  102348. _hasVertexAlpha: boolean;
  102349. _useVertexColors: boolean;
  102350. _numBoneInfluencers: number;
  102351. _applyFog: boolean;
  102352. _receiveShadows: boolean;
  102353. _facetData: _FacetDataStorage;
  102354. _visibility: number;
  102355. _skeleton: Nullable<Skeleton>;
  102356. _layerMask: number;
  102357. _computeBonesUsingShaders: boolean;
  102358. _isActive: boolean;
  102359. _onlyForInstances: boolean;
  102360. _isActiveIntermediate: boolean;
  102361. _onlyForInstancesIntermediate: boolean;
  102362. _actAsRegularMesh: boolean;
  102363. }
  102364. /**
  102365. * Class used to store all common mesh properties
  102366. */
  102367. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102368. /** No occlusion */
  102369. static OCCLUSION_TYPE_NONE: number;
  102370. /** Occlusion set to optimisitic */
  102371. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102372. /** Occlusion set to strict */
  102373. static OCCLUSION_TYPE_STRICT: number;
  102374. /** Use an accurante occlusion algorithm */
  102375. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102376. /** Use a conservative occlusion algorithm */
  102377. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102378. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102379. * Test order :
  102380. * Is the bounding sphere outside the frustum ?
  102381. * If not, are the bounding box vertices outside the frustum ?
  102382. * It not, then the cullable object is in the frustum.
  102383. */
  102384. static readonly CULLINGSTRATEGY_STANDARD: number;
  102385. /** Culling strategy : Bounding Sphere Only.
  102386. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102387. * It's also less accurate than the standard because some not visible objects can still be selected.
  102388. * Test : is the bounding sphere outside the frustum ?
  102389. * If not, then the cullable object is in the frustum.
  102390. */
  102391. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102392. /** Culling strategy : Optimistic Inclusion.
  102393. * This in an inclusion test first, then the standard exclusion test.
  102394. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102395. * 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.
  102396. * Anyway, it's as accurate as the standard strategy.
  102397. * Test :
  102398. * Is the cullable object bounding sphere center in the frustum ?
  102399. * If not, apply the default culling strategy.
  102400. */
  102401. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102402. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102403. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102404. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102405. * 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.
  102406. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102407. * Test :
  102408. * Is the cullable object bounding sphere center in the frustum ?
  102409. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102410. */
  102411. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102412. /**
  102413. * No billboard
  102414. */
  102415. static get BILLBOARDMODE_NONE(): number;
  102416. /** Billboard on X axis */
  102417. static get BILLBOARDMODE_X(): number;
  102418. /** Billboard on Y axis */
  102419. static get BILLBOARDMODE_Y(): number;
  102420. /** Billboard on Z axis */
  102421. static get BILLBOARDMODE_Z(): number;
  102422. /** Billboard on all axes */
  102423. static get BILLBOARDMODE_ALL(): number;
  102424. /** Billboard on using position instead of orientation */
  102425. static get BILLBOARDMODE_USE_POSITION(): number;
  102426. /** @hidden */
  102427. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102428. /**
  102429. * The culling strategy to use to check whether the mesh must be rendered or not.
  102430. * This value can be changed at any time and will be used on the next render mesh selection.
  102431. * The possible values are :
  102432. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102433. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102434. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102435. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102436. * Please read each static variable documentation to get details about the culling process.
  102437. * */
  102438. cullingStrategy: number;
  102439. /**
  102440. * Gets the number of facets in the mesh
  102441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102442. */
  102443. get facetNb(): number;
  102444. /**
  102445. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102447. */
  102448. get partitioningSubdivisions(): number;
  102449. set partitioningSubdivisions(nb: number);
  102450. /**
  102451. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102452. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102454. */
  102455. get partitioningBBoxRatio(): number;
  102456. set partitioningBBoxRatio(ratio: number);
  102457. /**
  102458. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102459. * Works only for updatable meshes.
  102460. * Doesn't work with multi-materials
  102461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102462. */
  102463. get mustDepthSortFacets(): boolean;
  102464. set mustDepthSortFacets(sort: boolean);
  102465. /**
  102466. * The location (Vector3) where the facet depth sort must be computed from.
  102467. * By default, the active camera position.
  102468. * Used only when facet depth sort is enabled
  102469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102470. */
  102471. get facetDepthSortFrom(): Vector3;
  102472. set facetDepthSortFrom(location: Vector3);
  102473. /**
  102474. * gets a boolean indicating if facetData is enabled
  102475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102476. */
  102477. get isFacetDataEnabled(): boolean;
  102478. /** @hidden */
  102479. _updateNonUniformScalingState(value: boolean): boolean;
  102480. /**
  102481. * An event triggered when this mesh collides with another one
  102482. */
  102483. onCollideObservable: Observable<AbstractMesh>;
  102484. /** Set a function to call when this mesh collides with another one */
  102485. set onCollide(callback: () => void);
  102486. /**
  102487. * An event triggered when the collision's position changes
  102488. */
  102489. onCollisionPositionChangeObservable: Observable<Vector3>;
  102490. /** Set a function to call when the collision's position changes */
  102491. set onCollisionPositionChange(callback: () => void);
  102492. /**
  102493. * An event triggered when material is changed
  102494. */
  102495. onMaterialChangedObservable: Observable<AbstractMesh>;
  102496. /**
  102497. * Gets or sets the orientation for POV movement & rotation
  102498. */
  102499. definedFacingForward: boolean;
  102500. /** @hidden */
  102501. _occlusionQuery: Nullable<WebGLQuery>;
  102502. /** @hidden */
  102503. _renderingGroup: Nullable<RenderingGroup>;
  102504. /**
  102505. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102506. */
  102507. get visibility(): number;
  102508. /**
  102509. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102510. */
  102511. set visibility(value: number);
  102512. /** Gets or sets the alpha index used to sort transparent meshes
  102513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102514. */
  102515. alphaIndex: number;
  102516. /**
  102517. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102518. */
  102519. isVisible: boolean;
  102520. /**
  102521. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102522. */
  102523. isPickable: boolean;
  102524. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102525. showSubMeshesBoundingBox: boolean;
  102526. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102527. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102528. */
  102529. isBlocker: boolean;
  102530. /**
  102531. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102532. */
  102533. enablePointerMoveEvents: boolean;
  102534. /**
  102535. * Specifies the rendering group id for this mesh (0 by default)
  102536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102537. */
  102538. renderingGroupId: number;
  102539. private _material;
  102540. /** Gets or sets current material */
  102541. get material(): Nullable<Material>;
  102542. set material(value: Nullable<Material>);
  102543. /**
  102544. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102545. * @see http://doc.babylonjs.com/babylon101/shadows
  102546. */
  102547. get receiveShadows(): boolean;
  102548. set receiveShadows(value: boolean);
  102549. /** Defines color to use when rendering outline */
  102550. outlineColor: Color3;
  102551. /** Define width to use when rendering outline */
  102552. outlineWidth: number;
  102553. /** Defines color to use when rendering overlay */
  102554. overlayColor: Color3;
  102555. /** Defines alpha to use when rendering overlay */
  102556. overlayAlpha: number;
  102557. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102558. get hasVertexAlpha(): boolean;
  102559. set hasVertexAlpha(value: boolean);
  102560. /** 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) */
  102561. get useVertexColors(): boolean;
  102562. set useVertexColors(value: boolean);
  102563. /**
  102564. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102565. */
  102566. get computeBonesUsingShaders(): boolean;
  102567. set computeBonesUsingShaders(value: boolean);
  102568. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102569. get numBoneInfluencers(): number;
  102570. set numBoneInfluencers(value: number);
  102571. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102572. get applyFog(): boolean;
  102573. set applyFog(value: boolean);
  102574. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102575. useOctreeForRenderingSelection: boolean;
  102576. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102577. useOctreeForPicking: boolean;
  102578. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102579. useOctreeForCollisions: boolean;
  102580. /**
  102581. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102582. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102583. */
  102584. get layerMask(): number;
  102585. set layerMask(value: number);
  102586. /**
  102587. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102588. */
  102589. alwaysSelectAsActiveMesh: boolean;
  102590. /**
  102591. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102592. */
  102593. doNotSyncBoundingInfo: boolean;
  102594. /**
  102595. * Gets or sets the current action manager
  102596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102597. */
  102598. actionManager: Nullable<AbstractActionManager>;
  102599. private _meshCollisionData;
  102600. /**
  102601. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102603. */
  102604. ellipsoid: Vector3;
  102605. /**
  102606. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102608. */
  102609. ellipsoidOffset: Vector3;
  102610. /**
  102611. * Gets or sets a collision mask used to mask collisions (default is -1).
  102612. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102613. */
  102614. get collisionMask(): number;
  102615. set collisionMask(mask: number);
  102616. /**
  102617. * Gets or sets the current collision group mask (-1 by default).
  102618. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102619. */
  102620. get collisionGroup(): number;
  102621. set collisionGroup(mask: number);
  102622. /**
  102623. * Gets or sets current surrounding meshes (null by default).
  102624. *
  102625. * By default collision detection is tested against every mesh in the scene.
  102626. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102627. * meshes will be tested for the collision.
  102628. *
  102629. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102630. */
  102631. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102632. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102633. /**
  102634. * Defines edge width used when edgesRenderer is enabled
  102635. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102636. */
  102637. edgesWidth: number;
  102638. /**
  102639. * Defines edge color used when edgesRenderer is enabled
  102640. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102641. */
  102642. edgesColor: Color4;
  102643. /** @hidden */
  102644. _edgesRenderer: Nullable<IEdgesRenderer>;
  102645. /** @hidden */
  102646. _masterMesh: Nullable<AbstractMesh>;
  102647. /** @hidden */
  102648. _boundingInfo: Nullable<BoundingInfo>;
  102649. /** @hidden */
  102650. _renderId: number;
  102651. /**
  102652. * Gets or sets the list of subMeshes
  102653. * @see http://doc.babylonjs.com/how_to/multi_materials
  102654. */
  102655. subMeshes: SubMesh[];
  102656. /** @hidden */
  102657. _intersectionsInProgress: AbstractMesh[];
  102658. /** @hidden */
  102659. _unIndexed: boolean;
  102660. /** @hidden */
  102661. _lightSources: Light[];
  102662. /** Gets the list of lights affecting that mesh */
  102663. get lightSources(): Light[];
  102664. /** @hidden */
  102665. get _positions(): Nullable<Vector3[]>;
  102666. /** @hidden */
  102667. _waitingData: {
  102668. lods: Nullable<any>;
  102669. actions: Nullable<any>;
  102670. freezeWorldMatrix: Nullable<boolean>;
  102671. };
  102672. /** @hidden */
  102673. _bonesTransformMatrices: Nullable<Float32Array>;
  102674. /** @hidden */
  102675. _transformMatrixTexture: Nullable<RawTexture>;
  102676. /**
  102677. * Gets or sets a skeleton to apply skining transformations
  102678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102679. */
  102680. set skeleton(value: Nullable<Skeleton>);
  102681. get skeleton(): Nullable<Skeleton>;
  102682. /**
  102683. * An event triggered when the mesh is rebuilt.
  102684. */
  102685. onRebuildObservable: Observable<AbstractMesh>;
  102686. /**
  102687. * Creates a new AbstractMesh
  102688. * @param name defines the name of the mesh
  102689. * @param scene defines the hosting scene
  102690. */
  102691. constructor(name: string, scene?: Nullable<Scene>);
  102692. /**
  102693. * Returns the string "AbstractMesh"
  102694. * @returns "AbstractMesh"
  102695. */
  102696. getClassName(): string;
  102697. /**
  102698. * Gets a string representation of the current mesh
  102699. * @param fullDetails defines a boolean indicating if full details must be included
  102700. * @returns a string representation of the current mesh
  102701. */
  102702. toString(fullDetails?: boolean): string;
  102703. /**
  102704. * @hidden
  102705. */
  102706. protected _getEffectiveParent(): Nullable<Node>;
  102707. /** @hidden */
  102708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102709. /** @hidden */
  102710. _rebuild(): void;
  102711. /** @hidden */
  102712. _resyncLightSources(): void;
  102713. /** @hidden */
  102714. _resyncLightSource(light: Light): void;
  102715. /** @hidden */
  102716. _unBindEffect(): void;
  102717. /** @hidden */
  102718. _removeLightSource(light: Light, dispose: boolean): void;
  102719. private _markSubMeshesAsDirty;
  102720. /** @hidden */
  102721. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102722. /** @hidden */
  102723. _markSubMeshesAsAttributesDirty(): void;
  102724. /** @hidden */
  102725. _markSubMeshesAsMiscDirty(): void;
  102726. /**
  102727. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102728. */
  102729. get scaling(): Vector3;
  102730. set scaling(newScaling: Vector3);
  102731. /**
  102732. * Returns true if the mesh is blocked. Implemented by child classes
  102733. */
  102734. get isBlocked(): boolean;
  102735. /**
  102736. * Returns the mesh itself by default. Implemented by child classes
  102737. * @param camera defines the camera to use to pick the right LOD level
  102738. * @returns the currentAbstractMesh
  102739. */
  102740. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102741. /**
  102742. * Returns 0 by default. Implemented by child classes
  102743. * @returns an integer
  102744. */
  102745. getTotalVertices(): number;
  102746. /**
  102747. * Returns a positive integer : the total number of indices in this mesh geometry.
  102748. * @returns the numner of indices or zero if the mesh has no geometry.
  102749. */
  102750. getTotalIndices(): number;
  102751. /**
  102752. * Returns null by default. Implemented by child classes
  102753. * @returns null
  102754. */
  102755. getIndices(): Nullable<IndicesArray>;
  102756. /**
  102757. * Returns the array of the requested vertex data kind. Implemented by child classes
  102758. * @param kind defines the vertex data kind to use
  102759. * @returns null
  102760. */
  102761. getVerticesData(kind: string): Nullable<FloatArray>;
  102762. /**
  102763. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102764. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102765. * Note that a new underlying VertexBuffer object is created each call.
  102766. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102767. * @param kind defines vertex data kind:
  102768. * * VertexBuffer.PositionKind
  102769. * * VertexBuffer.UVKind
  102770. * * VertexBuffer.UV2Kind
  102771. * * VertexBuffer.UV3Kind
  102772. * * VertexBuffer.UV4Kind
  102773. * * VertexBuffer.UV5Kind
  102774. * * VertexBuffer.UV6Kind
  102775. * * VertexBuffer.ColorKind
  102776. * * VertexBuffer.MatricesIndicesKind
  102777. * * VertexBuffer.MatricesIndicesExtraKind
  102778. * * VertexBuffer.MatricesWeightsKind
  102779. * * VertexBuffer.MatricesWeightsExtraKind
  102780. * @param data defines the data source
  102781. * @param updatable defines if the data must be flagged as updatable (or static)
  102782. * @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
  102783. * @returns the current mesh
  102784. */
  102785. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102786. /**
  102787. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102788. * If the mesh has no geometry, it is simply returned as it is.
  102789. * @param kind defines vertex data kind:
  102790. * * VertexBuffer.PositionKind
  102791. * * VertexBuffer.UVKind
  102792. * * VertexBuffer.UV2Kind
  102793. * * VertexBuffer.UV3Kind
  102794. * * VertexBuffer.UV4Kind
  102795. * * VertexBuffer.UV5Kind
  102796. * * VertexBuffer.UV6Kind
  102797. * * VertexBuffer.ColorKind
  102798. * * VertexBuffer.MatricesIndicesKind
  102799. * * VertexBuffer.MatricesIndicesExtraKind
  102800. * * VertexBuffer.MatricesWeightsKind
  102801. * * VertexBuffer.MatricesWeightsExtraKind
  102802. * @param data defines the data source
  102803. * @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
  102804. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102805. * @returns the current mesh
  102806. */
  102807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102808. /**
  102809. * Sets the mesh indices,
  102810. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102811. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102812. * @param totalVertices Defines the total number of vertices
  102813. * @returns the current mesh
  102814. */
  102815. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102816. /**
  102817. * Gets a boolean indicating if specific vertex data is present
  102818. * @param kind defines the vertex data kind to use
  102819. * @returns true is data kind is present
  102820. */
  102821. isVerticesDataPresent(kind: string): boolean;
  102822. /**
  102823. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102824. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102825. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102826. * @returns a BoundingInfo
  102827. */
  102828. getBoundingInfo(): BoundingInfo;
  102829. /**
  102830. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102831. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102832. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102833. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102834. * @returns the current mesh
  102835. */
  102836. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102837. /**
  102838. * Overwrite the current bounding info
  102839. * @param boundingInfo defines the new bounding info
  102840. * @returns the current mesh
  102841. */
  102842. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102843. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102844. get useBones(): boolean;
  102845. /** @hidden */
  102846. _preActivate(): void;
  102847. /** @hidden */
  102848. _preActivateForIntermediateRendering(renderId: number): void;
  102849. /** @hidden */
  102850. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102851. /** @hidden */
  102852. _postActivate(): void;
  102853. /** @hidden */
  102854. _freeze(): void;
  102855. /** @hidden */
  102856. _unFreeze(): void;
  102857. /**
  102858. * Gets the current world matrix
  102859. * @returns a Matrix
  102860. */
  102861. getWorldMatrix(): Matrix;
  102862. /** @hidden */
  102863. _getWorldMatrixDeterminant(): number;
  102864. /**
  102865. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102866. */
  102867. get isAnInstance(): boolean;
  102868. /**
  102869. * Gets a boolean indicating if this mesh has instances
  102870. */
  102871. get hasInstances(): boolean;
  102872. /**
  102873. * Perform relative position change from the point of view of behind the front of the mesh.
  102874. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102875. * Supports definition of mesh facing forward or backward
  102876. * @param amountRight defines the distance on the right axis
  102877. * @param amountUp defines the distance on the up axis
  102878. * @param amountForward defines the distance on the forward axis
  102879. * @returns the current mesh
  102880. */
  102881. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102882. /**
  102883. * Calculate relative position change from the point of view of behind the front of the mesh.
  102884. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102885. * Supports definition of mesh facing forward or backward
  102886. * @param amountRight defines the distance on the right axis
  102887. * @param amountUp defines the distance on the up axis
  102888. * @param amountForward defines the distance on the forward axis
  102889. * @returns the new displacement vector
  102890. */
  102891. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102892. /**
  102893. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102894. * Supports definition of mesh facing forward or backward
  102895. * @param flipBack defines the flip
  102896. * @param twirlClockwise defines the twirl
  102897. * @param tiltRight defines the tilt
  102898. * @returns the current mesh
  102899. */
  102900. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102901. /**
  102902. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102903. * Supports definition of mesh facing forward or backward.
  102904. * @param flipBack defines the flip
  102905. * @param twirlClockwise defines the twirl
  102906. * @param tiltRight defines the tilt
  102907. * @returns the new rotation vector
  102908. */
  102909. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102910. /**
  102911. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102912. * This means the mesh underlying bounding box and sphere are recomputed.
  102913. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102914. * @returns the current mesh
  102915. */
  102916. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102917. /** @hidden */
  102918. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102919. /** @hidden */
  102920. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102921. /** @hidden */
  102922. _updateBoundingInfo(): AbstractMesh;
  102923. /** @hidden */
  102924. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102925. /** @hidden */
  102926. protected _afterComputeWorldMatrix(): void;
  102927. /** @hidden */
  102928. get _effectiveMesh(): AbstractMesh;
  102929. /**
  102930. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102931. * A mesh is in the frustum if its bounding box intersects the frustum
  102932. * @param frustumPlanes defines the frustum to test
  102933. * @returns true if the mesh is in the frustum planes
  102934. */
  102935. isInFrustum(frustumPlanes: Plane[]): boolean;
  102936. /**
  102937. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102938. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102939. * @param frustumPlanes defines the frustum to test
  102940. * @returns true if the mesh is completely in the frustum planes
  102941. */
  102942. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102943. /**
  102944. * True if the mesh intersects another mesh or a SolidParticle object
  102945. * @param mesh defines a target mesh or SolidParticle to test
  102946. * @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)
  102947. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102948. * @returns true if there is an intersection
  102949. */
  102950. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102951. /**
  102952. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102953. * @param point defines the point to test
  102954. * @returns true if there is an intersection
  102955. */
  102956. intersectsPoint(point: Vector3): boolean;
  102957. /**
  102958. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102959. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102960. */
  102961. get checkCollisions(): boolean;
  102962. set checkCollisions(collisionEnabled: boolean);
  102963. /**
  102964. * Gets Collider object used to compute collisions (not physics)
  102965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102966. */
  102967. get collider(): Nullable<Collider>;
  102968. /**
  102969. * Move the mesh using collision engine
  102970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102971. * @param displacement defines the requested displacement vector
  102972. * @returns the current mesh
  102973. */
  102974. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102975. private _onCollisionPositionChange;
  102976. /** @hidden */
  102977. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102978. /** @hidden */
  102979. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102980. /** @hidden */
  102981. _checkCollision(collider: Collider): AbstractMesh;
  102982. /** @hidden */
  102983. _generatePointsArray(): boolean;
  102984. /**
  102985. * Checks if the passed Ray intersects with the mesh
  102986. * @param ray defines the ray to use
  102987. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102988. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102989. * @returns the picking info
  102990. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102991. */
  102992. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102993. /**
  102994. * Clones the current mesh
  102995. * @param name defines the mesh name
  102996. * @param newParent defines the new mesh parent
  102997. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  102998. * @returns the new mesh
  102999. */
  103000. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103001. /**
  103002. * Disposes all the submeshes of the current meshnp
  103003. * @returns the current mesh
  103004. */
  103005. releaseSubMeshes(): AbstractMesh;
  103006. /**
  103007. * Releases resources associated with this abstract mesh.
  103008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103010. */
  103011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103012. /**
  103013. * Adds the passed mesh as a child to the current mesh
  103014. * @param mesh defines the child mesh
  103015. * @returns the current mesh
  103016. */
  103017. addChild(mesh: AbstractMesh): AbstractMesh;
  103018. /**
  103019. * Removes the passed mesh from the current mesh children list
  103020. * @param mesh defines the child mesh
  103021. * @returns the current mesh
  103022. */
  103023. removeChild(mesh: AbstractMesh): AbstractMesh;
  103024. /** @hidden */
  103025. private _initFacetData;
  103026. /**
  103027. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103028. * This method can be called within the render loop.
  103029. * 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
  103030. * @returns the current mesh
  103031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103032. */
  103033. updateFacetData(): AbstractMesh;
  103034. /**
  103035. * Returns the facetLocalNormals array.
  103036. * The normals are expressed in the mesh local spac
  103037. * @returns an array of Vector3
  103038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103039. */
  103040. getFacetLocalNormals(): Vector3[];
  103041. /**
  103042. * Returns the facetLocalPositions array.
  103043. * The facet positions are expressed in the mesh local space
  103044. * @returns an array of Vector3
  103045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103046. */
  103047. getFacetLocalPositions(): Vector3[];
  103048. /**
  103049. * Returns the facetLocalPartioning array
  103050. * @returns an array of array of numbers
  103051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103052. */
  103053. getFacetLocalPartitioning(): number[][];
  103054. /**
  103055. * Returns the i-th facet position in the world system.
  103056. * This method allocates a new Vector3 per call
  103057. * @param i defines the facet index
  103058. * @returns a new Vector3
  103059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103060. */
  103061. getFacetPosition(i: number): Vector3;
  103062. /**
  103063. * Sets the reference Vector3 with the i-th facet position in the world system
  103064. * @param i defines the facet index
  103065. * @param ref defines the target vector
  103066. * @returns the current mesh
  103067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103068. */
  103069. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103070. /**
  103071. * Returns the i-th facet normal in the world system.
  103072. * This method allocates a new Vector3 per call
  103073. * @param i defines the facet index
  103074. * @returns a new Vector3
  103075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103076. */
  103077. getFacetNormal(i: number): Vector3;
  103078. /**
  103079. * Sets the reference Vector3 with the i-th facet normal in the world system
  103080. * @param i defines the facet index
  103081. * @param ref defines the target vector
  103082. * @returns the current mesh
  103083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103084. */
  103085. getFacetNormalToRef(i: number, ref: Vector3): this;
  103086. /**
  103087. * 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)
  103088. * @param x defines x coordinate
  103089. * @param y defines y coordinate
  103090. * @param z defines z coordinate
  103091. * @returns the array of facet indexes
  103092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103093. */
  103094. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103095. /**
  103096. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103097. * @param projected sets as the (x,y,z) world projection on the facet
  103098. * @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
  103099. * @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
  103100. * @param x defines x coordinate
  103101. * @param y defines y coordinate
  103102. * @param z defines z coordinate
  103103. * @returns the face index if found (or null instead)
  103104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103105. */
  103106. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103107. /**
  103108. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103109. * @param projected sets as the (x,y,z) local projection on the facet
  103110. * @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
  103111. * @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
  103112. * @param x defines x coordinate
  103113. * @param y defines y coordinate
  103114. * @param z defines z coordinate
  103115. * @returns the face index if found (or null instead)
  103116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103117. */
  103118. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103119. /**
  103120. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103121. * @returns the parameters
  103122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103123. */
  103124. getFacetDataParameters(): any;
  103125. /**
  103126. * Disables the feature FacetData and frees the related memory
  103127. * @returns the current mesh
  103128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103129. */
  103130. disableFacetData(): AbstractMesh;
  103131. /**
  103132. * Updates the AbstractMesh indices array
  103133. * @param indices defines the data source
  103134. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103135. * @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)
  103136. * @returns the current mesh
  103137. */
  103138. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103139. /**
  103140. * Creates new normals data for the mesh
  103141. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103142. * @returns the current mesh
  103143. */
  103144. createNormals(updatable: boolean): AbstractMesh;
  103145. /**
  103146. * Align the mesh with a normal
  103147. * @param normal defines the normal to use
  103148. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103149. * @returns the current mesh
  103150. */
  103151. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103152. /** @hidden */
  103153. _checkOcclusionQuery(): boolean;
  103154. /**
  103155. * Disables the mesh edge rendering mode
  103156. * @returns the currentAbstractMesh
  103157. */
  103158. disableEdgesRendering(): AbstractMesh;
  103159. /**
  103160. * Enables the edge rendering mode on the mesh.
  103161. * This mode makes the mesh edges visible
  103162. * @param epsilon defines the maximal distance between two angles to detect a face
  103163. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103164. * @returns the currentAbstractMesh
  103165. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103166. */
  103167. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /**
  103172. * Interface used to define ActionEvent
  103173. */
  103174. export interface IActionEvent {
  103175. /** The mesh or sprite that triggered the action */
  103176. source: any;
  103177. /** The X mouse cursor position at the time of the event */
  103178. pointerX: number;
  103179. /** The Y mouse cursor position at the time of the event */
  103180. pointerY: number;
  103181. /** The mesh that is currently pointed at (can be null) */
  103182. meshUnderPointer: Nullable<AbstractMesh>;
  103183. /** the original (browser) event that triggered the ActionEvent */
  103184. sourceEvent?: any;
  103185. /** additional data for the event */
  103186. additionalData?: any;
  103187. }
  103188. /**
  103189. * ActionEvent is the event being sent when an action is triggered.
  103190. */
  103191. export class ActionEvent implements IActionEvent {
  103192. /** The mesh or sprite that triggered the action */
  103193. source: any;
  103194. /** The X mouse cursor position at the time of the event */
  103195. pointerX: number;
  103196. /** The Y mouse cursor position at the time of the event */
  103197. pointerY: number;
  103198. /** The mesh that is currently pointed at (can be null) */
  103199. meshUnderPointer: Nullable<AbstractMesh>;
  103200. /** the original (browser) event that triggered the ActionEvent */
  103201. sourceEvent?: any;
  103202. /** additional data for the event */
  103203. additionalData?: any;
  103204. /**
  103205. * Creates a new ActionEvent
  103206. * @param source The mesh or sprite that triggered the action
  103207. * @param pointerX The X mouse cursor position at the time of the event
  103208. * @param pointerY The Y mouse cursor position at the time of the event
  103209. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103210. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103211. * @param additionalData additional data for the event
  103212. */
  103213. constructor(
  103214. /** The mesh or sprite that triggered the action */
  103215. source: any,
  103216. /** The X mouse cursor position at the time of the event */
  103217. pointerX: number,
  103218. /** The Y mouse cursor position at the time of the event */
  103219. pointerY: number,
  103220. /** The mesh that is currently pointed at (can be null) */
  103221. meshUnderPointer: Nullable<AbstractMesh>,
  103222. /** the original (browser) event that triggered the ActionEvent */
  103223. sourceEvent?: any,
  103224. /** additional data for the event */
  103225. additionalData?: any);
  103226. /**
  103227. * Helper function to auto-create an ActionEvent from a source mesh.
  103228. * @param source The source mesh that triggered the event
  103229. * @param evt The original (browser) event
  103230. * @param additionalData additional data for the event
  103231. * @returns the new ActionEvent
  103232. */
  103233. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103234. /**
  103235. * Helper function to auto-create an ActionEvent from a source sprite
  103236. * @param source The source sprite that triggered the event
  103237. * @param scene Scene associated with the sprite
  103238. * @param evt The original (browser) event
  103239. * @param additionalData additional data for the event
  103240. * @returns the new ActionEvent
  103241. */
  103242. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103243. /**
  103244. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103245. * @param scene the scene where the event occurred
  103246. * @param evt The original (browser) event
  103247. * @returns the new ActionEvent
  103248. */
  103249. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103250. /**
  103251. * Helper function to auto-create an ActionEvent from a primitive
  103252. * @param prim defines the target primitive
  103253. * @param pointerPos defines the pointer position
  103254. * @param evt The original (browser) event
  103255. * @param additionalData additional data for the event
  103256. * @returns the new ActionEvent
  103257. */
  103258. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103259. }
  103260. }
  103261. declare module BABYLON {
  103262. /**
  103263. * Abstract class used to decouple action Manager from scene and meshes.
  103264. * Do not instantiate.
  103265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103266. */
  103267. export abstract class AbstractActionManager implements IDisposable {
  103268. /** Gets the list of active triggers */
  103269. static Triggers: {
  103270. [key: string]: number;
  103271. };
  103272. /** Gets the cursor to use when hovering items */
  103273. hoverCursor: string;
  103274. /** Gets the list of actions */
  103275. actions: IAction[];
  103276. /**
  103277. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103278. */
  103279. isRecursive: boolean;
  103280. /**
  103281. * Releases all associated resources
  103282. */
  103283. abstract dispose(): void;
  103284. /**
  103285. * Does this action manager has pointer triggers
  103286. */
  103287. abstract get hasPointerTriggers(): boolean;
  103288. /**
  103289. * Does this action manager has pick triggers
  103290. */
  103291. abstract get hasPickTriggers(): boolean;
  103292. /**
  103293. * Process a specific trigger
  103294. * @param trigger defines the trigger to process
  103295. * @param evt defines the event details to be processed
  103296. */
  103297. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103298. /**
  103299. * Does this action manager handles actions of any of the given triggers
  103300. * @param triggers defines the triggers to be tested
  103301. * @return a boolean indicating whether one (or more) of the triggers is handled
  103302. */
  103303. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103304. /**
  103305. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103306. * speed.
  103307. * @param triggerA defines the trigger to be tested
  103308. * @param triggerB defines the trigger to be tested
  103309. * @return a boolean indicating whether one (or more) of the triggers is handled
  103310. */
  103311. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103312. /**
  103313. * Does this action manager handles actions of a given trigger
  103314. * @param trigger defines the trigger to be tested
  103315. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103316. * @return whether the trigger is handled
  103317. */
  103318. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103319. /**
  103320. * Serialize this manager to a JSON object
  103321. * @param name defines the property name to store this manager
  103322. * @returns a JSON representation of this manager
  103323. */
  103324. abstract serialize(name: string): any;
  103325. /**
  103326. * Registers an action to this action manager
  103327. * @param action defines the action to be registered
  103328. * @return the action amended (prepared) after registration
  103329. */
  103330. abstract registerAction(action: IAction): Nullable<IAction>;
  103331. /**
  103332. * Unregisters an action to this action manager
  103333. * @param action defines the action to be unregistered
  103334. * @return a boolean indicating whether the action has been unregistered
  103335. */
  103336. abstract unregisterAction(action: IAction): Boolean;
  103337. /**
  103338. * Does exist one action manager with at least one trigger
  103339. **/
  103340. static get HasTriggers(): boolean;
  103341. /**
  103342. * Does exist one action manager with at least one pick trigger
  103343. **/
  103344. static get HasPickTriggers(): boolean;
  103345. /**
  103346. * Does exist one action manager that handles actions of a given trigger
  103347. * @param trigger defines the trigger to be tested
  103348. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103349. **/
  103350. static HasSpecificTrigger(trigger: number): boolean;
  103351. }
  103352. }
  103353. declare module BABYLON {
  103354. /**
  103355. * Defines how a node can be built from a string name.
  103356. */
  103357. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103358. /**
  103359. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103360. */
  103361. export class Node implements IBehaviorAware<Node> {
  103362. /** @hidden */
  103363. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103364. private static _NodeConstructors;
  103365. /**
  103366. * Add a new node constructor
  103367. * @param type defines the type name of the node to construct
  103368. * @param constructorFunc defines the constructor function
  103369. */
  103370. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103371. /**
  103372. * Returns a node constructor based on type name
  103373. * @param type defines the type name
  103374. * @param name defines the new node name
  103375. * @param scene defines the hosting scene
  103376. * @param options defines optional options to transmit to constructors
  103377. * @returns the new constructor or null
  103378. */
  103379. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103380. /**
  103381. * Gets or sets the name of the node
  103382. */
  103383. name: string;
  103384. /**
  103385. * Gets or sets the id of the node
  103386. */
  103387. id: string;
  103388. /**
  103389. * Gets or sets the unique id of the node
  103390. */
  103391. uniqueId: number;
  103392. /**
  103393. * Gets or sets a string used to store user defined state for the node
  103394. */
  103395. state: string;
  103396. /**
  103397. * Gets or sets an object used to store user defined information for the node
  103398. */
  103399. metadata: any;
  103400. /**
  103401. * For internal use only. Please do not use.
  103402. */
  103403. reservedDataStore: any;
  103404. /**
  103405. * List of inspectable custom properties (used by the Inspector)
  103406. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103407. */
  103408. inspectableCustomProperties: IInspectable[];
  103409. private _doNotSerialize;
  103410. /**
  103411. * Gets or sets a boolean used to define if the node must be serialized
  103412. */
  103413. get doNotSerialize(): boolean;
  103414. set doNotSerialize(value: boolean);
  103415. /** @hidden */
  103416. _isDisposed: boolean;
  103417. /**
  103418. * Gets a list of Animations associated with the node
  103419. */
  103420. animations: Animation[];
  103421. protected _ranges: {
  103422. [name: string]: Nullable<AnimationRange>;
  103423. };
  103424. /**
  103425. * Callback raised when the node is ready to be used
  103426. */
  103427. onReady: Nullable<(node: Node) => void>;
  103428. private _isEnabled;
  103429. private _isParentEnabled;
  103430. private _isReady;
  103431. /** @hidden */
  103432. _currentRenderId: number;
  103433. private _parentUpdateId;
  103434. /** @hidden */
  103435. _childUpdateId: number;
  103436. /** @hidden */
  103437. _waitingParentId: Nullable<string>;
  103438. /** @hidden */
  103439. _scene: Scene;
  103440. /** @hidden */
  103441. _cache: any;
  103442. private _parentNode;
  103443. private _children;
  103444. /** @hidden */
  103445. _worldMatrix: Matrix;
  103446. /** @hidden */
  103447. _worldMatrixDeterminant: number;
  103448. /** @hidden */
  103449. _worldMatrixDeterminantIsDirty: boolean;
  103450. /** @hidden */
  103451. private _sceneRootNodesIndex;
  103452. /**
  103453. * Gets a boolean indicating if the node has been disposed
  103454. * @returns true if the node was disposed
  103455. */
  103456. isDisposed(): boolean;
  103457. /**
  103458. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103459. * @see https://doc.babylonjs.com/how_to/parenting
  103460. */
  103461. set parent(parent: Nullable<Node>);
  103462. get parent(): Nullable<Node>;
  103463. /** @hidden */
  103464. _addToSceneRootNodes(): void;
  103465. /** @hidden */
  103466. _removeFromSceneRootNodes(): void;
  103467. private _animationPropertiesOverride;
  103468. /**
  103469. * Gets or sets the animation properties override
  103470. */
  103471. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103472. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103473. /**
  103474. * Gets a string idenfifying the name of the class
  103475. * @returns "Node" string
  103476. */
  103477. getClassName(): string;
  103478. /** @hidden */
  103479. readonly _isNode: boolean;
  103480. /**
  103481. * An event triggered when the mesh is disposed
  103482. */
  103483. onDisposeObservable: Observable<Node>;
  103484. private _onDisposeObserver;
  103485. /**
  103486. * Sets a callback that will be raised when the node will be disposed
  103487. */
  103488. set onDispose(callback: () => void);
  103489. /**
  103490. * Creates a new Node
  103491. * @param name the name and id to be given to this node
  103492. * @param scene the scene this node will be added to
  103493. */
  103494. constructor(name: string, scene?: Nullable<Scene>);
  103495. /**
  103496. * Gets the scene of the node
  103497. * @returns a scene
  103498. */
  103499. getScene(): Scene;
  103500. /**
  103501. * Gets the engine of the node
  103502. * @returns a Engine
  103503. */
  103504. getEngine(): Engine;
  103505. private _behaviors;
  103506. /**
  103507. * Attach a behavior to the node
  103508. * @see http://doc.babylonjs.com/features/behaviour
  103509. * @param behavior defines the behavior to attach
  103510. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103511. * @returns the current Node
  103512. */
  103513. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103514. /**
  103515. * Remove an attached behavior
  103516. * @see http://doc.babylonjs.com/features/behaviour
  103517. * @param behavior defines the behavior to attach
  103518. * @returns the current Node
  103519. */
  103520. removeBehavior(behavior: Behavior<Node>): Node;
  103521. /**
  103522. * Gets the list of attached behaviors
  103523. * @see http://doc.babylonjs.com/features/behaviour
  103524. */
  103525. get behaviors(): Behavior<Node>[];
  103526. /**
  103527. * Gets an attached behavior by name
  103528. * @param name defines the name of the behavior to look for
  103529. * @see http://doc.babylonjs.com/features/behaviour
  103530. * @returns null if behavior was not found else the requested behavior
  103531. */
  103532. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103533. /**
  103534. * Returns the latest update of the World matrix
  103535. * @returns a Matrix
  103536. */
  103537. getWorldMatrix(): Matrix;
  103538. /** @hidden */
  103539. _getWorldMatrixDeterminant(): number;
  103540. /**
  103541. * Returns directly the latest state of the mesh World matrix.
  103542. * A Matrix is returned.
  103543. */
  103544. get worldMatrixFromCache(): Matrix;
  103545. /** @hidden */
  103546. _initCache(): void;
  103547. /** @hidden */
  103548. updateCache(force?: boolean): void;
  103549. /** @hidden */
  103550. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103551. /** @hidden */
  103552. _updateCache(ignoreParentClass?: boolean): void;
  103553. /** @hidden */
  103554. _isSynchronized(): boolean;
  103555. /** @hidden */
  103556. _markSyncedWithParent(): void;
  103557. /** @hidden */
  103558. isSynchronizedWithParent(): boolean;
  103559. /** @hidden */
  103560. isSynchronized(): boolean;
  103561. /**
  103562. * Is this node ready to be used/rendered
  103563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103564. * @return true if the node is ready
  103565. */
  103566. isReady(completeCheck?: boolean): boolean;
  103567. /**
  103568. * Is this node enabled?
  103569. * 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
  103570. * @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
  103571. * @return whether this node (and its parent) is enabled
  103572. */
  103573. isEnabled(checkAncestors?: boolean): boolean;
  103574. /** @hidden */
  103575. protected _syncParentEnabledState(): void;
  103576. /**
  103577. * Set the enabled state of this node
  103578. * @param value defines the new enabled state
  103579. */
  103580. setEnabled(value: boolean): void;
  103581. /**
  103582. * Is this node a descendant of the given node?
  103583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103584. * @param ancestor defines the parent node to inspect
  103585. * @returns a boolean indicating if this node is a descendant of the given node
  103586. */
  103587. isDescendantOf(ancestor: Node): boolean;
  103588. /** @hidden */
  103589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103590. /**
  103591. * Will return all nodes that have this node as ascendant
  103592. * @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
  103593. * @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
  103594. * @return all children nodes of all types
  103595. */
  103596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103597. /**
  103598. * Get all child-meshes of this node
  103599. * @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)
  103600. * @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
  103601. * @returns an array of AbstractMesh
  103602. */
  103603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103604. /**
  103605. * Get all direct children of this node
  103606. * @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
  103607. * @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)
  103608. * @returns an array of Node
  103609. */
  103610. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103611. /** @hidden */
  103612. _setReady(state: boolean): void;
  103613. /**
  103614. * Get an animation by name
  103615. * @param name defines the name of the animation to look for
  103616. * @returns null if not found else the requested animation
  103617. */
  103618. getAnimationByName(name: string): Nullable<Animation>;
  103619. /**
  103620. * Creates an animation range for this node
  103621. * @param name defines the name of the range
  103622. * @param from defines the starting key
  103623. * @param to defines the end key
  103624. */
  103625. createAnimationRange(name: string, from: number, to: number): void;
  103626. /**
  103627. * Delete a specific animation range
  103628. * @param name defines the name of the range to delete
  103629. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103630. */
  103631. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103632. /**
  103633. * Get an animation range by name
  103634. * @param name defines the name of the animation range to look for
  103635. * @returns null if not found else the requested animation range
  103636. */
  103637. getAnimationRange(name: string): Nullable<AnimationRange>;
  103638. /**
  103639. * Gets the list of all animation ranges defined on this node
  103640. * @returns an array
  103641. */
  103642. getAnimationRanges(): Nullable<AnimationRange>[];
  103643. /**
  103644. * Will start the animation sequence
  103645. * @param name defines the range frames for animation sequence
  103646. * @param loop defines if the animation should loop (false by default)
  103647. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103648. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103649. * @returns the object created for this animation. If range does not exist, it will return null
  103650. */
  103651. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103652. /**
  103653. * Serialize animation ranges into a JSON compatible object
  103654. * @returns serialization object
  103655. */
  103656. serializeAnimationRanges(): any;
  103657. /**
  103658. * Computes the world matrix of the node
  103659. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103660. * @returns the world matrix
  103661. */
  103662. computeWorldMatrix(force?: boolean): Matrix;
  103663. /**
  103664. * Releases resources associated with this node.
  103665. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103666. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103667. */
  103668. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103669. /**
  103670. * Parse animation range data from a serialization object and store them into a given node
  103671. * @param node defines where to store the animation ranges
  103672. * @param parsedNode defines the serialization object to read data from
  103673. * @param scene defines the hosting scene
  103674. */
  103675. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103676. /**
  103677. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103678. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103679. * @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
  103680. * @returns the new bounding vectors
  103681. */
  103682. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103683. min: Vector3;
  103684. max: Vector3;
  103685. };
  103686. }
  103687. }
  103688. declare module BABYLON {
  103689. /**
  103690. * @hidden
  103691. */
  103692. export class _IAnimationState {
  103693. key: number;
  103694. repeatCount: number;
  103695. workValue?: any;
  103696. loopMode?: number;
  103697. offsetValue?: any;
  103698. highLimitValue?: any;
  103699. }
  103700. /**
  103701. * Class used to store any kind of animation
  103702. */
  103703. export class Animation {
  103704. /**Name of the animation */
  103705. name: string;
  103706. /**Property to animate */
  103707. targetProperty: string;
  103708. /**The frames per second of the animation */
  103709. framePerSecond: number;
  103710. /**The data type of the animation */
  103711. dataType: number;
  103712. /**The loop mode of the animation */
  103713. loopMode?: number | undefined;
  103714. /**Specifies if blending should be enabled */
  103715. enableBlending?: boolean | undefined;
  103716. /**
  103717. * Use matrix interpolation instead of using direct key value when animating matrices
  103718. */
  103719. static AllowMatricesInterpolation: boolean;
  103720. /**
  103721. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103722. */
  103723. static AllowMatrixDecomposeForInterpolation: boolean;
  103724. /**
  103725. * Stores the key frames of the animation
  103726. */
  103727. private _keys;
  103728. /**
  103729. * Stores the easing function of the animation
  103730. */
  103731. private _easingFunction;
  103732. /**
  103733. * @hidden Internal use only
  103734. */
  103735. _runtimeAnimations: RuntimeAnimation[];
  103736. /**
  103737. * The set of event that will be linked to this animation
  103738. */
  103739. private _events;
  103740. /**
  103741. * Stores an array of target property paths
  103742. */
  103743. targetPropertyPath: string[];
  103744. /**
  103745. * Stores the blending speed of the animation
  103746. */
  103747. blendingSpeed: number;
  103748. /**
  103749. * Stores the animation ranges for the animation
  103750. */
  103751. private _ranges;
  103752. /**
  103753. * @hidden Internal use
  103754. */
  103755. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103756. /**
  103757. * Sets up an animation
  103758. * @param property The property to animate
  103759. * @param animationType The animation type to apply
  103760. * @param framePerSecond The frames per second of the animation
  103761. * @param easingFunction The easing function used in the animation
  103762. * @returns The created animation
  103763. */
  103764. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103765. /**
  103766. * Create and start an animation on a node
  103767. * @param name defines the name of the global animation that will be run on all nodes
  103768. * @param node defines the root node where the animation will take place
  103769. * @param targetProperty defines property to animate
  103770. * @param framePerSecond defines the number of frame per second yo use
  103771. * @param totalFrame defines the number of frames in total
  103772. * @param from defines the initial value
  103773. * @param to defines the final value
  103774. * @param loopMode defines which loop mode you want to use (off by default)
  103775. * @param easingFunction defines the easing function to use (linear by default)
  103776. * @param onAnimationEnd defines the callback to call when animation end
  103777. * @returns the animatable created for this animation
  103778. */
  103779. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103780. /**
  103781. * Create and start an animation on a node and its descendants
  103782. * @param name defines the name of the global animation that will be run on all nodes
  103783. * @param node defines the root node where the animation will take place
  103784. * @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
  103785. * @param targetProperty defines property to animate
  103786. * @param framePerSecond defines the number of frame per second to use
  103787. * @param totalFrame defines the number of frames in total
  103788. * @param from defines the initial value
  103789. * @param to defines the final value
  103790. * @param loopMode defines which loop mode you want to use (off by default)
  103791. * @param easingFunction defines the easing function to use (linear by default)
  103792. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103793. * @returns the list of animatables created for all nodes
  103794. * @example https://www.babylonjs-playground.com/#MH0VLI
  103795. */
  103796. 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[]>;
  103797. /**
  103798. * Creates a new animation, merges it with the existing animations and starts it
  103799. * @param name Name of the animation
  103800. * @param node Node which contains the scene that begins the animations
  103801. * @param targetProperty Specifies which property to animate
  103802. * @param framePerSecond The frames per second of the animation
  103803. * @param totalFrame The total number of frames
  103804. * @param from The frame at the beginning of the animation
  103805. * @param to The frame at the end of the animation
  103806. * @param loopMode Specifies the loop mode of the animation
  103807. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103808. * @param onAnimationEnd Callback to run once the animation is complete
  103809. * @returns Nullable animation
  103810. */
  103811. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103812. /**
  103813. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103814. * @param sourceAnimation defines the Animation containing keyframes to convert
  103815. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103816. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103817. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103818. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103819. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103820. */
  103821. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103822. /**
  103823. * Transition property of an host to the target Value
  103824. * @param property The property to transition
  103825. * @param targetValue The target Value of the property
  103826. * @param host The object where the property to animate belongs
  103827. * @param scene Scene used to run the animation
  103828. * @param frameRate Framerate (in frame/s) to use
  103829. * @param transition The transition type we want to use
  103830. * @param duration The duration of the animation, in milliseconds
  103831. * @param onAnimationEnd Callback trigger at the end of the animation
  103832. * @returns Nullable animation
  103833. */
  103834. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103835. /**
  103836. * Return the array of runtime animations currently using this animation
  103837. */
  103838. get runtimeAnimations(): RuntimeAnimation[];
  103839. /**
  103840. * Specifies if any of the runtime animations are currently running
  103841. */
  103842. get hasRunningRuntimeAnimations(): boolean;
  103843. /**
  103844. * Initializes the animation
  103845. * @param name Name of the animation
  103846. * @param targetProperty Property to animate
  103847. * @param framePerSecond The frames per second of the animation
  103848. * @param dataType The data type of the animation
  103849. * @param loopMode The loop mode of the animation
  103850. * @param enableBlending Specifies if blending should be enabled
  103851. */
  103852. constructor(
  103853. /**Name of the animation */
  103854. name: string,
  103855. /**Property to animate */
  103856. targetProperty: string,
  103857. /**The frames per second of the animation */
  103858. framePerSecond: number,
  103859. /**The data type of the animation */
  103860. dataType: number,
  103861. /**The loop mode of the animation */
  103862. loopMode?: number | undefined,
  103863. /**Specifies if blending should be enabled */
  103864. enableBlending?: boolean | undefined);
  103865. /**
  103866. * Converts the animation to a string
  103867. * @param fullDetails support for multiple levels of logging within scene loading
  103868. * @returns String form of the animation
  103869. */
  103870. toString(fullDetails?: boolean): string;
  103871. /**
  103872. * Add an event to this animation
  103873. * @param event Event to add
  103874. */
  103875. addEvent(event: AnimationEvent): void;
  103876. /**
  103877. * Remove all events found at the given frame
  103878. * @param frame The frame to remove events from
  103879. */
  103880. removeEvents(frame: number): void;
  103881. /**
  103882. * Retrieves all the events from the animation
  103883. * @returns Events from the animation
  103884. */
  103885. getEvents(): AnimationEvent[];
  103886. /**
  103887. * Creates an animation range
  103888. * @param name Name of the animation range
  103889. * @param from Starting frame of the animation range
  103890. * @param to Ending frame of the animation
  103891. */
  103892. createRange(name: string, from: number, to: number): void;
  103893. /**
  103894. * Deletes an animation range by name
  103895. * @param name Name of the animation range to delete
  103896. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103897. */
  103898. deleteRange(name: string, deleteFrames?: boolean): void;
  103899. /**
  103900. * Gets the animation range by name, or null if not defined
  103901. * @param name Name of the animation range
  103902. * @returns Nullable animation range
  103903. */
  103904. getRange(name: string): Nullable<AnimationRange>;
  103905. /**
  103906. * Gets the key frames from the animation
  103907. * @returns The key frames of the animation
  103908. */
  103909. getKeys(): Array<IAnimationKey>;
  103910. /**
  103911. * Gets the highest frame rate of the animation
  103912. * @returns Highest frame rate of the animation
  103913. */
  103914. getHighestFrame(): number;
  103915. /**
  103916. * Gets the easing function of the animation
  103917. * @returns Easing function of the animation
  103918. */
  103919. getEasingFunction(): IEasingFunction;
  103920. /**
  103921. * Sets the easing function of the animation
  103922. * @param easingFunction A custom mathematical formula for animation
  103923. */
  103924. setEasingFunction(easingFunction: EasingFunction): void;
  103925. /**
  103926. * Interpolates a scalar linearly
  103927. * @param startValue Start value of the animation curve
  103928. * @param endValue End value of the animation curve
  103929. * @param gradient Scalar amount to interpolate
  103930. * @returns Interpolated scalar value
  103931. */
  103932. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103933. /**
  103934. * Interpolates a scalar cubically
  103935. * @param startValue Start value of the animation curve
  103936. * @param outTangent End tangent of the animation
  103937. * @param endValue End value of the animation curve
  103938. * @param inTangent Start tangent of the animation curve
  103939. * @param gradient Scalar amount to interpolate
  103940. * @returns Interpolated scalar value
  103941. */
  103942. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103943. /**
  103944. * Interpolates a quaternion using a spherical linear interpolation
  103945. * @param startValue Start value of the animation curve
  103946. * @param endValue End value of the animation curve
  103947. * @param gradient Scalar amount to interpolate
  103948. * @returns Interpolated quaternion value
  103949. */
  103950. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103951. /**
  103952. * Interpolates a quaternion cubically
  103953. * @param startValue Start value of the animation curve
  103954. * @param outTangent End tangent of the animation curve
  103955. * @param endValue End value of the animation curve
  103956. * @param inTangent Start tangent of the animation curve
  103957. * @param gradient Scalar amount to interpolate
  103958. * @returns Interpolated quaternion value
  103959. */
  103960. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103961. /**
  103962. * Interpolates a Vector3 linearl
  103963. * @param startValue Start value of the animation curve
  103964. * @param endValue End value of the animation curve
  103965. * @param gradient Scalar amount to interpolate
  103966. * @returns Interpolated scalar value
  103967. */
  103968. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103969. /**
  103970. * Interpolates a Vector3 cubically
  103971. * @param startValue Start value of the animation curve
  103972. * @param outTangent End tangent of the animation
  103973. * @param endValue End value of the animation curve
  103974. * @param inTangent Start tangent of the animation curve
  103975. * @param gradient Scalar amount to interpolate
  103976. * @returns InterpolatedVector3 value
  103977. */
  103978. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103979. /**
  103980. * Interpolates a Vector2 linearly
  103981. * @param startValue Start value of the animation curve
  103982. * @param endValue End value of the animation curve
  103983. * @param gradient Scalar amount to interpolate
  103984. * @returns Interpolated Vector2 value
  103985. */
  103986. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103987. /**
  103988. * Interpolates a Vector2 cubically
  103989. * @param startValue Start value of the animation curve
  103990. * @param outTangent End tangent of the animation
  103991. * @param endValue End value of the animation curve
  103992. * @param inTangent Start tangent of the animation curve
  103993. * @param gradient Scalar amount to interpolate
  103994. * @returns Interpolated Vector2 value
  103995. */
  103996. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  103997. /**
  103998. * Interpolates a size linearly
  103999. * @param startValue Start value of the animation curve
  104000. * @param endValue End value of the animation curve
  104001. * @param gradient Scalar amount to interpolate
  104002. * @returns Interpolated Size value
  104003. */
  104004. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104005. /**
  104006. * Interpolates a Color3 linearly
  104007. * @param startValue Start value of the animation curve
  104008. * @param endValue End value of the animation curve
  104009. * @param gradient Scalar amount to interpolate
  104010. * @returns Interpolated Color3 value
  104011. */
  104012. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104013. /**
  104014. * Interpolates a Color4 linearly
  104015. * @param startValue Start value of the animation curve
  104016. * @param endValue End value of the animation curve
  104017. * @param gradient Scalar amount to interpolate
  104018. * @returns Interpolated Color3 value
  104019. */
  104020. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104021. /**
  104022. * @hidden Internal use only
  104023. */
  104024. _getKeyValue(value: any): any;
  104025. /**
  104026. * @hidden Internal use only
  104027. */
  104028. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104029. /**
  104030. * Defines the function to use to interpolate matrices
  104031. * @param startValue defines the start matrix
  104032. * @param endValue defines the end matrix
  104033. * @param gradient defines the gradient between both matrices
  104034. * @param result defines an optional target matrix where to store the interpolation
  104035. * @returns the interpolated matrix
  104036. */
  104037. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104038. /**
  104039. * Makes a copy of the animation
  104040. * @returns Cloned animation
  104041. */
  104042. clone(): Animation;
  104043. /**
  104044. * Sets the key frames of the animation
  104045. * @param values The animation key frames to set
  104046. */
  104047. setKeys(values: Array<IAnimationKey>): void;
  104048. /**
  104049. * Serializes the animation to an object
  104050. * @returns Serialized object
  104051. */
  104052. serialize(): any;
  104053. /**
  104054. * Float animation type
  104055. */
  104056. static readonly ANIMATIONTYPE_FLOAT: number;
  104057. /**
  104058. * Vector3 animation type
  104059. */
  104060. static readonly ANIMATIONTYPE_VECTOR3: number;
  104061. /**
  104062. * Quaternion animation type
  104063. */
  104064. static readonly ANIMATIONTYPE_QUATERNION: number;
  104065. /**
  104066. * Matrix animation type
  104067. */
  104068. static readonly ANIMATIONTYPE_MATRIX: number;
  104069. /**
  104070. * Color3 animation type
  104071. */
  104072. static readonly ANIMATIONTYPE_COLOR3: number;
  104073. /**
  104074. * Color3 animation type
  104075. */
  104076. static readonly ANIMATIONTYPE_COLOR4: number;
  104077. /**
  104078. * Vector2 animation type
  104079. */
  104080. static readonly ANIMATIONTYPE_VECTOR2: number;
  104081. /**
  104082. * Size animation type
  104083. */
  104084. static readonly ANIMATIONTYPE_SIZE: number;
  104085. /**
  104086. * Relative Loop Mode
  104087. */
  104088. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104089. /**
  104090. * Cycle Loop Mode
  104091. */
  104092. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104093. /**
  104094. * Constant Loop Mode
  104095. */
  104096. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104097. /** @hidden */
  104098. static _UniversalLerp(left: any, right: any, amount: number): any;
  104099. /**
  104100. * Parses an animation object and creates an animation
  104101. * @param parsedAnimation Parsed animation object
  104102. * @returns Animation object
  104103. */
  104104. static Parse(parsedAnimation: any): Animation;
  104105. /**
  104106. * Appends the serialized animations from the source animations
  104107. * @param source Source containing the animations
  104108. * @param destination Target to store the animations
  104109. */
  104110. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104111. }
  104112. }
  104113. declare module BABYLON {
  104114. /**
  104115. * Interface containing an array of animations
  104116. */
  104117. export interface IAnimatable {
  104118. /**
  104119. * Array of animations
  104120. */
  104121. animations: Nullable<Array<Animation>>;
  104122. }
  104123. }
  104124. declare module BABYLON {
  104125. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104126. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104127. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104128. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104129. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104130. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104131. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104132. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104133. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104134. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104135. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104136. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104137. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104138. /**
  104139. * Decorator used to define property that can be serialized as reference to a camera
  104140. * @param sourceName defines the name of the property to decorate
  104141. */
  104142. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104143. /**
  104144. * Class used to help serialization objects
  104145. */
  104146. export class SerializationHelper {
  104147. /** @hidden */
  104148. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104149. /** @hidden */
  104150. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104151. /** @hidden */
  104152. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104153. /** @hidden */
  104154. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104155. /**
  104156. * Appends the serialized animations from the source animations
  104157. * @param source Source containing the animations
  104158. * @param destination Target to store the animations
  104159. */
  104160. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104161. /**
  104162. * Static function used to serialized a specific entity
  104163. * @param entity defines the entity to serialize
  104164. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104165. * @returns a JSON compatible object representing the serialization of the entity
  104166. */
  104167. static Serialize<T>(entity: T, serializationObject?: any): any;
  104168. /**
  104169. * Creates a new entity from a serialization data object
  104170. * @param creationFunction defines a function used to instanciated the new entity
  104171. * @param source defines the source serialization data
  104172. * @param scene defines the hosting scene
  104173. * @param rootUrl defines the root url for resources
  104174. * @returns a new entity
  104175. */
  104176. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104177. /**
  104178. * Clones an object
  104179. * @param creationFunction defines the function used to instanciate the new object
  104180. * @param source defines the source object
  104181. * @returns the cloned object
  104182. */
  104183. static Clone<T>(creationFunction: () => T, source: T): T;
  104184. /**
  104185. * Instanciates a new object based on a source one (some data will be shared between both object)
  104186. * @param creationFunction defines the function used to instanciate the new object
  104187. * @param source defines the source object
  104188. * @returns the new object
  104189. */
  104190. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104191. }
  104192. }
  104193. declare module BABYLON {
  104194. /**
  104195. * Class used to manipulate GUIDs
  104196. */
  104197. export class GUID {
  104198. /**
  104199. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104200. * Be aware Math.random() could cause collisions, but:
  104201. * "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"
  104202. * @returns a pseudo random id
  104203. */
  104204. static RandomId(): string;
  104205. }
  104206. }
  104207. declare module BABYLON {
  104208. /**
  104209. * Base class of all the textures in babylon.
  104210. * It groups all the common properties the materials, post process, lights... might need
  104211. * in order to make a correct use of the texture.
  104212. */
  104213. export class BaseTexture implements IAnimatable {
  104214. /**
  104215. * Default anisotropic filtering level for the application.
  104216. * It is set to 4 as a good tradeoff between perf and quality.
  104217. */
  104218. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104219. /**
  104220. * Gets or sets the unique id of the texture
  104221. */
  104222. uniqueId: number;
  104223. /**
  104224. * Define the name of the texture.
  104225. */
  104226. name: string;
  104227. /**
  104228. * Gets or sets an object used to store user defined information.
  104229. */
  104230. metadata: any;
  104231. /**
  104232. * For internal use only. Please do not use.
  104233. */
  104234. reservedDataStore: any;
  104235. private _hasAlpha;
  104236. /**
  104237. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104238. */
  104239. set hasAlpha(value: boolean);
  104240. get hasAlpha(): boolean;
  104241. /**
  104242. * Defines if the alpha value should be determined via the rgb values.
  104243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104244. */
  104245. getAlphaFromRGB: boolean;
  104246. /**
  104247. * Intensity or strength of the texture.
  104248. * It is commonly used by materials to fine tune the intensity of the texture
  104249. */
  104250. level: number;
  104251. /**
  104252. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104253. * This is part of the texture as textures usually maps to one uv set.
  104254. */
  104255. coordinatesIndex: number;
  104256. private _coordinatesMode;
  104257. /**
  104258. * How a texture is mapped.
  104259. *
  104260. * | Value | Type | Description |
  104261. * | ----- | ----------------------------------- | ----------- |
  104262. * | 0 | EXPLICIT_MODE | |
  104263. * | 1 | SPHERICAL_MODE | |
  104264. * | 2 | PLANAR_MODE | |
  104265. * | 3 | CUBIC_MODE | |
  104266. * | 4 | PROJECTION_MODE | |
  104267. * | 5 | SKYBOX_MODE | |
  104268. * | 6 | INVCUBIC_MODE | |
  104269. * | 7 | EQUIRECTANGULAR_MODE | |
  104270. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104271. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104272. */
  104273. set coordinatesMode(value: number);
  104274. get coordinatesMode(): number;
  104275. /**
  104276. * | Value | Type | Description |
  104277. * | ----- | ------------------ | ----------- |
  104278. * | 0 | CLAMP_ADDRESSMODE | |
  104279. * | 1 | WRAP_ADDRESSMODE | |
  104280. * | 2 | MIRROR_ADDRESSMODE | |
  104281. */
  104282. wrapU: number;
  104283. /**
  104284. * | Value | Type | Description |
  104285. * | ----- | ------------------ | ----------- |
  104286. * | 0 | CLAMP_ADDRESSMODE | |
  104287. * | 1 | WRAP_ADDRESSMODE | |
  104288. * | 2 | MIRROR_ADDRESSMODE | |
  104289. */
  104290. wrapV: number;
  104291. /**
  104292. * | Value | Type | Description |
  104293. * | ----- | ------------------ | ----------- |
  104294. * | 0 | CLAMP_ADDRESSMODE | |
  104295. * | 1 | WRAP_ADDRESSMODE | |
  104296. * | 2 | MIRROR_ADDRESSMODE | |
  104297. */
  104298. wrapR: number;
  104299. /**
  104300. * With compliant hardware and browser (supporting anisotropic filtering)
  104301. * this defines the level of anisotropic filtering in the texture.
  104302. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104303. */
  104304. anisotropicFilteringLevel: number;
  104305. /**
  104306. * Define if the texture is a cube texture or if false a 2d texture.
  104307. */
  104308. get isCube(): boolean;
  104309. set isCube(value: boolean);
  104310. /**
  104311. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104312. */
  104313. get is3D(): boolean;
  104314. set is3D(value: boolean);
  104315. /**
  104316. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104317. */
  104318. get is2DArray(): boolean;
  104319. set is2DArray(value: boolean);
  104320. /**
  104321. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104322. * HDR texture are usually stored in linear space.
  104323. * This only impacts the PBR and Background materials
  104324. */
  104325. gammaSpace: boolean;
  104326. /**
  104327. * Gets or sets whether or not the texture contains RGBD data.
  104328. */
  104329. get isRGBD(): boolean;
  104330. set isRGBD(value: boolean);
  104331. /**
  104332. * Is Z inverted in the texture (useful in a cube texture).
  104333. */
  104334. invertZ: boolean;
  104335. /**
  104336. * Are mip maps generated for this texture or not.
  104337. */
  104338. get noMipmap(): boolean;
  104339. /**
  104340. * @hidden
  104341. */
  104342. lodLevelInAlpha: boolean;
  104343. /**
  104344. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104345. */
  104346. get lodGenerationOffset(): number;
  104347. set lodGenerationOffset(value: number);
  104348. /**
  104349. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104350. */
  104351. get lodGenerationScale(): number;
  104352. set lodGenerationScale(value: number);
  104353. /**
  104354. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104355. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104356. * average roughness values.
  104357. */
  104358. get linearSpecularLOD(): boolean;
  104359. set linearSpecularLOD(value: boolean);
  104360. /**
  104361. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104362. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104363. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104364. */
  104365. get irradianceTexture(): Nullable<BaseTexture>;
  104366. set irradianceTexture(value: Nullable<BaseTexture>);
  104367. /**
  104368. * Define if the texture is a render target.
  104369. */
  104370. isRenderTarget: boolean;
  104371. /**
  104372. * Define the unique id of the texture in the scene.
  104373. */
  104374. get uid(): string;
  104375. /**
  104376. * Return a string representation of the texture.
  104377. * @returns the texture as a string
  104378. */
  104379. toString(): string;
  104380. /**
  104381. * Get the class name of the texture.
  104382. * @returns "BaseTexture"
  104383. */
  104384. getClassName(): string;
  104385. /**
  104386. * Define the list of animation attached to the texture.
  104387. */
  104388. animations: Animation[];
  104389. /**
  104390. * An event triggered when the texture is disposed.
  104391. */
  104392. onDisposeObservable: Observable<BaseTexture>;
  104393. private _onDisposeObserver;
  104394. /**
  104395. * Callback triggered when the texture has been disposed.
  104396. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104397. */
  104398. set onDispose(callback: () => void);
  104399. /**
  104400. * Define the current state of the loading sequence when in delayed load mode.
  104401. */
  104402. delayLoadState: number;
  104403. private _scene;
  104404. /** @hidden */
  104405. _texture: Nullable<InternalTexture>;
  104406. private _uid;
  104407. /**
  104408. * Define if the texture is preventinga material to render or not.
  104409. * If not and the texture is not ready, the engine will use a default black texture instead.
  104410. */
  104411. get isBlocking(): boolean;
  104412. /**
  104413. * Instantiates a new BaseTexture.
  104414. * Base class of all the textures in babylon.
  104415. * It groups all the common properties the materials, post process, lights... might need
  104416. * in order to make a correct use of the texture.
  104417. * @param scene Define the scene the texture blongs to
  104418. */
  104419. constructor(scene: Nullable<Scene>);
  104420. /**
  104421. * Get the scene the texture belongs to.
  104422. * @returns the scene or null if undefined
  104423. */
  104424. getScene(): Nullable<Scene>;
  104425. /**
  104426. * Get the texture transform matrix used to offset tile the texture for istance.
  104427. * @returns the transformation matrix
  104428. */
  104429. getTextureMatrix(): Matrix;
  104430. /**
  104431. * Get the texture reflection matrix used to rotate/transform the reflection.
  104432. * @returns the reflection matrix
  104433. */
  104434. getReflectionTextureMatrix(): Matrix;
  104435. /**
  104436. * Get the underlying lower level texture from Babylon.
  104437. * @returns the insternal texture
  104438. */
  104439. getInternalTexture(): Nullable<InternalTexture>;
  104440. /**
  104441. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104442. * @returns true if ready or not blocking
  104443. */
  104444. isReadyOrNotBlocking(): boolean;
  104445. /**
  104446. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104447. * @returns true if fully ready
  104448. */
  104449. isReady(): boolean;
  104450. private _cachedSize;
  104451. /**
  104452. * Get the size of the texture.
  104453. * @returns the texture size.
  104454. */
  104455. getSize(): ISize;
  104456. /**
  104457. * Get the base size of the texture.
  104458. * It can be different from the size if the texture has been resized for POT for instance
  104459. * @returns the base size
  104460. */
  104461. getBaseSize(): ISize;
  104462. /**
  104463. * Update the sampling mode of the texture.
  104464. * Default is Trilinear mode.
  104465. *
  104466. * | Value | Type | Description |
  104467. * | ----- | ------------------ | ----------- |
  104468. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104469. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104470. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104471. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104472. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104473. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104474. * | 7 | NEAREST_LINEAR | |
  104475. * | 8 | NEAREST_NEAREST | |
  104476. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104477. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104478. * | 11 | LINEAR_LINEAR | |
  104479. * | 12 | LINEAR_NEAREST | |
  104480. *
  104481. * > _mag_: magnification filter (close to the viewer)
  104482. * > _min_: minification filter (far from the viewer)
  104483. * > _mip_: filter used between mip map levels
  104484. *@param samplingMode Define the new sampling mode of the texture
  104485. */
  104486. updateSamplingMode(samplingMode: number): void;
  104487. /**
  104488. * Scales the texture if is `canRescale()`
  104489. * @param ratio the resize factor we want to use to rescale
  104490. */
  104491. scale(ratio: number): void;
  104492. /**
  104493. * Get if the texture can rescale.
  104494. */
  104495. get canRescale(): boolean;
  104496. /** @hidden */
  104497. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104498. /** @hidden */
  104499. _rebuild(): void;
  104500. /**
  104501. * Triggers the load sequence in delayed load mode.
  104502. */
  104503. delayLoad(): void;
  104504. /**
  104505. * Clones the texture.
  104506. * @returns the cloned texture
  104507. */
  104508. clone(): Nullable<BaseTexture>;
  104509. /**
  104510. * Get the texture underlying type (INT, FLOAT...)
  104511. */
  104512. get textureType(): number;
  104513. /**
  104514. * Get the texture underlying format (RGB, RGBA...)
  104515. */
  104516. get textureFormat(): number;
  104517. /**
  104518. * Indicates that textures need to be re-calculated for all materials
  104519. */
  104520. protected _markAllSubMeshesAsTexturesDirty(): void;
  104521. /**
  104522. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104523. * This will returns an RGBA array buffer containing either in values (0-255) or
  104524. * float values (0-1) depending of the underlying buffer type.
  104525. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104526. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104527. * @param buffer defines a user defined buffer to fill with data (can be null)
  104528. * @returns The Array buffer containing the pixels data.
  104529. */
  104530. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104531. /**
  104532. * Release and destroy the underlying lower level texture aka internalTexture.
  104533. */
  104534. releaseInternalTexture(): void;
  104535. /** @hidden */
  104536. get _lodTextureHigh(): Nullable<BaseTexture>;
  104537. /** @hidden */
  104538. get _lodTextureMid(): Nullable<BaseTexture>;
  104539. /** @hidden */
  104540. get _lodTextureLow(): Nullable<BaseTexture>;
  104541. /**
  104542. * Dispose the texture and release its associated resources.
  104543. */
  104544. dispose(): void;
  104545. /**
  104546. * Serialize the texture into a JSON representation that can be parsed later on.
  104547. * @returns the JSON representation of the texture
  104548. */
  104549. serialize(): any;
  104550. /**
  104551. * Helper function to be called back once a list of texture contains only ready textures.
  104552. * @param textures Define the list of textures to wait for
  104553. * @param callback Define the callback triggered once the entire list will be ready
  104554. */
  104555. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104556. }
  104557. }
  104558. declare module BABYLON {
  104559. /**
  104560. * Options to be used when creating an effect.
  104561. */
  104562. export interface IEffectCreationOptions {
  104563. /**
  104564. * Atrributes that will be used in the shader.
  104565. */
  104566. attributes: string[];
  104567. /**
  104568. * Uniform varible names that will be set in the shader.
  104569. */
  104570. uniformsNames: string[];
  104571. /**
  104572. * Uniform buffer variable names that will be set in the shader.
  104573. */
  104574. uniformBuffersNames: string[];
  104575. /**
  104576. * Sampler texture variable names that will be set in the shader.
  104577. */
  104578. samplers: string[];
  104579. /**
  104580. * Define statements that will be set in the shader.
  104581. */
  104582. defines: any;
  104583. /**
  104584. * Possible fallbacks for this effect to improve performance when needed.
  104585. */
  104586. fallbacks: Nullable<IEffectFallbacks>;
  104587. /**
  104588. * Callback that will be called when the shader is compiled.
  104589. */
  104590. onCompiled: Nullable<(effect: Effect) => void>;
  104591. /**
  104592. * Callback that will be called if an error occurs during shader compilation.
  104593. */
  104594. onError: Nullable<(effect: Effect, errors: string) => void>;
  104595. /**
  104596. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104597. */
  104598. indexParameters?: any;
  104599. /**
  104600. * Max number of lights that can be used in the shader.
  104601. */
  104602. maxSimultaneousLights?: number;
  104603. /**
  104604. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104605. */
  104606. transformFeedbackVaryings?: Nullable<string[]>;
  104607. }
  104608. /**
  104609. * Effect containing vertex and fragment shader that can be executed on an object.
  104610. */
  104611. export class Effect implements IDisposable {
  104612. /**
  104613. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104614. */
  104615. static ShadersRepository: string;
  104616. /**
  104617. * Enable logging of the shader code when a compilation error occurs
  104618. */
  104619. static LogShaderCodeOnCompilationError: boolean;
  104620. /**
  104621. * Name of the effect.
  104622. */
  104623. name: any;
  104624. /**
  104625. * String container all the define statements that should be set on the shader.
  104626. */
  104627. defines: string;
  104628. /**
  104629. * Callback that will be called when the shader is compiled.
  104630. */
  104631. onCompiled: Nullable<(effect: Effect) => void>;
  104632. /**
  104633. * Callback that will be called if an error occurs during shader compilation.
  104634. */
  104635. onError: Nullable<(effect: Effect, errors: string) => void>;
  104636. /**
  104637. * Callback that will be called when effect is bound.
  104638. */
  104639. onBind: Nullable<(effect: Effect) => void>;
  104640. /**
  104641. * Unique ID of the effect.
  104642. */
  104643. uniqueId: number;
  104644. /**
  104645. * Observable that will be called when the shader is compiled.
  104646. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104647. */
  104648. onCompileObservable: Observable<Effect>;
  104649. /**
  104650. * Observable that will be called if an error occurs during shader compilation.
  104651. */
  104652. onErrorObservable: Observable<Effect>;
  104653. /** @hidden */
  104654. _onBindObservable: Nullable<Observable<Effect>>;
  104655. /**
  104656. * @hidden
  104657. * Specifies if the effect was previously ready
  104658. */
  104659. _wasPreviouslyReady: boolean;
  104660. /**
  104661. * Observable that will be called when effect is bound.
  104662. */
  104663. get onBindObservable(): Observable<Effect>;
  104664. /** @hidden */
  104665. _bonesComputationForcedToCPU: boolean;
  104666. private static _uniqueIdSeed;
  104667. private _engine;
  104668. private _uniformBuffersNames;
  104669. private _uniformsNames;
  104670. private _samplerList;
  104671. private _samplers;
  104672. private _isReady;
  104673. private _compilationError;
  104674. private _allFallbacksProcessed;
  104675. private _attributesNames;
  104676. private _attributes;
  104677. private _attributeLocationByName;
  104678. private _uniforms;
  104679. /**
  104680. * Key for the effect.
  104681. * @hidden
  104682. */
  104683. _key: string;
  104684. private _indexParameters;
  104685. private _fallbacks;
  104686. private _vertexSourceCode;
  104687. private _fragmentSourceCode;
  104688. private _vertexSourceCodeOverride;
  104689. private _fragmentSourceCodeOverride;
  104690. private _transformFeedbackVaryings;
  104691. /**
  104692. * Compiled shader to webGL program.
  104693. * @hidden
  104694. */
  104695. _pipelineContext: Nullable<IPipelineContext>;
  104696. private _valueCache;
  104697. private static _baseCache;
  104698. /**
  104699. * Instantiates an effect.
  104700. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104701. * @param baseName Name of the effect.
  104702. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104703. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104704. * @param samplers List of sampler variables that will be passed to the shader.
  104705. * @param engine Engine to be used to render the effect
  104706. * @param defines Define statements to be added to the shader.
  104707. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104708. * @param onCompiled Callback that will be called when the shader is compiled.
  104709. * @param onError Callback that will be called if an error occurs during shader compilation.
  104710. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104711. */
  104712. 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);
  104713. private _useFinalCode;
  104714. /**
  104715. * Unique key for this effect
  104716. */
  104717. get key(): string;
  104718. /**
  104719. * If the effect has been compiled and prepared.
  104720. * @returns if the effect is compiled and prepared.
  104721. */
  104722. isReady(): boolean;
  104723. private _isReadyInternal;
  104724. /**
  104725. * The engine the effect was initialized with.
  104726. * @returns the engine.
  104727. */
  104728. getEngine(): Engine;
  104729. /**
  104730. * The pipeline context for this effect
  104731. * @returns the associated pipeline context
  104732. */
  104733. getPipelineContext(): Nullable<IPipelineContext>;
  104734. /**
  104735. * The set of names of attribute variables for the shader.
  104736. * @returns An array of attribute names.
  104737. */
  104738. getAttributesNames(): string[];
  104739. /**
  104740. * Returns the attribute at the given index.
  104741. * @param index The index of the attribute.
  104742. * @returns The location of the attribute.
  104743. */
  104744. getAttributeLocation(index: number): number;
  104745. /**
  104746. * Returns the attribute based on the name of the variable.
  104747. * @param name of the attribute to look up.
  104748. * @returns the attribute location.
  104749. */
  104750. getAttributeLocationByName(name: string): number;
  104751. /**
  104752. * The number of attributes.
  104753. * @returns the numnber of attributes.
  104754. */
  104755. getAttributesCount(): number;
  104756. /**
  104757. * Gets the index of a uniform variable.
  104758. * @param uniformName of the uniform to look up.
  104759. * @returns the index.
  104760. */
  104761. getUniformIndex(uniformName: string): number;
  104762. /**
  104763. * Returns the attribute based on the name of the variable.
  104764. * @param uniformName of the uniform to look up.
  104765. * @returns the location of the uniform.
  104766. */
  104767. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104768. /**
  104769. * Returns an array of sampler variable names
  104770. * @returns The array of sampler variable neames.
  104771. */
  104772. getSamplers(): string[];
  104773. /**
  104774. * The error from the last compilation.
  104775. * @returns the error string.
  104776. */
  104777. getCompilationError(): string;
  104778. /**
  104779. * Gets a boolean indicating that all fallbacks were used during compilation
  104780. * @returns true if all fallbacks were used
  104781. */
  104782. allFallbacksProcessed(): boolean;
  104783. /**
  104784. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104785. * @param func The callback to be used.
  104786. */
  104787. executeWhenCompiled(func: (effect: Effect) => void): void;
  104788. private _checkIsReady;
  104789. private _loadShader;
  104790. /**
  104791. * Recompiles the webGL program
  104792. * @param vertexSourceCode The source code for the vertex shader.
  104793. * @param fragmentSourceCode The source code for the fragment shader.
  104794. * @param onCompiled Callback called when completed.
  104795. * @param onError Callback called on error.
  104796. * @hidden
  104797. */
  104798. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104799. /**
  104800. * Prepares the effect
  104801. * @hidden
  104802. */
  104803. _prepareEffect(): void;
  104804. private _getShaderCodeAndErrorLine;
  104805. private _processCompilationErrors;
  104806. /**
  104807. * Checks if the effect is supported. (Must be called after compilation)
  104808. */
  104809. get isSupported(): boolean;
  104810. /**
  104811. * Binds a texture to the engine to be used as output of the shader.
  104812. * @param channel Name of the output variable.
  104813. * @param texture Texture to bind.
  104814. * @hidden
  104815. */
  104816. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104817. /**
  104818. * Sets a texture on the engine to be used in the shader.
  104819. * @param channel Name of the sampler variable.
  104820. * @param texture Texture to set.
  104821. */
  104822. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104823. /**
  104824. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104825. * @param channel Name of the sampler variable.
  104826. * @param texture Texture to set.
  104827. */
  104828. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104829. /**
  104830. * Sets an array of textures on the engine to be used in the shader.
  104831. * @param channel Name of the variable.
  104832. * @param textures Textures to set.
  104833. */
  104834. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104835. /**
  104836. * 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)
  104837. * @param channel Name of the sampler variable.
  104838. * @param postProcess Post process to get the input texture from.
  104839. */
  104840. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104841. /**
  104842. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104843. * 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)
  104844. * @param channel Name of the sampler variable.
  104845. * @param postProcess Post process to get the output texture from.
  104846. */
  104847. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104848. /** @hidden */
  104849. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104850. /** @hidden */
  104851. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104852. /** @hidden */
  104853. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104854. /** @hidden */
  104855. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104856. /**
  104857. * Binds a buffer to a uniform.
  104858. * @param buffer Buffer to bind.
  104859. * @param name Name of the uniform variable to bind to.
  104860. */
  104861. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104862. /**
  104863. * Binds block to a uniform.
  104864. * @param blockName Name of the block to bind.
  104865. * @param index Index to bind.
  104866. */
  104867. bindUniformBlock(blockName: string, index: number): void;
  104868. /**
  104869. * Sets an interger value on a uniform variable.
  104870. * @param uniformName Name of the variable.
  104871. * @param value Value to be set.
  104872. * @returns this effect.
  104873. */
  104874. setInt(uniformName: string, value: number): Effect;
  104875. /**
  104876. * Sets an int array on a uniform variable.
  104877. * @param uniformName Name of the variable.
  104878. * @param array array to be set.
  104879. * @returns this effect.
  104880. */
  104881. setIntArray(uniformName: string, array: Int32Array): Effect;
  104882. /**
  104883. * 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)
  104884. * @param uniformName Name of the variable.
  104885. * @param array array to be set.
  104886. * @returns this effect.
  104887. */
  104888. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104889. /**
  104890. * 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)
  104891. * @param uniformName Name of the variable.
  104892. * @param array array to be set.
  104893. * @returns this effect.
  104894. */
  104895. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104896. /**
  104897. * 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)
  104898. * @param uniformName Name of the variable.
  104899. * @param array array to be set.
  104900. * @returns this effect.
  104901. */
  104902. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104903. /**
  104904. * Sets an float array on a uniform variable.
  104905. * @param uniformName Name of the variable.
  104906. * @param array array to be set.
  104907. * @returns this effect.
  104908. */
  104909. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104910. /**
  104911. * 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)
  104912. * @param uniformName Name of the variable.
  104913. * @param array array to be set.
  104914. * @returns this effect.
  104915. */
  104916. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104917. /**
  104918. * 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)
  104919. * @param uniformName Name of the variable.
  104920. * @param array array to be set.
  104921. * @returns this effect.
  104922. */
  104923. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104924. /**
  104925. * 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)
  104926. * @param uniformName Name of the variable.
  104927. * @param array array to be set.
  104928. * @returns this effect.
  104929. */
  104930. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104931. /**
  104932. * Sets an array on a uniform variable.
  104933. * @param uniformName Name of the variable.
  104934. * @param array array to be set.
  104935. * @returns this effect.
  104936. */
  104937. setArray(uniformName: string, array: number[]): Effect;
  104938. /**
  104939. * 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)
  104940. * @param uniformName Name of the variable.
  104941. * @param array array to be set.
  104942. * @returns this effect.
  104943. */
  104944. setArray2(uniformName: string, array: number[]): Effect;
  104945. /**
  104946. * 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)
  104947. * @param uniformName Name of the variable.
  104948. * @param array array to be set.
  104949. * @returns this effect.
  104950. */
  104951. setArray3(uniformName: string, array: number[]): Effect;
  104952. /**
  104953. * 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)
  104954. * @param uniformName Name of the variable.
  104955. * @param array array to be set.
  104956. * @returns this effect.
  104957. */
  104958. setArray4(uniformName: string, array: number[]): Effect;
  104959. /**
  104960. * Sets matrices on a uniform variable.
  104961. * @param uniformName Name of the variable.
  104962. * @param matrices matrices to be set.
  104963. * @returns this effect.
  104964. */
  104965. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104966. /**
  104967. * Sets matrix on a uniform variable.
  104968. * @param uniformName Name of the variable.
  104969. * @param matrix matrix to be set.
  104970. * @returns this effect.
  104971. */
  104972. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104973. /**
  104974. * 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)
  104975. * @param uniformName Name of the variable.
  104976. * @param matrix matrix to be set.
  104977. * @returns this effect.
  104978. */
  104979. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104980. /**
  104981. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104982. * @param uniformName Name of the variable.
  104983. * @param matrix matrix to be set.
  104984. * @returns this effect.
  104985. */
  104986. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104987. /**
  104988. * Sets a float on a uniform variable.
  104989. * @param uniformName Name of the variable.
  104990. * @param value value to be set.
  104991. * @returns this effect.
  104992. */
  104993. setFloat(uniformName: string, value: number): Effect;
  104994. /**
  104995. * Sets a boolean on a uniform variable.
  104996. * @param uniformName Name of the variable.
  104997. * @param bool value to be set.
  104998. * @returns this effect.
  104999. */
  105000. setBool(uniformName: string, bool: boolean): Effect;
  105001. /**
  105002. * Sets a Vector2 on a uniform variable.
  105003. * @param uniformName Name of the variable.
  105004. * @param vector2 vector2 to be set.
  105005. * @returns this effect.
  105006. */
  105007. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105008. /**
  105009. * Sets a float2 on a uniform variable.
  105010. * @param uniformName Name of the variable.
  105011. * @param x First float in float2.
  105012. * @param y Second float in float2.
  105013. * @returns this effect.
  105014. */
  105015. setFloat2(uniformName: string, x: number, y: number): Effect;
  105016. /**
  105017. * Sets a Vector3 on a uniform variable.
  105018. * @param uniformName Name of the variable.
  105019. * @param vector3 Value to be set.
  105020. * @returns this effect.
  105021. */
  105022. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105023. /**
  105024. * Sets a float3 on a uniform variable.
  105025. * @param uniformName Name of the variable.
  105026. * @param x First float in float3.
  105027. * @param y Second float in float3.
  105028. * @param z Third float in float3.
  105029. * @returns this effect.
  105030. */
  105031. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105032. /**
  105033. * Sets a Vector4 on a uniform variable.
  105034. * @param uniformName Name of the variable.
  105035. * @param vector4 Value to be set.
  105036. * @returns this effect.
  105037. */
  105038. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105039. /**
  105040. * Sets a float4 on a uniform variable.
  105041. * @param uniformName Name of the variable.
  105042. * @param x First float in float4.
  105043. * @param y Second float in float4.
  105044. * @param z Third float in float4.
  105045. * @param w Fourth float in float4.
  105046. * @returns this effect.
  105047. */
  105048. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105049. /**
  105050. * Sets a Color3 on a uniform variable.
  105051. * @param uniformName Name of the variable.
  105052. * @param color3 Value to be set.
  105053. * @returns this effect.
  105054. */
  105055. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105056. /**
  105057. * Sets a Color4 on a uniform variable.
  105058. * @param uniformName Name of the variable.
  105059. * @param color3 Value to be set.
  105060. * @param alpha Alpha value to be set.
  105061. * @returns this effect.
  105062. */
  105063. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105064. /**
  105065. * Sets a Color4 on a uniform variable
  105066. * @param uniformName defines the name of the variable
  105067. * @param color4 defines the value to be set
  105068. * @returns this effect.
  105069. */
  105070. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105071. /** Release all associated resources */
  105072. dispose(): void;
  105073. /**
  105074. * This function will add a new shader to the shader store
  105075. * @param name the name of the shader
  105076. * @param pixelShader optional pixel shader content
  105077. * @param vertexShader optional vertex shader content
  105078. */
  105079. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105080. /**
  105081. * Store of each shader (The can be looked up using effect.key)
  105082. */
  105083. static ShadersStore: {
  105084. [key: string]: string;
  105085. };
  105086. /**
  105087. * Store of each included file for a shader (The can be looked up using effect.key)
  105088. */
  105089. static IncludesShadersStore: {
  105090. [key: string]: string;
  105091. };
  105092. /**
  105093. * Resets the cache of effects.
  105094. */
  105095. static ResetCache(): void;
  105096. }
  105097. }
  105098. declare module BABYLON {
  105099. /**
  105100. * Interface used to describe the capabilities of the engine relatively to the current browser
  105101. */
  105102. export interface EngineCapabilities {
  105103. /** Maximum textures units per fragment shader */
  105104. maxTexturesImageUnits: number;
  105105. /** Maximum texture units per vertex shader */
  105106. maxVertexTextureImageUnits: number;
  105107. /** Maximum textures units in the entire pipeline */
  105108. maxCombinedTexturesImageUnits: number;
  105109. /** Maximum texture size */
  105110. maxTextureSize: number;
  105111. /** Maximum texture samples */
  105112. maxSamples?: number;
  105113. /** Maximum cube texture size */
  105114. maxCubemapTextureSize: number;
  105115. /** Maximum render texture size */
  105116. maxRenderTextureSize: number;
  105117. /** Maximum number of vertex attributes */
  105118. maxVertexAttribs: number;
  105119. /** Maximum number of varyings */
  105120. maxVaryingVectors: number;
  105121. /** Maximum number of uniforms per vertex shader */
  105122. maxVertexUniformVectors: number;
  105123. /** Maximum number of uniforms per fragment shader */
  105124. maxFragmentUniformVectors: number;
  105125. /** Defines if standard derivates (dx/dy) are supported */
  105126. standardDerivatives: boolean;
  105127. /** Defines if s3tc texture compression is supported */
  105128. s3tc?: WEBGL_compressed_texture_s3tc;
  105129. /** Defines if pvrtc texture compression is supported */
  105130. pvrtc: any;
  105131. /** Defines if etc1 texture compression is supported */
  105132. etc1: any;
  105133. /** Defines if etc2 texture compression is supported */
  105134. etc2: any;
  105135. /** Defines if astc texture compression is supported */
  105136. astc: any;
  105137. /** Defines if float textures are supported */
  105138. textureFloat: boolean;
  105139. /** Defines if vertex array objects are supported */
  105140. vertexArrayObject: boolean;
  105141. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105142. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105143. /** Gets the maximum level of anisotropy supported */
  105144. maxAnisotropy: number;
  105145. /** Defines if instancing is supported */
  105146. instancedArrays: boolean;
  105147. /** Defines if 32 bits indices are supported */
  105148. uintIndices: boolean;
  105149. /** Defines if high precision shaders are supported */
  105150. highPrecisionShaderSupported: boolean;
  105151. /** Defines if depth reading in the fragment shader is supported */
  105152. fragmentDepthSupported: boolean;
  105153. /** Defines if float texture linear filtering is supported*/
  105154. textureFloatLinearFiltering: boolean;
  105155. /** Defines if rendering to float textures is supported */
  105156. textureFloatRender: boolean;
  105157. /** Defines if half float textures are supported*/
  105158. textureHalfFloat: boolean;
  105159. /** Defines if half float texture linear filtering is supported*/
  105160. textureHalfFloatLinearFiltering: boolean;
  105161. /** Defines if rendering to half float textures is supported */
  105162. textureHalfFloatRender: boolean;
  105163. /** Defines if textureLOD shader command is supported */
  105164. textureLOD: boolean;
  105165. /** Defines if draw buffers extension is supported */
  105166. drawBuffersExtension: boolean;
  105167. /** Defines if depth textures are supported */
  105168. depthTextureExtension: boolean;
  105169. /** Defines if float color buffer are supported */
  105170. colorBufferFloat: boolean;
  105171. /** Gets disjoint timer query extension (null if not supported) */
  105172. timerQuery?: EXT_disjoint_timer_query;
  105173. /** Defines if timestamp can be used with timer query */
  105174. canUseTimestampForTimerQuery: boolean;
  105175. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105176. multiview?: any;
  105177. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105178. oculusMultiview?: any;
  105179. /** Function used to let the system compiles shaders in background */
  105180. parallelShaderCompile?: {
  105181. COMPLETION_STATUS_KHR: number;
  105182. };
  105183. /** Max number of texture samples for MSAA */
  105184. maxMSAASamples: number;
  105185. /** Defines if the blend min max extension is supported */
  105186. blendMinMax: boolean;
  105187. }
  105188. }
  105189. declare module BABYLON {
  105190. /**
  105191. * @hidden
  105192. **/
  105193. export class DepthCullingState {
  105194. private _isDepthTestDirty;
  105195. private _isDepthMaskDirty;
  105196. private _isDepthFuncDirty;
  105197. private _isCullFaceDirty;
  105198. private _isCullDirty;
  105199. private _isZOffsetDirty;
  105200. private _isFrontFaceDirty;
  105201. private _depthTest;
  105202. private _depthMask;
  105203. private _depthFunc;
  105204. private _cull;
  105205. private _cullFace;
  105206. private _zOffset;
  105207. private _frontFace;
  105208. /**
  105209. * Initializes the state.
  105210. */
  105211. constructor();
  105212. get isDirty(): boolean;
  105213. get zOffset(): number;
  105214. set zOffset(value: number);
  105215. get cullFace(): Nullable<number>;
  105216. set cullFace(value: Nullable<number>);
  105217. get cull(): Nullable<boolean>;
  105218. set cull(value: Nullable<boolean>);
  105219. get depthFunc(): Nullable<number>;
  105220. set depthFunc(value: Nullable<number>);
  105221. get depthMask(): boolean;
  105222. set depthMask(value: boolean);
  105223. get depthTest(): boolean;
  105224. set depthTest(value: boolean);
  105225. get frontFace(): Nullable<number>;
  105226. set frontFace(value: Nullable<number>);
  105227. reset(): void;
  105228. apply(gl: WebGLRenderingContext): void;
  105229. }
  105230. }
  105231. declare module BABYLON {
  105232. /**
  105233. * @hidden
  105234. **/
  105235. export class StencilState {
  105236. /** 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 */
  105237. static readonly ALWAYS: number;
  105238. /** Passed to stencilOperation to specify that stencil value must be kept */
  105239. static readonly KEEP: number;
  105240. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105241. static readonly REPLACE: number;
  105242. private _isStencilTestDirty;
  105243. private _isStencilMaskDirty;
  105244. private _isStencilFuncDirty;
  105245. private _isStencilOpDirty;
  105246. private _stencilTest;
  105247. private _stencilMask;
  105248. private _stencilFunc;
  105249. private _stencilFuncRef;
  105250. private _stencilFuncMask;
  105251. private _stencilOpStencilFail;
  105252. private _stencilOpDepthFail;
  105253. private _stencilOpStencilDepthPass;
  105254. get isDirty(): boolean;
  105255. get stencilFunc(): number;
  105256. set stencilFunc(value: number);
  105257. get stencilFuncRef(): number;
  105258. set stencilFuncRef(value: number);
  105259. get stencilFuncMask(): number;
  105260. set stencilFuncMask(value: number);
  105261. get stencilOpStencilFail(): number;
  105262. set stencilOpStencilFail(value: number);
  105263. get stencilOpDepthFail(): number;
  105264. set stencilOpDepthFail(value: number);
  105265. get stencilOpStencilDepthPass(): number;
  105266. set stencilOpStencilDepthPass(value: number);
  105267. get stencilMask(): number;
  105268. set stencilMask(value: number);
  105269. get stencilTest(): boolean;
  105270. set stencilTest(value: boolean);
  105271. constructor();
  105272. reset(): void;
  105273. apply(gl: WebGLRenderingContext): void;
  105274. }
  105275. }
  105276. declare module BABYLON {
  105277. /**
  105278. * @hidden
  105279. **/
  105280. export class AlphaState {
  105281. private _isAlphaBlendDirty;
  105282. private _isBlendFunctionParametersDirty;
  105283. private _isBlendEquationParametersDirty;
  105284. private _isBlendConstantsDirty;
  105285. private _alphaBlend;
  105286. private _blendFunctionParameters;
  105287. private _blendEquationParameters;
  105288. private _blendConstants;
  105289. /**
  105290. * Initializes the state.
  105291. */
  105292. constructor();
  105293. get isDirty(): boolean;
  105294. get alphaBlend(): boolean;
  105295. set alphaBlend(value: boolean);
  105296. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105297. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105298. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105299. reset(): void;
  105300. apply(gl: WebGLRenderingContext): void;
  105301. }
  105302. }
  105303. declare module BABYLON {
  105304. /** @hidden */
  105305. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105306. attributeProcessor(attribute: string): string;
  105307. varyingProcessor(varying: string, isFragment: boolean): string;
  105308. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105309. }
  105310. }
  105311. declare module BABYLON {
  105312. /**
  105313. * Interface for attribute information associated with buffer instanciation
  105314. */
  105315. export interface InstancingAttributeInfo {
  105316. /**
  105317. * Name of the GLSL attribute
  105318. * if attribute index is not specified, this is used to retrieve the index from the effect
  105319. */
  105320. attributeName: string;
  105321. /**
  105322. * Index/offset of the attribute in the vertex shader
  105323. * if not specified, this will be computes from the name.
  105324. */
  105325. index?: number;
  105326. /**
  105327. * size of the attribute, 1, 2, 3 or 4
  105328. */
  105329. attributeSize: number;
  105330. /**
  105331. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105332. */
  105333. offset: number;
  105334. /**
  105335. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105336. * default to 1
  105337. */
  105338. divisor?: number;
  105339. /**
  105340. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105341. * default is FLOAT
  105342. */
  105343. attributeType?: number;
  105344. /**
  105345. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105346. */
  105347. normalized?: boolean;
  105348. }
  105349. }
  105350. declare module BABYLON {
  105351. interface ThinEngine {
  105352. /**
  105353. * Update a video texture
  105354. * @param texture defines the texture to update
  105355. * @param video defines the video element to use
  105356. * @param invertY defines if data must be stored with Y axis inverted
  105357. */
  105358. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105359. }
  105360. }
  105361. declare module BABYLON {
  105362. /**
  105363. * Settings for finer control over video usage
  105364. */
  105365. export interface VideoTextureSettings {
  105366. /**
  105367. * Applies `autoplay` to video, if specified
  105368. */
  105369. autoPlay?: boolean;
  105370. /**
  105371. * Applies `loop` to video, if specified
  105372. */
  105373. loop?: boolean;
  105374. /**
  105375. * Automatically updates internal texture from video at every frame in the render loop
  105376. */
  105377. autoUpdateTexture: boolean;
  105378. /**
  105379. * Image src displayed during the video loading or until the user interacts with the video.
  105380. */
  105381. poster?: string;
  105382. }
  105383. /**
  105384. * If you want to display a video in your scene, this is the special texture for that.
  105385. * This special texture works similar to other textures, with the exception of a few parameters.
  105386. * @see https://doc.babylonjs.com/how_to/video_texture
  105387. */
  105388. export class VideoTexture extends Texture {
  105389. /**
  105390. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105391. */
  105392. readonly autoUpdateTexture: boolean;
  105393. /**
  105394. * The video instance used by the texture internally
  105395. */
  105396. readonly video: HTMLVideoElement;
  105397. private _onUserActionRequestedObservable;
  105398. /**
  105399. * Event triggerd when a dom action is required by the user to play the video.
  105400. * This happens due to recent changes in browser policies preventing video to auto start.
  105401. */
  105402. get onUserActionRequestedObservable(): Observable<Texture>;
  105403. private _generateMipMaps;
  105404. private _engine;
  105405. private _stillImageCaptured;
  105406. private _displayingPosterTexture;
  105407. private _settings;
  105408. private _createInternalTextureOnEvent;
  105409. private _frameId;
  105410. private _currentSrc;
  105411. /**
  105412. * Creates a video texture.
  105413. * If you want to display a video in your scene, this is the special texture for that.
  105414. * This special texture works similar to other textures, with the exception of a few parameters.
  105415. * @see https://doc.babylonjs.com/how_to/video_texture
  105416. * @param name optional name, will detect from video source, if not defined
  105417. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105418. * @param scene is obviously the current scene.
  105419. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105420. * @param invertY is false by default but can be used to invert video on Y axis
  105421. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105422. * @param settings allows finer control over video usage
  105423. */
  105424. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105425. private _getName;
  105426. private _getVideo;
  105427. private _createInternalTexture;
  105428. private reset;
  105429. /**
  105430. * @hidden Internal method to initiate `update`.
  105431. */
  105432. _rebuild(): void;
  105433. /**
  105434. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105435. */
  105436. update(): void;
  105437. /**
  105438. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105439. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105440. */
  105441. updateTexture(isVisible: boolean): void;
  105442. protected _updateInternalTexture: () => void;
  105443. /**
  105444. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105445. * @param url New url.
  105446. */
  105447. updateURL(url: string): void;
  105448. /**
  105449. * Clones the texture.
  105450. * @returns the cloned texture
  105451. */
  105452. clone(): VideoTexture;
  105453. /**
  105454. * Dispose the texture and release its associated resources.
  105455. */
  105456. dispose(): void;
  105457. /**
  105458. * Creates a video texture straight from a stream.
  105459. * @param scene Define the scene the texture should be created in
  105460. * @param stream Define the stream the texture should be created from
  105461. * @returns The created video texture as a promise
  105462. */
  105463. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105464. /**
  105465. * Creates a video texture straight from your WebCam video feed.
  105466. * @param scene Define the scene the texture should be created in
  105467. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105468. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105469. * @returns The created video texture as a promise
  105470. */
  105471. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105472. minWidth: number;
  105473. maxWidth: number;
  105474. minHeight: number;
  105475. maxHeight: number;
  105476. deviceId: string;
  105477. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105478. /**
  105479. * Creates a video texture straight from your WebCam video feed.
  105480. * @param scene Define the scene the texture should be created in
  105481. * @param onReady Define a callback to triggered once the texture will be ready
  105482. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105483. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105484. */
  105485. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105486. minWidth: number;
  105487. maxWidth: number;
  105488. minHeight: number;
  105489. maxHeight: number;
  105490. deviceId: string;
  105491. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105492. }
  105493. }
  105494. declare module BABYLON {
  105495. /**
  105496. * Defines the interface used by objects working like Scene
  105497. * @hidden
  105498. */
  105499. export interface ISceneLike {
  105500. _addPendingData(data: any): void;
  105501. _removePendingData(data: any): void;
  105502. offlineProvider: IOfflineProvider;
  105503. }
  105504. /** Interface defining initialization parameters for Engine class */
  105505. export interface EngineOptions extends WebGLContextAttributes {
  105506. /**
  105507. * Defines if the engine should no exceed a specified device ratio
  105508. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105509. */
  105510. limitDeviceRatio?: number;
  105511. /**
  105512. * Defines if webvr should be enabled automatically
  105513. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105514. */
  105515. autoEnableWebVR?: boolean;
  105516. /**
  105517. * Defines if webgl2 should be turned off even if supported
  105518. * @see http://doc.babylonjs.com/features/webgl2
  105519. */
  105520. disableWebGL2Support?: boolean;
  105521. /**
  105522. * Defines if webaudio should be initialized as well
  105523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105524. */
  105525. audioEngine?: boolean;
  105526. /**
  105527. * Defines if animations should run using a deterministic lock step
  105528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105529. */
  105530. deterministicLockstep?: boolean;
  105531. /** Defines the maximum steps to use with deterministic lock step mode */
  105532. lockstepMaxSteps?: number;
  105533. /** Defines the seconds between each deterministic lock step */
  105534. timeStep?: number;
  105535. /**
  105536. * Defines that engine should ignore context lost events
  105537. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105538. */
  105539. doNotHandleContextLost?: boolean;
  105540. /**
  105541. * Defines that engine should ignore modifying touch action attribute and style
  105542. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105543. */
  105544. doNotHandleTouchAction?: boolean;
  105545. /**
  105546. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105547. */
  105548. useHighPrecisionFloats?: boolean;
  105549. }
  105550. /**
  105551. * The base engine class (root of all engines)
  105552. */
  105553. export class ThinEngine {
  105554. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105555. static ExceptionList: ({
  105556. key: string;
  105557. capture: string;
  105558. captureConstraint: number;
  105559. targets: string[];
  105560. } | {
  105561. key: string;
  105562. capture: null;
  105563. captureConstraint: null;
  105564. targets: string[];
  105565. })[];
  105566. /** @hidden */
  105567. static _TextureLoaders: IInternalTextureLoader[];
  105568. /**
  105569. * Returns the current npm package of the sdk
  105570. */
  105571. static get NpmPackage(): string;
  105572. /**
  105573. * Returns the current version of the framework
  105574. */
  105575. static get Version(): string;
  105576. /**
  105577. * Returns a string describing the current engine
  105578. */
  105579. get description(): string;
  105580. /**
  105581. * Gets or sets the epsilon value used by collision engine
  105582. */
  105583. static CollisionsEpsilon: number;
  105584. /**
  105585. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105586. */
  105587. static get ShadersRepository(): string;
  105588. static set ShadersRepository(value: string);
  105589. /** @hidden */
  105590. _shaderProcessor: IShaderProcessor;
  105591. /**
  105592. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105593. */
  105594. forcePOTTextures: boolean;
  105595. /**
  105596. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105597. */
  105598. isFullscreen: boolean;
  105599. /**
  105600. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105601. */
  105602. cullBackFaces: boolean;
  105603. /**
  105604. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105605. */
  105606. renderEvenInBackground: boolean;
  105607. /**
  105608. * Gets or sets a boolean indicating that cache can be kept between frames
  105609. */
  105610. preventCacheWipeBetweenFrames: boolean;
  105611. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105612. validateShaderPrograms: boolean;
  105613. /**
  105614. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105615. * This can provide greater z depth for distant objects.
  105616. */
  105617. useReverseDepthBuffer: boolean;
  105618. /**
  105619. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105620. */
  105621. disableUniformBuffers: boolean;
  105622. /** @hidden */
  105623. _uniformBuffers: UniformBuffer[];
  105624. /**
  105625. * Gets a boolean indicating that the engine supports uniform buffers
  105626. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105627. */
  105628. get supportsUniformBuffers(): boolean;
  105629. /** @hidden */
  105630. _gl: WebGLRenderingContext;
  105631. /** @hidden */
  105632. _webGLVersion: number;
  105633. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105634. protected _windowIsBackground: boolean;
  105635. protected _creationOptions: EngineOptions;
  105636. protected _highPrecisionShadersAllowed: boolean;
  105637. /** @hidden */
  105638. get _shouldUseHighPrecisionShader(): boolean;
  105639. /**
  105640. * Gets a boolean indicating that only power of 2 textures are supported
  105641. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105642. */
  105643. get needPOTTextures(): boolean;
  105644. /** @hidden */
  105645. _badOS: boolean;
  105646. /** @hidden */
  105647. _badDesktopOS: boolean;
  105648. private _hardwareScalingLevel;
  105649. /** @hidden */
  105650. _caps: EngineCapabilities;
  105651. private _isStencilEnable;
  105652. private _glVersion;
  105653. private _glRenderer;
  105654. private _glVendor;
  105655. /** @hidden */
  105656. _videoTextureSupported: boolean;
  105657. protected _renderingQueueLaunched: boolean;
  105658. protected _activeRenderLoops: (() => void)[];
  105659. /**
  105660. * Observable signaled when a context lost event is raised
  105661. */
  105662. onContextLostObservable: Observable<ThinEngine>;
  105663. /**
  105664. * Observable signaled when a context restored event is raised
  105665. */
  105666. onContextRestoredObservable: Observable<ThinEngine>;
  105667. private _onContextLost;
  105668. private _onContextRestored;
  105669. protected _contextWasLost: boolean;
  105670. /** @hidden */
  105671. _doNotHandleContextLost: boolean;
  105672. /**
  105673. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105675. */
  105676. get doNotHandleContextLost(): boolean;
  105677. set doNotHandleContextLost(value: boolean);
  105678. /**
  105679. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105680. */
  105681. disableVertexArrayObjects: boolean;
  105682. /** @hidden */
  105683. protected _colorWrite: boolean;
  105684. /** @hidden */
  105685. protected _colorWriteChanged: boolean;
  105686. /** @hidden */
  105687. protected _depthCullingState: DepthCullingState;
  105688. /** @hidden */
  105689. protected _stencilState: StencilState;
  105690. /** @hidden */
  105691. _alphaState: AlphaState;
  105692. /** @hidden */
  105693. _alphaMode: number;
  105694. /** @hidden */
  105695. _alphaEquation: number;
  105696. /** @hidden */
  105697. _internalTexturesCache: InternalTexture[];
  105698. /** @hidden */
  105699. protected _activeChannel: number;
  105700. private _currentTextureChannel;
  105701. /** @hidden */
  105702. protected _boundTexturesCache: {
  105703. [key: string]: Nullable<InternalTexture>;
  105704. };
  105705. /** @hidden */
  105706. protected _currentEffect: Nullable<Effect>;
  105707. /** @hidden */
  105708. protected _currentProgram: Nullable<WebGLProgram>;
  105709. private _compiledEffects;
  105710. private _vertexAttribArraysEnabled;
  105711. /** @hidden */
  105712. protected _cachedViewport: Nullable<IViewportLike>;
  105713. private _cachedVertexArrayObject;
  105714. /** @hidden */
  105715. protected _cachedVertexBuffers: any;
  105716. /** @hidden */
  105717. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105718. /** @hidden */
  105719. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105720. /** @hidden */
  105721. _currentRenderTarget: Nullable<InternalTexture>;
  105722. private _uintIndicesCurrentlySet;
  105723. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105724. /** @hidden */
  105725. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105726. private _currentBufferPointers;
  105727. private _currentInstanceLocations;
  105728. private _currentInstanceBuffers;
  105729. private _textureUnits;
  105730. /** @hidden */
  105731. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105732. /** @hidden */
  105733. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105734. /** @hidden */
  105735. _boundRenderFunction: any;
  105736. private _vaoRecordInProgress;
  105737. private _mustWipeVertexAttributes;
  105738. private _emptyTexture;
  105739. private _emptyCubeTexture;
  105740. private _emptyTexture3D;
  105741. private _emptyTexture2DArray;
  105742. /** @hidden */
  105743. _frameHandler: number;
  105744. private _nextFreeTextureSlots;
  105745. private _maxSimultaneousTextures;
  105746. private _activeRequests;
  105747. /** @hidden */
  105748. _transformTextureUrl: Nullable<(url: string) => string>;
  105749. protected get _supportsHardwareTextureRescaling(): boolean;
  105750. private _framebufferDimensionsObject;
  105751. /**
  105752. * sets the object from which width and height will be taken from when getting render width and height
  105753. * Will fallback to the gl object
  105754. * @param dimensions the framebuffer width and height that will be used.
  105755. */
  105756. set framebufferDimensionsObject(dimensions: Nullable<{
  105757. framebufferWidth: number;
  105758. framebufferHeight: number;
  105759. }>);
  105760. /**
  105761. * Gets the current viewport
  105762. */
  105763. get currentViewport(): Nullable<IViewportLike>;
  105764. /**
  105765. * Gets the default empty texture
  105766. */
  105767. get emptyTexture(): InternalTexture;
  105768. /**
  105769. * Gets the default empty 3D texture
  105770. */
  105771. get emptyTexture3D(): InternalTexture;
  105772. /**
  105773. * Gets the default empty 2D array texture
  105774. */
  105775. get emptyTexture2DArray(): InternalTexture;
  105776. /**
  105777. * Gets the default empty cube texture
  105778. */
  105779. get emptyCubeTexture(): InternalTexture;
  105780. /**
  105781. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105782. */
  105783. readonly premultipliedAlpha: boolean;
  105784. /**
  105785. * Observable event triggered before each texture is initialized
  105786. */
  105787. onBeforeTextureInitObservable: Observable<Texture>;
  105788. /**
  105789. * Creates a new engine
  105790. * @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
  105791. * @param antialias defines enable antialiasing (default: false)
  105792. * @param options defines further options to be sent to the getContext() function
  105793. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105794. */
  105795. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105796. private _rebuildInternalTextures;
  105797. private _rebuildEffects;
  105798. /**
  105799. * Gets a boolean indicating if all created effects are ready
  105800. * @returns true if all effects are ready
  105801. */
  105802. areAllEffectsReady(): boolean;
  105803. protected _rebuildBuffers(): void;
  105804. protected _initGLContext(): void;
  105805. /**
  105806. * Gets version of the current webGL context
  105807. */
  105808. get webGLVersion(): number;
  105809. /**
  105810. * Gets a string idenfifying the name of the class
  105811. * @returns "Engine" string
  105812. */
  105813. getClassName(): string;
  105814. /**
  105815. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105816. */
  105817. get isStencilEnable(): boolean;
  105818. /** @hidden */
  105819. _prepareWorkingCanvas(): void;
  105820. /**
  105821. * Reset the texture cache to empty state
  105822. */
  105823. resetTextureCache(): void;
  105824. /**
  105825. * Gets an object containing information about the current webGL context
  105826. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105827. */
  105828. getGlInfo(): {
  105829. vendor: string;
  105830. renderer: string;
  105831. version: string;
  105832. };
  105833. /**
  105834. * Defines the hardware scaling level.
  105835. * By default the hardware scaling level is computed from the window device ratio.
  105836. * 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.
  105837. * @param level defines the level to use
  105838. */
  105839. setHardwareScalingLevel(level: number): void;
  105840. /**
  105841. * Gets the current hardware scaling level.
  105842. * By default the hardware scaling level is computed from the window device ratio.
  105843. * 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.
  105844. * @returns a number indicating the current hardware scaling level
  105845. */
  105846. getHardwareScalingLevel(): number;
  105847. /**
  105848. * Gets the list of loaded textures
  105849. * @returns an array containing all loaded textures
  105850. */
  105851. getLoadedTexturesCache(): InternalTexture[];
  105852. /**
  105853. * Gets the object containing all engine capabilities
  105854. * @returns the EngineCapabilities object
  105855. */
  105856. getCaps(): EngineCapabilities;
  105857. /**
  105858. * stop executing a render loop function and remove it from the execution array
  105859. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105860. */
  105861. stopRenderLoop(renderFunction?: () => void): void;
  105862. /** @hidden */
  105863. _renderLoop(): void;
  105864. /**
  105865. * Gets the HTML canvas attached with the current webGL context
  105866. * @returns a HTML canvas
  105867. */
  105868. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105869. /**
  105870. * Gets host window
  105871. * @returns the host window object
  105872. */
  105873. getHostWindow(): Nullable<Window>;
  105874. /**
  105875. * Gets the current render width
  105876. * @param useScreen defines if screen size must be used (or the current render target if any)
  105877. * @returns a number defining the current render width
  105878. */
  105879. getRenderWidth(useScreen?: boolean): number;
  105880. /**
  105881. * Gets the current render height
  105882. * @param useScreen defines if screen size must be used (or the current render target if any)
  105883. * @returns a number defining the current render height
  105884. */
  105885. getRenderHeight(useScreen?: boolean): number;
  105886. /**
  105887. * Can be used to override the current requestAnimationFrame requester.
  105888. * @hidden
  105889. */
  105890. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105891. /**
  105892. * Register and execute a render loop. The engine can have more than one render function
  105893. * @param renderFunction defines the function to continuously execute
  105894. */
  105895. runRenderLoop(renderFunction: () => void): void;
  105896. /**
  105897. * Clear the current render buffer or the current render target (if any is set up)
  105898. * @param color defines the color to use
  105899. * @param backBuffer defines if the back buffer must be cleared
  105900. * @param depth defines if the depth buffer must be cleared
  105901. * @param stencil defines if the stencil buffer must be cleared
  105902. */
  105903. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105904. private _viewportCached;
  105905. /** @hidden */
  105906. _viewport(x: number, y: number, width: number, height: number): void;
  105907. /**
  105908. * Set the WebGL's viewport
  105909. * @param viewport defines the viewport element to be used
  105910. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105911. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105912. */
  105913. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105914. /**
  105915. * Begin a new frame
  105916. */
  105917. beginFrame(): void;
  105918. /**
  105919. * Enf the current frame
  105920. */
  105921. endFrame(): void;
  105922. /**
  105923. * Resize the view according to the canvas' size
  105924. */
  105925. resize(): void;
  105926. /**
  105927. * Force a specific size of the canvas
  105928. * @param width defines the new canvas' width
  105929. * @param height defines the new canvas' height
  105930. */
  105931. setSize(width: number, height: number): void;
  105932. /**
  105933. * Binds the frame buffer to the specified texture.
  105934. * @param texture The texture to render to or null for the default canvas
  105935. * @param faceIndex The face of the texture to render to in case of cube texture
  105936. * @param requiredWidth The width of the target to render to
  105937. * @param requiredHeight The height of the target to render to
  105938. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105939. * @param lodLevel defines the lod level to bind to the frame buffer
  105940. * @param layer defines the 2d array index to bind to frame buffer to
  105941. */
  105942. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105943. /** @hidden */
  105944. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105945. /**
  105946. * Unbind the current render target texture from the webGL context
  105947. * @param texture defines the render target texture to unbind
  105948. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105949. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105950. */
  105951. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105952. /**
  105953. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105954. */
  105955. flushFramebuffer(): void;
  105956. /**
  105957. * Unbind the current render target and bind the default framebuffer
  105958. */
  105959. restoreDefaultFramebuffer(): void;
  105960. /** @hidden */
  105961. protected _resetVertexBufferBinding(): void;
  105962. /**
  105963. * Creates a vertex buffer
  105964. * @param data the data for the vertex buffer
  105965. * @returns the new WebGL static buffer
  105966. */
  105967. createVertexBuffer(data: DataArray): DataBuffer;
  105968. private _createVertexBuffer;
  105969. /**
  105970. * Creates a dynamic vertex buffer
  105971. * @param data the data for the dynamic vertex buffer
  105972. * @returns the new WebGL dynamic buffer
  105973. */
  105974. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105975. protected _resetIndexBufferBinding(): void;
  105976. /**
  105977. * Creates a new index buffer
  105978. * @param indices defines the content of the index buffer
  105979. * @param updatable defines if the index buffer must be updatable
  105980. * @returns a new webGL buffer
  105981. */
  105982. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105983. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105984. /**
  105985. * Bind a webGL buffer to the webGL context
  105986. * @param buffer defines the buffer to bind
  105987. */
  105988. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105989. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105990. private bindBuffer;
  105991. /**
  105992. * update the bound buffer with the given data
  105993. * @param data defines the data to update
  105994. */
  105995. updateArrayBuffer(data: Float32Array): void;
  105996. private _vertexAttribPointer;
  105997. /** @hidden */
  105998. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  105999. private _bindVertexBuffersAttributes;
  106000. /**
  106001. * Records a vertex array object
  106002. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106003. * @param vertexBuffers defines the list of vertex buffers to store
  106004. * @param indexBuffer defines the index buffer to store
  106005. * @param effect defines the effect to store
  106006. * @returns the new vertex array object
  106007. */
  106008. recordVertexArrayObject(vertexBuffers: {
  106009. [key: string]: VertexBuffer;
  106010. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106011. /**
  106012. * Bind a specific vertex array object
  106013. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106014. * @param vertexArrayObject defines the vertex array object to bind
  106015. * @param indexBuffer defines the index buffer to bind
  106016. */
  106017. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106018. /**
  106019. * Bind webGl buffers directly to the webGL context
  106020. * @param vertexBuffer defines the vertex buffer to bind
  106021. * @param indexBuffer defines the index buffer to bind
  106022. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106023. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106024. * @param effect defines the effect associated with the vertex buffer
  106025. */
  106026. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106027. private _unbindVertexArrayObject;
  106028. /**
  106029. * Bind a list of vertex buffers to the webGL context
  106030. * @param vertexBuffers defines the list of vertex buffers to bind
  106031. * @param indexBuffer defines the index buffer to bind
  106032. * @param effect defines the effect associated with the vertex buffers
  106033. */
  106034. bindBuffers(vertexBuffers: {
  106035. [key: string]: Nullable<VertexBuffer>;
  106036. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106037. /**
  106038. * Unbind all instance attributes
  106039. */
  106040. unbindInstanceAttributes(): void;
  106041. /**
  106042. * Release and free the memory of a vertex array object
  106043. * @param vao defines the vertex array object to delete
  106044. */
  106045. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106046. /** @hidden */
  106047. _releaseBuffer(buffer: DataBuffer): boolean;
  106048. protected _deleteBuffer(buffer: DataBuffer): void;
  106049. /**
  106050. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106051. * @param instancesBuffer defines the webGL buffer to update and bind
  106052. * @param data defines the data to store in the buffer
  106053. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106054. */
  106055. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106056. /**
  106057. * Bind the content of a webGL buffer used with instantiation
  106058. * @param instancesBuffer defines the webGL buffer to bind
  106059. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106060. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106061. */
  106062. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106063. /**
  106064. * Disable the instance attribute corresponding to the name in parameter
  106065. * @param name defines the name of the attribute to disable
  106066. */
  106067. disableInstanceAttributeByName(name: string): void;
  106068. /**
  106069. * Disable the instance attribute corresponding to the location in parameter
  106070. * @param attributeLocation defines the attribute location of the attribute to disable
  106071. */
  106072. disableInstanceAttribute(attributeLocation: number): void;
  106073. /**
  106074. * Disable the attribute corresponding to the location in parameter
  106075. * @param attributeLocation defines the attribute location of the attribute to disable
  106076. */
  106077. disableAttributeByIndex(attributeLocation: number): void;
  106078. /**
  106079. * Send a draw order
  106080. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106081. * @param indexStart defines the starting index
  106082. * @param indexCount defines the number of index to draw
  106083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106084. */
  106085. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106086. /**
  106087. * Draw a list of points
  106088. * @param verticesStart defines the index of first vertex to draw
  106089. * @param verticesCount defines the count of vertices to draw
  106090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106091. */
  106092. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106093. /**
  106094. * Draw a list of unindexed primitives
  106095. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106096. * @param verticesStart defines the index of first vertex to draw
  106097. * @param verticesCount defines the count of vertices to draw
  106098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106099. */
  106100. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106101. /**
  106102. * Draw a list of indexed primitives
  106103. * @param fillMode defines the primitive to use
  106104. * @param indexStart defines the starting index
  106105. * @param indexCount defines the number of index to draw
  106106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106107. */
  106108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106109. /**
  106110. * Draw a list of unindexed primitives
  106111. * @param fillMode defines the primitive to use
  106112. * @param verticesStart defines the index of first vertex to draw
  106113. * @param verticesCount defines the count of vertices to draw
  106114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106115. */
  106116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106117. private _drawMode;
  106118. /** @hidden */
  106119. protected _reportDrawCall(): void;
  106120. /** @hidden */
  106121. _releaseEffect(effect: Effect): void;
  106122. /** @hidden */
  106123. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106124. /**
  106125. * Create a new effect (used to store vertex/fragment shaders)
  106126. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106127. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106128. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106129. * @param samplers defines an array of string used to represent textures
  106130. * @param defines defines the string containing the defines to use to compile the shaders
  106131. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106132. * @param onCompiled defines a function to call when the effect creation is successful
  106133. * @param onError defines a function to call when the effect creation has failed
  106134. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106135. * @returns the new Effect
  106136. */
  106137. 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;
  106138. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106139. private _compileShader;
  106140. private _compileRawShader;
  106141. /** @hidden */
  106142. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106143. /**
  106144. * Directly creates a webGL program
  106145. * @param pipelineContext defines the pipeline context to attach to
  106146. * @param vertexCode defines the vertex shader code to use
  106147. * @param fragmentCode defines the fragment shader code to use
  106148. * @param context defines the webGL context to use (if not set, the current one will be used)
  106149. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106150. * @returns the new webGL program
  106151. */
  106152. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106153. /**
  106154. * Creates a webGL program
  106155. * @param pipelineContext defines the pipeline context to attach to
  106156. * @param vertexCode defines the vertex shader code to use
  106157. * @param fragmentCode defines the fragment shader code to use
  106158. * @param defines defines the string containing the defines to use to compile the shaders
  106159. * @param context defines the webGL context to use (if not set, the current one will be used)
  106160. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106161. * @returns the new webGL program
  106162. */
  106163. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106164. /**
  106165. * Creates a new pipeline context
  106166. * @returns the new pipeline
  106167. */
  106168. createPipelineContext(): IPipelineContext;
  106169. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106170. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106171. /** @hidden */
  106172. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106173. /** @hidden */
  106174. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106175. /** @hidden */
  106176. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106177. /**
  106178. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106179. * @param pipelineContext defines the pipeline context to use
  106180. * @param uniformsNames defines the list of uniform names
  106181. * @returns an array of webGL uniform locations
  106182. */
  106183. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106184. /**
  106185. * Gets the lsit of active attributes for a given webGL program
  106186. * @param pipelineContext defines the pipeline context to use
  106187. * @param attributesNames defines the list of attribute names to get
  106188. * @returns an array of indices indicating the offset of each attribute
  106189. */
  106190. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106191. /**
  106192. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106193. * @param effect defines the effect to activate
  106194. */
  106195. enableEffect(effect: Nullable<Effect>): void;
  106196. /**
  106197. * Set the value of an uniform to a number (int)
  106198. * @param uniform defines the webGL uniform location where to store the value
  106199. * @param value defines the int number to store
  106200. */
  106201. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106202. /**
  106203. * Set the value of an uniform to an array of int32
  106204. * @param uniform defines the webGL uniform location where to store the value
  106205. * @param array defines the array of int32 to store
  106206. */
  106207. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106208. /**
  106209. * Set the value of an uniform to an array of int32 (stored as vec2)
  106210. * @param uniform defines the webGL uniform location where to store the value
  106211. * @param array defines the array of int32 to store
  106212. */
  106213. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106214. /**
  106215. * Set the value of an uniform to an array of int32 (stored as vec3)
  106216. * @param uniform defines the webGL uniform location where to store the value
  106217. * @param array defines the array of int32 to store
  106218. */
  106219. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106220. /**
  106221. * Set the value of an uniform to an array of int32 (stored as vec4)
  106222. * @param uniform defines the webGL uniform location where to store the value
  106223. * @param array defines the array of int32 to store
  106224. */
  106225. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106226. /**
  106227. * Set the value of an uniform to an array of number
  106228. * @param uniform defines the webGL uniform location where to store the value
  106229. * @param array defines the array of number to store
  106230. */
  106231. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106232. /**
  106233. * Set the value of an uniform to an array of number (stored as vec2)
  106234. * @param uniform defines the webGL uniform location where to store the value
  106235. * @param array defines the array of number to store
  106236. */
  106237. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106238. /**
  106239. * Set the value of an uniform to an array of number (stored as vec3)
  106240. * @param uniform defines the webGL uniform location where to store the value
  106241. * @param array defines the array of number to store
  106242. */
  106243. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106244. /**
  106245. * Set the value of an uniform to an array of number (stored as vec4)
  106246. * @param uniform defines the webGL uniform location where to store the value
  106247. * @param array defines the array of number to store
  106248. */
  106249. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106250. /**
  106251. * Set the value of an uniform to an array of float32 (stored as matrices)
  106252. * @param uniform defines the webGL uniform location where to store the value
  106253. * @param matrices defines the array of float32 to store
  106254. */
  106255. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106256. /**
  106257. * Set the value of an uniform to a matrix (3x3)
  106258. * @param uniform defines the webGL uniform location where to store the value
  106259. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106260. */
  106261. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106262. /**
  106263. * Set the value of an uniform to a matrix (2x2)
  106264. * @param uniform defines the webGL uniform location where to store the value
  106265. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106266. */
  106267. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106268. /**
  106269. * Set the value of an uniform to a number (float)
  106270. * @param uniform defines the webGL uniform location where to store the value
  106271. * @param value defines the float number to store
  106272. */
  106273. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106274. /**
  106275. * Set the value of an uniform to a vec2
  106276. * @param uniform defines the webGL uniform location where to store the value
  106277. * @param x defines the 1st component of the value
  106278. * @param y defines the 2nd component of the value
  106279. */
  106280. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106281. /**
  106282. * Set the value of an uniform to a vec3
  106283. * @param uniform defines the webGL uniform location where to store the value
  106284. * @param x defines the 1st component of the value
  106285. * @param y defines the 2nd component of the value
  106286. * @param z defines the 3rd component of the value
  106287. */
  106288. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106289. /**
  106290. * Set the value of an uniform to a vec4
  106291. * @param uniform defines the webGL uniform location where to store the value
  106292. * @param x defines the 1st component of the value
  106293. * @param y defines the 2nd component of the value
  106294. * @param z defines the 3rd component of the value
  106295. * @param w defines the 4th component of the value
  106296. */
  106297. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106298. /**
  106299. * Apply all cached states (depth, culling, stencil and alpha)
  106300. */
  106301. applyStates(): void;
  106302. /**
  106303. * Enable or disable color writing
  106304. * @param enable defines the state to set
  106305. */
  106306. setColorWrite(enable: boolean): void;
  106307. /**
  106308. * Gets a boolean indicating if color writing is enabled
  106309. * @returns the current color writing state
  106310. */
  106311. getColorWrite(): boolean;
  106312. /**
  106313. * Gets the depth culling state manager
  106314. */
  106315. get depthCullingState(): DepthCullingState;
  106316. /**
  106317. * Gets the alpha state manager
  106318. */
  106319. get alphaState(): AlphaState;
  106320. /**
  106321. * Gets the stencil state manager
  106322. */
  106323. get stencilState(): StencilState;
  106324. /**
  106325. * Clears the list of texture accessible through engine.
  106326. * This can help preventing texture load conflict due to name collision.
  106327. */
  106328. clearInternalTexturesCache(): void;
  106329. /**
  106330. * Force the entire cache to be cleared
  106331. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106332. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106333. */
  106334. wipeCaches(bruteForce?: boolean): void;
  106335. /** @hidden */
  106336. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106337. min: number;
  106338. mag: number;
  106339. };
  106340. /** @hidden */
  106341. _createTexture(): WebGLTexture;
  106342. /**
  106343. * Usually called from Texture.ts.
  106344. * Passed information to create a WebGLTexture
  106345. * @param url defines a value which contains one of the following:
  106346. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106347. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106348. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106350. * @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)
  106351. * @param scene needed for loading to the correct scene
  106352. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106353. * @param onLoad optional callback to be called upon successful completion
  106354. * @param onError optional callback to be called upon failure
  106355. * @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
  106356. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106357. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106358. * @param forcedExtension defines the extension to use to pick the right loader
  106359. * @param mimeType defines an optional mime type
  106360. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106361. */
  106362. 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;
  106363. /**
  106364. * Loads an image as an HTMLImageElement.
  106365. * @param input url string, ArrayBuffer, or Blob to load
  106366. * @param onLoad callback called when the image successfully loads
  106367. * @param onError callback called when the image fails to load
  106368. * @param offlineProvider offline provider for caching
  106369. * @param mimeType optional mime type
  106370. * @returns the HTMLImageElement of the loaded image
  106371. * @hidden
  106372. */
  106373. 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>;
  106374. /**
  106375. * @hidden
  106376. */
  106377. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106378. /**
  106379. * Creates a raw texture
  106380. * @param data defines the data to store in the texture
  106381. * @param width defines the width of the texture
  106382. * @param height defines the height of the texture
  106383. * @param format defines the format of the data
  106384. * @param generateMipMaps defines if the engine should generate the mip levels
  106385. * @param invertY defines if data must be stored with Y axis inverted
  106386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106387. * @param compression defines the compression used (null by default)
  106388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106389. * @returns the raw texture inside an InternalTexture
  106390. */
  106391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106392. /**
  106393. * Creates a new raw cube texture
  106394. * @param data defines the array of data to use to create each face
  106395. * @param size defines the size of the textures
  106396. * @param format defines the format of the data
  106397. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106398. * @param generateMipMaps defines if the engine should generate the mip levels
  106399. * @param invertY defines if data must be stored with Y axis inverted
  106400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106401. * @param compression defines the compression used (null by default)
  106402. * @returns the cube texture as an InternalTexture
  106403. */
  106404. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106405. /**
  106406. * Creates a new raw 3D texture
  106407. * @param data defines the data used to create the texture
  106408. * @param width defines the width of the texture
  106409. * @param height defines the height of the texture
  106410. * @param depth defines the depth of the texture
  106411. * @param format defines the format of the texture
  106412. * @param generateMipMaps defines if the engine must generate mip levels
  106413. * @param invertY defines if data must be stored with Y axis inverted
  106414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106415. * @param compression defines the compressed used (can be null)
  106416. * @param textureType defines the compressed used (can be null)
  106417. * @returns a new raw 3D texture (stored in an InternalTexture)
  106418. */
  106419. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106420. /**
  106421. * Creates a new raw 2D array texture
  106422. * @param data defines the data used to create the texture
  106423. * @param width defines the width of the texture
  106424. * @param height defines the height of the texture
  106425. * @param depth defines the number of layers of the texture
  106426. * @param format defines the format of the texture
  106427. * @param generateMipMaps defines if the engine must generate mip levels
  106428. * @param invertY defines if data must be stored with Y axis inverted
  106429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106430. * @param compression defines the compressed used (can be null)
  106431. * @param textureType defines the compressed used (can be null)
  106432. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106433. */
  106434. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106435. private _unpackFlipYCached;
  106436. /**
  106437. * In case you are sharing the context with other applications, it might
  106438. * be interested to not cache the unpack flip y state to ensure a consistent
  106439. * value would be set.
  106440. */
  106441. enableUnpackFlipYCached: boolean;
  106442. /** @hidden */
  106443. _unpackFlipY(value: boolean): void;
  106444. /** @hidden */
  106445. _getUnpackAlignement(): number;
  106446. private _getTextureTarget;
  106447. /**
  106448. * Update the sampling mode of a given texture
  106449. * @param samplingMode defines the required sampling mode
  106450. * @param texture defines the texture to update
  106451. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106452. */
  106453. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106454. /**
  106455. * Update the sampling mode of a given texture
  106456. * @param texture defines the texture to update
  106457. * @param wrapU defines the texture wrap mode of the u coordinates
  106458. * @param wrapV defines the texture wrap mode of the v coordinates
  106459. * @param wrapR defines the texture wrap mode of the r coordinates
  106460. */
  106461. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106462. /** @hidden */
  106463. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106464. width: number;
  106465. height: number;
  106466. layers?: number;
  106467. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106468. /** @hidden */
  106469. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106470. /** @hidden */
  106471. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106472. /**
  106473. * Update a portion of an internal texture
  106474. * @param texture defines the texture to update
  106475. * @param imageData defines the data to store into the texture
  106476. * @param xOffset defines the x coordinates of the update rectangle
  106477. * @param yOffset defines the y coordinates of the update rectangle
  106478. * @param width defines the width of the update rectangle
  106479. * @param height defines the height of the update rectangle
  106480. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106481. * @param lod defines the lod level to update (0 by default)
  106482. */
  106483. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106484. /** @hidden */
  106485. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106486. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106487. private _prepareWebGLTexture;
  106488. /** @hidden */
  106489. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106490. private _getDepthStencilBuffer;
  106491. /** @hidden */
  106492. _releaseFramebufferObjects(texture: InternalTexture): void;
  106493. /** @hidden */
  106494. _releaseTexture(texture: InternalTexture): void;
  106495. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106496. protected _setProgram(program: WebGLProgram): void;
  106497. protected _boundUniforms: {
  106498. [key: number]: WebGLUniformLocation;
  106499. };
  106500. /**
  106501. * Binds an effect to the webGL context
  106502. * @param effect defines the effect to bind
  106503. */
  106504. bindSamplers(effect: Effect): void;
  106505. private _activateCurrentTexture;
  106506. /** @hidden */
  106507. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106508. /** @hidden */
  106509. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106510. /**
  106511. * Unbind all textures from the webGL context
  106512. */
  106513. unbindAllTextures(): void;
  106514. /**
  106515. * Sets a texture to the according uniform.
  106516. * @param channel The texture channel
  106517. * @param uniform The uniform to set
  106518. * @param texture The texture to apply
  106519. */
  106520. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106521. private _bindSamplerUniformToChannel;
  106522. private _getTextureWrapMode;
  106523. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106524. /**
  106525. * Sets an array of texture to the webGL context
  106526. * @param channel defines the channel where the texture array must be set
  106527. * @param uniform defines the associated uniform location
  106528. * @param textures defines the array of textures to bind
  106529. */
  106530. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106531. /** @hidden */
  106532. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106533. private _setTextureParameterFloat;
  106534. private _setTextureParameterInteger;
  106535. /**
  106536. * Unbind all vertex attributes from the webGL context
  106537. */
  106538. unbindAllAttributes(): void;
  106539. /**
  106540. * 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
  106541. */
  106542. releaseEffects(): void;
  106543. /**
  106544. * Dispose and release all associated resources
  106545. */
  106546. dispose(): void;
  106547. /**
  106548. * Attach a new callback raised when context lost event is fired
  106549. * @param callback defines the callback to call
  106550. */
  106551. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106552. /**
  106553. * Attach a new callback raised when context restored event is fired
  106554. * @param callback defines the callback to call
  106555. */
  106556. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106557. /**
  106558. * Get the current error code of the webGL context
  106559. * @returns the error code
  106560. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106561. */
  106562. getError(): number;
  106563. private _canRenderToFloatFramebuffer;
  106564. private _canRenderToHalfFloatFramebuffer;
  106565. private _canRenderToFramebuffer;
  106566. /** @hidden */
  106567. _getWebGLTextureType(type: number): number;
  106568. /** @hidden */
  106569. _getInternalFormat(format: number): number;
  106570. /** @hidden */
  106571. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106572. /** @hidden */
  106573. _getRGBAMultiSampleBufferFormat(type: number): number;
  106574. /** @hidden */
  106575. _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;
  106576. /**
  106577. * Loads a file from a url
  106578. * @param url url to load
  106579. * @param onSuccess callback called when the file successfully loads
  106580. * @param onProgress callback called while file is loading (if the server supports this mode)
  106581. * @param offlineProvider defines the offline provider for caching
  106582. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106583. * @param onError callback called when the file fails to load
  106584. * @returns a file request object
  106585. * @hidden
  106586. */
  106587. 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;
  106588. /**
  106589. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106590. * @param x defines the x coordinate of the rectangle where pixels must be read
  106591. * @param y defines the y coordinate of the rectangle where pixels must be read
  106592. * @param width defines the width of the rectangle where pixels must be read
  106593. * @param height defines the height of the rectangle where pixels must be read
  106594. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106595. * @returns a Uint8Array containing RGBA colors
  106596. */
  106597. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106598. private static _isSupported;
  106599. /**
  106600. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106601. * @returns true if the engine can be created
  106602. * @ignorenaming
  106603. */
  106604. static isSupported(): boolean;
  106605. /**
  106606. * Find the next highest power of two.
  106607. * @param x Number to start search from.
  106608. * @return Next highest power of two.
  106609. */
  106610. static CeilingPOT(x: number): number;
  106611. /**
  106612. * Find the next lowest power of two.
  106613. * @param x Number to start search from.
  106614. * @return Next lowest power of two.
  106615. */
  106616. static FloorPOT(x: number): number;
  106617. /**
  106618. * Find the nearest power of two.
  106619. * @param x Number to start search from.
  106620. * @return Next nearest power of two.
  106621. */
  106622. static NearestPOT(x: number): number;
  106623. /**
  106624. * Get the closest exponent of two
  106625. * @param value defines the value to approximate
  106626. * @param max defines the maximum value to return
  106627. * @param mode defines how to define the closest value
  106628. * @returns closest exponent of two of the given value
  106629. */
  106630. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106631. /**
  106632. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106633. * @param func - the function to be called
  106634. * @param requester - the object that will request the next frame. Falls back to window.
  106635. * @returns frame number
  106636. */
  106637. static QueueNewFrame(func: () => void, requester?: any): number;
  106638. /**
  106639. * Gets host document
  106640. * @returns the host document object
  106641. */
  106642. getHostDocument(): Nullable<Document>;
  106643. }
  106644. }
  106645. declare module BABYLON {
  106646. /**
  106647. * Class representing spherical harmonics coefficients to the 3rd degree
  106648. */
  106649. export class SphericalHarmonics {
  106650. /**
  106651. * Defines whether or not the harmonics have been prescaled for rendering.
  106652. */
  106653. preScaled: boolean;
  106654. /**
  106655. * The l0,0 coefficients of the spherical harmonics
  106656. */
  106657. l00: Vector3;
  106658. /**
  106659. * The l1,-1 coefficients of the spherical harmonics
  106660. */
  106661. l1_1: Vector3;
  106662. /**
  106663. * The l1,0 coefficients of the spherical harmonics
  106664. */
  106665. l10: Vector3;
  106666. /**
  106667. * The l1,1 coefficients of the spherical harmonics
  106668. */
  106669. l11: Vector3;
  106670. /**
  106671. * The l2,-2 coefficients of the spherical harmonics
  106672. */
  106673. l2_2: Vector3;
  106674. /**
  106675. * The l2,-1 coefficients of the spherical harmonics
  106676. */
  106677. l2_1: Vector3;
  106678. /**
  106679. * The l2,0 coefficients of the spherical harmonics
  106680. */
  106681. l20: Vector3;
  106682. /**
  106683. * The l2,1 coefficients of the spherical harmonics
  106684. */
  106685. l21: Vector3;
  106686. /**
  106687. * The l2,2 coefficients of the spherical harmonics
  106688. */
  106689. l22: Vector3;
  106690. /**
  106691. * Adds a light to the spherical harmonics
  106692. * @param direction the direction of the light
  106693. * @param color the color of the light
  106694. * @param deltaSolidAngle the delta solid angle of the light
  106695. */
  106696. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106697. /**
  106698. * Scales the spherical harmonics by the given amount
  106699. * @param scale the amount to scale
  106700. */
  106701. scaleInPlace(scale: number): void;
  106702. /**
  106703. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106704. *
  106705. * ```
  106706. * E_lm = A_l * L_lm
  106707. * ```
  106708. *
  106709. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106710. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106711. * the scaling factors are given in equation 9.
  106712. */
  106713. convertIncidentRadianceToIrradiance(): void;
  106714. /**
  106715. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106716. *
  106717. * ```
  106718. * L = (1/pi) * E * rho
  106719. * ```
  106720. *
  106721. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106722. */
  106723. convertIrradianceToLambertianRadiance(): void;
  106724. /**
  106725. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106726. * required operations at run time.
  106727. *
  106728. * This is simply done by scaling back the SH with Ylm constants parameter.
  106729. * The trigonometric part being applied by the shader at run time.
  106730. */
  106731. preScaleForRendering(): void;
  106732. /**
  106733. * Constructs a spherical harmonics from an array.
  106734. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106735. * @returns the spherical harmonics
  106736. */
  106737. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106738. /**
  106739. * Gets the spherical harmonics from polynomial
  106740. * @param polynomial the spherical polynomial
  106741. * @returns the spherical harmonics
  106742. */
  106743. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106744. }
  106745. /**
  106746. * Class representing spherical polynomial coefficients to the 3rd degree
  106747. */
  106748. export class SphericalPolynomial {
  106749. private _harmonics;
  106750. /**
  106751. * The spherical harmonics used to create the polynomials.
  106752. */
  106753. get preScaledHarmonics(): SphericalHarmonics;
  106754. /**
  106755. * The x coefficients of the spherical polynomial
  106756. */
  106757. x: Vector3;
  106758. /**
  106759. * The y coefficients of the spherical polynomial
  106760. */
  106761. y: Vector3;
  106762. /**
  106763. * The z coefficients of the spherical polynomial
  106764. */
  106765. z: Vector3;
  106766. /**
  106767. * The xx coefficients of the spherical polynomial
  106768. */
  106769. xx: Vector3;
  106770. /**
  106771. * The yy coefficients of the spherical polynomial
  106772. */
  106773. yy: Vector3;
  106774. /**
  106775. * The zz coefficients of the spherical polynomial
  106776. */
  106777. zz: Vector3;
  106778. /**
  106779. * The xy coefficients of the spherical polynomial
  106780. */
  106781. xy: Vector3;
  106782. /**
  106783. * The yz coefficients of the spherical polynomial
  106784. */
  106785. yz: Vector3;
  106786. /**
  106787. * The zx coefficients of the spherical polynomial
  106788. */
  106789. zx: Vector3;
  106790. /**
  106791. * Adds an ambient color to the spherical polynomial
  106792. * @param color the color to add
  106793. */
  106794. addAmbient(color: Color3): void;
  106795. /**
  106796. * Scales the spherical polynomial by the given amount
  106797. * @param scale the amount to scale
  106798. */
  106799. scaleInPlace(scale: number): void;
  106800. /**
  106801. * Gets the spherical polynomial from harmonics
  106802. * @param harmonics the spherical harmonics
  106803. * @returns the spherical polynomial
  106804. */
  106805. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106806. /**
  106807. * Constructs a spherical polynomial from an array.
  106808. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106809. * @returns the spherical polynomial
  106810. */
  106811. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106812. }
  106813. }
  106814. declare module BABYLON {
  106815. /**
  106816. * Defines the source of the internal texture
  106817. */
  106818. export enum InternalTextureSource {
  106819. /**
  106820. * The source of the texture data is unknown
  106821. */
  106822. Unknown = 0,
  106823. /**
  106824. * Texture data comes from an URL
  106825. */
  106826. Url = 1,
  106827. /**
  106828. * Texture data is only used for temporary storage
  106829. */
  106830. Temp = 2,
  106831. /**
  106832. * Texture data comes from raw data (ArrayBuffer)
  106833. */
  106834. Raw = 3,
  106835. /**
  106836. * Texture content is dynamic (video or dynamic texture)
  106837. */
  106838. Dynamic = 4,
  106839. /**
  106840. * Texture content is generated by rendering to it
  106841. */
  106842. RenderTarget = 5,
  106843. /**
  106844. * Texture content is part of a multi render target process
  106845. */
  106846. MultiRenderTarget = 6,
  106847. /**
  106848. * Texture data comes from a cube data file
  106849. */
  106850. Cube = 7,
  106851. /**
  106852. * Texture data comes from a raw cube data
  106853. */
  106854. CubeRaw = 8,
  106855. /**
  106856. * Texture data come from a prefiltered cube data file
  106857. */
  106858. CubePrefiltered = 9,
  106859. /**
  106860. * Texture content is raw 3D data
  106861. */
  106862. Raw3D = 10,
  106863. /**
  106864. * Texture content is raw 2D array data
  106865. */
  106866. Raw2DArray = 11,
  106867. /**
  106868. * Texture content is a depth texture
  106869. */
  106870. Depth = 12,
  106871. /**
  106872. * Texture data comes from a raw cube data encoded with RGBD
  106873. */
  106874. CubeRawRGBD = 13
  106875. }
  106876. /**
  106877. * Class used to store data associated with WebGL texture data for the engine
  106878. * This class should not be used directly
  106879. */
  106880. export class InternalTexture {
  106881. /** @hidden */
  106882. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106883. /**
  106884. * Defines if the texture is ready
  106885. */
  106886. isReady: boolean;
  106887. /**
  106888. * Defines if the texture is a cube texture
  106889. */
  106890. isCube: boolean;
  106891. /**
  106892. * Defines if the texture contains 3D data
  106893. */
  106894. is3D: boolean;
  106895. /**
  106896. * Defines if the texture contains 2D array data
  106897. */
  106898. is2DArray: boolean;
  106899. /**
  106900. * Defines if the texture contains multiview data
  106901. */
  106902. isMultiview: boolean;
  106903. /**
  106904. * Gets the URL used to load this texture
  106905. */
  106906. url: string;
  106907. /**
  106908. * Gets the sampling mode of the texture
  106909. */
  106910. samplingMode: number;
  106911. /**
  106912. * Gets a boolean indicating if the texture needs mipmaps generation
  106913. */
  106914. generateMipMaps: boolean;
  106915. /**
  106916. * Gets the number of samples used by the texture (WebGL2+ only)
  106917. */
  106918. samples: number;
  106919. /**
  106920. * Gets the type of the texture (int, float...)
  106921. */
  106922. type: number;
  106923. /**
  106924. * Gets the format of the texture (RGB, RGBA...)
  106925. */
  106926. format: number;
  106927. /**
  106928. * Observable called when the texture is loaded
  106929. */
  106930. onLoadedObservable: Observable<InternalTexture>;
  106931. /**
  106932. * Gets the width of the texture
  106933. */
  106934. width: number;
  106935. /**
  106936. * Gets the height of the texture
  106937. */
  106938. height: number;
  106939. /**
  106940. * Gets the depth of the texture
  106941. */
  106942. depth: number;
  106943. /**
  106944. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106945. */
  106946. baseWidth: number;
  106947. /**
  106948. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106949. */
  106950. baseHeight: number;
  106951. /**
  106952. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106953. */
  106954. baseDepth: number;
  106955. /**
  106956. * Gets a boolean indicating if the texture is inverted on Y axis
  106957. */
  106958. invertY: boolean;
  106959. /** @hidden */
  106960. _invertVScale: boolean;
  106961. /** @hidden */
  106962. _associatedChannel: number;
  106963. /** @hidden */
  106964. _source: InternalTextureSource;
  106965. /** @hidden */
  106966. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106967. /** @hidden */
  106968. _bufferView: Nullable<ArrayBufferView>;
  106969. /** @hidden */
  106970. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106971. /** @hidden */
  106972. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106973. /** @hidden */
  106974. _size: number;
  106975. /** @hidden */
  106976. _extension: string;
  106977. /** @hidden */
  106978. _files: Nullable<string[]>;
  106979. /** @hidden */
  106980. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106981. /** @hidden */
  106982. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106983. /** @hidden */
  106984. _framebuffer: Nullable<WebGLFramebuffer>;
  106985. /** @hidden */
  106986. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106987. /** @hidden */
  106988. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106989. /** @hidden */
  106990. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106991. /** @hidden */
  106992. _attachments: Nullable<number[]>;
  106993. /** @hidden */
  106994. _cachedCoordinatesMode: Nullable<number>;
  106995. /** @hidden */
  106996. _cachedWrapU: Nullable<number>;
  106997. /** @hidden */
  106998. _cachedWrapV: Nullable<number>;
  106999. /** @hidden */
  107000. _cachedWrapR: Nullable<number>;
  107001. /** @hidden */
  107002. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107003. /** @hidden */
  107004. _isDisabled: boolean;
  107005. /** @hidden */
  107006. _compression: Nullable<string>;
  107007. /** @hidden */
  107008. _generateStencilBuffer: boolean;
  107009. /** @hidden */
  107010. _generateDepthBuffer: boolean;
  107011. /** @hidden */
  107012. _comparisonFunction: number;
  107013. /** @hidden */
  107014. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107015. /** @hidden */
  107016. _lodGenerationScale: number;
  107017. /** @hidden */
  107018. _lodGenerationOffset: number;
  107019. /** @hidden */
  107020. _depthStencilTexture: Nullable<InternalTexture>;
  107021. /** @hidden */
  107022. _colorTextureArray: Nullable<WebGLTexture>;
  107023. /** @hidden */
  107024. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107025. /** @hidden */
  107026. _lodTextureHigh: Nullable<BaseTexture>;
  107027. /** @hidden */
  107028. _lodTextureMid: Nullable<BaseTexture>;
  107029. /** @hidden */
  107030. _lodTextureLow: Nullable<BaseTexture>;
  107031. /** @hidden */
  107032. _isRGBD: boolean;
  107033. /** @hidden */
  107034. _linearSpecularLOD: boolean;
  107035. /** @hidden */
  107036. _irradianceTexture: Nullable<BaseTexture>;
  107037. /** @hidden */
  107038. _webGLTexture: Nullable<WebGLTexture>;
  107039. /** @hidden */
  107040. _references: number;
  107041. private _engine;
  107042. /**
  107043. * Gets the Engine the texture belongs to.
  107044. * @returns The babylon engine
  107045. */
  107046. getEngine(): ThinEngine;
  107047. /**
  107048. * Gets the data source type of the texture
  107049. */
  107050. get source(): InternalTextureSource;
  107051. /**
  107052. * Creates a new InternalTexture
  107053. * @param engine defines the engine to use
  107054. * @param source defines the type of data that will be used
  107055. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107056. */
  107057. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107058. /**
  107059. * Increments the number of references (ie. the number of Texture that point to it)
  107060. */
  107061. incrementReferences(): void;
  107062. /**
  107063. * Change the size of the texture (not the size of the content)
  107064. * @param width defines the new width
  107065. * @param height defines the new height
  107066. * @param depth defines the new depth (1 by default)
  107067. */
  107068. updateSize(width: int, height: int, depth?: int): void;
  107069. /** @hidden */
  107070. _rebuild(): void;
  107071. /** @hidden */
  107072. _swapAndDie(target: InternalTexture): void;
  107073. /**
  107074. * Dispose the current allocated resources
  107075. */
  107076. dispose(): void;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. /**
  107081. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107083. */
  107084. export class Analyser {
  107085. /**
  107086. * Gets or sets the smoothing
  107087. * @ignorenaming
  107088. */
  107089. SMOOTHING: number;
  107090. /**
  107091. * Gets or sets the FFT table size
  107092. * @ignorenaming
  107093. */
  107094. FFT_SIZE: number;
  107095. /**
  107096. * Gets or sets the bar graph amplitude
  107097. * @ignorenaming
  107098. */
  107099. BARGRAPHAMPLITUDE: number;
  107100. /**
  107101. * Gets or sets the position of the debug canvas
  107102. * @ignorenaming
  107103. */
  107104. DEBUGCANVASPOS: {
  107105. x: number;
  107106. y: number;
  107107. };
  107108. /**
  107109. * Gets or sets the debug canvas size
  107110. * @ignorenaming
  107111. */
  107112. DEBUGCANVASSIZE: {
  107113. width: number;
  107114. height: number;
  107115. };
  107116. private _byteFreqs;
  107117. private _byteTime;
  107118. private _floatFreqs;
  107119. private _webAudioAnalyser;
  107120. private _debugCanvas;
  107121. private _debugCanvasContext;
  107122. private _scene;
  107123. private _registerFunc;
  107124. private _audioEngine;
  107125. /**
  107126. * Creates a new analyser
  107127. * @param scene defines hosting scene
  107128. */
  107129. constructor(scene: Scene);
  107130. /**
  107131. * Get the number of data values you will have to play with for the visualization
  107132. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107133. * @returns a number
  107134. */
  107135. getFrequencyBinCount(): number;
  107136. /**
  107137. * Gets the current frequency data as a byte array
  107138. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107139. * @returns a Uint8Array
  107140. */
  107141. getByteFrequencyData(): Uint8Array;
  107142. /**
  107143. * Gets the current waveform as a byte array
  107144. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107145. * @returns a Uint8Array
  107146. */
  107147. getByteTimeDomainData(): Uint8Array;
  107148. /**
  107149. * Gets the current frequency data as a float array
  107150. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107151. * @returns a Float32Array
  107152. */
  107153. getFloatFrequencyData(): Float32Array;
  107154. /**
  107155. * Renders the debug canvas
  107156. */
  107157. drawDebugCanvas(): void;
  107158. /**
  107159. * Stops rendering the debug canvas and removes it
  107160. */
  107161. stopDebugCanvas(): void;
  107162. /**
  107163. * Connects two audio nodes
  107164. * @param inputAudioNode defines first node to connect
  107165. * @param outputAudioNode defines second node to connect
  107166. */
  107167. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107168. /**
  107169. * Releases all associated resources
  107170. */
  107171. dispose(): void;
  107172. }
  107173. }
  107174. declare module BABYLON {
  107175. /**
  107176. * This represents an audio engine and it is responsible
  107177. * to play, synchronize and analyse sounds throughout the application.
  107178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107179. */
  107180. export interface IAudioEngine extends IDisposable {
  107181. /**
  107182. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107183. */
  107184. readonly canUseWebAudio: boolean;
  107185. /**
  107186. * Gets the current AudioContext if available.
  107187. */
  107188. readonly audioContext: Nullable<AudioContext>;
  107189. /**
  107190. * The master gain node defines the global audio volume of your audio engine.
  107191. */
  107192. readonly masterGain: GainNode;
  107193. /**
  107194. * Gets whether or not mp3 are supported by your browser.
  107195. */
  107196. readonly isMP3supported: boolean;
  107197. /**
  107198. * Gets whether or not ogg are supported by your browser.
  107199. */
  107200. readonly isOGGsupported: boolean;
  107201. /**
  107202. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107203. * @ignoreNaming
  107204. */
  107205. WarnedWebAudioUnsupported: boolean;
  107206. /**
  107207. * Defines if the audio engine relies on a custom unlocked button.
  107208. * In this case, the embedded button will not be displayed.
  107209. */
  107210. useCustomUnlockedButton: boolean;
  107211. /**
  107212. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107213. */
  107214. readonly unlocked: boolean;
  107215. /**
  107216. * Event raised when audio has been unlocked on the browser.
  107217. */
  107218. onAudioUnlockedObservable: Observable<AudioEngine>;
  107219. /**
  107220. * Event raised when audio has been locked on the browser.
  107221. */
  107222. onAudioLockedObservable: Observable<AudioEngine>;
  107223. /**
  107224. * Flags the audio engine in Locked state.
  107225. * This happens due to new browser policies preventing audio to autoplay.
  107226. */
  107227. lock(): void;
  107228. /**
  107229. * Unlocks the audio engine once a user action has been done on the dom.
  107230. * This is helpful to resume play once browser policies have been satisfied.
  107231. */
  107232. unlock(): void;
  107233. /**
  107234. * Gets the global volume sets on the master gain.
  107235. * @returns the global volume if set or -1 otherwise
  107236. */
  107237. getGlobalVolume(): number;
  107238. /**
  107239. * Sets the global volume of your experience (sets on the master gain).
  107240. * @param newVolume Defines the new global volume of the application
  107241. */
  107242. setGlobalVolume(newVolume: number): void;
  107243. /**
  107244. * Connect the audio engine to an audio analyser allowing some amazing
  107245. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107247. * @param analyser The analyser to connect to the engine
  107248. */
  107249. connectToAnalyser(analyser: Analyser): void;
  107250. }
  107251. /**
  107252. * This represents the default audio engine used in babylon.
  107253. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107255. */
  107256. export class AudioEngine implements IAudioEngine {
  107257. private _audioContext;
  107258. private _audioContextInitialized;
  107259. private _muteButton;
  107260. private _hostElement;
  107261. /**
  107262. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107263. */
  107264. canUseWebAudio: boolean;
  107265. /**
  107266. * The master gain node defines the global audio volume of your audio engine.
  107267. */
  107268. masterGain: GainNode;
  107269. /**
  107270. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107271. * @ignoreNaming
  107272. */
  107273. WarnedWebAudioUnsupported: boolean;
  107274. /**
  107275. * Gets whether or not mp3 are supported by your browser.
  107276. */
  107277. isMP3supported: boolean;
  107278. /**
  107279. * Gets whether or not ogg are supported by your browser.
  107280. */
  107281. isOGGsupported: boolean;
  107282. /**
  107283. * Gets whether audio has been unlocked on the device.
  107284. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107285. * a user interaction has happened.
  107286. */
  107287. unlocked: boolean;
  107288. /**
  107289. * Defines if the audio engine relies on a custom unlocked button.
  107290. * In this case, the embedded button will not be displayed.
  107291. */
  107292. useCustomUnlockedButton: boolean;
  107293. /**
  107294. * Event raised when audio has been unlocked on the browser.
  107295. */
  107296. onAudioUnlockedObservable: Observable<AudioEngine>;
  107297. /**
  107298. * Event raised when audio has been locked on the browser.
  107299. */
  107300. onAudioLockedObservable: Observable<AudioEngine>;
  107301. /**
  107302. * Gets the current AudioContext if available.
  107303. */
  107304. get audioContext(): Nullable<AudioContext>;
  107305. private _connectedAnalyser;
  107306. /**
  107307. * Instantiates a new audio engine.
  107308. *
  107309. * There should be only one per page as some browsers restrict the number
  107310. * of audio contexts you can create.
  107311. * @param hostElement defines the host element where to display the mute icon if necessary
  107312. */
  107313. constructor(hostElement?: Nullable<HTMLElement>);
  107314. /**
  107315. * Flags the audio engine in Locked state.
  107316. * This happens due to new browser policies preventing audio to autoplay.
  107317. */
  107318. lock(): void;
  107319. /**
  107320. * Unlocks the audio engine once a user action has been done on the dom.
  107321. * This is helpful to resume play once browser policies have been satisfied.
  107322. */
  107323. unlock(): void;
  107324. private _resumeAudioContext;
  107325. private _initializeAudioContext;
  107326. private _tryToRun;
  107327. private _triggerRunningState;
  107328. private _triggerSuspendedState;
  107329. private _displayMuteButton;
  107330. private _moveButtonToTopLeft;
  107331. private _onResize;
  107332. private _hideMuteButton;
  107333. /**
  107334. * Destroy and release the resources associated with the audio ccontext.
  107335. */
  107336. dispose(): void;
  107337. /**
  107338. * Gets the global volume sets on the master gain.
  107339. * @returns the global volume if set or -1 otherwise
  107340. */
  107341. getGlobalVolume(): number;
  107342. /**
  107343. * Sets the global volume of your experience (sets on the master gain).
  107344. * @param newVolume Defines the new global volume of the application
  107345. */
  107346. setGlobalVolume(newVolume: number): void;
  107347. /**
  107348. * Connect the audio engine to an audio analyser allowing some amazing
  107349. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107351. * @param analyser The analyser to connect to the engine
  107352. */
  107353. connectToAnalyser(analyser: Analyser): void;
  107354. }
  107355. }
  107356. declare module BABYLON {
  107357. /**
  107358. * Interface used to present a loading screen while loading a scene
  107359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107360. */
  107361. export interface ILoadingScreen {
  107362. /**
  107363. * Function called to display the loading screen
  107364. */
  107365. displayLoadingUI: () => void;
  107366. /**
  107367. * Function called to hide the loading screen
  107368. */
  107369. hideLoadingUI: () => void;
  107370. /**
  107371. * Gets or sets the color to use for the background
  107372. */
  107373. loadingUIBackgroundColor: string;
  107374. /**
  107375. * Gets or sets the text to display while loading
  107376. */
  107377. loadingUIText: string;
  107378. }
  107379. /**
  107380. * Class used for the default loading screen
  107381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107382. */
  107383. export class DefaultLoadingScreen implements ILoadingScreen {
  107384. private _renderingCanvas;
  107385. private _loadingText;
  107386. private _loadingDivBackgroundColor;
  107387. private _loadingDiv;
  107388. private _loadingTextDiv;
  107389. /** Gets or sets the logo url to use for the default loading screen */
  107390. static DefaultLogoUrl: string;
  107391. /** Gets or sets the spinner url to use for the default loading screen */
  107392. static DefaultSpinnerUrl: string;
  107393. /**
  107394. * Creates a new default loading screen
  107395. * @param _renderingCanvas defines the canvas used to render the scene
  107396. * @param _loadingText defines the default text to display
  107397. * @param _loadingDivBackgroundColor defines the default background color
  107398. */
  107399. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107400. /**
  107401. * Function called to display the loading screen
  107402. */
  107403. displayLoadingUI(): void;
  107404. /**
  107405. * Function called to hide the loading screen
  107406. */
  107407. hideLoadingUI(): void;
  107408. /**
  107409. * Gets or sets the text to display while loading
  107410. */
  107411. set loadingUIText(text: string);
  107412. get loadingUIText(): string;
  107413. /**
  107414. * Gets or sets the color to use for the background
  107415. */
  107416. get loadingUIBackgroundColor(): string;
  107417. set loadingUIBackgroundColor(color: string);
  107418. private _resizeLoadingUI;
  107419. }
  107420. }
  107421. declare module BABYLON {
  107422. /**
  107423. * Interface for any object that can request an animation frame
  107424. */
  107425. export interface ICustomAnimationFrameRequester {
  107426. /**
  107427. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107428. */
  107429. renderFunction?: Function;
  107430. /**
  107431. * Called to request the next frame to render to
  107432. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107433. */
  107434. requestAnimationFrame: Function;
  107435. /**
  107436. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107437. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107438. */
  107439. requestID?: number;
  107440. }
  107441. }
  107442. declare module BABYLON {
  107443. /**
  107444. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107445. */
  107446. export class PerformanceMonitor {
  107447. private _enabled;
  107448. private _rollingFrameTime;
  107449. private _lastFrameTimeMs;
  107450. /**
  107451. * constructor
  107452. * @param frameSampleSize The number of samples required to saturate the sliding window
  107453. */
  107454. constructor(frameSampleSize?: number);
  107455. /**
  107456. * Samples current frame
  107457. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107458. */
  107459. sampleFrame(timeMs?: number): void;
  107460. /**
  107461. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107462. */
  107463. get averageFrameTime(): number;
  107464. /**
  107465. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107466. */
  107467. get averageFrameTimeVariance(): number;
  107468. /**
  107469. * Returns the frame time of the most recent frame
  107470. */
  107471. get instantaneousFrameTime(): number;
  107472. /**
  107473. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107474. */
  107475. get averageFPS(): number;
  107476. /**
  107477. * Returns the average framerate in frames per second using the most recent frame time
  107478. */
  107479. get instantaneousFPS(): number;
  107480. /**
  107481. * Returns true if enough samples have been taken to completely fill the sliding window
  107482. */
  107483. get isSaturated(): boolean;
  107484. /**
  107485. * Enables contributions to the sliding window sample set
  107486. */
  107487. enable(): void;
  107488. /**
  107489. * Disables contributions to the sliding window sample set
  107490. * Samples will not be interpolated over the disabled period
  107491. */
  107492. disable(): void;
  107493. /**
  107494. * Returns true if sampling is enabled
  107495. */
  107496. get isEnabled(): boolean;
  107497. /**
  107498. * Resets performance monitor
  107499. */
  107500. reset(): void;
  107501. }
  107502. /**
  107503. * RollingAverage
  107504. *
  107505. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107506. */
  107507. export class RollingAverage {
  107508. /**
  107509. * Current average
  107510. */
  107511. average: number;
  107512. /**
  107513. * Current variance
  107514. */
  107515. variance: number;
  107516. protected _samples: Array<number>;
  107517. protected _sampleCount: number;
  107518. protected _pos: number;
  107519. protected _m2: number;
  107520. /**
  107521. * constructor
  107522. * @param length The number of samples required to saturate the sliding window
  107523. */
  107524. constructor(length: number);
  107525. /**
  107526. * Adds a sample to the sample set
  107527. * @param v The sample value
  107528. */
  107529. add(v: number): void;
  107530. /**
  107531. * Returns previously added values or null if outside of history or outside the sliding window domain
  107532. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107533. * @return Value previously recorded with add() or null if outside of range
  107534. */
  107535. history(i: number): number;
  107536. /**
  107537. * Returns true if enough samples have been taken to completely fill the sliding window
  107538. * @return true if sample-set saturated
  107539. */
  107540. isSaturated(): boolean;
  107541. /**
  107542. * Resets the rolling average (equivalent to 0 samples taken so far)
  107543. */
  107544. reset(): void;
  107545. /**
  107546. * Wraps a value around the sample range boundaries
  107547. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107548. * @return Wrapped position in sample range
  107549. */
  107550. protected _wrapPosition(i: number): number;
  107551. }
  107552. }
  107553. declare module BABYLON {
  107554. /**
  107555. * This class is used to track a performance counter which is number based.
  107556. * The user has access to many properties which give statistics of different nature.
  107557. *
  107558. * The implementer can track two kinds of Performance Counter: time and count.
  107559. * 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.
  107560. * 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.
  107561. */
  107562. export class PerfCounter {
  107563. /**
  107564. * Gets or sets a global boolean to turn on and off all the counters
  107565. */
  107566. static Enabled: boolean;
  107567. /**
  107568. * Returns the smallest value ever
  107569. */
  107570. get min(): number;
  107571. /**
  107572. * Returns the biggest value ever
  107573. */
  107574. get max(): number;
  107575. /**
  107576. * Returns the average value since the performance counter is running
  107577. */
  107578. get average(): number;
  107579. /**
  107580. * Returns the average value of the last second the counter was monitored
  107581. */
  107582. get lastSecAverage(): number;
  107583. /**
  107584. * Returns the current value
  107585. */
  107586. get current(): number;
  107587. /**
  107588. * Gets the accumulated total
  107589. */
  107590. get total(): number;
  107591. /**
  107592. * Gets the total value count
  107593. */
  107594. get count(): number;
  107595. /**
  107596. * Creates a new counter
  107597. */
  107598. constructor();
  107599. /**
  107600. * Call this method to start monitoring a new frame.
  107601. * 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.
  107602. */
  107603. fetchNewFrame(): void;
  107604. /**
  107605. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107606. * @param newCount the count value to add to the monitored count
  107607. * @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.
  107608. */
  107609. addCount(newCount: number, fetchResult: boolean): void;
  107610. /**
  107611. * Start monitoring this performance counter
  107612. */
  107613. beginMonitoring(): void;
  107614. /**
  107615. * Compute the time lapsed since the previous beginMonitoring() call.
  107616. * @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
  107617. */
  107618. endMonitoring(newFrame?: boolean): void;
  107619. private _fetchResult;
  107620. private _startMonitoringTime;
  107621. private _min;
  107622. private _max;
  107623. private _average;
  107624. private _current;
  107625. private _totalValueCount;
  107626. private _totalAccumulated;
  107627. private _lastSecAverage;
  107628. private _lastSecAccumulated;
  107629. private _lastSecTime;
  107630. private _lastSecValueCount;
  107631. }
  107632. }
  107633. declare module BABYLON {
  107634. interface ThinEngine {
  107635. /**
  107636. * Sets alpha constants used by some alpha blending modes
  107637. * @param r defines the red component
  107638. * @param g defines the green component
  107639. * @param b defines the blue component
  107640. * @param a defines the alpha component
  107641. */
  107642. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107643. /**
  107644. * Sets the current alpha mode
  107645. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107646. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107647. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107648. */
  107649. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107650. /**
  107651. * Gets the current alpha mode
  107652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107653. * @returns the current alpha mode
  107654. */
  107655. getAlphaMode(): number;
  107656. /**
  107657. * Sets the current alpha equation
  107658. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107659. */
  107660. setAlphaEquation(equation: number): void;
  107661. /**
  107662. * Gets the current alpha equation.
  107663. * @returns the current alpha equation
  107664. */
  107665. getAlphaEquation(): number;
  107666. }
  107667. }
  107668. declare module BABYLON {
  107669. /**
  107670. * Defines the interface used by display changed events
  107671. */
  107672. export interface IDisplayChangedEventArgs {
  107673. /** Gets the vrDisplay object (if any) */
  107674. vrDisplay: Nullable<any>;
  107675. /** Gets a boolean indicating if webVR is supported */
  107676. vrSupported: boolean;
  107677. }
  107678. /**
  107679. * Defines the interface used by objects containing a viewport (like a camera)
  107680. */
  107681. interface IViewportOwnerLike {
  107682. /**
  107683. * Gets or sets the viewport
  107684. */
  107685. viewport: IViewportLike;
  107686. }
  107687. /**
  107688. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107689. */
  107690. export class Engine extends ThinEngine {
  107691. /** Defines that alpha blending is disabled */
  107692. static readonly ALPHA_DISABLE: number;
  107693. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107694. static readonly ALPHA_ADD: number;
  107695. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107696. static readonly ALPHA_COMBINE: number;
  107697. /** Defines that alpha blending to DEST - SRC * DEST */
  107698. static readonly ALPHA_SUBTRACT: number;
  107699. /** Defines that alpha blending to SRC * DEST */
  107700. static readonly ALPHA_MULTIPLY: number;
  107701. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107702. static readonly ALPHA_MAXIMIZED: number;
  107703. /** Defines that alpha blending to SRC + DEST */
  107704. static readonly ALPHA_ONEONE: number;
  107705. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107706. static readonly ALPHA_PREMULTIPLIED: number;
  107707. /**
  107708. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107709. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107710. */
  107711. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107712. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107713. static readonly ALPHA_INTERPOLATE: number;
  107714. /**
  107715. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107716. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107717. */
  107718. static readonly ALPHA_SCREENMODE: number;
  107719. /** Defines that the ressource is not delayed*/
  107720. static readonly DELAYLOADSTATE_NONE: number;
  107721. /** Defines that the ressource was successfully delay loaded */
  107722. static readonly DELAYLOADSTATE_LOADED: number;
  107723. /** Defines that the ressource is currently delay loading */
  107724. static readonly DELAYLOADSTATE_LOADING: number;
  107725. /** Defines that the ressource is delayed and has not started loading */
  107726. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107728. static readonly NEVER: number;
  107729. /** 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 */
  107730. static readonly ALWAYS: number;
  107731. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107732. static readonly LESS: number;
  107733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107734. static readonly EQUAL: number;
  107735. /** 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 */
  107736. static readonly LEQUAL: number;
  107737. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107738. static readonly GREATER: number;
  107739. /** 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 */
  107740. static readonly GEQUAL: number;
  107741. /** 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 */
  107742. static readonly NOTEQUAL: number;
  107743. /** Passed to stencilOperation to specify that stencil value must be kept */
  107744. static readonly KEEP: number;
  107745. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107746. static readonly REPLACE: number;
  107747. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107748. static readonly INCR: number;
  107749. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107750. static readonly DECR: number;
  107751. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107752. static readonly INVERT: number;
  107753. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107754. static readonly INCR_WRAP: number;
  107755. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107756. static readonly DECR_WRAP: number;
  107757. /** Texture is not repeating outside of 0..1 UVs */
  107758. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107759. /** Texture is repeating outside of 0..1 UVs */
  107760. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107761. /** Texture is repeating and mirrored */
  107762. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107763. /** ALPHA */
  107764. static readonly TEXTUREFORMAT_ALPHA: number;
  107765. /** LUMINANCE */
  107766. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107767. /** LUMINANCE_ALPHA */
  107768. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107769. /** RGB */
  107770. static readonly TEXTUREFORMAT_RGB: number;
  107771. /** RGBA */
  107772. static readonly TEXTUREFORMAT_RGBA: number;
  107773. /** RED */
  107774. static readonly TEXTUREFORMAT_RED: number;
  107775. /** RED (2nd reference) */
  107776. static readonly TEXTUREFORMAT_R: number;
  107777. /** RG */
  107778. static readonly TEXTUREFORMAT_RG: number;
  107779. /** RED_INTEGER */
  107780. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107781. /** RED_INTEGER (2nd reference) */
  107782. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107783. /** RG_INTEGER */
  107784. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107785. /** RGB_INTEGER */
  107786. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107787. /** RGBA_INTEGER */
  107788. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107789. /** UNSIGNED_BYTE */
  107790. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107791. /** UNSIGNED_BYTE (2nd reference) */
  107792. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107793. /** FLOAT */
  107794. static readonly TEXTURETYPE_FLOAT: number;
  107795. /** HALF_FLOAT */
  107796. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107797. /** BYTE */
  107798. static readonly TEXTURETYPE_BYTE: number;
  107799. /** SHORT */
  107800. static readonly TEXTURETYPE_SHORT: number;
  107801. /** UNSIGNED_SHORT */
  107802. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107803. /** INT */
  107804. static readonly TEXTURETYPE_INT: number;
  107805. /** UNSIGNED_INT */
  107806. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107807. /** UNSIGNED_SHORT_4_4_4_4 */
  107808. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107809. /** UNSIGNED_SHORT_5_5_5_1 */
  107810. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107811. /** UNSIGNED_SHORT_5_6_5 */
  107812. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107813. /** UNSIGNED_INT_2_10_10_10_REV */
  107814. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107815. /** UNSIGNED_INT_24_8 */
  107816. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107817. /** UNSIGNED_INT_10F_11F_11F_REV */
  107818. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107819. /** UNSIGNED_INT_5_9_9_9_REV */
  107820. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107821. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107822. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107823. /** nearest is mag = nearest and min = nearest and mip = linear */
  107824. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107825. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107826. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107827. /** Trilinear is mag = linear and min = linear and mip = linear */
  107828. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107829. /** nearest is mag = nearest and min = nearest and mip = linear */
  107830. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107831. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107832. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107833. /** Trilinear is mag = linear and min = linear and mip = linear */
  107834. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107835. /** mag = nearest and min = nearest and mip = nearest */
  107836. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107837. /** mag = nearest and min = linear and mip = nearest */
  107838. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107839. /** mag = nearest and min = linear and mip = linear */
  107840. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107841. /** mag = nearest and min = linear and mip = none */
  107842. static readonly TEXTURE_NEAREST_LINEAR: number;
  107843. /** mag = nearest and min = nearest and mip = none */
  107844. static readonly TEXTURE_NEAREST_NEAREST: number;
  107845. /** mag = linear and min = nearest and mip = nearest */
  107846. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107847. /** mag = linear and min = nearest and mip = linear */
  107848. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107849. /** mag = linear and min = linear and mip = none */
  107850. static readonly TEXTURE_LINEAR_LINEAR: number;
  107851. /** mag = linear and min = nearest and mip = none */
  107852. static readonly TEXTURE_LINEAR_NEAREST: number;
  107853. /** Explicit coordinates mode */
  107854. static readonly TEXTURE_EXPLICIT_MODE: number;
  107855. /** Spherical coordinates mode */
  107856. static readonly TEXTURE_SPHERICAL_MODE: number;
  107857. /** Planar coordinates mode */
  107858. static readonly TEXTURE_PLANAR_MODE: number;
  107859. /** Cubic coordinates mode */
  107860. static readonly TEXTURE_CUBIC_MODE: number;
  107861. /** Projection coordinates mode */
  107862. static readonly TEXTURE_PROJECTION_MODE: number;
  107863. /** Skybox coordinates mode */
  107864. static readonly TEXTURE_SKYBOX_MODE: number;
  107865. /** Inverse Cubic coordinates mode */
  107866. static readonly TEXTURE_INVCUBIC_MODE: number;
  107867. /** Equirectangular coordinates mode */
  107868. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107869. /** Equirectangular Fixed coordinates mode */
  107870. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107871. /** Equirectangular Fixed Mirrored coordinates mode */
  107872. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107873. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107874. static readonly SCALEMODE_FLOOR: number;
  107875. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107876. static readonly SCALEMODE_NEAREST: number;
  107877. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107878. static readonly SCALEMODE_CEILING: number;
  107879. /**
  107880. * Returns the current npm package of the sdk
  107881. */
  107882. static get NpmPackage(): string;
  107883. /**
  107884. * Returns the current version of the framework
  107885. */
  107886. static get Version(): string;
  107887. /** Gets the list of created engines */
  107888. static get Instances(): Engine[];
  107889. /**
  107890. * Gets the latest created engine
  107891. */
  107892. static get LastCreatedEngine(): Nullable<Engine>;
  107893. /**
  107894. * Gets the latest created scene
  107895. */
  107896. static get LastCreatedScene(): Nullable<Scene>;
  107897. /**
  107898. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107899. * @param flag defines which part of the materials must be marked as dirty
  107900. * @param predicate defines a predicate used to filter which materials should be affected
  107901. */
  107902. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107903. /**
  107904. * Method called to create the default loading screen.
  107905. * This can be overriden in your own app.
  107906. * @param canvas The rendering canvas element
  107907. * @returns The loading screen
  107908. */
  107909. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107910. /**
  107911. * Method called to create the default rescale post process on each engine.
  107912. */
  107913. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107914. /**
  107915. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107916. **/
  107917. enableOfflineSupport: boolean;
  107918. /**
  107919. * 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)
  107920. **/
  107921. disableManifestCheck: boolean;
  107922. /**
  107923. * Gets the list of created scenes
  107924. */
  107925. scenes: Scene[];
  107926. /**
  107927. * Event raised when a new scene is created
  107928. */
  107929. onNewSceneAddedObservable: Observable<Scene>;
  107930. /**
  107931. * Gets the list of created postprocesses
  107932. */
  107933. postProcesses: PostProcess[];
  107934. /**
  107935. * Gets a boolean indicating if the pointer is currently locked
  107936. */
  107937. isPointerLock: boolean;
  107938. /**
  107939. * Observable event triggered each time the rendering canvas is resized
  107940. */
  107941. onResizeObservable: Observable<Engine>;
  107942. /**
  107943. * Observable event triggered each time the canvas loses focus
  107944. */
  107945. onCanvasBlurObservable: Observable<Engine>;
  107946. /**
  107947. * Observable event triggered each time the canvas gains focus
  107948. */
  107949. onCanvasFocusObservable: Observable<Engine>;
  107950. /**
  107951. * Observable event triggered each time the canvas receives pointerout event
  107952. */
  107953. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107954. /**
  107955. * Observable raised when the engine begins a new frame
  107956. */
  107957. onBeginFrameObservable: Observable<Engine>;
  107958. /**
  107959. * If set, will be used to request the next animation frame for the render loop
  107960. */
  107961. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107962. /**
  107963. * Observable raised when the engine ends the current frame
  107964. */
  107965. onEndFrameObservable: Observable<Engine>;
  107966. /**
  107967. * Observable raised when the engine is about to compile a shader
  107968. */
  107969. onBeforeShaderCompilationObservable: Observable<Engine>;
  107970. /**
  107971. * Observable raised when the engine has jsut compiled a shader
  107972. */
  107973. onAfterShaderCompilationObservable: Observable<Engine>;
  107974. /**
  107975. * Gets the audio engine
  107976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107977. * @ignorenaming
  107978. */
  107979. static audioEngine: IAudioEngine;
  107980. /**
  107981. * Default AudioEngine factory responsible of creating the Audio Engine.
  107982. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107983. */
  107984. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107985. /**
  107986. * Default offline support factory responsible of creating a tool used to store data locally.
  107987. * By default, this will create a Database object if the workload has been embedded.
  107988. */
  107989. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107990. private _loadingScreen;
  107991. private _pointerLockRequested;
  107992. private _dummyFramebuffer;
  107993. private _rescalePostProcess;
  107994. private _deterministicLockstep;
  107995. private _lockstepMaxSteps;
  107996. private _timeStep;
  107997. protected get _supportsHardwareTextureRescaling(): boolean;
  107998. private _fps;
  107999. private _deltaTime;
  108000. /** @hidden */
  108001. _drawCalls: PerfCounter;
  108002. /** 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 */
  108003. canvasTabIndex: number;
  108004. /**
  108005. * Turn this value on if you want to pause FPS computation when in background
  108006. */
  108007. disablePerformanceMonitorInBackground: boolean;
  108008. private _performanceMonitor;
  108009. /**
  108010. * Gets the performance monitor attached to this engine
  108011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108012. */
  108013. get performanceMonitor(): PerformanceMonitor;
  108014. private _onFocus;
  108015. private _onBlur;
  108016. private _onCanvasPointerOut;
  108017. private _onCanvasBlur;
  108018. private _onCanvasFocus;
  108019. private _onFullscreenChange;
  108020. private _onPointerLockChange;
  108021. /**
  108022. * Gets the HTML element used to attach event listeners
  108023. * @returns a HTML element
  108024. */
  108025. getInputElement(): Nullable<HTMLElement>;
  108026. /**
  108027. * Creates a new engine
  108028. * @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
  108029. * @param antialias defines enable antialiasing (default: false)
  108030. * @param options defines further options to be sent to the getContext() function
  108031. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108032. */
  108033. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108034. /**
  108035. * Gets current aspect ratio
  108036. * @param viewportOwner defines the camera to use to get the aspect ratio
  108037. * @param useScreen defines if screen size must be used (or the current render target if any)
  108038. * @returns a number defining the aspect ratio
  108039. */
  108040. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108041. /**
  108042. * Gets current screen aspect ratio
  108043. * @returns a number defining the aspect ratio
  108044. */
  108045. getScreenAspectRatio(): number;
  108046. /**
  108047. * Gets the client rect of the HTML canvas attached with the current webGL context
  108048. * @returns a client rectanglee
  108049. */
  108050. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108051. /**
  108052. * Gets the client rect of the HTML element used for events
  108053. * @returns a client rectanglee
  108054. */
  108055. getInputElementClientRect(): Nullable<ClientRect>;
  108056. /**
  108057. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108059. * @returns true if engine is in deterministic lock step mode
  108060. */
  108061. isDeterministicLockStep(): boolean;
  108062. /**
  108063. * Gets the max steps when engine is running in deterministic lock step
  108064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108065. * @returns the max steps
  108066. */
  108067. getLockstepMaxSteps(): number;
  108068. /**
  108069. * Returns the time in ms between steps when using deterministic lock step.
  108070. * @returns time step in (ms)
  108071. */
  108072. getTimeStep(): number;
  108073. /**
  108074. * Force the mipmap generation for the given render target texture
  108075. * @param texture defines the render target texture to use
  108076. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108077. */
  108078. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108079. /** States */
  108080. /**
  108081. * Set various states to the webGL context
  108082. * @param culling defines backface culling state
  108083. * @param zOffset defines the value to apply to zOffset (0 by default)
  108084. * @param force defines if states must be applied even if cache is up to date
  108085. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108086. */
  108087. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108088. /**
  108089. * Set the z offset to apply to current rendering
  108090. * @param value defines the offset to apply
  108091. */
  108092. setZOffset(value: number): void;
  108093. /**
  108094. * Gets the current value of the zOffset
  108095. * @returns the current zOffset state
  108096. */
  108097. getZOffset(): number;
  108098. /**
  108099. * Enable or disable depth buffering
  108100. * @param enable defines the state to set
  108101. */
  108102. setDepthBuffer(enable: boolean): void;
  108103. /**
  108104. * Gets a boolean indicating if depth writing is enabled
  108105. * @returns the current depth writing state
  108106. */
  108107. getDepthWrite(): boolean;
  108108. /**
  108109. * Enable or disable depth writing
  108110. * @param enable defines the state to set
  108111. */
  108112. setDepthWrite(enable: boolean): void;
  108113. /**
  108114. * Gets a boolean indicating if stencil buffer is enabled
  108115. * @returns the current stencil buffer state
  108116. */
  108117. getStencilBuffer(): boolean;
  108118. /**
  108119. * Enable or disable the stencil buffer
  108120. * @param enable defines if the stencil buffer must be enabled or disabled
  108121. */
  108122. setStencilBuffer(enable: boolean): void;
  108123. /**
  108124. * Gets the current stencil mask
  108125. * @returns a number defining the new stencil mask to use
  108126. */
  108127. getStencilMask(): number;
  108128. /**
  108129. * Sets the current stencil mask
  108130. * @param mask defines the new stencil mask to use
  108131. */
  108132. setStencilMask(mask: number): void;
  108133. /**
  108134. * Gets the current stencil function
  108135. * @returns a number defining the stencil function to use
  108136. */
  108137. getStencilFunction(): number;
  108138. /**
  108139. * Gets the current stencil reference value
  108140. * @returns a number defining the stencil reference value to use
  108141. */
  108142. getStencilFunctionReference(): number;
  108143. /**
  108144. * Gets the current stencil mask
  108145. * @returns a number defining the stencil mask to use
  108146. */
  108147. getStencilFunctionMask(): number;
  108148. /**
  108149. * Sets the current stencil function
  108150. * @param stencilFunc defines the new stencil function to use
  108151. */
  108152. setStencilFunction(stencilFunc: number): void;
  108153. /**
  108154. * Sets the current stencil reference
  108155. * @param reference defines the new stencil reference to use
  108156. */
  108157. setStencilFunctionReference(reference: number): void;
  108158. /**
  108159. * Sets the current stencil mask
  108160. * @param mask defines the new stencil mask to use
  108161. */
  108162. setStencilFunctionMask(mask: number): void;
  108163. /**
  108164. * Gets the current stencil operation when stencil fails
  108165. * @returns a number defining stencil operation to use when stencil fails
  108166. */
  108167. getStencilOperationFail(): number;
  108168. /**
  108169. * Gets the current stencil operation when depth fails
  108170. * @returns a number defining stencil operation to use when depth fails
  108171. */
  108172. getStencilOperationDepthFail(): number;
  108173. /**
  108174. * Gets the current stencil operation when stencil passes
  108175. * @returns a number defining stencil operation to use when stencil passes
  108176. */
  108177. getStencilOperationPass(): number;
  108178. /**
  108179. * Sets the stencil operation to use when stencil fails
  108180. * @param operation defines the stencil operation to use when stencil fails
  108181. */
  108182. setStencilOperationFail(operation: number): void;
  108183. /**
  108184. * Sets the stencil operation to use when depth fails
  108185. * @param operation defines the stencil operation to use when depth fails
  108186. */
  108187. setStencilOperationDepthFail(operation: number): void;
  108188. /**
  108189. * Sets the stencil operation to use when stencil passes
  108190. * @param operation defines the stencil operation to use when stencil passes
  108191. */
  108192. setStencilOperationPass(operation: number): void;
  108193. /**
  108194. * Sets a boolean indicating if the dithering state is enabled or disabled
  108195. * @param value defines the dithering state
  108196. */
  108197. setDitheringState(value: boolean): void;
  108198. /**
  108199. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108200. * @param value defines the rasterizer state
  108201. */
  108202. setRasterizerState(value: boolean): void;
  108203. /**
  108204. * Gets the current depth function
  108205. * @returns a number defining the depth function
  108206. */
  108207. getDepthFunction(): Nullable<number>;
  108208. /**
  108209. * Sets the current depth function
  108210. * @param depthFunc defines the function to use
  108211. */
  108212. setDepthFunction(depthFunc: number): void;
  108213. /**
  108214. * Sets the current depth function to GREATER
  108215. */
  108216. setDepthFunctionToGreater(): void;
  108217. /**
  108218. * Sets the current depth function to GEQUAL
  108219. */
  108220. setDepthFunctionToGreaterOrEqual(): void;
  108221. /**
  108222. * Sets the current depth function to LESS
  108223. */
  108224. setDepthFunctionToLess(): void;
  108225. /**
  108226. * Sets the current depth function to LEQUAL
  108227. */
  108228. setDepthFunctionToLessOrEqual(): void;
  108229. private _cachedStencilBuffer;
  108230. private _cachedStencilFunction;
  108231. private _cachedStencilMask;
  108232. private _cachedStencilOperationPass;
  108233. private _cachedStencilOperationFail;
  108234. private _cachedStencilOperationDepthFail;
  108235. private _cachedStencilReference;
  108236. /**
  108237. * Caches the the state of the stencil buffer
  108238. */
  108239. cacheStencilState(): void;
  108240. /**
  108241. * Restores the state of the stencil buffer
  108242. */
  108243. restoreStencilState(): void;
  108244. /**
  108245. * Directly set the WebGL Viewport
  108246. * @param x defines the x coordinate of the viewport (in screen space)
  108247. * @param y defines the y coordinate of the viewport (in screen space)
  108248. * @param width defines the width of the viewport (in screen space)
  108249. * @param height defines the height of the viewport (in screen space)
  108250. * @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
  108251. */
  108252. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108253. /**
  108254. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108255. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108256. * @param y defines the y-coordinate of the corner of the clear rectangle
  108257. * @param width defines the width of the clear rectangle
  108258. * @param height defines the height of the clear rectangle
  108259. * @param clearColor defines the clear color
  108260. */
  108261. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108262. /**
  108263. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108264. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108265. * @param y defines the y-coordinate of the corner of the clear rectangle
  108266. * @param width defines the width of the clear rectangle
  108267. * @param height defines the height of the clear rectangle
  108268. */
  108269. enableScissor(x: number, y: number, width: number, height: number): void;
  108270. /**
  108271. * Disable previously set scissor test rectangle
  108272. */
  108273. disableScissor(): void;
  108274. protected _reportDrawCall(): void;
  108275. /**
  108276. * Initializes a webVR display and starts listening to display change events
  108277. * The onVRDisplayChangedObservable will be notified upon these changes
  108278. * @returns The onVRDisplayChangedObservable
  108279. */
  108280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108281. /** @hidden */
  108282. _prepareVRComponent(): void;
  108283. /** @hidden */
  108284. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108285. /** @hidden */
  108286. _submitVRFrame(): void;
  108287. /**
  108288. * Call this function to leave webVR mode
  108289. * Will do nothing if webVR is not supported or if there is no webVR device
  108290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108291. */
  108292. disableVR(): void;
  108293. /**
  108294. * Gets a boolean indicating that the system is in VR mode and is presenting
  108295. * @returns true if VR mode is engaged
  108296. */
  108297. isVRPresenting(): boolean;
  108298. /** @hidden */
  108299. _requestVRFrame(): void;
  108300. /** @hidden */
  108301. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108302. /**
  108303. * Gets the source code of the vertex shader associated with a specific webGL program
  108304. * @param program defines the program to use
  108305. * @returns a string containing the source code of the vertex shader associated with the program
  108306. */
  108307. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108308. /**
  108309. * Gets the source code of the fragment shader associated with a specific webGL program
  108310. * @param program defines the program to use
  108311. * @returns a string containing the source code of the fragment shader associated with the program
  108312. */
  108313. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108314. /**
  108315. * Sets a depth stencil texture from a render target to the according uniform.
  108316. * @param channel The texture channel
  108317. * @param uniform The uniform to set
  108318. * @param texture The render target texture containing the depth stencil texture to apply
  108319. */
  108320. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108321. /**
  108322. * Sets a texture to the webGL context from a postprocess
  108323. * @param channel defines the channel to use
  108324. * @param postProcess defines the source postprocess
  108325. */
  108326. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108327. /**
  108328. * Binds the output of the passed in post process to the texture channel specified
  108329. * @param channel The channel the texture should be bound to
  108330. * @param postProcess The post process which's output should be bound
  108331. */
  108332. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108333. /** @hidden */
  108334. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108335. protected _rebuildBuffers(): void;
  108336. /** @hidden */
  108337. _renderFrame(): void;
  108338. _renderLoop(): void;
  108339. /** @hidden */
  108340. _renderViews(): boolean;
  108341. /**
  108342. * Toggle full screen mode
  108343. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108344. */
  108345. switchFullscreen(requestPointerLock: boolean): void;
  108346. /**
  108347. * Enters full screen mode
  108348. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108349. */
  108350. enterFullscreen(requestPointerLock: boolean): void;
  108351. /**
  108352. * Exits full screen mode
  108353. */
  108354. exitFullscreen(): void;
  108355. /**
  108356. * Enters Pointerlock mode
  108357. */
  108358. enterPointerlock(): void;
  108359. /**
  108360. * Exits Pointerlock mode
  108361. */
  108362. exitPointerlock(): void;
  108363. /**
  108364. * Begin a new frame
  108365. */
  108366. beginFrame(): void;
  108367. /**
  108368. * Enf the current frame
  108369. */
  108370. endFrame(): void;
  108371. resize(): void;
  108372. /**
  108373. * Force a specific size of the canvas
  108374. * @param width defines the new canvas' width
  108375. * @param height defines the new canvas' height
  108376. */
  108377. setSize(width: number, height: number): void;
  108378. /**
  108379. * Updates a dynamic vertex buffer.
  108380. * @param vertexBuffer the vertex buffer to update
  108381. * @param data the data used to update the vertex buffer
  108382. * @param byteOffset the byte offset of the data
  108383. * @param byteLength the byte length of the data
  108384. */
  108385. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108386. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108387. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108388. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108389. _releaseTexture(texture: InternalTexture): void;
  108390. /**
  108391. * @hidden
  108392. * Rescales a texture
  108393. * @param source input texutre
  108394. * @param destination destination texture
  108395. * @param scene scene to use to render the resize
  108396. * @param internalFormat format to use when resizing
  108397. * @param onComplete callback to be called when resize has completed
  108398. */
  108399. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108400. /**
  108401. * Gets the current framerate
  108402. * @returns a number representing the framerate
  108403. */
  108404. getFps(): number;
  108405. /**
  108406. * Gets the time spent between current and previous frame
  108407. * @returns a number representing the delta time in ms
  108408. */
  108409. getDeltaTime(): number;
  108410. private _measureFps;
  108411. /** @hidden */
  108412. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108413. /**
  108414. * Update a dynamic index buffer
  108415. * @param indexBuffer defines the target index buffer
  108416. * @param indices defines the data to update
  108417. * @param offset defines the offset in the target index buffer where update should start
  108418. */
  108419. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108420. /**
  108421. * Updates the sample count of a render target texture
  108422. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108423. * @param texture defines the texture to update
  108424. * @param samples defines the sample count to set
  108425. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108426. */
  108427. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108428. /**
  108429. * Updates a depth texture Comparison Mode and Function.
  108430. * If the comparison Function is equal to 0, the mode will be set to none.
  108431. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108432. * @param texture The texture to set the comparison function for
  108433. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108434. */
  108435. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108436. /**
  108437. * Creates a webGL buffer to use with instanciation
  108438. * @param capacity defines the size of the buffer
  108439. * @returns the webGL buffer
  108440. */
  108441. createInstancesBuffer(capacity: number): DataBuffer;
  108442. /**
  108443. * Delete a webGL buffer used with instanciation
  108444. * @param buffer defines the webGL buffer to delete
  108445. */
  108446. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108447. private _clientWaitAsync;
  108448. /** @hidden */
  108449. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108450. /** @hidden */
  108451. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108452. dispose(): void;
  108453. private _disableTouchAction;
  108454. /**
  108455. * Display the loading screen
  108456. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108457. */
  108458. displayLoadingUI(): void;
  108459. /**
  108460. * Hide the loading screen
  108461. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108462. */
  108463. hideLoadingUI(): void;
  108464. /**
  108465. * Gets the current loading screen object
  108466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108467. */
  108468. get loadingScreen(): ILoadingScreen;
  108469. /**
  108470. * Sets the current loading screen object
  108471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108472. */
  108473. set loadingScreen(loadingScreen: ILoadingScreen);
  108474. /**
  108475. * Sets the current loading screen text
  108476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108477. */
  108478. set loadingUIText(text: string);
  108479. /**
  108480. * Sets the current loading screen background color
  108481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108482. */
  108483. set loadingUIBackgroundColor(color: string);
  108484. /** Pointerlock and fullscreen */
  108485. /**
  108486. * Ask the browser to promote the current element to pointerlock mode
  108487. * @param element defines the DOM element to promote
  108488. */
  108489. static _RequestPointerlock(element: HTMLElement): void;
  108490. /**
  108491. * Asks the browser to exit pointerlock mode
  108492. */
  108493. static _ExitPointerlock(): void;
  108494. /**
  108495. * Ask the browser to promote the current element to fullscreen rendering mode
  108496. * @param element defines the DOM element to promote
  108497. */
  108498. static _RequestFullscreen(element: HTMLElement): void;
  108499. /**
  108500. * Asks the browser to exit fullscreen mode
  108501. */
  108502. static _ExitFullscreen(): void;
  108503. }
  108504. }
  108505. declare module BABYLON {
  108506. /**
  108507. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108508. * during the life time of the application.
  108509. */
  108510. export class EngineStore {
  108511. /** Gets the list of created engines */
  108512. static Instances: Engine[];
  108513. /** @hidden */
  108514. static _LastCreatedScene: Nullable<Scene>;
  108515. /**
  108516. * Gets the latest created engine
  108517. */
  108518. static get LastCreatedEngine(): Nullable<Engine>;
  108519. /**
  108520. * Gets the latest created scene
  108521. */
  108522. static get LastCreatedScene(): Nullable<Scene>;
  108523. /**
  108524. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108525. * @ignorenaming
  108526. */
  108527. static UseFallbackTexture: boolean;
  108528. /**
  108529. * Texture content used if a texture cannot loaded
  108530. * @ignorenaming
  108531. */
  108532. static FallbackTexture: string;
  108533. }
  108534. }
  108535. declare module BABYLON {
  108536. /**
  108537. * Helper class that provides a small promise polyfill
  108538. */
  108539. export class PromisePolyfill {
  108540. /**
  108541. * Static function used to check if the polyfill is required
  108542. * If this is the case then the function will inject the polyfill to window.Promise
  108543. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108544. */
  108545. static Apply(force?: boolean): void;
  108546. }
  108547. }
  108548. declare module BABYLON {
  108549. /**
  108550. * Interface for screenshot methods with describe argument called `size` as object with options
  108551. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108552. */
  108553. export interface IScreenshotSize {
  108554. /**
  108555. * number in pixels for canvas height
  108556. */
  108557. height?: number;
  108558. /**
  108559. * multiplier allowing render at a higher or lower resolution
  108560. * If value is defined then height and width will be ignored and taken from camera
  108561. */
  108562. precision?: number;
  108563. /**
  108564. * number in pixels for canvas width
  108565. */
  108566. width?: number;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. interface IColor4Like {
  108571. r: float;
  108572. g: float;
  108573. b: float;
  108574. a: float;
  108575. }
  108576. /**
  108577. * Class containing a set of static utilities functions
  108578. */
  108579. export class Tools {
  108580. /**
  108581. * Gets or sets the base URL to use to load assets
  108582. */
  108583. static get BaseUrl(): string;
  108584. static set BaseUrl(value: string);
  108585. /**
  108586. * Enable/Disable Custom HTTP Request Headers globally.
  108587. * default = false
  108588. * @see CustomRequestHeaders
  108589. */
  108590. static UseCustomRequestHeaders: boolean;
  108591. /**
  108592. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108593. * i.e. when loading files, where the server/service expects an Authorization header
  108594. */
  108595. static CustomRequestHeaders: {
  108596. [key: string]: string;
  108597. };
  108598. /**
  108599. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108600. */
  108601. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108602. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108603. /**
  108604. * Default behaviour for cors in the application.
  108605. * It can be a string if the expected behavior is identical in the entire app.
  108606. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108607. */
  108608. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108609. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108610. /**
  108611. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108612. * @ignorenaming
  108613. */
  108614. static get UseFallbackTexture(): boolean;
  108615. static set UseFallbackTexture(value: boolean);
  108616. /**
  108617. * Use this object to register external classes like custom textures or material
  108618. * to allow the laoders to instantiate them
  108619. */
  108620. static get RegisteredExternalClasses(): {
  108621. [key: string]: Object;
  108622. };
  108623. static set RegisteredExternalClasses(classes: {
  108624. [key: string]: Object;
  108625. });
  108626. /**
  108627. * Texture content used if a texture cannot loaded
  108628. * @ignorenaming
  108629. */
  108630. static get fallbackTexture(): string;
  108631. static set fallbackTexture(value: string);
  108632. /**
  108633. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108634. * @param u defines the coordinate on X axis
  108635. * @param v defines the coordinate on Y axis
  108636. * @param width defines the width of the source data
  108637. * @param height defines the height of the source data
  108638. * @param pixels defines the source byte array
  108639. * @param color defines the output color
  108640. */
  108641. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108642. /**
  108643. * Interpolates between a and b via alpha
  108644. * @param a The lower value (returned when alpha = 0)
  108645. * @param b The upper value (returned when alpha = 1)
  108646. * @param alpha The interpolation-factor
  108647. * @return The mixed value
  108648. */
  108649. static Mix(a: number, b: number, alpha: number): number;
  108650. /**
  108651. * Tries to instantiate a new object from a given class name
  108652. * @param className defines the class name to instantiate
  108653. * @returns the new object or null if the system was not able to do the instantiation
  108654. */
  108655. static Instantiate(className: string): any;
  108656. /**
  108657. * Provides a slice function that will work even on IE
  108658. * @param data defines the array to slice
  108659. * @param start defines the start of the data (optional)
  108660. * @param end defines the end of the data (optional)
  108661. * @returns the new sliced array
  108662. */
  108663. static Slice<T>(data: T, start?: number, end?: number): T;
  108664. /**
  108665. * Polyfill for setImmediate
  108666. * @param action defines the action to execute after the current execution block
  108667. */
  108668. static SetImmediate(action: () => void): void;
  108669. /**
  108670. * Function indicating if a number is an exponent of 2
  108671. * @param value defines the value to test
  108672. * @returns true if the value is an exponent of 2
  108673. */
  108674. static IsExponentOfTwo(value: number): boolean;
  108675. private static _tmpFloatArray;
  108676. /**
  108677. * Returns the nearest 32-bit single precision float representation of a Number
  108678. * @param value A Number. If the parameter is of a different type, it will get converted
  108679. * to a number or to NaN if it cannot be converted
  108680. * @returns number
  108681. */
  108682. static FloatRound(value: number): number;
  108683. /**
  108684. * Extracts the filename from a path
  108685. * @param path defines the path to use
  108686. * @returns the filename
  108687. */
  108688. static GetFilename(path: string): string;
  108689. /**
  108690. * Extracts the "folder" part of a path (everything before the filename).
  108691. * @param uri The URI to extract the info from
  108692. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108693. * @returns The "folder" part of the path
  108694. */
  108695. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108696. /**
  108697. * Extracts text content from a DOM element hierarchy
  108698. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108699. */
  108700. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108701. /**
  108702. * Convert an angle in radians to degrees
  108703. * @param angle defines the angle to convert
  108704. * @returns the angle in degrees
  108705. */
  108706. static ToDegrees(angle: number): number;
  108707. /**
  108708. * Convert an angle in degrees to radians
  108709. * @param angle defines the angle to convert
  108710. * @returns the angle in radians
  108711. */
  108712. static ToRadians(angle: number): number;
  108713. /**
  108714. * Returns an array if obj is not an array
  108715. * @param obj defines the object to evaluate as an array
  108716. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108717. * @returns either obj directly if obj is an array or a new array containing obj
  108718. */
  108719. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108720. /**
  108721. * Gets the pointer prefix to use
  108722. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108723. */
  108724. static GetPointerPrefix(): string;
  108725. /**
  108726. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108727. * @param url define the url we are trying
  108728. * @param element define the dom element where to configure the cors policy
  108729. */
  108730. static SetCorsBehavior(url: string | string[], element: {
  108731. crossOrigin: string | null;
  108732. }): void;
  108733. /**
  108734. * Removes unwanted characters from an url
  108735. * @param url defines the url to clean
  108736. * @returns the cleaned url
  108737. */
  108738. static CleanUrl(url: string): string;
  108739. /**
  108740. * Gets or sets a function used to pre-process url before using them to load assets
  108741. */
  108742. static get PreprocessUrl(): (url: string) => string;
  108743. static set PreprocessUrl(processor: (url: string) => string);
  108744. /**
  108745. * Loads an image as an HTMLImageElement.
  108746. * @param input url string, ArrayBuffer, or Blob to load
  108747. * @param onLoad callback called when the image successfully loads
  108748. * @param onError callback called when the image fails to load
  108749. * @param offlineProvider offline provider for caching
  108750. * @param mimeType optional mime type
  108751. * @returns the HTMLImageElement of the loaded image
  108752. */
  108753. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108754. /**
  108755. * Loads a file from a url
  108756. * @param url url string, ArrayBuffer, or Blob to load
  108757. * @param onSuccess callback called when the file successfully loads
  108758. * @param onProgress callback called while file is loading (if the server supports this mode)
  108759. * @param offlineProvider defines the offline provider for caching
  108760. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108761. * @param onError callback called when the file fails to load
  108762. * @returns a file request object
  108763. */
  108764. 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;
  108765. /**
  108766. * Loads a file from a url
  108767. * @param url the file url to load
  108768. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108769. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108770. */
  108771. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108772. /**
  108773. * Load a script (identified by an url). When the url returns, the
  108774. * content of this file is added into a new script element, attached to the DOM (body element)
  108775. * @param scriptUrl defines the url of the script to laod
  108776. * @param onSuccess defines the callback called when the script is loaded
  108777. * @param onError defines the callback to call if an error occurs
  108778. * @param scriptId defines the id of the script element
  108779. */
  108780. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108781. /**
  108782. * Load an asynchronous script (identified by an url). When the url returns, the
  108783. * content of this file is added into a new script element, attached to the DOM (body element)
  108784. * @param scriptUrl defines the url of the script to laod
  108785. * @param scriptId defines the id of the script element
  108786. * @returns a promise request object
  108787. */
  108788. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108789. /**
  108790. * Loads a file from a blob
  108791. * @param fileToLoad defines the blob to use
  108792. * @param callback defines the callback to call when data is loaded
  108793. * @param progressCallback defines the callback to call during loading process
  108794. * @returns a file request object
  108795. */
  108796. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108797. /**
  108798. * Reads a file from a File object
  108799. * @param file defines the file to load
  108800. * @param onSuccess defines the callback to call when data is loaded
  108801. * @param onProgress defines the callback to call during loading process
  108802. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108803. * @param onError defines the callback to call when an error occurs
  108804. * @returns a file request object
  108805. */
  108806. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108807. /**
  108808. * Creates a data url from a given string content
  108809. * @param content defines the content to convert
  108810. * @returns the new data url link
  108811. */
  108812. static FileAsURL(content: string): string;
  108813. /**
  108814. * Format the given number to a specific decimal format
  108815. * @param value defines the number to format
  108816. * @param decimals defines the number of decimals to use
  108817. * @returns the formatted string
  108818. */
  108819. static Format(value: number, decimals?: number): string;
  108820. /**
  108821. * Tries to copy an object by duplicating every property
  108822. * @param source defines the source object
  108823. * @param destination defines the target object
  108824. * @param doNotCopyList defines a list of properties to avoid
  108825. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108826. */
  108827. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108828. /**
  108829. * Gets a boolean indicating if the given object has no own property
  108830. * @param obj defines the object to test
  108831. * @returns true if object has no own property
  108832. */
  108833. static IsEmpty(obj: any): boolean;
  108834. /**
  108835. * Function used to register events at window level
  108836. * @param windowElement defines the Window object to use
  108837. * @param events defines the events to register
  108838. */
  108839. static RegisterTopRootEvents(windowElement: Window, events: {
  108840. name: string;
  108841. handler: Nullable<(e: FocusEvent) => any>;
  108842. }[]): void;
  108843. /**
  108844. * Function used to unregister events from window level
  108845. * @param windowElement defines the Window object to use
  108846. * @param events defines the events to unregister
  108847. */
  108848. static UnregisterTopRootEvents(windowElement: Window, events: {
  108849. name: string;
  108850. handler: Nullable<(e: FocusEvent) => any>;
  108851. }[]): void;
  108852. /**
  108853. * @ignore
  108854. */
  108855. static _ScreenshotCanvas: HTMLCanvasElement;
  108856. /**
  108857. * Dumps the current bound framebuffer
  108858. * @param width defines the rendering width
  108859. * @param height defines the rendering height
  108860. * @param engine defines the hosting engine
  108861. * @param successCallback defines the callback triggered once the data are available
  108862. * @param mimeType defines the mime type of the result
  108863. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108864. */
  108865. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108866. /**
  108867. * Converts the canvas data to blob.
  108868. * This acts as a polyfill for browsers not supporting the to blob function.
  108869. * @param canvas Defines the canvas to extract the data from
  108870. * @param successCallback Defines the callback triggered once the data are available
  108871. * @param mimeType Defines the mime type of the result
  108872. */
  108873. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108874. /**
  108875. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108876. * @param successCallback defines the callback triggered once the data are available
  108877. * @param mimeType defines the mime type of the result
  108878. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108879. */
  108880. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108881. /**
  108882. * Downloads a blob in the browser
  108883. * @param blob defines the blob to download
  108884. * @param fileName defines the name of the downloaded file
  108885. */
  108886. static Download(blob: Blob, fileName: string): void;
  108887. /**
  108888. * Captures a screenshot of the current rendering
  108889. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108890. * @param engine defines the rendering engine
  108891. * @param camera defines the source camera
  108892. * @param size This parameter can be set to a single number or to an object with the
  108893. * following (optional) properties: precision, width, height. If a single number is passed,
  108894. * it will be used for both width and height. If an object is passed, the screenshot size
  108895. * will be derived from the parameters. The precision property is a multiplier allowing
  108896. * rendering at a higher or lower resolution
  108897. * @param successCallback defines the callback receives a single parameter which contains the
  108898. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108899. * src parameter of an <img> to display it
  108900. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108901. * Check your browser for supported MIME types
  108902. */
  108903. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108904. /**
  108905. * Captures a screenshot of the current rendering
  108906. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108907. * @param engine defines the rendering engine
  108908. * @param camera defines the source camera
  108909. * @param size This parameter can be set to a single number or to an object with the
  108910. * following (optional) properties: precision, width, height. If a single number is passed,
  108911. * it will be used for both width and height. If an object is passed, the screenshot size
  108912. * will be derived from the parameters. The precision property is a multiplier allowing
  108913. * rendering at a higher or lower resolution
  108914. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108915. * Check your browser for supported MIME types
  108916. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108917. * to the src parameter of an <img> to display it
  108918. */
  108919. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108920. /**
  108921. * Generates an image screenshot from the specified camera.
  108922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108923. * @param engine The engine to use for rendering
  108924. * @param camera The camera to use for rendering
  108925. * @param size This parameter can be set to a single number or to an object with the
  108926. * following (optional) properties: precision, width, height. If a single number is passed,
  108927. * it will be used for both width and height. If an object is passed, the screenshot size
  108928. * will be derived from the parameters. The precision property is a multiplier allowing
  108929. * rendering at a higher or lower resolution
  108930. * @param successCallback The callback receives a single parameter which contains the
  108931. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108932. * src parameter of an <img> to display it
  108933. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108934. * Check your browser for supported MIME types
  108935. * @param samples Texture samples (default: 1)
  108936. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108937. * @param fileName A name for for the downloaded file.
  108938. */
  108939. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108940. /**
  108941. * Generates an image screenshot from the specified camera.
  108942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108943. * @param engine The engine to use for rendering
  108944. * @param camera The camera to use for rendering
  108945. * @param size This parameter can be set to a single number or to an object with the
  108946. * following (optional) properties: precision, width, height. If a single number is passed,
  108947. * it will be used for both width and height. If an object is passed, the screenshot size
  108948. * will be derived from the parameters. The precision property is a multiplier allowing
  108949. * rendering at a higher or lower resolution
  108950. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108951. * Check your browser for supported MIME types
  108952. * @param samples Texture samples (default: 1)
  108953. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108954. * @param fileName A name for for the downloaded file.
  108955. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108956. * to the src parameter of an <img> to display it
  108957. */
  108958. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108959. /**
  108960. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108961. * Be aware Math.random() could cause collisions, but:
  108962. * "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"
  108963. * @returns a pseudo random id
  108964. */
  108965. static RandomId(): string;
  108966. /**
  108967. * Test if the given uri is a base64 string
  108968. * @param uri The uri to test
  108969. * @return True if the uri is a base64 string or false otherwise
  108970. */
  108971. static IsBase64(uri: string): boolean;
  108972. /**
  108973. * Decode the given base64 uri.
  108974. * @param uri The uri to decode
  108975. * @return The decoded base64 data.
  108976. */
  108977. static DecodeBase64(uri: string): ArrayBuffer;
  108978. /**
  108979. * Gets the absolute url.
  108980. * @param url the input url
  108981. * @return the absolute url
  108982. */
  108983. static GetAbsoluteUrl(url: string): string;
  108984. /**
  108985. * No log
  108986. */
  108987. static readonly NoneLogLevel: number;
  108988. /**
  108989. * Only message logs
  108990. */
  108991. static readonly MessageLogLevel: number;
  108992. /**
  108993. * Only warning logs
  108994. */
  108995. static readonly WarningLogLevel: number;
  108996. /**
  108997. * Only error logs
  108998. */
  108999. static readonly ErrorLogLevel: number;
  109000. /**
  109001. * All logs
  109002. */
  109003. static readonly AllLogLevel: number;
  109004. /**
  109005. * Gets a value indicating the number of loading errors
  109006. * @ignorenaming
  109007. */
  109008. static get errorsCount(): number;
  109009. /**
  109010. * Callback called when a new log is added
  109011. */
  109012. static OnNewCacheEntry: (entry: string) => void;
  109013. /**
  109014. * Log a message to the console
  109015. * @param message defines the message to log
  109016. */
  109017. static Log(message: string): void;
  109018. /**
  109019. * Write a warning message to the console
  109020. * @param message defines the message to log
  109021. */
  109022. static Warn(message: string): void;
  109023. /**
  109024. * Write an error message to the console
  109025. * @param message defines the message to log
  109026. */
  109027. static Error(message: string): void;
  109028. /**
  109029. * Gets current log cache (list of logs)
  109030. */
  109031. static get LogCache(): string;
  109032. /**
  109033. * Clears the log cache
  109034. */
  109035. static ClearLogCache(): void;
  109036. /**
  109037. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109038. */
  109039. static set LogLevels(level: number);
  109040. /**
  109041. * Checks if the window object exists
  109042. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109043. */
  109044. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109045. /**
  109046. * No performance log
  109047. */
  109048. static readonly PerformanceNoneLogLevel: number;
  109049. /**
  109050. * Use user marks to log performance
  109051. */
  109052. static readonly PerformanceUserMarkLogLevel: number;
  109053. /**
  109054. * Log performance to the console
  109055. */
  109056. static readonly PerformanceConsoleLogLevel: number;
  109057. private static _performance;
  109058. /**
  109059. * Sets the current performance log level
  109060. */
  109061. static set PerformanceLogLevel(level: number);
  109062. private static _StartPerformanceCounterDisabled;
  109063. private static _EndPerformanceCounterDisabled;
  109064. private static _StartUserMark;
  109065. private static _EndUserMark;
  109066. private static _StartPerformanceConsole;
  109067. private static _EndPerformanceConsole;
  109068. /**
  109069. * Starts a performance counter
  109070. */
  109071. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109072. /**
  109073. * Ends a specific performance coutner
  109074. */
  109075. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109076. /**
  109077. * Gets either window.performance.now() if supported or Date.now() else
  109078. */
  109079. static get Now(): number;
  109080. /**
  109081. * This method will return the name of the class used to create the instance of the given object.
  109082. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109083. * @param object the object to get the class name from
  109084. * @param isType defines if the object is actually a type
  109085. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109086. */
  109087. static GetClassName(object: any, isType?: boolean): string;
  109088. /**
  109089. * Gets the first element of an array satisfying a given predicate
  109090. * @param array defines the array to browse
  109091. * @param predicate defines the predicate to use
  109092. * @returns null if not found or the element
  109093. */
  109094. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109095. /**
  109096. * This method will return the name of the full name of the class, including its owning module (if any).
  109097. * 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).
  109098. * @param object the object to get the class name from
  109099. * @param isType defines if the object is actually a type
  109100. * @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.
  109101. * @ignorenaming
  109102. */
  109103. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109104. /**
  109105. * Returns a promise that resolves after the given amount of time.
  109106. * @param delay Number of milliseconds to delay
  109107. * @returns Promise that resolves after the given amount of time
  109108. */
  109109. static DelayAsync(delay: number): Promise<void>;
  109110. /**
  109111. * Utility function to detect if the current user agent is Safari
  109112. * @returns whether or not the current user agent is safari
  109113. */
  109114. static IsSafari(): boolean;
  109115. }
  109116. /**
  109117. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109118. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109119. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109120. * @param name The name of the class, case should be preserved
  109121. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109122. */
  109123. export function className(name: string, module?: string): (target: Object) => void;
  109124. /**
  109125. * An implementation of a loop for asynchronous functions.
  109126. */
  109127. export class AsyncLoop {
  109128. /**
  109129. * Defines the number of iterations for the loop
  109130. */
  109131. iterations: number;
  109132. /**
  109133. * Defines the current index of the loop.
  109134. */
  109135. index: number;
  109136. private _done;
  109137. private _fn;
  109138. private _successCallback;
  109139. /**
  109140. * Constructor.
  109141. * @param iterations the number of iterations.
  109142. * @param func the function to run each iteration
  109143. * @param successCallback the callback that will be called upon succesful execution
  109144. * @param offset starting offset.
  109145. */
  109146. constructor(
  109147. /**
  109148. * Defines the number of iterations for the loop
  109149. */
  109150. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109151. /**
  109152. * Execute the next iteration. Must be called after the last iteration was finished.
  109153. */
  109154. executeNext(): void;
  109155. /**
  109156. * Break the loop and run the success callback.
  109157. */
  109158. breakLoop(): void;
  109159. /**
  109160. * Create and run an async loop.
  109161. * @param iterations the number of iterations.
  109162. * @param fn the function to run each iteration
  109163. * @param successCallback the callback that will be called upon succesful execution
  109164. * @param offset starting offset.
  109165. * @returns the created async loop object
  109166. */
  109167. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109168. /**
  109169. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109170. * @param iterations total number of iterations
  109171. * @param syncedIterations number of synchronous iterations in each async iteration.
  109172. * @param fn the function to call each iteration.
  109173. * @param callback a success call back that will be called when iterating stops.
  109174. * @param breakFunction a break condition (optional)
  109175. * @param timeout timeout settings for the setTimeout function. default - 0.
  109176. * @returns the created async loop object
  109177. */
  109178. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109179. }
  109180. }
  109181. declare module BABYLON {
  109182. /**
  109183. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109184. * The underlying implementation relies on an associative array to ensure the best performances.
  109185. * The value can be anything including 'null' but except 'undefined'
  109186. */
  109187. export class StringDictionary<T> {
  109188. /**
  109189. * This will clear this dictionary and copy the content from the 'source' one.
  109190. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109191. * @param source the dictionary to take the content from and copy to this dictionary
  109192. */
  109193. copyFrom(source: StringDictionary<T>): void;
  109194. /**
  109195. * Get a value based from its key
  109196. * @param key the given key to get the matching value from
  109197. * @return the value if found, otherwise undefined is returned
  109198. */
  109199. get(key: string): T | undefined;
  109200. /**
  109201. * Get a value from its key or add it if it doesn't exist.
  109202. * This method will ensure you that a given key/data will be present in the dictionary.
  109203. * @param key the given key to get the matching value from
  109204. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109205. * The factory will only be invoked if there's no data for the given key.
  109206. * @return the value corresponding to the key.
  109207. */
  109208. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109209. /**
  109210. * Get a value from its key if present in the dictionary otherwise add it
  109211. * @param key the key to get the value from
  109212. * @param val if there's no such key/value pair in the dictionary add it with this value
  109213. * @return the value corresponding to the key
  109214. */
  109215. getOrAdd(key: string, val: T): T;
  109216. /**
  109217. * Check if there's a given key in the dictionary
  109218. * @param key the key to check for
  109219. * @return true if the key is present, false otherwise
  109220. */
  109221. contains(key: string): boolean;
  109222. /**
  109223. * Add a new key and its corresponding value
  109224. * @param key the key to add
  109225. * @param value the value corresponding to the key
  109226. * @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
  109227. */
  109228. add(key: string, value: T): boolean;
  109229. /**
  109230. * Update a specific value associated to a key
  109231. * @param key defines the key to use
  109232. * @param value defines the value to store
  109233. * @returns true if the value was updated (or false if the key was not found)
  109234. */
  109235. set(key: string, value: T): boolean;
  109236. /**
  109237. * Get the element of the given key and remove it from the dictionary
  109238. * @param key defines the key to search
  109239. * @returns the value associated with the key or null if not found
  109240. */
  109241. getAndRemove(key: string): Nullable<T>;
  109242. /**
  109243. * Remove a key/value from the dictionary.
  109244. * @param key the key to remove
  109245. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109246. */
  109247. remove(key: string): boolean;
  109248. /**
  109249. * Clear the whole content of the dictionary
  109250. */
  109251. clear(): void;
  109252. /**
  109253. * Gets the current count
  109254. */
  109255. get count(): number;
  109256. /**
  109257. * Execute a callback on each key/val of the dictionary.
  109258. * Note that you can remove any element in this dictionary in the callback implementation
  109259. * @param callback the callback to execute on a given key/value pair
  109260. */
  109261. forEach(callback: (key: string, val: T) => void): void;
  109262. /**
  109263. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109264. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109265. * Note that you can remove any element in this dictionary in the callback implementation
  109266. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109267. * @returns the first item
  109268. */
  109269. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109270. private _count;
  109271. private _data;
  109272. }
  109273. }
  109274. declare module BABYLON {
  109275. /** @hidden */
  109276. export interface ICollisionCoordinator {
  109277. createCollider(): Collider;
  109278. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109279. init(scene: Scene): void;
  109280. }
  109281. /** @hidden */
  109282. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109283. private _scene;
  109284. private _scaledPosition;
  109285. private _scaledVelocity;
  109286. private _finalPosition;
  109287. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109288. createCollider(): Collider;
  109289. init(scene: Scene): void;
  109290. private _collideWithWorld;
  109291. }
  109292. }
  109293. declare module BABYLON {
  109294. /**
  109295. * Class used to manage all inputs for the scene.
  109296. */
  109297. export class InputManager {
  109298. /** The distance in pixel that you have to move to prevent some events */
  109299. static DragMovementThreshold: number;
  109300. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109301. static LongPressDelay: number;
  109302. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109303. static DoubleClickDelay: number;
  109304. /** If you need to check double click without raising a single click at first click, enable this flag */
  109305. static ExclusiveDoubleClickMode: boolean;
  109306. private _wheelEventName;
  109307. private _onPointerMove;
  109308. private _onPointerDown;
  109309. private _onPointerUp;
  109310. private _initClickEvent;
  109311. private _initActionManager;
  109312. private _delayedSimpleClick;
  109313. private _delayedSimpleClickTimeout;
  109314. private _previousDelayedSimpleClickTimeout;
  109315. private _meshPickProceed;
  109316. private _previousButtonPressed;
  109317. private _currentPickResult;
  109318. private _previousPickResult;
  109319. private _totalPointersPressed;
  109320. private _doubleClickOccured;
  109321. private _pointerOverMesh;
  109322. private _pickedDownMesh;
  109323. private _pickedUpMesh;
  109324. private _pointerX;
  109325. private _pointerY;
  109326. private _unTranslatedPointerX;
  109327. private _unTranslatedPointerY;
  109328. private _startingPointerPosition;
  109329. private _previousStartingPointerPosition;
  109330. private _startingPointerTime;
  109331. private _previousStartingPointerTime;
  109332. private _pointerCaptures;
  109333. private _onKeyDown;
  109334. private _onKeyUp;
  109335. private _onCanvasFocusObserver;
  109336. private _onCanvasBlurObserver;
  109337. private _scene;
  109338. /**
  109339. * Creates a new InputManager
  109340. * @param scene defines the hosting scene
  109341. */
  109342. constructor(scene: Scene);
  109343. /**
  109344. * Gets the mesh that is currently under the pointer
  109345. */
  109346. get meshUnderPointer(): Nullable<AbstractMesh>;
  109347. /**
  109348. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109349. */
  109350. get unTranslatedPointer(): Vector2;
  109351. /**
  109352. * Gets or sets the current on-screen X position of the pointer
  109353. */
  109354. get pointerX(): number;
  109355. set pointerX(value: number);
  109356. /**
  109357. * Gets or sets the current on-screen Y position of the pointer
  109358. */
  109359. get pointerY(): number;
  109360. set pointerY(value: number);
  109361. private _updatePointerPosition;
  109362. private _processPointerMove;
  109363. private _setRayOnPointerInfo;
  109364. private _checkPrePointerObservable;
  109365. /**
  109366. * Use this method to simulate a pointer move on a mesh
  109367. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109368. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109369. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109370. */
  109371. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109372. /**
  109373. * Use this method to simulate a pointer down on a mesh
  109374. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109375. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109376. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109377. */
  109378. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109379. private _processPointerDown;
  109380. /** @hidden */
  109381. _isPointerSwiping(): boolean;
  109382. /**
  109383. * Use this method to simulate a pointer up on a mesh
  109384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109387. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109388. */
  109389. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109390. private _processPointerUp;
  109391. /**
  109392. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109393. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109394. * @returns true if the pointer was captured
  109395. */
  109396. isPointerCaptured(pointerId?: number): boolean;
  109397. /**
  109398. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109399. * @param attachUp defines if you want to attach events to pointerup
  109400. * @param attachDown defines if you want to attach events to pointerdown
  109401. * @param attachMove defines if you want to attach events to pointermove
  109402. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109403. */
  109404. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109405. /**
  109406. * Detaches all event handlers
  109407. */
  109408. detachControl(): void;
  109409. /**
  109410. * Force the value of meshUnderPointer
  109411. * @param mesh defines the mesh to use
  109412. */
  109413. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109414. /**
  109415. * Gets the mesh under the pointer
  109416. * @returns a Mesh or null if no mesh is under the pointer
  109417. */
  109418. getPointerOverMesh(): Nullable<AbstractMesh>;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Helper class used to generate session unique ID
  109424. */
  109425. export class UniqueIdGenerator {
  109426. private static _UniqueIdCounter;
  109427. /**
  109428. * Gets an unique (relatively to the current scene) Id
  109429. */
  109430. static get UniqueId(): number;
  109431. }
  109432. }
  109433. declare module BABYLON {
  109434. /**
  109435. * This class defines the direct association between an animation and a target
  109436. */
  109437. export class TargetedAnimation {
  109438. /**
  109439. * Animation to perform
  109440. */
  109441. animation: Animation;
  109442. /**
  109443. * Target to animate
  109444. */
  109445. target: any;
  109446. /**
  109447. * Serialize the object
  109448. * @returns the JSON object representing the current entity
  109449. */
  109450. serialize(): any;
  109451. }
  109452. /**
  109453. * Use this class to create coordinated animations on multiple targets
  109454. */
  109455. export class AnimationGroup implements IDisposable {
  109456. /** The name of the animation group */
  109457. name: string;
  109458. private _scene;
  109459. private _targetedAnimations;
  109460. private _animatables;
  109461. private _from;
  109462. private _to;
  109463. private _isStarted;
  109464. private _isPaused;
  109465. private _speedRatio;
  109466. private _loopAnimation;
  109467. private _isAdditive;
  109468. /**
  109469. * Gets or sets the unique id of the node
  109470. */
  109471. uniqueId: number;
  109472. /**
  109473. * This observable will notify when one animation have ended
  109474. */
  109475. onAnimationEndObservable: Observable<TargetedAnimation>;
  109476. /**
  109477. * Observer raised when one animation loops
  109478. */
  109479. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109480. /**
  109481. * Observer raised when all animations have looped
  109482. */
  109483. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109484. /**
  109485. * This observable will notify when all animations have ended.
  109486. */
  109487. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109488. /**
  109489. * This observable will notify when all animations have paused.
  109490. */
  109491. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109492. /**
  109493. * This observable will notify when all animations are playing.
  109494. */
  109495. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109496. /**
  109497. * Gets the first frame
  109498. */
  109499. get from(): number;
  109500. /**
  109501. * Gets the last frame
  109502. */
  109503. get to(): number;
  109504. /**
  109505. * Define if the animations are started
  109506. */
  109507. get isStarted(): boolean;
  109508. /**
  109509. * Gets a value indicating that the current group is playing
  109510. */
  109511. get isPlaying(): boolean;
  109512. /**
  109513. * Gets or sets the speed ratio to use for all animations
  109514. */
  109515. get speedRatio(): number;
  109516. /**
  109517. * Gets or sets the speed ratio to use for all animations
  109518. */
  109519. set speedRatio(value: number);
  109520. /**
  109521. * Gets or sets if all animations should loop or not
  109522. */
  109523. get loopAnimation(): boolean;
  109524. set loopAnimation(value: boolean);
  109525. /**
  109526. * Gets or sets if all animations should be evaluated additively
  109527. */
  109528. get isAdditive(): boolean;
  109529. set isAdditive(value: boolean);
  109530. /**
  109531. * Gets the targeted animations for this animation group
  109532. */
  109533. get targetedAnimations(): Array<TargetedAnimation>;
  109534. /**
  109535. * returning the list of animatables controlled by this animation group.
  109536. */
  109537. get animatables(): Array<Animatable>;
  109538. /**
  109539. * Instantiates a new Animation Group.
  109540. * This helps managing several animations at once.
  109541. * @see http://doc.babylonjs.com/how_to/group
  109542. * @param name Defines the name of the group
  109543. * @param scene Defines the scene the group belongs to
  109544. */
  109545. constructor(
  109546. /** The name of the animation group */
  109547. name: string, scene?: Nullable<Scene>);
  109548. /**
  109549. * Add an animation (with its target) in the group
  109550. * @param animation defines the animation we want to add
  109551. * @param target defines the target of the animation
  109552. * @returns the TargetedAnimation object
  109553. */
  109554. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109555. /**
  109556. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109557. * It can add constant keys at begin or end
  109558. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109559. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109560. * @returns the animation group
  109561. */
  109562. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109563. private _animationLoopCount;
  109564. private _animationLoopFlags;
  109565. private _processLoop;
  109566. /**
  109567. * Start all animations on given targets
  109568. * @param loop defines if animations must loop
  109569. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109570. * @param from defines the from key (optional)
  109571. * @param to defines the to key (optional)
  109572. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109573. * @returns the current animation group
  109574. */
  109575. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109576. /**
  109577. * Pause all animations
  109578. * @returns the animation group
  109579. */
  109580. pause(): AnimationGroup;
  109581. /**
  109582. * Play all animations to initial state
  109583. * This function will start() the animations if they were not started or will restart() them if they were paused
  109584. * @param loop defines if animations must loop
  109585. * @returns the animation group
  109586. */
  109587. play(loop?: boolean): AnimationGroup;
  109588. /**
  109589. * Reset all animations to initial state
  109590. * @returns the animation group
  109591. */
  109592. reset(): AnimationGroup;
  109593. /**
  109594. * Restart animations from key 0
  109595. * @returns the animation group
  109596. */
  109597. restart(): AnimationGroup;
  109598. /**
  109599. * Stop all animations
  109600. * @returns the animation group
  109601. */
  109602. stop(): AnimationGroup;
  109603. /**
  109604. * Set animation weight for all animatables
  109605. * @param weight defines the weight to use
  109606. * @return the animationGroup
  109607. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109608. */
  109609. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109610. /**
  109611. * Synchronize and normalize all animatables with a source animatable
  109612. * @param root defines the root animatable to synchronize with
  109613. * @return the animationGroup
  109614. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109615. */
  109616. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109617. /**
  109618. * Goes to a specific frame in this animation group
  109619. * @param frame the frame number to go to
  109620. * @return the animationGroup
  109621. */
  109622. goToFrame(frame: number): AnimationGroup;
  109623. /**
  109624. * Dispose all associated resources
  109625. */
  109626. dispose(): void;
  109627. private _checkAnimationGroupEnded;
  109628. /**
  109629. * Clone the current animation group and returns a copy
  109630. * @param newName defines the name of the new group
  109631. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109632. * @returns the new aniamtion group
  109633. */
  109634. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109635. /**
  109636. * Serializes the animationGroup to an object
  109637. * @returns Serialized object
  109638. */
  109639. serialize(): any;
  109640. /**
  109641. * Returns a new AnimationGroup object parsed from the source provided.
  109642. * @param parsedAnimationGroup defines the source
  109643. * @param scene defines the scene that will receive the animationGroup
  109644. * @returns a new AnimationGroup
  109645. */
  109646. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109647. /**
  109648. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109649. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109650. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109651. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109652. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109653. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109654. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109655. */
  109656. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109657. /**
  109658. * Returns the string "AnimationGroup"
  109659. * @returns "AnimationGroup"
  109660. */
  109661. getClassName(): string;
  109662. /**
  109663. * Creates a detailled string about the object
  109664. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109665. * @returns a string representing the object
  109666. */
  109667. toString(fullDetails?: boolean): string;
  109668. }
  109669. }
  109670. declare module BABYLON {
  109671. /**
  109672. * Define an interface for all classes that will hold resources
  109673. */
  109674. export interface IDisposable {
  109675. /**
  109676. * Releases all held resources
  109677. */
  109678. dispose(): void;
  109679. }
  109680. /** Interface defining initialization parameters for Scene class */
  109681. export interface SceneOptions {
  109682. /**
  109683. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109684. * It will improve performance when the number of geometries becomes important.
  109685. */
  109686. useGeometryUniqueIdsMap?: boolean;
  109687. /**
  109688. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109689. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109690. */
  109691. useMaterialMeshMap?: boolean;
  109692. /**
  109693. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109694. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109695. */
  109696. useClonedMeshMap?: boolean;
  109697. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109698. virtual?: boolean;
  109699. }
  109700. /**
  109701. * Represents a scene to be rendered by the engine.
  109702. * @see http://doc.babylonjs.com/features/scene
  109703. */
  109704. export class Scene extends AbstractScene implements IAnimatable {
  109705. /** The fog is deactivated */
  109706. static readonly FOGMODE_NONE: number;
  109707. /** The fog density is following an exponential function */
  109708. static readonly FOGMODE_EXP: number;
  109709. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109710. static readonly FOGMODE_EXP2: number;
  109711. /** The fog density is following a linear function. */
  109712. static readonly FOGMODE_LINEAR: number;
  109713. /**
  109714. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109715. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109716. */
  109717. static MinDeltaTime: number;
  109718. /**
  109719. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109720. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109721. */
  109722. static MaxDeltaTime: number;
  109723. /**
  109724. * Factory used to create the default material.
  109725. * @param name The name of the material to create
  109726. * @param scene The scene to create the material for
  109727. * @returns The default material
  109728. */
  109729. static DefaultMaterialFactory(scene: Scene): Material;
  109730. /**
  109731. * Factory used to create the a collision coordinator.
  109732. * @returns The collision coordinator
  109733. */
  109734. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109735. /** @hidden */
  109736. _inputManager: InputManager;
  109737. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109738. cameraToUseForPointers: Nullable<Camera>;
  109739. /** @hidden */
  109740. readonly _isScene: boolean;
  109741. /** @hidden */
  109742. _blockEntityCollection: boolean;
  109743. /**
  109744. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109745. */
  109746. autoClear: boolean;
  109747. /**
  109748. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109749. */
  109750. autoClearDepthAndStencil: boolean;
  109751. /**
  109752. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109753. */
  109754. clearColor: Color4;
  109755. /**
  109756. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109757. */
  109758. ambientColor: Color3;
  109759. /**
  109760. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109761. * It should only be one of the following (if not the default embedded one):
  109762. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109763. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109764. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109765. * The material properties need to be setup according to the type of texture in use.
  109766. */
  109767. environmentBRDFTexture: BaseTexture;
  109768. /** @hidden */
  109769. protected _environmentTexture: Nullable<BaseTexture>;
  109770. /**
  109771. * Texture used in all pbr material as the reflection texture.
  109772. * As in the majority of the scene they are the same (exception for multi room and so on),
  109773. * this is easier to reference from here than from all the materials.
  109774. */
  109775. get environmentTexture(): Nullable<BaseTexture>;
  109776. /**
  109777. * Texture used in all pbr material as the reflection texture.
  109778. * As in the majority of the scene they are the same (exception for multi room and so on),
  109779. * this is easier to set here than in all the materials.
  109780. */
  109781. set environmentTexture(value: Nullable<BaseTexture>);
  109782. /** @hidden */
  109783. protected _environmentIntensity: number;
  109784. /**
  109785. * Intensity of the environment in all pbr material.
  109786. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109787. * As in the majority of the scene they are the same (exception for multi room and so on),
  109788. * this is easier to reference from here than from all the materials.
  109789. */
  109790. get environmentIntensity(): number;
  109791. /**
  109792. * Intensity of the environment in all pbr material.
  109793. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109794. * As in the majority of the scene they are the same (exception for multi room and so on),
  109795. * this is easier to set here than in all the materials.
  109796. */
  109797. set environmentIntensity(value: number);
  109798. /** @hidden */
  109799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109800. /**
  109801. * Default image processing configuration used either in the rendering
  109802. * Forward main pass or through the imageProcessingPostProcess if present.
  109803. * As in the majority of the scene they are the same (exception for multi camera),
  109804. * this is easier to reference from here than from all the materials and post process.
  109805. *
  109806. * No setter as we it is a shared configuration, you can set the values instead.
  109807. */
  109808. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109809. private _forceWireframe;
  109810. /**
  109811. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109812. */
  109813. set forceWireframe(value: boolean);
  109814. get forceWireframe(): boolean;
  109815. private _skipFrustumClipping;
  109816. /**
  109817. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109818. */
  109819. set skipFrustumClipping(value: boolean);
  109820. get skipFrustumClipping(): boolean;
  109821. private _forcePointsCloud;
  109822. /**
  109823. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109824. */
  109825. set forcePointsCloud(value: boolean);
  109826. get forcePointsCloud(): boolean;
  109827. /**
  109828. * Gets or sets the active clipplane 1
  109829. */
  109830. clipPlane: Nullable<Plane>;
  109831. /**
  109832. * Gets or sets the active clipplane 2
  109833. */
  109834. clipPlane2: Nullable<Plane>;
  109835. /**
  109836. * Gets or sets the active clipplane 3
  109837. */
  109838. clipPlane3: Nullable<Plane>;
  109839. /**
  109840. * Gets or sets the active clipplane 4
  109841. */
  109842. clipPlane4: Nullable<Plane>;
  109843. /**
  109844. * Gets or sets the active clipplane 5
  109845. */
  109846. clipPlane5: Nullable<Plane>;
  109847. /**
  109848. * Gets or sets the active clipplane 6
  109849. */
  109850. clipPlane6: Nullable<Plane>;
  109851. /**
  109852. * Gets or sets a boolean indicating if animations are enabled
  109853. */
  109854. animationsEnabled: boolean;
  109855. private _animationPropertiesOverride;
  109856. /**
  109857. * Gets or sets the animation properties override
  109858. */
  109859. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109860. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109861. /**
  109862. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109863. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109864. */
  109865. useConstantAnimationDeltaTime: boolean;
  109866. /**
  109867. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109868. * Please note that it requires to run a ray cast through the scene on every frame
  109869. */
  109870. constantlyUpdateMeshUnderPointer: boolean;
  109871. /**
  109872. * Defines the HTML cursor to use when hovering over interactive elements
  109873. */
  109874. hoverCursor: string;
  109875. /**
  109876. * Defines the HTML default cursor to use (empty by default)
  109877. */
  109878. defaultCursor: string;
  109879. /**
  109880. * Defines whether cursors are handled by the scene.
  109881. */
  109882. doNotHandleCursors: boolean;
  109883. /**
  109884. * This is used to call preventDefault() on pointer down
  109885. * in order to block unwanted artifacts like system double clicks
  109886. */
  109887. preventDefaultOnPointerDown: boolean;
  109888. /**
  109889. * This is used to call preventDefault() on pointer up
  109890. * in order to block unwanted artifacts like system double clicks
  109891. */
  109892. preventDefaultOnPointerUp: boolean;
  109893. /**
  109894. * Gets or sets user defined metadata
  109895. */
  109896. metadata: any;
  109897. /**
  109898. * For internal use only. Please do not use.
  109899. */
  109900. reservedDataStore: any;
  109901. /**
  109902. * Gets the name of the plugin used to load this scene (null by default)
  109903. */
  109904. loadingPluginName: string;
  109905. /**
  109906. * Use this array to add regular expressions used to disable offline support for specific urls
  109907. */
  109908. disableOfflineSupportExceptionRules: RegExp[];
  109909. /**
  109910. * An event triggered when the scene is disposed.
  109911. */
  109912. onDisposeObservable: Observable<Scene>;
  109913. private _onDisposeObserver;
  109914. /** Sets a function to be executed when this scene is disposed. */
  109915. set onDispose(callback: () => void);
  109916. /**
  109917. * An event triggered before rendering the scene (right after animations and physics)
  109918. */
  109919. onBeforeRenderObservable: Observable<Scene>;
  109920. private _onBeforeRenderObserver;
  109921. /** Sets a function to be executed before rendering this scene */
  109922. set beforeRender(callback: Nullable<() => void>);
  109923. /**
  109924. * An event triggered after rendering the scene
  109925. */
  109926. onAfterRenderObservable: Observable<Scene>;
  109927. /**
  109928. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109929. */
  109930. onAfterRenderCameraObservable: Observable<Camera>;
  109931. private _onAfterRenderObserver;
  109932. /** Sets a function to be executed after rendering this scene */
  109933. set afterRender(callback: Nullable<() => void>);
  109934. /**
  109935. * An event triggered before animating the scene
  109936. */
  109937. onBeforeAnimationsObservable: Observable<Scene>;
  109938. /**
  109939. * An event triggered after animations processing
  109940. */
  109941. onAfterAnimationsObservable: Observable<Scene>;
  109942. /**
  109943. * An event triggered before draw calls are ready to be sent
  109944. */
  109945. onBeforeDrawPhaseObservable: Observable<Scene>;
  109946. /**
  109947. * An event triggered after draw calls have been sent
  109948. */
  109949. onAfterDrawPhaseObservable: Observable<Scene>;
  109950. /**
  109951. * An event triggered when the scene is ready
  109952. */
  109953. onReadyObservable: Observable<Scene>;
  109954. /**
  109955. * An event triggered before rendering a camera
  109956. */
  109957. onBeforeCameraRenderObservable: Observable<Camera>;
  109958. private _onBeforeCameraRenderObserver;
  109959. /** Sets a function to be executed before rendering a camera*/
  109960. set beforeCameraRender(callback: () => void);
  109961. /**
  109962. * An event triggered after rendering a camera
  109963. */
  109964. onAfterCameraRenderObservable: Observable<Camera>;
  109965. private _onAfterCameraRenderObserver;
  109966. /** Sets a function to be executed after rendering a camera*/
  109967. set afterCameraRender(callback: () => void);
  109968. /**
  109969. * An event triggered when active meshes evaluation is about to start
  109970. */
  109971. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109972. /**
  109973. * An event triggered when active meshes evaluation is done
  109974. */
  109975. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109976. /**
  109977. * An event triggered when particles rendering is about to start
  109978. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109979. */
  109980. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109981. /**
  109982. * An event triggered when particles rendering is done
  109983. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109984. */
  109985. onAfterParticlesRenderingObservable: Observable<Scene>;
  109986. /**
  109987. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109988. */
  109989. onDataLoadedObservable: Observable<Scene>;
  109990. /**
  109991. * An event triggered when a camera is created
  109992. */
  109993. onNewCameraAddedObservable: Observable<Camera>;
  109994. /**
  109995. * An event triggered when a camera is removed
  109996. */
  109997. onCameraRemovedObservable: Observable<Camera>;
  109998. /**
  109999. * An event triggered when a light is created
  110000. */
  110001. onNewLightAddedObservable: Observable<Light>;
  110002. /**
  110003. * An event triggered when a light is removed
  110004. */
  110005. onLightRemovedObservable: Observable<Light>;
  110006. /**
  110007. * An event triggered when a geometry is created
  110008. */
  110009. onNewGeometryAddedObservable: Observable<Geometry>;
  110010. /**
  110011. * An event triggered when a geometry is removed
  110012. */
  110013. onGeometryRemovedObservable: Observable<Geometry>;
  110014. /**
  110015. * An event triggered when a transform node is created
  110016. */
  110017. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110018. /**
  110019. * An event triggered when a transform node is removed
  110020. */
  110021. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110022. /**
  110023. * An event triggered when a mesh is created
  110024. */
  110025. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110026. /**
  110027. * An event triggered when a mesh is removed
  110028. */
  110029. onMeshRemovedObservable: Observable<AbstractMesh>;
  110030. /**
  110031. * An event triggered when a skeleton is created
  110032. */
  110033. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110034. /**
  110035. * An event triggered when a skeleton is removed
  110036. */
  110037. onSkeletonRemovedObservable: Observable<Skeleton>;
  110038. /**
  110039. * An event triggered when a material is created
  110040. */
  110041. onNewMaterialAddedObservable: Observable<Material>;
  110042. /**
  110043. * An event triggered when a material is removed
  110044. */
  110045. onMaterialRemovedObservable: Observable<Material>;
  110046. /**
  110047. * An event triggered when a texture is created
  110048. */
  110049. onNewTextureAddedObservable: Observable<BaseTexture>;
  110050. /**
  110051. * An event triggered when a texture is removed
  110052. */
  110053. onTextureRemovedObservable: Observable<BaseTexture>;
  110054. /**
  110055. * An event triggered when render targets are about to be rendered
  110056. * Can happen multiple times per frame.
  110057. */
  110058. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110059. /**
  110060. * An event triggered when render targets were rendered.
  110061. * Can happen multiple times per frame.
  110062. */
  110063. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110064. /**
  110065. * An event triggered before calculating deterministic simulation step
  110066. */
  110067. onBeforeStepObservable: Observable<Scene>;
  110068. /**
  110069. * An event triggered after calculating deterministic simulation step
  110070. */
  110071. onAfterStepObservable: Observable<Scene>;
  110072. /**
  110073. * An event triggered when the activeCamera property is updated
  110074. */
  110075. onActiveCameraChanged: Observable<Scene>;
  110076. /**
  110077. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110078. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110079. * 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)
  110080. */
  110081. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110082. /**
  110083. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110084. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110085. * 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)
  110086. */
  110087. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110088. /**
  110089. * This Observable will when a mesh has been imported into the scene.
  110090. */
  110091. onMeshImportedObservable: Observable<AbstractMesh>;
  110092. /**
  110093. * This Observable will when an animation file has been imported into the scene.
  110094. */
  110095. onAnimationFileImportedObservable: Observable<Scene>;
  110096. /**
  110097. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110098. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110099. */
  110100. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110101. /** @hidden */
  110102. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110103. /**
  110104. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110105. */
  110106. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110107. /**
  110108. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110109. */
  110110. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110111. /**
  110112. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110113. */
  110114. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110115. /** Callback called when a pointer move is detected */
  110116. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110117. /** Callback called when a pointer down is detected */
  110118. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110119. /** Callback called when a pointer up is detected */
  110120. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110121. /** Callback called when a pointer pick is detected */
  110122. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110123. /**
  110124. * 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).
  110125. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110126. */
  110127. onPrePointerObservable: Observable<PointerInfoPre>;
  110128. /**
  110129. * Observable event triggered each time an input event is received from the rendering canvas
  110130. */
  110131. onPointerObservable: Observable<PointerInfo>;
  110132. /**
  110133. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110134. */
  110135. get unTranslatedPointer(): Vector2;
  110136. /**
  110137. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110138. */
  110139. static get DragMovementThreshold(): number;
  110140. static set DragMovementThreshold(value: number);
  110141. /**
  110142. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110143. */
  110144. static get LongPressDelay(): number;
  110145. static set LongPressDelay(value: number);
  110146. /**
  110147. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110148. */
  110149. static get DoubleClickDelay(): number;
  110150. static set DoubleClickDelay(value: number);
  110151. /** If you need to check double click without raising a single click at first click, enable this flag */
  110152. static get ExclusiveDoubleClickMode(): boolean;
  110153. static set ExclusiveDoubleClickMode(value: boolean);
  110154. /** @hidden */
  110155. _mirroredCameraPosition: Nullable<Vector3>;
  110156. /**
  110157. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110158. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110159. */
  110160. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110161. /**
  110162. * Observable event triggered each time an keyboard event is received from the hosting window
  110163. */
  110164. onKeyboardObservable: Observable<KeyboardInfo>;
  110165. private _useRightHandedSystem;
  110166. /**
  110167. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110168. */
  110169. set useRightHandedSystem(value: boolean);
  110170. get useRightHandedSystem(): boolean;
  110171. private _timeAccumulator;
  110172. private _currentStepId;
  110173. private _currentInternalStep;
  110174. /**
  110175. * Sets the step Id used by deterministic lock step
  110176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110177. * @param newStepId defines the step Id
  110178. */
  110179. setStepId(newStepId: number): void;
  110180. /**
  110181. * Gets the step Id used by deterministic lock step
  110182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110183. * @returns the step Id
  110184. */
  110185. getStepId(): number;
  110186. /**
  110187. * Gets the internal step used by deterministic lock step
  110188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110189. * @returns the internal step
  110190. */
  110191. getInternalStep(): number;
  110192. private _fogEnabled;
  110193. /**
  110194. * Gets or sets a boolean indicating if fog is enabled on this scene
  110195. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110196. * (Default is true)
  110197. */
  110198. set fogEnabled(value: boolean);
  110199. get fogEnabled(): boolean;
  110200. private _fogMode;
  110201. /**
  110202. * Gets or sets the fog mode to use
  110203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110204. * | mode | value |
  110205. * | --- | --- |
  110206. * | FOGMODE_NONE | 0 |
  110207. * | FOGMODE_EXP | 1 |
  110208. * | FOGMODE_EXP2 | 2 |
  110209. * | FOGMODE_LINEAR | 3 |
  110210. */
  110211. set fogMode(value: number);
  110212. get fogMode(): number;
  110213. /**
  110214. * Gets or sets the fog color to use
  110215. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110216. * (Default is Color3(0.2, 0.2, 0.3))
  110217. */
  110218. fogColor: Color3;
  110219. /**
  110220. * Gets or sets the fog density to use
  110221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110222. * (Default is 0.1)
  110223. */
  110224. fogDensity: number;
  110225. /**
  110226. * Gets or sets the fog start distance to use
  110227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110228. * (Default is 0)
  110229. */
  110230. fogStart: number;
  110231. /**
  110232. * Gets or sets the fog end distance to use
  110233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110234. * (Default is 1000)
  110235. */
  110236. fogEnd: number;
  110237. private _shadowsEnabled;
  110238. /**
  110239. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110240. */
  110241. set shadowsEnabled(value: boolean);
  110242. get shadowsEnabled(): boolean;
  110243. private _lightsEnabled;
  110244. /**
  110245. * Gets or sets a boolean indicating if lights are enabled on this scene
  110246. */
  110247. set lightsEnabled(value: boolean);
  110248. get lightsEnabled(): boolean;
  110249. /** All of the active cameras added to this scene. */
  110250. activeCameras: Camera[];
  110251. /** @hidden */
  110252. _activeCamera: Nullable<Camera>;
  110253. /** Gets or sets the current active camera */
  110254. get activeCamera(): Nullable<Camera>;
  110255. set activeCamera(value: Nullable<Camera>);
  110256. private _defaultMaterial;
  110257. /** The default material used on meshes when no material is affected */
  110258. get defaultMaterial(): Material;
  110259. /** The default material used on meshes when no material is affected */
  110260. set defaultMaterial(value: Material);
  110261. private _texturesEnabled;
  110262. /**
  110263. * Gets or sets a boolean indicating if textures are enabled on this scene
  110264. */
  110265. set texturesEnabled(value: boolean);
  110266. get texturesEnabled(): boolean;
  110267. /**
  110268. * Gets or sets a boolean indicating if particles are enabled on this scene
  110269. */
  110270. particlesEnabled: boolean;
  110271. /**
  110272. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110273. */
  110274. spritesEnabled: boolean;
  110275. private _skeletonsEnabled;
  110276. /**
  110277. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110278. */
  110279. set skeletonsEnabled(value: boolean);
  110280. get skeletonsEnabled(): boolean;
  110281. /**
  110282. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110283. */
  110284. lensFlaresEnabled: boolean;
  110285. /**
  110286. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110288. */
  110289. collisionsEnabled: boolean;
  110290. private _collisionCoordinator;
  110291. /** @hidden */
  110292. get collisionCoordinator(): ICollisionCoordinator;
  110293. /**
  110294. * Defines the gravity applied to this scene (used only for collisions)
  110295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110296. */
  110297. gravity: Vector3;
  110298. /**
  110299. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110300. */
  110301. postProcessesEnabled: boolean;
  110302. /**
  110303. * The list of postprocesses added to the scene
  110304. */
  110305. postProcesses: PostProcess[];
  110306. /**
  110307. * Gets the current postprocess manager
  110308. */
  110309. postProcessManager: PostProcessManager;
  110310. /**
  110311. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110312. */
  110313. renderTargetsEnabled: boolean;
  110314. /**
  110315. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110316. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110317. */
  110318. dumpNextRenderTargets: boolean;
  110319. /**
  110320. * The list of user defined render targets added to the scene
  110321. */
  110322. customRenderTargets: RenderTargetTexture[];
  110323. /**
  110324. * Defines if texture loading must be delayed
  110325. * If true, textures will only be loaded when they need to be rendered
  110326. */
  110327. useDelayedTextureLoading: boolean;
  110328. /**
  110329. * Gets the list of meshes imported to the scene through SceneLoader
  110330. */
  110331. importedMeshesFiles: String[];
  110332. /**
  110333. * Gets or sets a boolean indicating if probes are enabled on this scene
  110334. */
  110335. probesEnabled: boolean;
  110336. /**
  110337. * Gets or sets the current offline provider to use to store scene data
  110338. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110339. */
  110340. offlineProvider: IOfflineProvider;
  110341. /**
  110342. * Gets or sets the action manager associated with the scene
  110343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110344. */
  110345. actionManager: AbstractActionManager;
  110346. private _meshesForIntersections;
  110347. /**
  110348. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110349. */
  110350. proceduralTexturesEnabled: boolean;
  110351. private _engine;
  110352. private _totalVertices;
  110353. /** @hidden */
  110354. _activeIndices: PerfCounter;
  110355. /** @hidden */
  110356. _activeParticles: PerfCounter;
  110357. /** @hidden */
  110358. _activeBones: PerfCounter;
  110359. private _animationRatio;
  110360. /** @hidden */
  110361. _animationTimeLast: number;
  110362. /** @hidden */
  110363. _animationTime: number;
  110364. /**
  110365. * Gets or sets a general scale for animation speed
  110366. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110367. */
  110368. animationTimeScale: number;
  110369. /** @hidden */
  110370. _cachedMaterial: Nullable<Material>;
  110371. /** @hidden */
  110372. _cachedEffect: Nullable<Effect>;
  110373. /** @hidden */
  110374. _cachedVisibility: Nullable<number>;
  110375. private _renderId;
  110376. private _frameId;
  110377. private _executeWhenReadyTimeoutId;
  110378. private _intermediateRendering;
  110379. private _viewUpdateFlag;
  110380. private _projectionUpdateFlag;
  110381. /** @hidden */
  110382. _toBeDisposed: Nullable<IDisposable>[];
  110383. private _activeRequests;
  110384. /** @hidden */
  110385. _pendingData: any[];
  110386. private _isDisposed;
  110387. /**
  110388. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110389. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110390. */
  110391. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110392. private _activeMeshes;
  110393. private _processedMaterials;
  110394. private _renderTargets;
  110395. /** @hidden */
  110396. _activeParticleSystems: SmartArray<IParticleSystem>;
  110397. private _activeSkeletons;
  110398. private _softwareSkinnedMeshes;
  110399. private _renderingManager;
  110400. /** @hidden */
  110401. _activeAnimatables: Animatable[];
  110402. private _transformMatrix;
  110403. private _sceneUbo;
  110404. /** @hidden */
  110405. _viewMatrix: Matrix;
  110406. private _projectionMatrix;
  110407. /** @hidden */
  110408. _forcedViewPosition: Nullable<Vector3>;
  110409. /** @hidden */
  110410. _frustumPlanes: Plane[];
  110411. /**
  110412. * Gets the list of frustum planes (built from the active camera)
  110413. */
  110414. get frustumPlanes(): Plane[];
  110415. /**
  110416. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110417. * This is useful if there are more lights that the maximum simulteanous authorized
  110418. */
  110419. requireLightSorting: boolean;
  110420. /** @hidden */
  110421. readonly useMaterialMeshMap: boolean;
  110422. /** @hidden */
  110423. readonly useClonedMeshMap: boolean;
  110424. private _externalData;
  110425. private _uid;
  110426. /**
  110427. * @hidden
  110428. * Backing store of defined scene components.
  110429. */
  110430. _components: ISceneComponent[];
  110431. /**
  110432. * @hidden
  110433. * Backing store of defined scene components.
  110434. */
  110435. _serializableComponents: ISceneSerializableComponent[];
  110436. /**
  110437. * List of components to register on the next registration step.
  110438. */
  110439. private _transientComponents;
  110440. /**
  110441. * Registers the transient components if needed.
  110442. */
  110443. private _registerTransientComponents;
  110444. /**
  110445. * @hidden
  110446. * Add a component to the scene.
  110447. * Note that the ccomponent could be registered on th next frame if this is called after
  110448. * the register component stage.
  110449. * @param component Defines the component to add to the scene
  110450. */
  110451. _addComponent(component: ISceneComponent): void;
  110452. /**
  110453. * @hidden
  110454. * Gets a component from the scene.
  110455. * @param name defines the name of the component to retrieve
  110456. * @returns the component or null if not present
  110457. */
  110458. _getComponent(name: string): Nullable<ISceneComponent>;
  110459. /**
  110460. * @hidden
  110461. * Defines the actions happening before camera updates.
  110462. */
  110463. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110464. /**
  110465. * @hidden
  110466. * Defines the actions happening before clear the canvas.
  110467. */
  110468. _beforeClearStage: Stage<SimpleStageAction>;
  110469. /**
  110470. * @hidden
  110471. * Defines the actions when collecting render targets for the frame.
  110472. */
  110473. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110474. /**
  110475. * @hidden
  110476. * Defines the actions happening for one camera in the frame.
  110477. */
  110478. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110479. /**
  110480. * @hidden
  110481. * Defines the actions happening during the per mesh ready checks.
  110482. */
  110483. _isReadyForMeshStage: Stage<MeshStageAction>;
  110484. /**
  110485. * @hidden
  110486. * Defines the actions happening before evaluate active mesh checks.
  110487. */
  110488. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110489. /**
  110490. * @hidden
  110491. * Defines the actions happening during the evaluate sub mesh checks.
  110492. */
  110493. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110494. /**
  110495. * @hidden
  110496. * Defines the actions happening during the active mesh stage.
  110497. */
  110498. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110499. /**
  110500. * @hidden
  110501. * Defines the actions happening during the per camera render target step.
  110502. */
  110503. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110504. /**
  110505. * @hidden
  110506. * Defines the actions happening just before the active camera is drawing.
  110507. */
  110508. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110509. /**
  110510. * @hidden
  110511. * Defines the actions happening just before a render target is drawing.
  110512. */
  110513. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110514. /**
  110515. * @hidden
  110516. * Defines the actions happening just before a rendering group is drawing.
  110517. */
  110518. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110519. /**
  110520. * @hidden
  110521. * Defines the actions happening just before a mesh is drawing.
  110522. */
  110523. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110524. /**
  110525. * @hidden
  110526. * Defines the actions happening just after a mesh has been drawn.
  110527. */
  110528. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110529. /**
  110530. * @hidden
  110531. * Defines the actions happening just after a rendering group has been drawn.
  110532. */
  110533. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110534. /**
  110535. * @hidden
  110536. * Defines the actions happening just after the active camera has been drawn.
  110537. */
  110538. _afterCameraDrawStage: Stage<CameraStageAction>;
  110539. /**
  110540. * @hidden
  110541. * Defines the actions happening just after a render target has been drawn.
  110542. */
  110543. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110544. /**
  110545. * @hidden
  110546. * Defines the actions happening just after rendering all cameras and computing intersections.
  110547. */
  110548. _afterRenderStage: Stage<SimpleStageAction>;
  110549. /**
  110550. * @hidden
  110551. * Defines the actions happening when a pointer move event happens.
  110552. */
  110553. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110554. /**
  110555. * @hidden
  110556. * Defines the actions happening when a pointer down event happens.
  110557. */
  110558. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110559. /**
  110560. * @hidden
  110561. * Defines the actions happening when a pointer up event happens.
  110562. */
  110563. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110564. /**
  110565. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110566. */
  110567. private geometriesByUniqueId;
  110568. /**
  110569. * Creates a new Scene
  110570. * @param engine defines the engine to use to render this scene
  110571. * @param options defines the scene options
  110572. */
  110573. constructor(engine: Engine, options?: SceneOptions);
  110574. /**
  110575. * Gets a string idenfifying the name of the class
  110576. * @returns "Scene" string
  110577. */
  110578. getClassName(): string;
  110579. private _defaultMeshCandidates;
  110580. /**
  110581. * @hidden
  110582. */
  110583. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110584. private _defaultSubMeshCandidates;
  110585. /**
  110586. * @hidden
  110587. */
  110588. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110589. /**
  110590. * Sets the default candidate providers for the scene.
  110591. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110592. * and getCollidingSubMeshCandidates to their default function
  110593. */
  110594. setDefaultCandidateProviders(): void;
  110595. /**
  110596. * Gets the mesh that is currently under the pointer
  110597. */
  110598. get meshUnderPointer(): Nullable<AbstractMesh>;
  110599. /**
  110600. * Gets or sets the current on-screen X position of the pointer
  110601. */
  110602. get pointerX(): number;
  110603. set pointerX(value: number);
  110604. /**
  110605. * Gets or sets the current on-screen Y position of the pointer
  110606. */
  110607. get pointerY(): number;
  110608. set pointerY(value: number);
  110609. /**
  110610. * Gets the cached material (ie. the latest rendered one)
  110611. * @returns the cached material
  110612. */
  110613. getCachedMaterial(): Nullable<Material>;
  110614. /**
  110615. * Gets the cached effect (ie. the latest rendered one)
  110616. * @returns the cached effect
  110617. */
  110618. getCachedEffect(): Nullable<Effect>;
  110619. /**
  110620. * Gets the cached visibility state (ie. the latest rendered one)
  110621. * @returns the cached visibility state
  110622. */
  110623. getCachedVisibility(): Nullable<number>;
  110624. /**
  110625. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110626. * @param material defines the current material
  110627. * @param effect defines the current effect
  110628. * @param visibility defines the current visibility state
  110629. * @returns true if one parameter is not cached
  110630. */
  110631. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110632. /**
  110633. * Gets the engine associated with the scene
  110634. * @returns an Engine
  110635. */
  110636. getEngine(): Engine;
  110637. /**
  110638. * Gets the total number of vertices rendered per frame
  110639. * @returns the total number of vertices rendered per frame
  110640. */
  110641. getTotalVertices(): number;
  110642. /**
  110643. * Gets the performance counter for total vertices
  110644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110645. */
  110646. get totalVerticesPerfCounter(): PerfCounter;
  110647. /**
  110648. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110649. * @returns the total number of active indices rendered per frame
  110650. */
  110651. getActiveIndices(): number;
  110652. /**
  110653. * Gets the performance counter for active indices
  110654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110655. */
  110656. get totalActiveIndicesPerfCounter(): PerfCounter;
  110657. /**
  110658. * Gets the total number of active particles rendered per frame
  110659. * @returns the total number of active particles rendered per frame
  110660. */
  110661. getActiveParticles(): number;
  110662. /**
  110663. * Gets the performance counter for active particles
  110664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110665. */
  110666. get activeParticlesPerfCounter(): PerfCounter;
  110667. /**
  110668. * Gets the total number of active bones rendered per frame
  110669. * @returns the total number of active bones rendered per frame
  110670. */
  110671. getActiveBones(): number;
  110672. /**
  110673. * Gets the performance counter for active bones
  110674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110675. */
  110676. get activeBonesPerfCounter(): PerfCounter;
  110677. /**
  110678. * Gets the array of active meshes
  110679. * @returns an array of AbstractMesh
  110680. */
  110681. getActiveMeshes(): SmartArray<AbstractMesh>;
  110682. /**
  110683. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110684. * @returns a number
  110685. */
  110686. getAnimationRatio(): number;
  110687. /**
  110688. * Gets an unique Id for the current render phase
  110689. * @returns a number
  110690. */
  110691. getRenderId(): number;
  110692. /**
  110693. * Gets an unique Id for the current frame
  110694. * @returns a number
  110695. */
  110696. getFrameId(): number;
  110697. /** Call this function if you want to manually increment the render Id*/
  110698. incrementRenderId(): void;
  110699. private _createUbo;
  110700. /**
  110701. * Use this method to simulate a pointer move on a mesh
  110702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110705. * @returns the current scene
  110706. */
  110707. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110708. /**
  110709. * Use this method to simulate a pointer down on a mesh
  110710. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110711. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110712. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110713. * @returns the current scene
  110714. */
  110715. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110716. /**
  110717. * Use this method to simulate a pointer up on a mesh
  110718. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110719. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110720. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110721. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110722. * @returns the current scene
  110723. */
  110724. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110725. /**
  110726. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110727. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110728. * @returns true if the pointer was captured
  110729. */
  110730. isPointerCaptured(pointerId?: number): boolean;
  110731. /**
  110732. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110733. * @param attachUp defines if you want to attach events to pointerup
  110734. * @param attachDown defines if you want to attach events to pointerdown
  110735. * @param attachMove defines if you want to attach events to pointermove
  110736. */
  110737. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110738. /** Detaches all event handlers*/
  110739. detachControl(): void;
  110740. /**
  110741. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110742. * Delay loaded resources are not taking in account
  110743. * @return true if all required resources are ready
  110744. */
  110745. isReady(): boolean;
  110746. /** Resets all cached information relative to material (including effect and visibility) */
  110747. resetCachedMaterial(): void;
  110748. /**
  110749. * Registers a function to be called before every frame render
  110750. * @param func defines the function to register
  110751. */
  110752. registerBeforeRender(func: () => void): void;
  110753. /**
  110754. * Unregisters a function called before every frame render
  110755. * @param func defines the function to unregister
  110756. */
  110757. unregisterBeforeRender(func: () => void): void;
  110758. /**
  110759. * Registers a function to be called after every frame render
  110760. * @param func defines the function to register
  110761. */
  110762. registerAfterRender(func: () => void): void;
  110763. /**
  110764. * Unregisters a function called after every frame render
  110765. * @param func defines the function to unregister
  110766. */
  110767. unregisterAfterRender(func: () => void): void;
  110768. private _executeOnceBeforeRender;
  110769. /**
  110770. * The provided function will run before render once and will be disposed afterwards.
  110771. * A timeout delay can be provided so that the function will be executed in N ms.
  110772. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110773. * @param func The function to be executed.
  110774. * @param timeout optional delay in ms
  110775. */
  110776. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110777. /** @hidden */
  110778. _addPendingData(data: any): void;
  110779. /** @hidden */
  110780. _removePendingData(data: any): void;
  110781. /**
  110782. * Returns the number of items waiting to be loaded
  110783. * @returns the number of items waiting to be loaded
  110784. */
  110785. getWaitingItemsCount(): number;
  110786. /**
  110787. * Returns a boolean indicating if the scene is still loading data
  110788. */
  110789. get isLoading(): boolean;
  110790. /**
  110791. * Registers a function to be executed when the scene is ready
  110792. * @param {Function} func - the function to be executed
  110793. */
  110794. executeWhenReady(func: () => void): void;
  110795. /**
  110796. * Returns a promise that resolves when the scene is ready
  110797. * @returns A promise that resolves when the scene is ready
  110798. */
  110799. whenReadyAsync(): Promise<void>;
  110800. /** @hidden */
  110801. _checkIsReady(): void;
  110802. /**
  110803. * Gets all animatable attached to the scene
  110804. */
  110805. get animatables(): Animatable[];
  110806. /**
  110807. * Resets the last animation time frame.
  110808. * Useful to override when animations start running when loading a scene for the first time.
  110809. */
  110810. resetLastAnimationTimeFrame(): void;
  110811. /**
  110812. * Gets the current view matrix
  110813. * @returns a Matrix
  110814. */
  110815. getViewMatrix(): Matrix;
  110816. /**
  110817. * Gets the current projection matrix
  110818. * @returns a Matrix
  110819. */
  110820. getProjectionMatrix(): Matrix;
  110821. /**
  110822. * Gets the current transform matrix
  110823. * @returns a Matrix made of View * Projection
  110824. */
  110825. getTransformMatrix(): Matrix;
  110826. /**
  110827. * Sets the current transform matrix
  110828. * @param viewL defines the View matrix to use
  110829. * @param projectionL defines the Projection matrix to use
  110830. * @param viewR defines the right View matrix to use (if provided)
  110831. * @param projectionR defines the right Projection matrix to use (if provided)
  110832. */
  110833. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110834. /**
  110835. * Gets the uniform buffer used to store scene data
  110836. * @returns a UniformBuffer
  110837. */
  110838. getSceneUniformBuffer(): UniformBuffer;
  110839. /**
  110840. * Gets an unique (relatively to the current scene) Id
  110841. * @returns an unique number for the scene
  110842. */
  110843. getUniqueId(): number;
  110844. /**
  110845. * Add a mesh to the list of scene's meshes
  110846. * @param newMesh defines the mesh to add
  110847. * @param recursive if all child meshes should also be added to the scene
  110848. */
  110849. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110850. /**
  110851. * Remove a mesh for the list of scene's meshes
  110852. * @param toRemove defines the mesh to remove
  110853. * @param recursive if all child meshes should also be removed from the scene
  110854. * @returns the index where the mesh was in the mesh list
  110855. */
  110856. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110857. /**
  110858. * Add a transform node to the list of scene's transform nodes
  110859. * @param newTransformNode defines the transform node to add
  110860. */
  110861. addTransformNode(newTransformNode: TransformNode): void;
  110862. /**
  110863. * Remove a transform node for the list of scene's transform nodes
  110864. * @param toRemove defines the transform node to remove
  110865. * @returns the index where the transform node was in the transform node list
  110866. */
  110867. removeTransformNode(toRemove: TransformNode): number;
  110868. /**
  110869. * Remove a skeleton for the list of scene's skeletons
  110870. * @param toRemove defines the skeleton to remove
  110871. * @returns the index where the skeleton was in the skeleton list
  110872. */
  110873. removeSkeleton(toRemove: Skeleton): number;
  110874. /**
  110875. * Remove a morph target for the list of scene's morph targets
  110876. * @param toRemove defines the morph target to remove
  110877. * @returns the index where the morph target was in the morph target list
  110878. */
  110879. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110880. /**
  110881. * Remove a light for the list of scene's lights
  110882. * @param toRemove defines the light to remove
  110883. * @returns the index where the light was in the light list
  110884. */
  110885. removeLight(toRemove: Light): number;
  110886. /**
  110887. * Remove a camera for the list of scene's cameras
  110888. * @param toRemove defines the camera to remove
  110889. * @returns the index where the camera was in the camera list
  110890. */
  110891. removeCamera(toRemove: Camera): number;
  110892. /**
  110893. * Remove a particle system for the list of scene's particle systems
  110894. * @param toRemove defines the particle system to remove
  110895. * @returns the index where the particle system was in the particle system list
  110896. */
  110897. removeParticleSystem(toRemove: IParticleSystem): number;
  110898. /**
  110899. * Remove a animation for the list of scene's animations
  110900. * @param toRemove defines the animation to remove
  110901. * @returns the index where the animation was in the animation list
  110902. */
  110903. removeAnimation(toRemove: Animation): number;
  110904. /**
  110905. * Will stop the animation of the given target
  110906. * @param target - the target
  110907. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110908. * @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)
  110909. */
  110910. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110911. /**
  110912. * Removes the given animation group from this scene.
  110913. * @param toRemove The animation group to remove
  110914. * @returns The index of the removed animation group
  110915. */
  110916. removeAnimationGroup(toRemove: AnimationGroup): number;
  110917. /**
  110918. * Removes the given multi-material from this scene.
  110919. * @param toRemove The multi-material to remove
  110920. * @returns The index of the removed multi-material
  110921. */
  110922. removeMultiMaterial(toRemove: MultiMaterial): number;
  110923. /**
  110924. * Removes the given material from this scene.
  110925. * @param toRemove The material to remove
  110926. * @returns The index of the removed material
  110927. */
  110928. removeMaterial(toRemove: Material): number;
  110929. /**
  110930. * Removes the given action manager from this scene.
  110931. * @param toRemove The action manager to remove
  110932. * @returns The index of the removed action manager
  110933. */
  110934. removeActionManager(toRemove: AbstractActionManager): number;
  110935. /**
  110936. * Removes the given texture from this scene.
  110937. * @param toRemove The texture to remove
  110938. * @returns The index of the removed texture
  110939. */
  110940. removeTexture(toRemove: BaseTexture): number;
  110941. /**
  110942. * Adds the given light to this scene
  110943. * @param newLight The light to add
  110944. */
  110945. addLight(newLight: Light): void;
  110946. /**
  110947. * Sorts the list list based on light priorities
  110948. */
  110949. sortLightsByPriority(): void;
  110950. /**
  110951. * Adds the given camera to this scene
  110952. * @param newCamera The camera to add
  110953. */
  110954. addCamera(newCamera: Camera): void;
  110955. /**
  110956. * Adds the given skeleton to this scene
  110957. * @param newSkeleton The skeleton to add
  110958. */
  110959. addSkeleton(newSkeleton: Skeleton): void;
  110960. /**
  110961. * Adds the given particle system to this scene
  110962. * @param newParticleSystem The particle system to add
  110963. */
  110964. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110965. /**
  110966. * Adds the given animation to this scene
  110967. * @param newAnimation The animation to add
  110968. */
  110969. addAnimation(newAnimation: Animation): void;
  110970. /**
  110971. * Adds the given animation group to this scene.
  110972. * @param newAnimationGroup The animation group to add
  110973. */
  110974. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110975. /**
  110976. * Adds the given multi-material to this scene
  110977. * @param newMultiMaterial The multi-material to add
  110978. */
  110979. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110980. /**
  110981. * Adds the given material to this scene
  110982. * @param newMaterial The material to add
  110983. */
  110984. addMaterial(newMaterial: Material): void;
  110985. /**
  110986. * Adds the given morph target to this scene
  110987. * @param newMorphTargetManager The morph target to add
  110988. */
  110989. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110990. /**
  110991. * Adds the given geometry to this scene
  110992. * @param newGeometry The geometry to add
  110993. */
  110994. addGeometry(newGeometry: Geometry): void;
  110995. /**
  110996. * Adds the given action manager to this scene
  110997. * @param newActionManager The action manager to add
  110998. */
  110999. addActionManager(newActionManager: AbstractActionManager): void;
  111000. /**
  111001. * Adds the given texture to this scene.
  111002. * @param newTexture The texture to add
  111003. */
  111004. addTexture(newTexture: BaseTexture): void;
  111005. /**
  111006. * Switch active camera
  111007. * @param newCamera defines the new active camera
  111008. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111009. */
  111010. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111011. /**
  111012. * sets the active camera of the scene using its ID
  111013. * @param id defines the camera's ID
  111014. * @return the new active camera or null if none found.
  111015. */
  111016. setActiveCameraByID(id: string): Nullable<Camera>;
  111017. /**
  111018. * sets the active camera of the scene using its name
  111019. * @param name defines the camera's name
  111020. * @returns the new active camera or null if none found.
  111021. */
  111022. setActiveCameraByName(name: string): Nullable<Camera>;
  111023. /**
  111024. * get an animation group using its name
  111025. * @param name defines the material's name
  111026. * @return the animation group or null if none found.
  111027. */
  111028. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111029. /**
  111030. * Get a material using its unique id
  111031. * @param uniqueId defines the material's unique id
  111032. * @return the material or null if none found.
  111033. */
  111034. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111035. /**
  111036. * get a material using its id
  111037. * @param id defines the material's ID
  111038. * @return the material or null if none found.
  111039. */
  111040. getMaterialByID(id: string): Nullable<Material>;
  111041. /**
  111042. * Gets a the last added material using a given id
  111043. * @param id defines the material's ID
  111044. * @return the last material with the given id or null if none found.
  111045. */
  111046. getLastMaterialByID(id: string): Nullable<Material>;
  111047. /**
  111048. * Gets a material using its name
  111049. * @param name defines the material's name
  111050. * @return the material or null if none found.
  111051. */
  111052. getMaterialByName(name: string): Nullable<Material>;
  111053. /**
  111054. * Get a texture using its unique id
  111055. * @param uniqueId defines the texture's unique id
  111056. * @return the texture or null if none found.
  111057. */
  111058. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111059. /**
  111060. * Gets a camera using its id
  111061. * @param id defines the id to look for
  111062. * @returns the camera or null if not found
  111063. */
  111064. getCameraByID(id: string): Nullable<Camera>;
  111065. /**
  111066. * Gets a camera using its unique id
  111067. * @param uniqueId defines the unique id to look for
  111068. * @returns the camera or null if not found
  111069. */
  111070. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111071. /**
  111072. * Gets a camera using its name
  111073. * @param name defines the camera's name
  111074. * @return the camera or null if none found.
  111075. */
  111076. getCameraByName(name: string): Nullable<Camera>;
  111077. /**
  111078. * Gets a bone using its id
  111079. * @param id defines the bone's id
  111080. * @return the bone or null if not found
  111081. */
  111082. getBoneByID(id: string): Nullable<Bone>;
  111083. /**
  111084. * Gets a bone using its id
  111085. * @param name defines the bone's name
  111086. * @return the bone or null if not found
  111087. */
  111088. getBoneByName(name: string): Nullable<Bone>;
  111089. /**
  111090. * Gets a light node using its name
  111091. * @param name defines the the light's name
  111092. * @return the light or null if none found.
  111093. */
  111094. getLightByName(name: string): Nullable<Light>;
  111095. /**
  111096. * Gets a light node using its id
  111097. * @param id defines the light's id
  111098. * @return the light or null if none found.
  111099. */
  111100. getLightByID(id: string): Nullable<Light>;
  111101. /**
  111102. * Gets a light node using its scene-generated unique ID
  111103. * @param uniqueId defines the light's unique id
  111104. * @return the light or null if none found.
  111105. */
  111106. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111107. /**
  111108. * Gets a particle system by id
  111109. * @param id defines the particle system id
  111110. * @return the corresponding system or null if none found
  111111. */
  111112. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111113. /**
  111114. * Gets a geometry using its ID
  111115. * @param id defines the geometry's id
  111116. * @return the geometry or null if none found.
  111117. */
  111118. getGeometryByID(id: string): Nullable<Geometry>;
  111119. private _getGeometryByUniqueID;
  111120. /**
  111121. * Add a new geometry to this scene
  111122. * @param geometry defines the geometry to be added to the scene.
  111123. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111124. * @return a boolean defining if the geometry was added or not
  111125. */
  111126. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111127. /**
  111128. * Removes an existing geometry
  111129. * @param geometry defines the geometry to be removed from the scene
  111130. * @return a boolean defining if the geometry was removed or not
  111131. */
  111132. removeGeometry(geometry: Geometry): boolean;
  111133. /**
  111134. * Gets the list of geometries attached to the scene
  111135. * @returns an array of Geometry
  111136. */
  111137. getGeometries(): Geometry[];
  111138. /**
  111139. * Gets the first added mesh found of a given ID
  111140. * @param id defines the id to search for
  111141. * @return the mesh found or null if not found at all
  111142. */
  111143. getMeshByID(id: string): Nullable<AbstractMesh>;
  111144. /**
  111145. * Gets a list of meshes using their id
  111146. * @param id defines the id to search for
  111147. * @returns a list of meshes
  111148. */
  111149. getMeshesByID(id: string): Array<AbstractMesh>;
  111150. /**
  111151. * Gets the first added transform node found of a given ID
  111152. * @param id defines the id to search for
  111153. * @return the found transform node or null if not found at all.
  111154. */
  111155. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111156. /**
  111157. * Gets a transform node with its auto-generated unique id
  111158. * @param uniqueId efines the unique id to search for
  111159. * @return the found transform node or null if not found at all.
  111160. */
  111161. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111162. /**
  111163. * Gets a list of transform nodes using their id
  111164. * @param id defines the id to search for
  111165. * @returns a list of transform nodes
  111166. */
  111167. getTransformNodesByID(id: string): Array<TransformNode>;
  111168. /**
  111169. * Gets a mesh with its auto-generated unique id
  111170. * @param uniqueId defines the unique id to search for
  111171. * @return the found mesh or null if not found at all.
  111172. */
  111173. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111174. /**
  111175. * Gets a the last added mesh using a given id
  111176. * @param id defines the id to search for
  111177. * @return the found mesh or null if not found at all.
  111178. */
  111179. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111180. /**
  111181. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111182. * @param id defines the id to search for
  111183. * @return the found node or null if not found at all
  111184. */
  111185. getLastEntryByID(id: string): Nullable<Node>;
  111186. /**
  111187. * Gets a node (Mesh, Camera, Light) using a given id
  111188. * @param id defines the id to search for
  111189. * @return the found node or null if not found at all
  111190. */
  111191. getNodeByID(id: string): Nullable<Node>;
  111192. /**
  111193. * Gets a node (Mesh, Camera, Light) using a given name
  111194. * @param name defines the name to search for
  111195. * @return the found node or null if not found at all.
  111196. */
  111197. getNodeByName(name: string): Nullable<Node>;
  111198. /**
  111199. * Gets a mesh using a given name
  111200. * @param name defines the name to search for
  111201. * @return the found mesh or null if not found at all.
  111202. */
  111203. getMeshByName(name: string): Nullable<AbstractMesh>;
  111204. /**
  111205. * Gets a transform node using a given name
  111206. * @param name defines the name to search for
  111207. * @return the found transform node or null if not found at all.
  111208. */
  111209. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111210. /**
  111211. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111212. * @param id defines the id to search for
  111213. * @return the found skeleton or null if not found at all.
  111214. */
  111215. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111216. /**
  111217. * Gets a skeleton using a given auto generated unique id
  111218. * @param uniqueId defines the unique id to search for
  111219. * @return the found skeleton or null if not found at all.
  111220. */
  111221. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111222. /**
  111223. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111224. * @param id defines the id to search for
  111225. * @return the found skeleton or null if not found at all.
  111226. */
  111227. getSkeletonById(id: string): Nullable<Skeleton>;
  111228. /**
  111229. * Gets a skeleton using a given name
  111230. * @param name defines the name to search for
  111231. * @return the found skeleton or null if not found at all.
  111232. */
  111233. getSkeletonByName(name: string): Nullable<Skeleton>;
  111234. /**
  111235. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111236. * @param id defines the id to search for
  111237. * @return the found morph target manager or null if not found at all.
  111238. */
  111239. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111240. /**
  111241. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111242. * @param id defines the id to search for
  111243. * @return the found morph target or null if not found at all.
  111244. */
  111245. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111246. /**
  111247. * Gets a boolean indicating if the given mesh is active
  111248. * @param mesh defines the mesh to look for
  111249. * @returns true if the mesh is in the active list
  111250. */
  111251. isActiveMesh(mesh: AbstractMesh): boolean;
  111252. /**
  111253. * Return a unique id as a string which can serve as an identifier for the scene
  111254. */
  111255. get uid(): string;
  111256. /**
  111257. * Add an externaly attached data from its key.
  111258. * This method call will fail and return false, if such key already exists.
  111259. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111260. * @param key the unique key that identifies the data
  111261. * @param data the data object to associate to the key for this Engine instance
  111262. * @return true if no such key were already present and the data was added successfully, false otherwise
  111263. */
  111264. addExternalData<T>(key: string, data: T): boolean;
  111265. /**
  111266. * Get an externaly attached data from its key
  111267. * @param key the unique key that identifies the data
  111268. * @return the associated data, if present (can be null), or undefined if not present
  111269. */
  111270. getExternalData<T>(key: string): Nullable<T>;
  111271. /**
  111272. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111273. * @param key the unique key that identifies the data
  111274. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111275. * @return the associated data, can be null if the factory returned null.
  111276. */
  111277. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111278. /**
  111279. * Remove an externaly attached data from the Engine instance
  111280. * @param key the unique key that identifies the data
  111281. * @return true if the data was successfully removed, false if it doesn't exist
  111282. */
  111283. removeExternalData(key: string): boolean;
  111284. private _evaluateSubMesh;
  111285. /**
  111286. * Clear the processed materials smart array preventing retention point in material dispose.
  111287. */
  111288. freeProcessedMaterials(): void;
  111289. private _preventFreeActiveMeshesAndRenderingGroups;
  111290. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111291. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111292. * when disposing several meshes in a row or a hierarchy of meshes.
  111293. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111294. */
  111295. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111296. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111297. /**
  111298. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111299. */
  111300. freeActiveMeshes(): void;
  111301. /**
  111302. * Clear the info related to rendering groups preventing retention points during dispose.
  111303. */
  111304. freeRenderingGroups(): void;
  111305. /** @hidden */
  111306. _isInIntermediateRendering(): boolean;
  111307. /**
  111308. * Lambda returning the list of potentially active meshes.
  111309. */
  111310. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111311. /**
  111312. * Lambda returning the list of potentially active sub meshes.
  111313. */
  111314. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111315. /**
  111316. * Lambda returning the list of potentially intersecting sub meshes.
  111317. */
  111318. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111319. /**
  111320. * Lambda returning the list of potentially colliding sub meshes.
  111321. */
  111322. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111323. private _activeMeshesFrozen;
  111324. private _skipEvaluateActiveMeshesCompletely;
  111325. /**
  111326. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111327. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111328. * @returns the current scene
  111329. */
  111330. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111331. /**
  111332. * Use this function to restart evaluating active meshes on every frame
  111333. * @returns the current scene
  111334. */
  111335. unfreezeActiveMeshes(): Scene;
  111336. private _evaluateActiveMeshes;
  111337. private _activeMesh;
  111338. /**
  111339. * Update the transform matrix to update from the current active camera
  111340. * @param force defines a boolean used to force the update even if cache is up to date
  111341. */
  111342. updateTransformMatrix(force?: boolean): void;
  111343. private _bindFrameBuffer;
  111344. /** @hidden */
  111345. _allowPostProcessClearColor: boolean;
  111346. /** @hidden */
  111347. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111348. private _processSubCameras;
  111349. private _checkIntersections;
  111350. /** @hidden */
  111351. _advancePhysicsEngineStep(step: number): void;
  111352. /**
  111353. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111354. */
  111355. getDeterministicFrameTime: () => number;
  111356. /** @hidden */
  111357. _animate(): void;
  111358. /** Execute all animations (for a frame) */
  111359. animate(): void;
  111360. /**
  111361. * Render the scene
  111362. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111363. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111364. */
  111365. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111366. /**
  111367. * Freeze all materials
  111368. * A frozen material will not be updatable but should be faster to render
  111369. */
  111370. freezeMaterials(): void;
  111371. /**
  111372. * Unfreeze all materials
  111373. * A frozen material will not be updatable but should be faster to render
  111374. */
  111375. unfreezeMaterials(): void;
  111376. /**
  111377. * Releases all held ressources
  111378. */
  111379. dispose(): void;
  111380. /**
  111381. * Gets if the scene is already disposed
  111382. */
  111383. get isDisposed(): boolean;
  111384. /**
  111385. * Call this function to reduce memory footprint of the scene.
  111386. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111387. */
  111388. clearCachedVertexData(): void;
  111389. /**
  111390. * This function will remove the local cached buffer data from texture.
  111391. * It will save memory but will prevent the texture from being rebuilt
  111392. */
  111393. cleanCachedTextureBuffer(): void;
  111394. /**
  111395. * Get the world extend vectors with an optional filter
  111396. *
  111397. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111398. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111399. */
  111400. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111401. min: Vector3;
  111402. max: Vector3;
  111403. };
  111404. /**
  111405. * Creates a ray that can be used to pick in the scene
  111406. * @param x defines the x coordinate of the origin (on-screen)
  111407. * @param y defines the y coordinate of the origin (on-screen)
  111408. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111409. * @param camera defines the camera to use for the picking
  111410. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111411. * @returns a Ray
  111412. */
  111413. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111414. /**
  111415. * Creates a ray that can be used to pick in the scene
  111416. * @param x defines the x coordinate of the origin (on-screen)
  111417. * @param y defines the y coordinate of the origin (on-screen)
  111418. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111419. * @param result defines the ray where to store the picking ray
  111420. * @param camera defines the camera to use for the picking
  111421. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111422. * @returns the current scene
  111423. */
  111424. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111425. /**
  111426. * Creates a ray that can be used to pick in the scene
  111427. * @param x defines the x coordinate of the origin (on-screen)
  111428. * @param y defines the y coordinate of the origin (on-screen)
  111429. * @param camera defines the camera to use for the picking
  111430. * @returns a Ray
  111431. */
  111432. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111433. /**
  111434. * Creates a ray that can be used to pick in the scene
  111435. * @param x defines the x coordinate of the origin (on-screen)
  111436. * @param y defines the y coordinate of the origin (on-screen)
  111437. * @param result defines the ray where to store the picking ray
  111438. * @param camera defines the camera to use for the picking
  111439. * @returns the current scene
  111440. */
  111441. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111442. /** Launch a ray to try to pick a mesh in the scene
  111443. * @param x position on screen
  111444. * @param y position on screen
  111445. * @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
  111446. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111447. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111449. * @returns a PickingInfo
  111450. */
  111451. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111452. /** Use the given ray to pick a mesh in the scene
  111453. * @param ray The ray to use to pick meshes
  111454. * @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
  111455. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111456. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111457. * @returns a PickingInfo
  111458. */
  111459. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111460. /**
  111461. * Launch a ray to try to pick a mesh in the scene
  111462. * @param x X position on screen
  111463. * @param y Y position on screen
  111464. * @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
  111465. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111467. * @returns an array of PickingInfo
  111468. */
  111469. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111470. /**
  111471. * Launch a ray to try to pick a mesh in the scene
  111472. * @param ray Ray to use
  111473. * @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
  111474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111475. * @returns an array of PickingInfo
  111476. */
  111477. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111478. /**
  111479. * Force the value of meshUnderPointer
  111480. * @param mesh defines the mesh to use
  111481. */
  111482. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111483. /**
  111484. * Gets the mesh under the pointer
  111485. * @returns a Mesh or null if no mesh is under the pointer
  111486. */
  111487. getPointerOverMesh(): Nullable<AbstractMesh>;
  111488. /** @hidden */
  111489. _rebuildGeometries(): void;
  111490. /** @hidden */
  111491. _rebuildTextures(): void;
  111492. private _getByTags;
  111493. /**
  111494. * Get a list of meshes by tags
  111495. * @param tagsQuery defines the tags query to use
  111496. * @param forEach defines a predicate used to filter results
  111497. * @returns an array of Mesh
  111498. */
  111499. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111500. /**
  111501. * Get a list of cameras by tags
  111502. * @param tagsQuery defines the tags query to use
  111503. * @param forEach defines a predicate used to filter results
  111504. * @returns an array of Camera
  111505. */
  111506. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111507. /**
  111508. * Get a list of lights by tags
  111509. * @param tagsQuery defines the tags query to use
  111510. * @param forEach defines a predicate used to filter results
  111511. * @returns an array of Light
  111512. */
  111513. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111514. /**
  111515. * Get a list of materials by tags
  111516. * @param tagsQuery defines the tags query to use
  111517. * @param forEach defines a predicate used to filter results
  111518. * @returns an array of Material
  111519. */
  111520. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111521. /**
  111522. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111523. * This allowed control for front to back rendering or reversly depending of the special needs.
  111524. *
  111525. * @param renderingGroupId The rendering group id corresponding to its index
  111526. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111527. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111528. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111529. */
  111530. 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;
  111531. /**
  111532. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111533. *
  111534. * @param renderingGroupId The rendering group id corresponding to its index
  111535. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111536. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111537. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111538. */
  111539. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111540. /**
  111541. * Gets the current auto clear configuration for one rendering group of the rendering
  111542. * manager.
  111543. * @param index the rendering group index to get the information for
  111544. * @returns The auto clear setup for the requested rendering group
  111545. */
  111546. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111547. private _blockMaterialDirtyMechanism;
  111548. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111549. get blockMaterialDirtyMechanism(): boolean;
  111550. set blockMaterialDirtyMechanism(value: boolean);
  111551. /**
  111552. * Will flag all materials as dirty to trigger new shader compilation
  111553. * @param flag defines the flag used to specify which material part must be marked as dirty
  111554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111555. */
  111556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111557. /** @hidden */
  111558. _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;
  111559. /** @hidden */
  111560. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111561. /** @hidden */
  111562. _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;
  111563. /** @hidden */
  111564. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111565. /** @hidden */
  111566. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111567. /** @hidden */
  111568. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111569. }
  111570. }
  111571. declare module BABYLON {
  111572. /**
  111573. * Set of assets to keep when moving a scene into an asset container.
  111574. */
  111575. export class KeepAssets extends AbstractScene {
  111576. }
  111577. /**
  111578. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111579. */
  111580. export class InstantiatedEntries {
  111581. /**
  111582. * List of new root nodes (eg. nodes with no parent)
  111583. */
  111584. rootNodes: TransformNode[];
  111585. /**
  111586. * List of new skeletons
  111587. */
  111588. skeletons: Skeleton[];
  111589. /**
  111590. * List of new animation groups
  111591. */
  111592. animationGroups: AnimationGroup[];
  111593. }
  111594. /**
  111595. * Container with a set of assets that can be added or removed from a scene.
  111596. */
  111597. export class AssetContainer extends AbstractScene {
  111598. private _wasAddedToScene;
  111599. /**
  111600. * The scene the AssetContainer belongs to.
  111601. */
  111602. scene: Scene;
  111603. /**
  111604. * Instantiates an AssetContainer.
  111605. * @param scene The scene the AssetContainer belongs to.
  111606. */
  111607. constructor(scene: Scene);
  111608. /**
  111609. * Instantiate or clone all meshes and add the new ones to the scene.
  111610. * Skeletons and animation groups will all be cloned
  111611. * @param nameFunction defines an optional function used to get new names for clones
  111612. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111613. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111614. */
  111615. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111616. /**
  111617. * Adds all the assets from the container to the scene.
  111618. */
  111619. addAllToScene(): void;
  111620. /**
  111621. * Removes all the assets in the container from the scene
  111622. */
  111623. removeAllFromScene(): void;
  111624. /**
  111625. * Disposes all the assets in the container
  111626. */
  111627. dispose(): void;
  111628. private _moveAssets;
  111629. /**
  111630. * Removes all the assets contained in the scene and adds them to the container.
  111631. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111632. */
  111633. moveAllFromScene(keepAssets?: KeepAssets): void;
  111634. /**
  111635. * 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.
  111636. * @returns the root mesh
  111637. */
  111638. createRootMesh(): Mesh;
  111639. /**
  111640. * Merge animations from this asset container into a scene
  111641. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111642. * @param animatables set of animatables to retarget to a node from the scene
  111643. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111644. */
  111645. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111646. }
  111647. }
  111648. declare module BABYLON {
  111649. /**
  111650. * Defines how the parser contract is defined.
  111651. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111652. */
  111653. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111654. /**
  111655. * Defines how the individual parser contract is defined.
  111656. * These parser can parse an individual asset
  111657. */
  111658. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111659. /**
  111660. * Base class of the scene acting as a container for the different elements composing a scene.
  111661. * This class is dynamically extended by the different components of the scene increasing
  111662. * flexibility and reducing coupling
  111663. */
  111664. export abstract class AbstractScene {
  111665. /**
  111666. * Stores the list of available parsers in the application.
  111667. */
  111668. private static _BabylonFileParsers;
  111669. /**
  111670. * Stores the list of available individual parsers in the application.
  111671. */
  111672. private static _IndividualBabylonFileParsers;
  111673. /**
  111674. * Adds a parser in the list of available ones
  111675. * @param name Defines the name of the parser
  111676. * @param parser Defines the parser to add
  111677. */
  111678. static AddParser(name: string, parser: BabylonFileParser): void;
  111679. /**
  111680. * Gets a general parser from the list of avaialble ones
  111681. * @param name Defines the name of the parser
  111682. * @returns the requested parser or null
  111683. */
  111684. static GetParser(name: string): Nullable<BabylonFileParser>;
  111685. /**
  111686. * Adds n individual parser in the list of available ones
  111687. * @param name Defines the name of the parser
  111688. * @param parser Defines the parser to add
  111689. */
  111690. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111691. /**
  111692. * Gets an individual parser from the list of avaialble ones
  111693. * @param name Defines the name of the parser
  111694. * @returns the requested parser or null
  111695. */
  111696. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111697. /**
  111698. * Parser json data and populate both a scene and its associated container object
  111699. * @param jsonData Defines the data to parse
  111700. * @param scene Defines the scene to parse the data for
  111701. * @param container Defines the container attached to the parsing sequence
  111702. * @param rootUrl Defines the root url of the data
  111703. */
  111704. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111705. /**
  111706. * Gets the list of root nodes (ie. nodes with no parent)
  111707. */
  111708. rootNodes: Node[];
  111709. /** All of the cameras added to this scene
  111710. * @see http://doc.babylonjs.com/babylon101/cameras
  111711. */
  111712. cameras: Camera[];
  111713. /**
  111714. * All of the lights added to this scene
  111715. * @see http://doc.babylonjs.com/babylon101/lights
  111716. */
  111717. lights: Light[];
  111718. /**
  111719. * All of the (abstract) meshes added to this scene
  111720. */
  111721. meshes: AbstractMesh[];
  111722. /**
  111723. * The list of skeletons added to the scene
  111724. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111725. */
  111726. skeletons: Skeleton[];
  111727. /**
  111728. * All of the particle systems added to this scene
  111729. * @see http://doc.babylonjs.com/babylon101/particles
  111730. */
  111731. particleSystems: IParticleSystem[];
  111732. /**
  111733. * Gets a list of Animations associated with the scene
  111734. */
  111735. animations: Animation[];
  111736. /**
  111737. * All of the animation groups added to this scene
  111738. * @see http://doc.babylonjs.com/how_to/group
  111739. */
  111740. animationGroups: AnimationGroup[];
  111741. /**
  111742. * All of the multi-materials added to this scene
  111743. * @see http://doc.babylonjs.com/how_to/multi_materials
  111744. */
  111745. multiMaterials: MultiMaterial[];
  111746. /**
  111747. * All of the materials added to this scene
  111748. * In the context of a Scene, it is not supposed to be modified manually.
  111749. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111750. * Note also that the order of the Material within the array is not significant and might change.
  111751. * @see http://doc.babylonjs.com/babylon101/materials
  111752. */
  111753. materials: Material[];
  111754. /**
  111755. * The list of morph target managers added to the scene
  111756. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111757. */
  111758. morphTargetManagers: MorphTargetManager[];
  111759. /**
  111760. * The list of geometries used in the scene.
  111761. */
  111762. geometries: Geometry[];
  111763. /**
  111764. * All of the tranform nodes added to this scene
  111765. * In the context of a Scene, it is not supposed to be modified manually.
  111766. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111767. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111768. * @see http://doc.babylonjs.com/how_to/transformnode
  111769. */
  111770. transformNodes: TransformNode[];
  111771. /**
  111772. * ActionManagers available on the scene.
  111773. */
  111774. actionManagers: AbstractActionManager[];
  111775. /**
  111776. * Textures to keep.
  111777. */
  111778. textures: BaseTexture[];
  111779. /**
  111780. * Environment texture for the scene
  111781. */
  111782. environmentTexture: Nullable<BaseTexture>;
  111783. /**
  111784. * @returns all meshes, lights, cameras, transformNodes and bones
  111785. */
  111786. getNodes(): Array<Node>;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Interface used to define options for Sound class
  111792. */
  111793. export interface ISoundOptions {
  111794. /**
  111795. * Does the sound autoplay once loaded.
  111796. */
  111797. autoplay?: boolean;
  111798. /**
  111799. * Does the sound loop after it finishes playing once.
  111800. */
  111801. loop?: boolean;
  111802. /**
  111803. * Sound's volume
  111804. */
  111805. volume?: number;
  111806. /**
  111807. * Is it a spatial sound?
  111808. */
  111809. spatialSound?: boolean;
  111810. /**
  111811. * Maximum distance to hear that sound
  111812. */
  111813. maxDistance?: number;
  111814. /**
  111815. * Uses user defined attenuation function
  111816. */
  111817. useCustomAttenuation?: boolean;
  111818. /**
  111819. * Define the roll off factor of spatial sounds.
  111820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111821. */
  111822. rolloffFactor?: number;
  111823. /**
  111824. * Define the reference distance the sound should be heard perfectly.
  111825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111826. */
  111827. refDistance?: number;
  111828. /**
  111829. * Define the distance attenuation model the sound will follow.
  111830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111831. */
  111832. distanceModel?: string;
  111833. /**
  111834. * Defines the playback speed (1 by default)
  111835. */
  111836. playbackRate?: number;
  111837. /**
  111838. * Defines if the sound is from a streaming source
  111839. */
  111840. streaming?: boolean;
  111841. /**
  111842. * Defines an optional length (in seconds) inside the sound file
  111843. */
  111844. length?: number;
  111845. /**
  111846. * Defines an optional offset (in seconds) inside the sound file
  111847. */
  111848. offset?: number;
  111849. /**
  111850. * If true, URLs will not be required to state the audio file codec to use.
  111851. */
  111852. skipCodecCheck?: boolean;
  111853. }
  111854. /**
  111855. * Defines a sound that can be played in the application.
  111856. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111858. */
  111859. export class Sound {
  111860. /**
  111861. * The name of the sound in the scene.
  111862. */
  111863. name: string;
  111864. /**
  111865. * Does the sound autoplay once loaded.
  111866. */
  111867. autoplay: boolean;
  111868. /**
  111869. * Does the sound loop after it finishes playing once.
  111870. */
  111871. loop: boolean;
  111872. /**
  111873. * Does the sound use a custom attenuation curve to simulate the falloff
  111874. * happening when the source gets further away from the camera.
  111875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111876. */
  111877. useCustomAttenuation: boolean;
  111878. /**
  111879. * The sound track id this sound belongs to.
  111880. */
  111881. soundTrackId: number;
  111882. /**
  111883. * Is this sound currently played.
  111884. */
  111885. isPlaying: boolean;
  111886. /**
  111887. * Is this sound currently paused.
  111888. */
  111889. isPaused: boolean;
  111890. /**
  111891. * Does this sound enables spatial sound.
  111892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111893. */
  111894. spatialSound: boolean;
  111895. /**
  111896. * Define the reference distance the sound should be heard perfectly.
  111897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111898. */
  111899. refDistance: number;
  111900. /**
  111901. * Define the roll off factor of spatial sounds.
  111902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111903. */
  111904. rolloffFactor: number;
  111905. /**
  111906. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111908. */
  111909. maxDistance: number;
  111910. /**
  111911. * Define the distance attenuation model the sound will follow.
  111912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111913. */
  111914. distanceModel: string;
  111915. /**
  111916. * @hidden
  111917. * Back Compat
  111918. **/
  111919. onended: () => any;
  111920. /**
  111921. * Observable event when the current playing sound finishes.
  111922. */
  111923. onEndedObservable: Observable<Sound>;
  111924. private _panningModel;
  111925. private _playbackRate;
  111926. private _streaming;
  111927. private _startTime;
  111928. private _startOffset;
  111929. private _position;
  111930. /** @hidden */
  111931. _positionInEmitterSpace: boolean;
  111932. private _localDirection;
  111933. private _volume;
  111934. private _isReadyToPlay;
  111935. private _isDirectional;
  111936. private _readyToPlayCallback;
  111937. private _audioBuffer;
  111938. private _soundSource;
  111939. private _streamingSource;
  111940. private _soundPanner;
  111941. private _soundGain;
  111942. private _inputAudioNode;
  111943. private _outputAudioNode;
  111944. private _coneInnerAngle;
  111945. private _coneOuterAngle;
  111946. private _coneOuterGain;
  111947. private _scene;
  111948. private _connectedTransformNode;
  111949. private _customAttenuationFunction;
  111950. private _registerFunc;
  111951. private _isOutputConnected;
  111952. private _htmlAudioElement;
  111953. private _urlType;
  111954. private _length?;
  111955. private _offset?;
  111956. /** @hidden */
  111957. static _SceneComponentInitialization: (scene: Scene) => void;
  111958. /**
  111959. * Create a sound and attach it to a scene
  111960. * @param name Name of your sound
  111961. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111962. * @param scene defines the scene the sound belongs to
  111963. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111964. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111965. */
  111966. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111967. /**
  111968. * Release the sound and its associated resources
  111969. */
  111970. dispose(): void;
  111971. /**
  111972. * Gets if the sounds is ready to be played or not.
  111973. * @returns true if ready, otherwise false
  111974. */
  111975. isReady(): boolean;
  111976. private _soundLoaded;
  111977. /**
  111978. * Sets the data of the sound from an audiobuffer
  111979. * @param audioBuffer The audioBuffer containing the data
  111980. */
  111981. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111982. /**
  111983. * Updates the current sounds options such as maxdistance, loop...
  111984. * @param options A JSON object containing values named as the object properties
  111985. */
  111986. updateOptions(options: ISoundOptions): void;
  111987. private _createSpatialParameters;
  111988. private _updateSpatialParameters;
  111989. /**
  111990. * Switch the panning model to HRTF:
  111991. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111993. */
  111994. switchPanningModelToHRTF(): void;
  111995. /**
  111996. * Switch the panning model to Equal Power:
  111997. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111999. */
  112000. switchPanningModelToEqualPower(): void;
  112001. private _switchPanningModel;
  112002. /**
  112003. * Connect this sound to a sound track audio node like gain...
  112004. * @param soundTrackAudioNode the sound track audio node to connect to
  112005. */
  112006. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112007. /**
  112008. * Transform this sound into a directional source
  112009. * @param coneInnerAngle Size of the inner cone in degree
  112010. * @param coneOuterAngle Size of the outer cone in degree
  112011. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112012. */
  112013. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112014. /**
  112015. * Gets or sets the inner angle for the directional cone.
  112016. */
  112017. get directionalConeInnerAngle(): number;
  112018. /**
  112019. * Gets or sets the inner angle for the directional cone.
  112020. */
  112021. set directionalConeInnerAngle(value: number);
  112022. /**
  112023. * Gets or sets the outer angle for the directional cone.
  112024. */
  112025. get directionalConeOuterAngle(): number;
  112026. /**
  112027. * Gets or sets the outer angle for the directional cone.
  112028. */
  112029. set directionalConeOuterAngle(value: number);
  112030. /**
  112031. * Sets the position of the emitter if spatial sound is enabled
  112032. * @param newPosition Defines the new posisiton
  112033. */
  112034. setPosition(newPosition: Vector3): void;
  112035. /**
  112036. * Sets the local direction of the emitter if spatial sound is enabled
  112037. * @param newLocalDirection Defines the new local direction
  112038. */
  112039. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112040. private _updateDirection;
  112041. /** @hidden */
  112042. updateDistanceFromListener(): void;
  112043. /**
  112044. * Sets a new custom attenuation function for the sound.
  112045. * @param callback Defines the function used for the attenuation
  112046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112047. */
  112048. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112049. /**
  112050. * Play the sound
  112051. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112052. * @param offset (optional) Start the sound at a specific time in seconds
  112053. * @param length (optional) Sound duration (in seconds)
  112054. */
  112055. play(time?: number, offset?: number, length?: number): void;
  112056. private _onended;
  112057. /**
  112058. * Stop the sound
  112059. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112060. */
  112061. stop(time?: number): void;
  112062. /**
  112063. * Put the sound in pause
  112064. */
  112065. pause(): void;
  112066. /**
  112067. * Sets a dedicated volume for this sounds
  112068. * @param newVolume Define the new volume of the sound
  112069. * @param time Define time for gradual change to new volume
  112070. */
  112071. setVolume(newVolume: number, time?: number): void;
  112072. /**
  112073. * Set the sound play back rate
  112074. * @param newPlaybackRate Define the playback rate the sound should be played at
  112075. */
  112076. setPlaybackRate(newPlaybackRate: number): void;
  112077. /**
  112078. * Gets the volume of the sound.
  112079. * @returns the volume of the sound
  112080. */
  112081. getVolume(): number;
  112082. /**
  112083. * Attach the sound to a dedicated mesh
  112084. * @param transformNode The transform node to connect the sound with
  112085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112086. */
  112087. attachToMesh(transformNode: TransformNode): void;
  112088. /**
  112089. * Detach the sound from the previously attached mesh
  112090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112091. */
  112092. detachFromMesh(): void;
  112093. private _onRegisterAfterWorldMatrixUpdate;
  112094. /**
  112095. * Clone the current sound in the scene.
  112096. * @returns the new sound clone
  112097. */
  112098. clone(): Nullable<Sound>;
  112099. /**
  112100. * Gets the current underlying audio buffer containing the data
  112101. * @returns the audio buffer
  112102. */
  112103. getAudioBuffer(): Nullable<AudioBuffer>;
  112104. /**
  112105. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112106. * @returns the source node
  112107. */
  112108. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112109. /**
  112110. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112111. * @returns the gain node
  112112. */
  112113. getSoundGain(): Nullable<GainNode>;
  112114. /**
  112115. * Serializes the Sound in a JSON representation
  112116. * @returns the JSON representation of the sound
  112117. */
  112118. serialize(): any;
  112119. /**
  112120. * Parse a JSON representation of a sound to innstantiate in a given scene
  112121. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112122. * @param scene Define the scene the new parsed sound should be created in
  112123. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112124. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112125. * @returns the newly parsed sound
  112126. */
  112127. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112128. }
  112129. }
  112130. declare module BABYLON {
  112131. /**
  112132. * This defines an action helpful to play a defined sound on a triggered action.
  112133. */
  112134. export class PlaySoundAction extends Action {
  112135. private _sound;
  112136. /**
  112137. * Instantiate the action
  112138. * @param triggerOptions defines the trigger options
  112139. * @param sound defines the sound to play
  112140. * @param condition defines the trigger related conditions
  112141. */
  112142. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112143. /** @hidden */
  112144. _prepare(): void;
  112145. /**
  112146. * Execute the action and play the sound.
  112147. */
  112148. execute(): void;
  112149. /**
  112150. * Serializes the actions and its related information.
  112151. * @param parent defines the object to serialize in
  112152. * @returns the serialized object
  112153. */
  112154. serialize(parent: any): any;
  112155. }
  112156. /**
  112157. * This defines an action helpful to stop a defined sound on a triggered action.
  112158. */
  112159. export class StopSoundAction extends Action {
  112160. private _sound;
  112161. /**
  112162. * Instantiate the action
  112163. * @param triggerOptions defines the trigger options
  112164. * @param sound defines the sound to stop
  112165. * @param condition defines the trigger related conditions
  112166. */
  112167. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112168. /** @hidden */
  112169. _prepare(): void;
  112170. /**
  112171. * Execute the action and stop the sound.
  112172. */
  112173. execute(): void;
  112174. /**
  112175. * Serializes the actions and its related information.
  112176. * @param parent defines the object to serialize in
  112177. * @returns the serialized object
  112178. */
  112179. serialize(parent: any): any;
  112180. }
  112181. }
  112182. declare module BABYLON {
  112183. /**
  112184. * This defines an action responsible to change the value of a property
  112185. * by interpolating between its current value and the newly set one once triggered.
  112186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112187. */
  112188. export class InterpolateValueAction extends Action {
  112189. /**
  112190. * Defines the path of the property where the value should be interpolated
  112191. */
  112192. propertyPath: string;
  112193. /**
  112194. * Defines the target value at the end of the interpolation.
  112195. */
  112196. value: any;
  112197. /**
  112198. * Defines the time it will take for the property to interpolate to the value.
  112199. */
  112200. duration: number;
  112201. /**
  112202. * Defines if the other scene animations should be stopped when the action has been triggered
  112203. */
  112204. stopOtherAnimations?: boolean;
  112205. /**
  112206. * Defines a callback raised once the interpolation animation has been done.
  112207. */
  112208. onInterpolationDone?: () => void;
  112209. /**
  112210. * Observable triggered once the interpolation animation has been done.
  112211. */
  112212. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112213. private _target;
  112214. private _effectiveTarget;
  112215. private _property;
  112216. /**
  112217. * Instantiate the action
  112218. * @param triggerOptions defines the trigger options
  112219. * @param target defines the object containing the value to interpolate
  112220. * @param propertyPath defines the path to the property in the target object
  112221. * @param value defines the target value at the end of the interpolation
  112222. * @param duration deines the time it will take for the property to interpolate to the value.
  112223. * @param condition defines the trigger related conditions
  112224. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112225. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112226. */
  112227. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112228. /** @hidden */
  112229. _prepare(): void;
  112230. /**
  112231. * Execute the action starts the value interpolation.
  112232. */
  112233. execute(): void;
  112234. /**
  112235. * Serializes the actions and its related information.
  112236. * @param parent defines the object to serialize in
  112237. * @returns the serialized object
  112238. */
  112239. serialize(parent: any): any;
  112240. }
  112241. }
  112242. declare module BABYLON {
  112243. /**
  112244. * Options allowed during the creation of a sound track.
  112245. */
  112246. export interface ISoundTrackOptions {
  112247. /**
  112248. * The volume the sound track should take during creation
  112249. */
  112250. volume?: number;
  112251. /**
  112252. * Define if the sound track is the main sound track of the scene
  112253. */
  112254. mainTrack?: boolean;
  112255. }
  112256. /**
  112257. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112258. * It will be also used in a future release to apply effects on a specific track.
  112259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112260. */
  112261. export class SoundTrack {
  112262. /**
  112263. * The unique identifier of the sound track in the scene.
  112264. */
  112265. id: number;
  112266. /**
  112267. * The list of sounds included in the sound track.
  112268. */
  112269. soundCollection: Array<Sound>;
  112270. private _outputAudioNode;
  112271. private _scene;
  112272. private _connectedAnalyser;
  112273. private _options;
  112274. private _isInitialized;
  112275. /**
  112276. * Creates a new sound track.
  112277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112278. * @param scene Define the scene the sound track belongs to
  112279. * @param options
  112280. */
  112281. constructor(scene: Scene, options?: ISoundTrackOptions);
  112282. private _initializeSoundTrackAudioGraph;
  112283. /**
  112284. * Release the sound track and its associated resources
  112285. */
  112286. dispose(): void;
  112287. /**
  112288. * Adds a sound to this sound track
  112289. * @param sound define the cound to add
  112290. * @ignoreNaming
  112291. */
  112292. AddSound(sound: Sound): void;
  112293. /**
  112294. * Removes a sound to this sound track
  112295. * @param sound define the cound to remove
  112296. * @ignoreNaming
  112297. */
  112298. RemoveSound(sound: Sound): void;
  112299. /**
  112300. * Set a global volume for the full sound track.
  112301. * @param newVolume Define the new volume of the sound track
  112302. */
  112303. setVolume(newVolume: number): void;
  112304. /**
  112305. * Switch the panning model to HRTF:
  112306. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112308. */
  112309. switchPanningModelToHRTF(): void;
  112310. /**
  112311. * Switch the panning model to Equal Power:
  112312. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112314. */
  112315. switchPanningModelToEqualPower(): void;
  112316. /**
  112317. * Connect the sound track to an audio analyser allowing some amazing
  112318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112320. * @param analyser The analyser to connect to the engine
  112321. */
  112322. connectToAnalyser(analyser: Analyser): void;
  112323. }
  112324. }
  112325. declare module BABYLON {
  112326. interface AbstractScene {
  112327. /**
  112328. * The list of sounds used in the scene.
  112329. */
  112330. sounds: Nullable<Array<Sound>>;
  112331. }
  112332. interface Scene {
  112333. /**
  112334. * @hidden
  112335. * Backing field
  112336. */
  112337. _mainSoundTrack: SoundTrack;
  112338. /**
  112339. * The main sound track played by the scene.
  112340. * It cotains your primary collection of sounds.
  112341. */
  112342. mainSoundTrack: SoundTrack;
  112343. /**
  112344. * The list of sound tracks added to the scene
  112345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112346. */
  112347. soundTracks: Nullable<Array<SoundTrack>>;
  112348. /**
  112349. * Gets a sound using a given name
  112350. * @param name defines the name to search for
  112351. * @return the found sound or null if not found at all.
  112352. */
  112353. getSoundByName(name: string): Nullable<Sound>;
  112354. /**
  112355. * Gets or sets if audio support is enabled
  112356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112357. */
  112358. audioEnabled: boolean;
  112359. /**
  112360. * Gets or sets if audio will be output to headphones
  112361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112362. */
  112363. headphone: boolean;
  112364. /**
  112365. * Gets or sets custom audio listener position provider
  112366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112367. */
  112368. audioListenerPositionProvider: Nullable<() => Vector3>;
  112369. /**
  112370. * Gets or sets a refresh rate when using 3D audio positioning
  112371. */
  112372. audioPositioningRefreshRate: number;
  112373. }
  112374. /**
  112375. * Defines the sound scene component responsible to manage any sounds
  112376. * in a given scene.
  112377. */
  112378. export class AudioSceneComponent implements ISceneSerializableComponent {
  112379. /**
  112380. * The component name helpfull to identify the component in the list of scene components.
  112381. */
  112382. readonly name: string;
  112383. /**
  112384. * The scene the component belongs to.
  112385. */
  112386. scene: Scene;
  112387. private _audioEnabled;
  112388. /**
  112389. * Gets whether audio is enabled or not.
  112390. * Please use related enable/disable method to switch state.
  112391. */
  112392. get audioEnabled(): boolean;
  112393. private _headphone;
  112394. /**
  112395. * Gets whether audio is outputing to headphone or not.
  112396. * Please use the according Switch methods to change output.
  112397. */
  112398. get headphone(): boolean;
  112399. /**
  112400. * Gets or sets a refresh rate when using 3D audio positioning
  112401. */
  112402. audioPositioningRefreshRate: number;
  112403. private _audioListenerPositionProvider;
  112404. /**
  112405. * Gets the current audio listener position provider
  112406. */
  112407. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112408. /**
  112409. * Sets a custom listener position for all sounds in the scene
  112410. * By default, this is the position of the first active camera
  112411. */
  112412. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112413. /**
  112414. * Creates a new instance of the component for the given scene
  112415. * @param scene Defines the scene to register the component in
  112416. */
  112417. constructor(scene: Scene);
  112418. /**
  112419. * Registers the component in a given scene
  112420. */
  112421. register(): void;
  112422. /**
  112423. * Rebuilds the elements related to this component in case of
  112424. * context lost for instance.
  112425. */
  112426. rebuild(): void;
  112427. /**
  112428. * Serializes the component data to the specified json object
  112429. * @param serializationObject The object to serialize to
  112430. */
  112431. serialize(serializationObject: any): void;
  112432. /**
  112433. * Adds all the elements from the container to the scene
  112434. * @param container the container holding the elements
  112435. */
  112436. addFromContainer(container: AbstractScene): void;
  112437. /**
  112438. * Removes all the elements in the container from the scene
  112439. * @param container contains the elements to remove
  112440. * @param dispose if the removed element should be disposed (default: false)
  112441. */
  112442. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112443. /**
  112444. * Disposes the component and the associated ressources.
  112445. */
  112446. dispose(): void;
  112447. /**
  112448. * Disables audio in the associated scene.
  112449. */
  112450. disableAudio(): void;
  112451. /**
  112452. * Enables audio in the associated scene.
  112453. */
  112454. enableAudio(): void;
  112455. /**
  112456. * Switch audio to headphone output.
  112457. */
  112458. switchAudioModeForHeadphones(): void;
  112459. /**
  112460. * Switch audio to normal speakers.
  112461. */
  112462. switchAudioModeForNormalSpeakers(): void;
  112463. private _cachedCameraDirection;
  112464. private _cachedCameraPosition;
  112465. private _lastCheck;
  112466. private _afterRender;
  112467. }
  112468. }
  112469. declare module BABYLON {
  112470. /**
  112471. * Wraps one or more Sound objects and selects one with random weight for playback.
  112472. */
  112473. export class WeightedSound {
  112474. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112475. loop: boolean;
  112476. private _coneInnerAngle;
  112477. private _coneOuterAngle;
  112478. private _volume;
  112479. /** A Sound is currently playing. */
  112480. isPlaying: boolean;
  112481. /** A Sound is currently paused. */
  112482. isPaused: boolean;
  112483. private _sounds;
  112484. private _weights;
  112485. private _currentIndex?;
  112486. /**
  112487. * Creates a new WeightedSound from the list of sounds given.
  112488. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112489. * @param sounds Array of Sounds that will be selected from.
  112490. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112491. */
  112492. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112493. /**
  112494. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112495. */
  112496. get directionalConeInnerAngle(): number;
  112497. /**
  112498. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112499. */
  112500. set directionalConeInnerAngle(value: number);
  112501. /**
  112502. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112503. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112504. */
  112505. get directionalConeOuterAngle(): number;
  112506. /**
  112507. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112508. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112509. */
  112510. set directionalConeOuterAngle(value: number);
  112511. /**
  112512. * Playback volume.
  112513. */
  112514. get volume(): number;
  112515. /**
  112516. * Playback volume.
  112517. */
  112518. set volume(value: number);
  112519. private _onended;
  112520. /**
  112521. * Suspend playback
  112522. */
  112523. pause(): void;
  112524. /**
  112525. * Stop playback
  112526. */
  112527. stop(): void;
  112528. /**
  112529. * Start playback.
  112530. * @param startOffset Position the clip head at a specific time in seconds.
  112531. */
  112532. play(startOffset?: number): void;
  112533. }
  112534. }
  112535. declare module BABYLON {
  112536. /**
  112537. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112538. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112539. */
  112540. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112541. /**
  112542. * Gets the name of the behavior.
  112543. */
  112544. get name(): string;
  112545. /**
  112546. * The easing function used by animations
  112547. */
  112548. static EasingFunction: BackEase;
  112549. /**
  112550. * The easing mode used by animations
  112551. */
  112552. static EasingMode: number;
  112553. /**
  112554. * The duration of the animation, in milliseconds
  112555. */
  112556. transitionDuration: number;
  112557. /**
  112558. * Length of the distance animated by the transition when lower radius is reached
  112559. */
  112560. lowerRadiusTransitionRange: number;
  112561. /**
  112562. * Length of the distance animated by the transition when upper radius is reached
  112563. */
  112564. upperRadiusTransitionRange: number;
  112565. private _autoTransitionRange;
  112566. /**
  112567. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112568. */
  112569. get autoTransitionRange(): boolean;
  112570. /**
  112571. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112572. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112573. */
  112574. set autoTransitionRange(value: boolean);
  112575. private _attachedCamera;
  112576. private _onAfterCheckInputsObserver;
  112577. private _onMeshTargetChangedObserver;
  112578. /**
  112579. * Initializes the behavior.
  112580. */
  112581. init(): void;
  112582. /**
  112583. * Attaches the behavior to its arc rotate camera.
  112584. * @param camera Defines the camera to attach the behavior to
  112585. */
  112586. attach(camera: ArcRotateCamera): void;
  112587. /**
  112588. * Detaches the behavior from its current arc rotate camera.
  112589. */
  112590. detach(): void;
  112591. private _radiusIsAnimating;
  112592. private _radiusBounceTransition;
  112593. private _animatables;
  112594. private _cachedWheelPrecision;
  112595. /**
  112596. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112597. * @param radiusLimit The limit to check against.
  112598. * @return Bool to indicate if at limit.
  112599. */
  112600. private _isRadiusAtLimit;
  112601. /**
  112602. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112603. * @param radiusDelta The delta by which to animate to. Can be negative.
  112604. */
  112605. private _applyBoundRadiusAnimation;
  112606. /**
  112607. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112608. */
  112609. protected _clearAnimationLocks(): void;
  112610. /**
  112611. * Stops and removes all animations that have been applied to the camera
  112612. */
  112613. stopAllAnimations(): void;
  112614. }
  112615. }
  112616. declare module BABYLON {
  112617. /**
  112618. * 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.
  112619. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112620. */
  112621. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112622. /**
  112623. * Gets the name of the behavior.
  112624. */
  112625. get name(): string;
  112626. private _mode;
  112627. private _radiusScale;
  112628. private _positionScale;
  112629. private _defaultElevation;
  112630. private _elevationReturnTime;
  112631. private _elevationReturnWaitTime;
  112632. private _zoomStopsAnimation;
  112633. private _framingTime;
  112634. /**
  112635. * The easing function used by animations
  112636. */
  112637. static EasingFunction: ExponentialEase;
  112638. /**
  112639. * The easing mode used by animations
  112640. */
  112641. static EasingMode: number;
  112642. /**
  112643. * Sets the current mode used by the behavior
  112644. */
  112645. set mode(mode: number);
  112646. /**
  112647. * Gets current mode used by the behavior.
  112648. */
  112649. get mode(): number;
  112650. /**
  112651. * Sets the scale applied to the radius (1 by default)
  112652. */
  112653. set radiusScale(radius: number);
  112654. /**
  112655. * Gets the scale applied to the radius
  112656. */
  112657. get radiusScale(): number;
  112658. /**
  112659. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112660. */
  112661. set positionScale(scale: number);
  112662. /**
  112663. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112664. */
  112665. get positionScale(): number;
  112666. /**
  112667. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112668. * behaviour is triggered, in radians.
  112669. */
  112670. set defaultElevation(elevation: number);
  112671. /**
  112672. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112673. * behaviour is triggered, in radians.
  112674. */
  112675. get defaultElevation(): number;
  112676. /**
  112677. * Sets the time (in milliseconds) taken to return to the default beta position.
  112678. * Negative value indicates camera should not return to default.
  112679. */
  112680. set elevationReturnTime(speed: number);
  112681. /**
  112682. * Gets the time (in milliseconds) taken to return to the default beta position.
  112683. * Negative value indicates camera should not return to default.
  112684. */
  112685. get elevationReturnTime(): number;
  112686. /**
  112687. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112688. */
  112689. set elevationReturnWaitTime(time: number);
  112690. /**
  112691. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112692. */
  112693. get elevationReturnWaitTime(): number;
  112694. /**
  112695. * Sets the flag that indicates if user zooming should stop animation.
  112696. */
  112697. set zoomStopsAnimation(flag: boolean);
  112698. /**
  112699. * Gets the flag that indicates if user zooming should stop animation.
  112700. */
  112701. get zoomStopsAnimation(): boolean;
  112702. /**
  112703. * Sets the transition time when framing the mesh, in milliseconds
  112704. */
  112705. set framingTime(time: number);
  112706. /**
  112707. * Gets the transition time when framing the mesh, in milliseconds
  112708. */
  112709. get framingTime(): number;
  112710. /**
  112711. * Define if the behavior should automatically change the configured
  112712. * camera limits and sensibilities.
  112713. */
  112714. autoCorrectCameraLimitsAndSensibility: boolean;
  112715. private _onPrePointerObservableObserver;
  112716. private _onAfterCheckInputsObserver;
  112717. private _onMeshTargetChangedObserver;
  112718. private _attachedCamera;
  112719. private _isPointerDown;
  112720. private _lastInteractionTime;
  112721. /**
  112722. * Initializes the behavior.
  112723. */
  112724. init(): void;
  112725. /**
  112726. * Attaches the behavior to its arc rotate camera.
  112727. * @param camera Defines the camera to attach the behavior to
  112728. */
  112729. attach(camera: ArcRotateCamera): void;
  112730. /**
  112731. * Detaches the behavior from its current arc rotate camera.
  112732. */
  112733. detach(): void;
  112734. private _animatables;
  112735. private _betaIsAnimating;
  112736. private _betaTransition;
  112737. private _radiusTransition;
  112738. private _vectorTransition;
  112739. /**
  112740. * Targets the given mesh and updates zoom level accordingly.
  112741. * @param mesh The mesh to target.
  112742. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112743. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112744. */
  112745. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112746. /**
  112747. * Targets the given mesh with its children and updates zoom level accordingly.
  112748. * @param mesh The mesh to target.
  112749. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112750. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112751. */
  112752. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112753. /**
  112754. * Targets the given meshes with their children and updates zoom level accordingly.
  112755. * @param meshes The mesh to target.
  112756. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112757. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112758. */
  112759. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112760. /**
  112761. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112762. * @param minimumWorld Determines the smaller position of the bounding box extend
  112763. * @param maximumWorld Determines the bigger position of the bounding box extend
  112764. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112765. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112766. */
  112767. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112768. /**
  112769. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112770. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112771. * frustum width.
  112772. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112773. * to fully enclose the mesh in the viewing frustum.
  112774. */
  112775. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112776. /**
  112777. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112778. * is automatically returned to its default position (expected to be above ground plane).
  112779. */
  112780. private _maintainCameraAboveGround;
  112781. /**
  112782. * Returns the frustum slope based on the canvas ratio and camera FOV
  112783. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112784. */
  112785. private _getFrustumSlope;
  112786. /**
  112787. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112788. */
  112789. private _clearAnimationLocks;
  112790. /**
  112791. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112792. */
  112793. private _applyUserInteraction;
  112794. /**
  112795. * Stops and removes all animations that have been applied to the camera
  112796. */
  112797. stopAllAnimations(): void;
  112798. /**
  112799. * Gets a value indicating if the user is moving the camera
  112800. */
  112801. get isUserIsMoving(): boolean;
  112802. /**
  112803. * The camera can move all the way towards the mesh.
  112804. */
  112805. static IgnoreBoundsSizeMode: number;
  112806. /**
  112807. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112808. */
  112809. static FitFrustumSidesMode: number;
  112810. }
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * Base class for Camera Pointer Inputs.
  112815. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112816. * for example usage.
  112817. */
  112818. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112819. /**
  112820. * Defines the camera the input is attached to.
  112821. */
  112822. abstract camera: Camera;
  112823. /**
  112824. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112825. */
  112826. protected _altKey: boolean;
  112827. protected _ctrlKey: boolean;
  112828. protected _metaKey: boolean;
  112829. protected _shiftKey: boolean;
  112830. /**
  112831. * Which mouse buttons were pressed at time of last mouse event.
  112832. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112833. */
  112834. protected _buttonsPressed: number;
  112835. /**
  112836. * Defines the buttons associated with the input to handle camera move.
  112837. */
  112838. buttons: number[];
  112839. /**
  112840. * Attach the input controls to a specific dom element to get the input from.
  112841. * @param element Defines the element the controls should be listened from
  112842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112843. */
  112844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112845. /**
  112846. * Detach the current controls from the specified dom element.
  112847. * @param element Defines the element to stop listening the inputs from
  112848. */
  112849. detachControl(element: Nullable<HTMLElement>): void;
  112850. /**
  112851. * Gets the class name of the current input.
  112852. * @returns the class name
  112853. */
  112854. getClassName(): string;
  112855. /**
  112856. * Get the friendly name associated with the input class.
  112857. * @returns the input friendly name
  112858. */
  112859. getSimpleName(): string;
  112860. /**
  112861. * Called on pointer POINTERDOUBLETAP event.
  112862. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112863. */
  112864. protected onDoubleTap(type: string): void;
  112865. /**
  112866. * Called on pointer POINTERMOVE event if only a single touch is active.
  112867. * Override this method to provide functionality.
  112868. */
  112869. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112870. /**
  112871. * Called on pointer POINTERMOVE event if multiple touches are active.
  112872. * Override this method to provide functionality.
  112873. */
  112874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112875. /**
  112876. * Called on JS contextmenu event.
  112877. * Override this method to provide functionality.
  112878. */
  112879. protected onContextMenu(evt: PointerEvent): void;
  112880. /**
  112881. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112882. * press.
  112883. * Override this method to provide functionality.
  112884. */
  112885. protected onButtonDown(evt: PointerEvent): void;
  112886. /**
  112887. * Called each time a new POINTERUP event occurs. Ie, for each button
  112888. * release.
  112889. * Override this method to provide functionality.
  112890. */
  112891. protected onButtonUp(evt: PointerEvent): void;
  112892. /**
  112893. * Called when window becomes inactive.
  112894. * Override this method to provide functionality.
  112895. */
  112896. protected onLostFocus(): void;
  112897. private _pointerInput;
  112898. private _observer;
  112899. private _onLostFocus;
  112900. private pointA;
  112901. private pointB;
  112902. }
  112903. }
  112904. declare module BABYLON {
  112905. /**
  112906. * Manage the pointers inputs to control an arc rotate camera.
  112907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112908. */
  112909. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112910. /**
  112911. * Defines the camera the input is attached to.
  112912. */
  112913. camera: ArcRotateCamera;
  112914. /**
  112915. * Gets the class name of the current input.
  112916. * @returns the class name
  112917. */
  112918. getClassName(): string;
  112919. /**
  112920. * Defines the buttons associated with the input to handle camera move.
  112921. */
  112922. buttons: number[];
  112923. /**
  112924. * Defines the pointer angular sensibility along the X axis or how fast is
  112925. * the camera rotating.
  112926. */
  112927. angularSensibilityX: number;
  112928. /**
  112929. * Defines the pointer angular sensibility along the Y axis or how fast is
  112930. * the camera rotating.
  112931. */
  112932. angularSensibilityY: number;
  112933. /**
  112934. * Defines the pointer pinch precision or how fast is the camera zooming.
  112935. */
  112936. pinchPrecision: number;
  112937. /**
  112938. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112939. * from 0.
  112940. * It defines the percentage of current camera.radius to use as delta when
  112941. * pinch zoom is used.
  112942. */
  112943. pinchDeltaPercentage: number;
  112944. /**
  112945. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112946. * that any object in the plane at the camera's target point will scale
  112947. * perfectly with finger motion.
  112948. * Overrides pinchDeltaPercentage and pinchPrecision.
  112949. */
  112950. useNaturalPinchZoom: boolean;
  112951. /**
  112952. * Defines the pointer panning sensibility or how fast is the camera moving.
  112953. */
  112954. panningSensibility: number;
  112955. /**
  112956. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112957. */
  112958. multiTouchPanning: boolean;
  112959. /**
  112960. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112961. * zoom (pinch) through multitouch.
  112962. */
  112963. multiTouchPanAndZoom: boolean;
  112964. /**
  112965. * Revers pinch action direction.
  112966. */
  112967. pinchInwards: boolean;
  112968. private _isPanClick;
  112969. private _twoFingerActivityCount;
  112970. private _isPinching;
  112971. /**
  112972. * Called on pointer POINTERMOVE event if only a single touch is active.
  112973. */
  112974. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112975. /**
  112976. * Called on pointer POINTERDOUBLETAP event.
  112977. */
  112978. protected onDoubleTap(type: string): void;
  112979. /**
  112980. * Called on pointer POINTERMOVE event if multiple touches are active.
  112981. */
  112982. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112983. /**
  112984. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112985. * press.
  112986. */
  112987. protected onButtonDown(evt: PointerEvent): void;
  112988. /**
  112989. * Called each time a new POINTERUP event occurs. Ie, for each button
  112990. * release.
  112991. */
  112992. protected onButtonUp(evt: PointerEvent): void;
  112993. /**
  112994. * Called when window becomes inactive.
  112995. */
  112996. protected onLostFocus(): void;
  112997. }
  112998. }
  112999. declare module BABYLON {
  113000. /**
  113001. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113003. */
  113004. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113005. /**
  113006. * Defines the camera the input is attached to.
  113007. */
  113008. camera: ArcRotateCamera;
  113009. /**
  113010. * Defines the list of key codes associated with the up action (increase alpha)
  113011. */
  113012. keysUp: number[];
  113013. /**
  113014. * Defines the list of key codes associated with the down action (decrease alpha)
  113015. */
  113016. keysDown: number[];
  113017. /**
  113018. * Defines the list of key codes associated with the left action (increase beta)
  113019. */
  113020. keysLeft: number[];
  113021. /**
  113022. * Defines the list of key codes associated with the right action (decrease beta)
  113023. */
  113024. keysRight: number[];
  113025. /**
  113026. * Defines the list of key codes associated with the reset action.
  113027. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113028. */
  113029. keysReset: number[];
  113030. /**
  113031. * Defines the panning sensibility of the inputs.
  113032. * (How fast is the camera panning)
  113033. */
  113034. panningSensibility: number;
  113035. /**
  113036. * Defines the zooming sensibility of the inputs.
  113037. * (How fast is the camera zooming)
  113038. */
  113039. zoomingSensibility: number;
  113040. /**
  113041. * Defines whether maintaining the alt key down switch the movement mode from
  113042. * orientation to zoom.
  113043. */
  113044. useAltToZoom: boolean;
  113045. /**
  113046. * Rotation speed of the camera
  113047. */
  113048. angularSpeed: number;
  113049. private _keys;
  113050. private _ctrlPressed;
  113051. private _altPressed;
  113052. private _onCanvasBlurObserver;
  113053. private _onKeyboardObserver;
  113054. private _engine;
  113055. private _scene;
  113056. /**
  113057. * Attach the input controls to a specific dom element to get the input from.
  113058. * @param element Defines the element the controls should be listened from
  113059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113060. */
  113061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113062. /**
  113063. * Detach the current controls from the specified dom element.
  113064. * @param element Defines the element to stop listening the inputs from
  113065. */
  113066. detachControl(element: Nullable<HTMLElement>): void;
  113067. /**
  113068. * Update the current camera state depending on the inputs that have been used this frame.
  113069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113070. */
  113071. checkInputs(): void;
  113072. /**
  113073. * Gets the class name of the current intput.
  113074. * @returns the class name
  113075. */
  113076. getClassName(): string;
  113077. /**
  113078. * Get the friendly name associated with the input class.
  113079. * @returns the input friendly name
  113080. */
  113081. getSimpleName(): string;
  113082. }
  113083. }
  113084. declare module BABYLON {
  113085. /**
  113086. * Manage the mouse wheel inputs to control an arc rotate camera.
  113087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113088. */
  113089. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113090. /**
  113091. * Defines the camera the input is attached to.
  113092. */
  113093. camera: ArcRotateCamera;
  113094. /**
  113095. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113096. */
  113097. wheelPrecision: number;
  113098. /**
  113099. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113100. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113101. */
  113102. wheelDeltaPercentage: number;
  113103. private _wheel;
  113104. private _observer;
  113105. private computeDeltaFromMouseWheelLegacyEvent;
  113106. /**
  113107. * Attach the input controls to a specific dom element to get the input from.
  113108. * @param element Defines the element the controls should be listened from
  113109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113110. */
  113111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113112. /**
  113113. * Detach the current controls from the specified dom element.
  113114. * @param element Defines the element to stop listening the inputs from
  113115. */
  113116. detachControl(element: Nullable<HTMLElement>): void;
  113117. /**
  113118. * Gets the class name of the current intput.
  113119. * @returns the class name
  113120. */
  113121. getClassName(): string;
  113122. /**
  113123. * Get the friendly name associated with the input class.
  113124. * @returns the input friendly name
  113125. */
  113126. getSimpleName(): string;
  113127. }
  113128. }
  113129. declare module BABYLON {
  113130. /**
  113131. * Default Inputs manager for the ArcRotateCamera.
  113132. * It groups all the default supported inputs for ease of use.
  113133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113134. */
  113135. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113136. /**
  113137. * Instantiates a new ArcRotateCameraInputsManager.
  113138. * @param camera Defines the camera the inputs belong to
  113139. */
  113140. constructor(camera: ArcRotateCamera);
  113141. /**
  113142. * Add mouse wheel input support to the input manager.
  113143. * @returns the current input manager
  113144. */
  113145. addMouseWheel(): ArcRotateCameraInputsManager;
  113146. /**
  113147. * Add pointers input support to the input manager.
  113148. * @returns the current input manager
  113149. */
  113150. addPointers(): ArcRotateCameraInputsManager;
  113151. /**
  113152. * Add keyboard input support to the input manager.
  113153. * @returns the current input manager
  113154. */
  113155. addKeyboard(): ArcRotateCameraInputsManager;
  113156. }
  113157. }
  113158. declare module BABYLON {
  113159. /**
  113160. * This represents an orbital type of camera.
  113161. *
  113162. * 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.
  113163. * 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.
  113164. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113165. */
  113166. export class ArcRotateCamera extends TargetCamera {
  113167. /**
  113168. * Defines the rotation angle of the camera along the longitudinal axis.
  113169. */
  113170. alpha: number;
  113171. /**
  113172. * Defines the rotation angle of the camera along the latitudinal axis.
  113173. */
  113174. beta: number;
  113175. /**
  113176. * Defines the radius of the camera from it s target point.
  113177. */
  113178. radius: number;
  113179. protected _target: Vector3;
  113180. protected _targetHost: Nullable<AbstractMesh>;
  113181. /**
  113182. * Defines the target point of the camera.
  113183. * The camera looks towards it form the radius distance.
  113184. */
  113185. get target(): Vector3;
  113186. set target(value: Vector3);
  113187. /**
  113188. * Define the current local position of the camera in the scene
  113189. */
  113190. get position(): Vector3;
  113191. set position(newPosition: Vector3);
  113192. protected _upVector: Vector3;
  113193. protected _upToYMatrix: Matrix;
  113194. protected _YToUpMatrix: Matrix;
  113195. /**
  113196. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113197. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113198. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113199. */
  113200. set upVector(vec: Vector3);
  113201. get upVector(): Vector3;
  113202. /**
  113203. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113204. */
  113205. setMatUp(): void;
  113206. /**
  113207. * Current inertia value on the longitudinal axis.
  113208. * The bigger this number the longer it will take for the camera to stop.
  113209. */
  113210. inertialAlphaOffset: number;
  113211. /**
  113212. * Current inertia value on the latitudinal axis.
  113213. * The bigger this number the longer it will take for the camera to stop.
  113214. */
  113215. inertialBetaOffset: number;
  113216. /**
  113217. * Current inertia value on the radius axis.
  113218. * The bigger this number the longer it will take for the camera to stop.
  113219. */
  113220. inertialRadiusOffset: number;
  113221. /**
  113222. * Minimum allowed angle on the longitudinal axis.
  113223. * This can help limiting how the Camera is able to move in the scene.
  113224. */
  113225. lowerAlphaLimit: Nullable<number>;
  113226. /**
  113227. * Maximum allowed angle on the longitudinal axis.
  113228. * This can help limiting how the Camera is able to move in the scene.
  113229. */
  113230. upperAlphaLimit: Nullable<number>;
  113231. /**
  113232. * Minimum allowed angle on the latitudinal axis.
  113233. * This can help limiting how the Camera is able to move in the scene.
  113234. */
  113235. lowerBetaLimit: number;
  113236. /**
  113237. * Maximum allowed angle on the latitudinal axis.
  113238. * This can help limiting how the Camera is able to move in the scene.
  113239. */
  113240. upperBetaLimit: number;
  113241. /**
  113242. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113243. * This can help limiting how the Camera is able to move in the scene.
  113244. */
  113245. lowerRadiusLimit: Nullable<number>;
  113246. /**
  113247. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113248. * This can help limiting how the Camera is able to move in the scene.
  113249. */
  113250. upperRadiusLimit: Nullable<number>;
  113251. /**
  113252. * Defines the current inertia value used during panning of the camera along the X axis.
  113253. */
  113254. inertialPanningX: number;
  113255. /**
  113256. * Defines the current inertia value used during panning of the camera along the Y axis.
  113257. */
  113258. inertialPanningY: number;
  113259. /**
  113260. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113261. * Basically if your fingers moves away from more than this distance you will be considered
  113262. * in pinch mode.
  113263. */
  113264. pinchToPanMaxDistance: number;
  113265. /**
  113266. * Defines the maximum distance the camera can pan.
  113267. * This could help keeping the cammera always in your scene.
  113268. */
  113269. panningDistanceLimit: Nullable<number>;
  113270. /**
  113271. * Defines the target of the camera before paning.
  113272. */
  113273. panningOriginTarget: Vector3;
  113274. /**
  113275. * Defines the value of the inertia used during panning.
  113276. * 0 would mean stop inertia and one would mean no decelleration at all.
  113277. */
  113278. panningInertia: number;
  113279. /**
  113280. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113281. */
  113282. get angularSensibilityX(): number;
  113283. set angularSensibilityX(value: number);
  113284. /**
  113285. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113286. */
  113287. get angularSensibilityY(): number;
  113288. set angularSensibilityY(value: number);
  113289. /**
  113290. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113291. */
  113292. get pinchPrecision(): number;
  113293. set pinchPrecision(value: number);
  113294. /**
  113295. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113296. * It will be used instead of pinchDeltaPrecision if different from 0.
  113297. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113298. */
  113299. get pinchDeltaPercentage(): number;
  113300. set pinchDeltaPercentage(value: number);
  113301. /**
  113302. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113303. * and pinch delta percentage.
  113304. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113305. * that any object in the plane at the camera's target point will scale
  113306. * perfectly with finger motion.
  113307. */
  113308. get useNaturalPinchZoom(): boolean;
  113309. set useNaturalPinchZoom(value: boolean);
  113310. /**
  113311. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113312. */
  113313. get panningSensibility(): number;
  113314. set panningSensibility(value: number);
  113315. /**
  113316. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113317. */
  113318. get keysUp(): number[];
  113319. set keysUp(value: number[]);
  113320. /**
  113321. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113322. */
  113323. get keysDown(): number[];
  113324. set keysDown(value: number[]);
  113325. /**
  113326. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113327. */
  113328. get keysLeft(): number[];
  113329. set keysLeft(value: number[]);
  113330. /**
  113331. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113332. */
  113333. get keysRight(): number[];
  113334. set keysRight(value: number[]);
  113335. /**
  113336. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113337. */
  113338. get wheelPrecision(): number;
  113339. set wheelPrecision(value: number);
  113340. /**
  113341. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113342. * It will be used instead of pinchDeltaPrecision if different from 0.
  113343. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113344. */
  113345. get wheelDeltaPercentage(): number;
  113346. set wheelDeltaPercentage(value: number);
  113347. /**
  113348. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113349. */
  113350. zoomOnFactor: number;
  113351. /**
  113352. * Defines a screen offset for the camera position.
  113353. */
  113354. targetScreenOffset: Vector2;
  113355. /**
  113356. * Allows the camera to be completely reversed.
  113357. * If false the camera can not arrive upside down.
  113358. */
  113359. allowUpsideDown: boolean;
  113360. /**
  113361. * Define if double tap/click is used to restore the previously saved state of the camera.
  113362. */
  113363. useInputToRestoreState: boolean;
  113364. /** @hidden */
  113365. _viewMatrix: Matrix;
  113366. /** @hidden */
  113367. _useCtrlForPanning: boolean;
  113368. /** @hidden */
  113369. _panningMouseButton: number;
  113370. /**
  113371. * Defines the input associated to the camera.
  113372. */
  113373. inputs: ArcRotateCameraInputsManager;
  113374. /** @hidden */
  113375. _reset: () => void;
  113376. /**
  113377. * Defines the allowed panning axis.
  113378. */
  113379. panningAxis: Vector3;
  113380. protected _localDirection: Vector3;
  113381. protected _transformedDirection: Vector3;
  113382. private _bouncingBehavior;
  113383. /**
  113384. * Gets the bouncing behavior of the camera if it has been enabled.
  113385. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113386. */
  113387. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113388. /**
  113389. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113391. */
  113392. get useBouncingBehavior(): boolean;
  113393. set useBouncingBehavior(value: boolean);
  113394. private _framingBehavior;
  113395. /**
  113396. * Gets the framing behavior of the camera if it has been enabled.
  113397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113398. */
  113399. get framingBehavior(): Nullable<FramingBehavior>;
  113400. /**
  113401. * Defines if the framing behavior of the camera is enabled on the camera.
  113402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113403. */
  113404. get useFramingBehavior(): boolean;
  113405. set useFramingBehavior(value: boolean);
  113406. private _autoRotationBehavior;
  113407. /**
  113408. * Gets the auto rotation behavior of the camera if it has been enabled.
  113409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113410. */
  113411. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113412. /**
  113413. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113415. */
  113416. get useAutoRotationBehavior(): boolean;
  113417. set useAutoRotationBehavior(value: boolean);
  113418. /**
  113419. * Observable triggered when the mesh target has been changed on the camera.
  113420. */
  113421. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113422. /**
  113423. * Event raised when the camera is colliding with a mesh.
  113424. */
  113425. onCollide: (collidedMesh: AbstractMesh) => void;
  113426. /**
  113427. * Defines whether the camera should check collision with the objects oh the scene.
  113428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113429. */
  113430. checkCollisions: boolean;
  113431. /**
  113432. * Defines the collision radius of the camera.
  113433. * This simulates a sphere around the camera.
  113434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113435. */
  113436. collisionRadius: Vector3;
  113437. protected _collider: Collider;
  113438. protected _previousPosition: Vector3;
  113439. protected _collisionVelocity: Vector3;
  113440. protected _newPosition: Vector3;
  113441. protected _previousAlpha: number;
  113442. protected _previousBeta: number;
  113443. protected _previousRadius: number;
  113444. protected _collisionTriggered: boolean;
  113445. protected _targetBoundingCenter: Nullable<Vector3>;
  113446. private _computationVector;
  113447. /**
  113448. * Instantiates a new ArcRotateCamera in a given scene
  113449. * @param name Defines the name of the camera
  113450. * @param alpha Defines the camera rotation along the logitudinal axis
  113451. * @param beta Defines the camera rotation along the latitudinal axis
  113452. * @param radius Defines the camera distance from its target
  113453. * @param target Defines the camera target
  113454. * @param scene Defines the scene the camera belongs to
  113455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113456. */
  113457. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113458. /** @hidden */
  113459. _initCache(): void;
  113460. /** @hidden */
  113461. _updateCache(ignoreParentClass?: boolean): void;
  113462. protected _getTargetPosition(): Vector3;
  113463. private _storedAlpha;
  113464. private _storedBeta;
  113465. private _storedRadius;
  113466. private _storedTarget;
  113467. private _storedTargetScreenOffset;
  113468. /**
  113469. * Stores the current state of the camera (alpha, beta, radius and target)
  113470. * @returns the camera itself
  113471. */
  113472. storeState(): Camera;
  113473. /**
  113474. * @hidden
  113475. * Restored camera state. You must call storeState() first
  113476. */
  113477. _restoreStateValues(): boolean;
  113478. /** @hidden */
  113479. _isSynchronizedViewMatrix(): boolean;
  113480. /**
  113481. * Attached controls to the current camera.
  113482. * @param element Defines the element the controls should be listened from
  113483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113484. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113485. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113486. */
  113487. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113488. /**
  113489. * Detach the current controls from the camera.
  113490. * The camera will stop reacting to inputs.
  113491. * @param element Defines the element to stop listening the inputs from
  113492. */
  113493. detachControl(element: HTMLElement): void;
  113494. /** @hidden */
  113495. _checkInputs(): void;
  113496. protected _checkLimits(): void;
  113497. /**
  113498. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113499. */
  113500. rebuildAnglesAndRadius(): void;
  113501. /**
  113502. * Use a position to define the current camera related information like alpha, beta and radius
  113503. * @param position Defines the position to set the camera at
  113504. */
  113505. setPosition(position: Vector3): void;
  113506. /**
  113507. * Defines the target the camera should look at.
  113508. * This will automatically adapt alpha beta and radius to fit within the new target.
  113509. * @param target Defines the new target as a Vector or a mesh
  113510. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113511. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113512. */
  113513. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113514. /** @hidden */
  113515. _getViewMatrix(): Matrix;
  113516. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113517. /**
  113518. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113519. * @param meshes Defines the mesh to zoom on
  113520. * @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)
  113521. */
  113522. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113523. /**
  113524. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113525. * The target will be changed but the radius
  113526. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113527. * @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)
  113528. */
  113529. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113530. min: Vector3;
  113531. max: Vector3;
  113532. distance: number;
  113533. }, doNotUpdateMaxZ?: boolean): void;
  113534. /**
  113535. * @override
  113536. * Override Camera.createRigCamera
  113537. */
  113538. createRigCamera(name: string, cameraIndex: number): Camera;
  113539. /**
  113540. * @hidden
  113541. * @override
  113542. * Override Camera._updateRigCameras
  113543. */
  113544. _updateRigCameras(): void;
  113545. /**
  113546. * Destroy the camera and release the current resources hold by it.
  113547. */
  113548. dispose(): void;
  113549. /**
  113550. * Gets the current object class name.
  113551. * @return the class name
  113552. */
  113553. getClassName(): string;
  113554. }
  113555. }
  113556. declare module BABYLON {
  113557. /**
  113558. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113559. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113560. */
  113561. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113562. /**
  113563. * Gets the name of the behavior.
  113564. */
  113565. get name(): string;
  113566. private _zoomStopsAnimation;
  113567. private _idleRotationSpeed;
  113568. private _idleRotationWaitTime;
  113569. private _idleRotationSpinupTime;
  113570. /**
  113571. * Sets the flag that indicates if user zooming should stop animation.
  113572. */
  113573. set zoomStopsAnimation(flag: boolean);
  113574. /**
  113575. * Gets the flag that indicates if user zooming should stop animation.
  113576. */
  113577. get zoomStopsAnimation(): boolean;
  113578. /**
  113579. * Sets the default speed at which the camera rotates around the model.
  113580. */
  113581. set idleRotationSpeed(speed: number);
  113582. /**
  113583. * Gets the default speed at which the camera rotates around the model.
  113584. */
  113585. get idleRotationSpeed(): number;
  113586. /**
  113587. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113588. */
  113589. set idleRotationWaitTime(time: number);
  113590. /**
  113591. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113592. */
  113593. get idleRotationWaitTime(): number;
  113594. /**
  113595. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113596. */
  113597. set idleRotationSpinupTime(time: number);
  113598. /**
  113599. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113600. */
  113601. get idleRotationSpinupTime(): number;
  113602. /**
  113603. * Gets a value indicating if the camera is currently rotating because of this behavior
  113604. */
  113605. get rotationInProgress(): boolean;
  113606. private _onPrePointerObservableObserver;
  113607. private _onAfterCheckInputsObserver;
  113608. private _attachedCamera;
  113609. private _isPointerDown;
  113610. private _lastFrameTime;
  113611. private _lastInteractionTime;
  113612. private _cameraRotationSpeed;
  113613. /**
  113614. * Initializes the behavior.
  113615. */
  113616. init(): void;
  113617. /**
  113618. * Attaches the behavior to its arc rotate camera.
  113619. * @param camera Defines the camera to attach the behavior to
  113620. */
  113621. attach(camera: ArcRotateCamera): void;
  113622. /**
  113623. * Detaches the behavior from its current arc rotate camera.
  113624. */
  113625. detach(): void;
  113626. /**
  113627. * Returns true if user is scrolling.
  113628. * @return true if user is scrolling.
  113629. */
  113630. private _userIsZooming;
  113631. private _lastFrameRadius;
  113632. private _shouldAnimationStopForInteraction;
  113633. /**
  113634. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113635. */
  113636. private _applyUserInteraction;
  113637. private _userIsMoving;
  113638. }
  113639. }
  113640. declare module BABYLON {
  113641. /**
  113642. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113643. */
  113644. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113645. private ui;
  113646. /**
  113647. * The name of the behavior
  113648. */
  113649. name: string;
  113650. /**
  113651. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113652. */
  113653. distanceAwayFromFace: number;
  113654. /**
  113655. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113656. */
  113657. distanceAwayFromBottomOfFace: number;
  113658. private _faceVectors;
  113659. private _target;
  113660. private _scene;
  113661. private _onRenderObserver;
  113662. private _tmpMatrix;
  113663. private _tmpVector;
  113664. /**
  113665. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113666. * @param ui The transform node that should be attched to the mesh
  113667. */
  113668. constructor(ui: TransformNode);
  113669. /**
  113670. * Initializes the behavior
  113671. */
  113672. init(): void;
  113673. private _closestFace;
  113674. private _zeroVector;
  113675. private _lookAtTmpMatrix;
  113676. private _lookAtToRef;
  113677. /**
  113678. * Attaches the AttachToBoxBehavior to the passed in mesh
  113679. * @param target The mesh that the specified node will be attached to
  113680. */
  113681. attach(target: Mesh): void;
  113682. /**
  113683. * Detaches the behavior from the mesh
  113684. */
  113685. detach(): void;
  113686. }
  113687. }
  113688. declare module BABYLON {
  113689. /**
  113690. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113691. */
  113692. export class FadeInOutBehavior implements Behavior<Mesh> {
  113693. /**
  113694. * Time in milliseconds to delay before fading in (Default: 0)
  113695. */
  113696. delay: number;
  113697. /**
  113698. * Time in milliseconds for the mesh to fade in (Default: 300)
  113699. */
  113700. fadeInTime: number;
  113701. private _millisecondsPerFrame;
  113702. private _hovered;
  113703. private _hoverValue;
  113704. private _ownerNode;
  113705. /**
  113706. * Instatiates the FadeInOutBehavior
  113707. */
  113708. constructor();
  113709. /**
  113710. * The name of the behavior
  113711. */
  113712. get name(): string;
  113713. /**
  113714. * Initializes the behavior
  113715. */
  113716. init(): void;
  113717. /**
  113718. * Attaches the fade behavior on the passed in mesh
  113719. * @param ownerNode The mesh that will be faded in/out once attached
  113720. */
  113721. attach(ownerNode: Mesh): void;
  113722. /**
  113723. * Detaches the behavior from the mesh
  113724. */
  113725. detach(): void;
  113726. /**
  113727. * Triggers the mesh to begin fading in or out
  113728. * @param value if the object should fade in or out (true to fade in)
  113729. */
  113730. fadeIn(value: boolean): void;
  113731. private _update;
  113732. private _setAllVisibility;
  113733. }
  113734. }
  113735. declare module BABYLON {
  113736. /**
  113737. * Class containing a set of static utilities functions for managing Pivots
  113738. * @hidden
  113739. */
  113740. export class PivotTools {
  113741. private static _PivotCached;
  113742. private static _OldPivotPoint;
  113743. private static _PivotTranslation;
  113744. private static _PivotTmpVector;
  113745. /** @hidden */
  113746. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113747. /** @hidden */
  113748. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113749. }
  113750. }
  113751. declare module BABYLON {
  113752. /**
  113753. * Class containing static functions to help procedurally build meshes
  113754. */
  113755. export class PlaneBuilder {
  113756. /**
  113757. * Creates a plane mesh
  113758. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113759. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113760. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113764. * @param name defines the name of the mesh
  113765. * @param options defines the options used to create the mesh
  113766. * @param scene defines the hosting scene
  113767. * @returns the plane mesh
  113768. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113769. */
  113770. static CreatePlane(name: string, options: {
  113771. size?: number;
  113772. width?: number;
  113773. height?: number;
  113774. sideOrientation?: number;
  113775. frontUVs?: Vector4;
  113776. backUVs?: Vector4;
  113777. updatable?: boolean;
  113778. sourcePlane?: Plane;
  113779. }, scene?: Nullable<Scene>): Mesh;
  113780. }
  113781. }
  113782. declare module BABYLON {
  113783. /**
  113784. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113785. */
  113786. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113787. private static _AnyMouseID;
  113788. /**
  113789. * Abstract mesh the behavior is set on
  113790. */
  113791. attachedNode: AbstractMesh;
  113792. private _dragPlane;
  113793. private _scene;
  113794. private _pointerObserver;
  113795. private _beforeRenderObserver;
  113796. private static _planeScene;
  113797. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113798. /**
  113799. * 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)
  113800. */
  113801. maxDragAngle: number;
  113802. /**
  113803. * @hidden
  113804. */
  113805. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113806. /**
  113807. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113808. */
  113809. currentDraggingPointerID: number;
  113810. /**
  113811. * The last position where the pointer hit the drag plane in world space
  113812. */
  113813. lastDragPosition: Vector3;
  113814. /**
  113815. * If the behavior is currently in a dragging state
  113816. */
  113817. dragging: boolean;
  113818. /**
  113819. * 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)
  113820. */
  113821. dragDeltaRatio: number;
  113822. /**
  113823. * If the drag plane orientation should be updated during the dragging (Default: true)
  113824. */
  113825. updateDragPlane: boolean;
  113826. private _debugMode;
  113827. private _moving;
  113828. /**
  113829. * Fires each time the attached mesh is dragged with the pointer
  113830. * * delta between last drag position and current drag position in world space
  113831. * * dragDistance along the drag axis
  113832. * * dragPlaneNormal normal of the current drag plane used during the drag
  113833. * * dragPlanePoint in world space where the drag intersects the drag plane
  113834. */
  113835. onDragObservable: Observable<{
  113836. delta: Vector3;
  113837. dragPlanePoint: Vector3;
  113838. dragPlaneNormal: Vector3;
  113839. dragDistance: number;
  113840. pointerId: number;
  113841. }>;
  113842. /**
  113843. * Fires each time a drag begins (eg. mouse down on mesh)
  113844. */
  113845. onDragStartObservable: Observable<{
  113846. dragPlanePoint: Vector3;
  113847. pointerId: number;
  113848. }>;
  113849. /**
  113850. * Fires each time a drag ends (eg. mouse release after drag)
  113851. */
  113852. onDragEndObservable: Observable<{
  113853. dragPlanePoint: Vector3;
  113854. pointerId: number;
  113855. }>;
  113856. /**
  113857. * If the attached mesh should be moved when dragged
  113858. */
  113859. moveAttached: boolean;
  113860. /**
  113861. * If the drag behavior will react to drag events (Default: true)
  113862. */
  113863. enabled: boolean;
  113864. /**
  113865. * If pointer events should start and release the drag (Default: true)
  113866. */
  113867. startAndReleaseDragOnPointerEvents: boolean;
  113868. /**
  113869. * If camera controls should be detached during the drag
  113870. */
  113871. detachCameraControls: boolean;
  113872. /**
  113873. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113874. */
  113875. useObjectOrientationForDragging: boolean;
  113876. private _options;
  113877. /**
  113878. * Gets the options used by the behavior
  113879. */
  113880. get options(): {
  113881. dragAxis?: Vector3;
  113882. dragPlaneNormal?: Vector3;
  113883. };
  113884. /**
  113885. * Sets the options used by the behavior
  113886. */
  113887. set options(options: {
  113888. dragAxis?: Vector3;
  113889. dragPlaneNormal?: Vector3;
  113890. });
  113891. /**
  113892. * Creates a pointer drag behavior that can be attached to a mesh
  113893. * @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)
  113894. */
  113895. constructor(options?: {
  113896. dragAxis?: Vector3;
  113897. dragPlaneNormal?: Vector3;
  113898. });
  113899. /**
  113900. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113901. */
  113902. validateDrag: (targetPosition: Vector3) => boolean;
  113903. /**
  113904. * The name of the behavior
  113905. */
  113906. get name(): string;
  113907. /**
  113908. * Initializes the behavior
  113909. */
  113910. init(): void;
  113911. private _tmpVector;
  113912. private _alternatePickedPoint;
  113913. private _worldDragAxis;
  113914. private _targetPosition;
  113915. private _attachedElement;
  113916. /**
  113917. * Attaches the drag behavior the passed in mesh
  113918. * @param ownerNode The mesh that will be dragged around once attached
  113919. * @param predicate Predicate to use for pick filtering
  113920. */
  113921. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113922. /**
  113923. * Force relase the drag action by code.
  113924. */
  113925. releaseDrag(): void;
  113926. private _startDragRay;
  113927. private _lastPointerRay;
  113928. /**
  113929. * Simulates the start of a pointer drag event on the behavior
  113930. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113931. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113932. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113933. */
  113934. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113935. private _startDrag;
  113936. private _dragDelta;
  113937. private _moveDrag;
  113938. private _pickWithRayOnDragPlane;
  113939. private _pointA;
  113940. private _pointB;
  113941. private _pointC;
  113942. private _lineA;
  113943. private _lineB;
  113944. private _localAxis;
  113945. private _lookAt;
  113946. private _updateDragPlanePosition;
  113947. /**
  113948. * Detaches the behavior from the mesh
  113949. */
  113950. detach(): void;
  113951. }
  113952. }
  113953. declare module BABYLON {
  113954. /**
  113955. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113956. */
  113957. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113958. private _dragBehaviorA;
  113959. private _dragBehaviorB;
  113960. private _startDistance;
  113961. private _initialScale;
  113962. private _targetScale;
  113963. private _ownerNode;
  113964. private _sceneRenderObserver;
  113965. /**
  113966. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113967. */
  113968. constructor();
  113969. /**
  113970. * The name of the behavior
  113971. */
  113972. get name(): string;
  113973. /**
  113974. * Initializes the behavior
  113975. */
  113976. init(): void;
  113977. private _getCurrentDistance;
  113978. /**
  113979. * Attaches the scale behavior the passed in mesh
  113980. * @param ownerNode The mesh that will be scaled around once attached
  113981. */
  113982. attach(ownerNode: Mesh): void;
  113983. /**
  113984. * Detaches the behavior from the mesh
  113985. */
  113986. detach(): void;
  113987. }
  113988. }
  113989. declare module BABYLON {
  113990. /**
  113991. * 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
  113992. */
  113993. export class SixDofDragBehavior implements Behavior<Mesh> {
  113994. private static _virtualScene;
  113995. private _ownerNode;
  113996. private _sceneRenderObserver;
  113997. private _scene;
  113998. private _targetPosition;
  113999. private _virtualOriginMesh;
  114000. private _virtualDragMesh;
  114001. private _pointerObserver;
  114002. private _moving;
  114003. private _startingOrientation;
  114004. private _attachedElement;
  114005. /**
  114006. * 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)
  114007. */
  114008. private zDragFactor;
  114009. /**
  114010. * If the object should rotate to face the drag origin
  114011. */
  114012. rotateDraggedObject: boolean;
  114013. /**
  114014. * If the behavior is currently in a dragging state
  114015. */
  114016. dragging: boolean;
  114017. /**
  114018. * 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)
  114019. */
  114020. dragDeltaRatio: number;
  114021. /**
  114022. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114023. */
  114024. currentDraggingPointerID: number;
  114025. /**
  114026. * If camera controls should be detached during the drag
  114027. */
  114028. detachCameraControls: boolean;
  114029. /**
  114030. * Fires each time a drag starts
  114031. */
  114032. onDragStartObservable: Observable<{}>;
  114033. /**
  114034. * Fires each time a drag ends (eg. mouse release after drag)
  114035. */
  114036. onDragEndObservable: Observable<{}>;
  114037. /**
  114038. * 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
  114039. */
  114040. constructor();
  114041. /**
  114042. * The name of the behavior
  114043. */
  114044. get name(): string;
  114045. /**
  114046. * Initializes the behavior
  114047. */
  114048. init(): void;
  114049. /**
  114050. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114051. */
  114052. private get _pointerCamera();
  114053. /**
  114054. * Attaches the scale behavior the passed in mesh
  114055. * @param ownerNode The mesh that will be scaled around once attached
  114056. */
  114057. attach(ownerNode: Mesh): void;
  114058. /**
  114059. * Detaches the behavior from the mesh
  114060. */
  114061. detach(): void;
  114062. }
  114063. }
  114064. declare module BABYLON {
  114065. /**
  114066. * Class used to apply inverse kinematics to bones
  114067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114068. */
  114069. export class BoneIKController {
  114070. private static _tmpVecs;
  114071. private static _tmpQuat;
  114072. private static _tmpMats;
  114073. /**
  114074. * Gets or sets the target mesh
  114075. */
  114076. targetMesh: AbstractMesh;
  114077. /** Gets or sets the mesh used as pole */
  114078. poleTargetMesh: AbstractMesh;
  114079. /**
  114080. * Gets or sets the bone used as pole
  114081. */
  114082. poleTargetBone: Nullable<Bone>;
  114083. /**
  114084. * Gets or sets the target position
  114085. */
  114086. targetPosition: Vector3;
  114087. /**
  114088. * Gets or sets the pole target position
  114089. */
  114090. poleTargetPosition: Vector3;
  114091. /**
  114092. * Gets or sets the pole target local offset
  114093. */
  114094. poleTargetLocalOffset: Vector3;
  114095. /**
  114096. * Gets or sets the pole angle
  114097. */
  114098. poleAngle: number;
  114099. /**
  114100. * Gets or sets the mesh associated with the controller
  114101. */
  114102. mesh: AbstractMesh;
  114103. /**
  114104. * 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)
  114105. */
  114106. slerpAmount: number;
  114107. private _bone1Quat;
  114108. private _bone1Mat;
  114109. private _bone2Ang;
  114110. private _bone1;
  114111. private _bone2;
  114112. private _bone1Length;
  114113. private _bone2Length;
  114114. private _maxAngle;
  114115. private _maxReach;
  114116. private _rightHandedSystem;
  114117. private _bendAxis;
  114118. private _slerping;
  114119. private _adjustRoll;
  114120. /**
  114121. * Gets or sets maximum allowed angle
  114122. */
  114123. get maxAngle(): number;
  114124. set maxAngle(value: number);
  114125. /**
  114126. * Creates a new BoneIKController
  114127. * @param mesh defines the mesh to control
  114128. * @param bone defines the bone to control
  114129. * @param options defines options to set up the controller
  114130. */
  114131. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114132. targetMesh?: AbstractMesh;
  114133. poleTargetMesh?: AbstractMesh;
  114134. poleTargetBone?: Bone;
  114135. poleTargetLocalOffset?: Vector3;
  114136. poleAngle?: number;
  114137. bendAxis?: Vector3;
  114138. maxAngle?: number;
  114139. slerpAmount?: number;
  114140. });
  114141. private _setMaxAngle;
  114142. /**
  114143. * Force the controller to update the bones
  114144. */
  114145. update(): void;
  114146. }
  114147. }
  114148. declare module BABYLON {
  114149. /**
  114150. * Class used to make a bone look toward a point in space
  114151. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114152. */
  114153. export class BoneLookController {
  114154. private static _tmpVecs;
  114155. private static _tmpQuat;
  114156. private static _tmpMats;
  114157. /**
  114158. * The target Vector3 that the bone will look at
  114159. */
  114160. target: Vector3;
  114161. /**
  114162. * The mesh that the bone is attached to
  114163. */
  114164. mesh: AbstractMesh;
  114165. /**
  114166. * The bone that will be looking to the target
  114167. */
  114168. bone: Bone;
  114169. /**
  114170. * The up axis of the coordinate system that is used when the bone is rotated
  114171. */
  114172. upAxis: Vector3;
  114173. /**
  114174. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114175. */
  114176. upAxisSpace: Space;
  114177. /**
  114178. * Used to make an adjustment to the yaw of the bone
  114179. */
  114180. adjustYaw: number;
  114181. /**
  114182. * Used to make an adjustment to the pitch of the bone
  114183. */
  114184. adjustPitch: number;
  114185. /**
  114186. * Used to make an adjustment to the roll of the bone
  114187. */
  114188. adjustRoll: number;
  114189. /**
  114190. * 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)
  114191. */
  114192. slerpAmount: number;
  114193. private _minYaw;
  114194. private _maxYaw;
  114195. private _minPitch;
  114196. private _maxPitch;
  114197. private _minYawSin;
  114198. private _minYawCos;
  114199. private _maxYawSin;
  114200. private _maxYawCos;
  114201. private _midYawConstraint;
  114202. private _minPitchTan;
  114203. private _maxPitchTan;
  114204. private _boneQuat;
  114205. private _slerping;
  114206. private _transformYawPitch;
  114207. private _transformYawPitchInv;
  114208. private _firstFrameSkipped;
  114209. private _yawRange;
  114210. private _fowardAxis;
  114211. /**
  114212. * Gets or sets the minimum yaw angle that the bone can look to
  114213. */
  114214. get minYaw(): number;
  114215. set minYaw(value: number);
  114216. /**
  114217. * Gets or sets the maximum yaw angle that the bone can look to
  114218. */
  114219. get maxYaw(): number;
  114220. set maxYaw(value: number);
  114221. /**
  114222. * Gets or sets the minimum pitch angle that the bone can look to
  114223. */
  114224. get minPitch(): number;
  114225. set minPitch(value: number);
  114226. /**
  114227. * Gets or sets the maximum pitch angle that the bone can look to
  114228. */
  114229. get maxPitch(): number;
  114230. set maxPitch(value: number);
  114231. /**
  114232. * Create a BoneLookController
  114233. * @param mesh the mesh that the bone belongs to
  114234. * @param bone the bone that will be looking to the target
  114235. * @param target the target Vector3 to look at
  114236. * @param options optional settings:
  114237. * * maxYaw: the maximum angle the bone will yaw to
  114238. * * minYaw: the minimum angle the bone will yaw to
  114239. * * maxPitch: the maximum angle the bone will pitch to
  114240. * * minPitch: the minimum angle the bone will yaw to
  114241. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114242. * * upAxis: the up axis of the coordinate system
  114243. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114244. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114245. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114246. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114247. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114248. * * adjustRoll: used to make an adjustment to the roll of the bone
  114249. **/
  114250. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114251. maxYaw?: number;
  114252. minYaw?: number;
  114253. maxPitch?: number;
  114254. minPitch?: number;
  114255. slerpAmount?: number;
  114256. upAxis?: Vector3;
  114257. upAxisSpace?: Space;
  114258. yawAxis?: Vector3;
  114259. pitchAxis?: Vector3;
  114260. adjustYaw?: number;
  114261. adjustPitch?: number;
  114262. adjustRoll?: number;
  114263. });
  114264. /**
  114265. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114266. */
  114267. update(): void;
  114268. private _getAngleDiff;
  114269. private _getAngleBetween;
  114270. private _isAngleBetween;
  114271. }
  114272. }
  114273. declare module BABYLON {
  114274. /**
  114275. * Manage the gamepad inputs to control an arc rotate camera.
  114276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114277. */
  114278. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114279. /**
  114280. * Defines the camera the input is attached to.
  114281. */
  114282. camera: ArcRotateCamera;
  114283. /**
  114284. * Defines the gamepad the input is gathering event from.
  114285. */
  114286. gamepad: Nullable<Gamepad>;
  114287. /**
  114288. * Defines the gamepad rotation sensiblity.
  114289. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114290. */
  114291. gamepadRotationSensibility: number;
  114292. /**
  114293. * Defines the gamepad move sensiblity.
  114294. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114295. */
  114296. gamepadMoveSensibility: number;
  114297. private _yAxisScale;
  114298. /**
  114299. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114300. */
  114301. get invertYAxis(): boolean;
  114302. set invertYAxis(value: boolean);
  114303. private _onGamepadConnectedObserver;
  114304. private _onGamepadDisconnectedObserver;
  114305. /**
  114306. * Attach the input controls to a specific dom element to get the input from.
  114307. * @param element Defines the element the controls should be listened from
  114308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114309. */
  114310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114311. /**
  114312. * Detach the current controls from the specified dom element.
  114313. * @param element Defines the element to stop listening the inputs from
  114314. */
  114315. detachControl(element: Nullable<HTMLElement>): void;
  114316. /**
  114317. * Update the current camera state depending on the inputs that have been used this frame.
  114318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114319. */
  114320. checkInputs(): void;
  114321. /**
  114322. * Gets the class name of the current intput.
  114323. * @returns the class name
  114324. */
  114325. getClassName(): string;
  114326. /**
  114327. * Get the friendly name associated with the input class.
  114328. * @returns the input friendly name
  114329. */
  114330. getSimpleName(): string;
  114331. }
  114332. }
  114333. declare module BABYLON {
  114334. interface ArcRotateCameraInputsManager {
  114335. /**
  114336. * Add orientation input support to the input manager.
  114337. * @returns the current input manager
  114338. */
  114339. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114340. }
  114341. /**
  114342. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114344. */
  114345. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114346. /**
  114347. * Defines the camera the input is attached to.
  114348. */
  114349. camera: ArcRotateCamera;
  114350. /**
  114351. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114352. */
  114353. alphaCorrection: number;
  114354. /**
  114355. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114356. */
  114357. gammaCorrection: number;
  114358. private _alpha;
  114359. private _gamma;
  114360. private _dirty;
  114361. private _deviceOrientationHandler;
  114362. /**
  114363. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114364. */
  114365. constructor();
  114366. /**
  114367. * Attach the input controls to a specific dom element to get the input from.
  114368. * @param element Defines the element the controls should be listened from
  114369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114370. */
  114371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114372. /** @hidden */
  114373. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114374. /**
  114375. * Update the current camera state depending on the inputs that have been used this frame.
  114376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114377. */
  114378. checkInputs(): void;
  114379. /**
  114380. * Detach the current controls from the specified dom element.
  114381. * @param element Defines the element to stop listening the inputs from
  114382. */
  114383. detachControl(element: Nullable<HTMLElement>): void;
  114384. /**
  114385. * Gets the class name of the current intput.
  114386. * @returns the class name
  114387. */
  114388. getClassName(): string;
  114389. /**
  114390. * Get the friendly name associated with the input class.
  114391. * @returns the input friendly name
  114392. */
  114393. getSimpleName(): string;
  114394. }
  114395. }
  114396. declare module BABYLON {
  114397. /**
  114398. * Listen to mouse events to control the camera.
  114399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114400. */
  114401. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114402. /**
  114403. * Defines the camera the input is attached to.
  114404. */
  114405. camera: FlyCamera;
  114406. /**
  114407. * Defines if touch is enabled. (Default is true.)
  114408. */
  114409. touchEnabled: boolean;
  114410. /**
  114411. * Defines the buttons associated with the input to handle camera rotation.
  114412. */
  114413. buttons: number[];
  114414. /**
  114415. * Assign buttons for Yaw control.
  114416. */
  114417. buttonsYaw: number[];
  114418. /**
  114419. * Assign buttons for Pitch control.
  114420. */
  114421. buttonsPitch: number[];
  114422. /**
  114423. * Assign buttons for Roll control.
  114424. */
  114425. buttonsRoll: number[];
  114426. /**
  114427. * Detect if any button is being pressed while mouse is moved.
  114428. * -1 = Mouse locked.
  114429. * 0 = Left button.
  114430. * 1 = Middle Button.
  114431. * 2 = Right Button.
  114432. */
  114433. activeButton: number;
  114434. /**
  114435. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114436. * Higher values reduce its sensitivity.
  114437. */
  114438. angularSensibility: number;
  114439. private _mousemoveCallback;
  114440. private _observer;
  114441. private _rollObserver;
  114442. private previousPosition;
  114443. private noPreventDefault;
  114444. private element;
  114445. /**
  114446. * Listen to mouse events to control the camera.
  114447. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114449. */
  114450. constructor(touchEnabled?: boolean);
  114451. /**
  114452. * Attach the mouse control to the HTML DOM element.
  114453. * @param element Defines the element that listens to the input events.
  114454. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114455. */
  114456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114457. /**
  114458. * Detach the current controls from the specified dom element.
  114459. * @param element Defines the element to stop listening the inputs from
  114460. */
  114461. detachControl(element: Nullable<HTMLElement>): void;
  114462. /**
  114463. * Gets the class name of the current input.
  114464. * @returns the class name.
  114465. */
  114466. getClassName(): string;
  114467. /**
  114468. * Get the friendly name associated with the input class.
  114469. * @returns the input's friendly name.
  114470. */
  114471. getSimpleName(): string;
  114472. private _pointerInput;
  114473. private _onMouseMove;
  114474. /**
  114475. * Rotate camera by mouse offset.
  114476. */
  114477. private rotateCamera;
  114478. }
  114479. }
  114480. declare module BABYLON {
  114481. /**
  114482. * Default Inputs manager for the FlyCamera.
  114483. * It groups all the default supported inputs for ease of use.
  114484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114485. */
  114486. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114487. /**
  114488. * Instantiates a new FlyCameraInputsManager.
  114489. * @param camera Defines the camera the inputs belong to.
  114490. */
  114491. constructor(camera: FlyCamera);
  114492. /**
  114493. * Add keyboard input support to the input manager.
  114494. * @returns the new FlyCameraKeyboardMoveInput().
  114495. */
  114496. addKeyboard(): FlyCameraInputsManager;
  114497. /**
  114498. * Add mouse input support to the input manager.
  114499. * @param touchEnabled Enable touch screen support.
  114500. * @returns the new FlyCameraMouseInput().
  114501. */
  114502. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114503. }
  114504. }
  114505. declare module BABYLON {
  114506. /**
  114507. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114508. * such as in a 3D Space Shooter or a Flight Simulator.
  114509. */
  114510. export class FlyCamera extends TargetCamera {
  114511. /**
  114512. * Define the collision ellipsoid of the camera.
  114513. * This is helpful for simulating a camera body, like a player's body.
  114514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114515. */
  114516. ellipsoid: Vector3;
  114517. /**
  114518. * Define an offset for the position of the ellipsoid around the camera.
  114519. * This can be helpful if the camera is attached away from the player's body center,
  114520. * such as at its head.
  114521. */
  114522. ellipsoidOffset: Vector3;
  114523. /**
  114524. * Enable or disable collisions of the camera with the rest of the scene objects.
  114525. */
  114526. checkCollisions: boolean;
  114527. /**
  114528. * Enable or disable gravity on the camera.
  114529. */
  114530. applyGravity: boolean;
  114531. /**
  114532. * Define the current direction the camera is moving to.
  114533. */
  114534. cameraDirection: Vector3;
  114535. /**
  114536. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114537. * This overrides and empties cameraRotation.
  114538. */
  114539. rotationQuaternion: Quaternion;
  114540. /**
  114541. * Track Roll to maintain the wanted Rolling when looking around.
  114542. */
  114543. _trackRoll: number;
  114544. /**
  114545. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114546. */
  114547. rollCorrect: number;
  114548. /**
  114549. * Mimic a banked turn, Rolling the camera when Yawing.
  114550. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114551. */
  114552. bankedTurn: boolean;
  114553. /**
  114554. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114555. */
  114556. bankedTurnLimit: number;
  114557. /**
  114558. * Value of 0 disables the banked Roll.
  114559. * Value of 1 is equal to the Yaw angle in radians.
  114560. */
  114561. bankedTurnMultiplier: number;
  114562. /**
  114563. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114564. */
  114565. inputs: FlyCameraInputsManager;
  114566. /**
  114567. * Gets the input sensibility for mouse input.
  114568. * Higher values reduce sensitivity.
  114569. */
  114570. get angularSensibility(): number;
  114571. /**
  114572. * Sets the input sensibility for a mouse input.
  114573. * Higher values reduce sensitivity.
  114574. */
  114575. set angularSensibility(value: number);
  114576. /**
  114577. * Get the keys for camera movement forward.
  114578. */
  114579. get keysForward(): number[];
  114580. /**
  114581. * Set the keys for camera movement forward.
  114582. */
  114583. set keysForward(value: number[]);
  114584. /**
  114585. * Get the keys for camera movement backward.
  114586. */
  114587. get keysBackward(): number[];
  114588. set keysBackward(value: number[]);
  114589. /**
  114590. * Get the keys for camera movement up.
  114591. */
  114592. get keysUp(): number[];
  114593. /**
  114594. * Set the keys for camera movement up.
  114595. */
  114596. set keysUp(value: number[]);
  114597. /**
  114598. * Get the keys for camera movement down.
  114599. */
  114600. get keysDown(): number[];
  114601. /**
  114602. * Set the keys for camera movement down.
  114603. */
  114604. set keysDown(value: number[]);
  114605. /**
  114606. * Get the keys for camera movement left.
  114607. */
  114608. get keysLeft(): number[];
  114609. /**
  114610. * Set the keys for camera movement left.
  114611. */
  114612. set keysLeft(value: number[]);
  114613. /**
  114614. * Set the keys for camera movement right.
  114615. */
  114616. get keysRight(): number[];
  114617. /**
  114618. * Set the keys for camera movement right.
  114619. */
  114620. set keysRight(value: number[]);
  114621. /**
  114622. * Event raised when the camera collides with a mesh in the scene.
  114623. */
  114624. onCollide: (collidedMesh: AbstractMesh) => void;
  114625. private _collider;
  114626. private _needMoveForGravity;
  114627. private _oldPosition;
  114628. private _diffPosition;
  114629. private _newPosition;
  114630. /** @hidden */
  114631. _localDirection: Vector3;
  114632. /** @hidden */
  114633. _transformedDirection: Vector3;
  114634. /**
  114635. * Instantiates a FlyCamera.
  114636. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114637. * such as in a 3D Space Shooter or a Flight Simulator.
  114638. * @param name Define the name of the camera in the scene.
  114639. * @param position Define the starting position of the camera in the scene.
  114640. * @param scene Define the scene the camera belongs to.
  114641. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114642. */
  114643. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114644. /**
  114645. * Attach a control to the HTML DOM element.
  114646. * @param element Defines the element that listens to the input events.
  114647. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114648. */
  114649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114650. /**
  114651. * Detach a control from the HTML DOM element.
  114652. * The camera will stop reacting to that input.
  114653. * @param element Defines the element that listens to the input events.
  114654. */
  114655. detachControl(element: HTMLElement): void;
  114656. private _collisionMask;
  114657. /**
  114658. * Get the mask that the camera ignores in collision events.
  114659. */
  114660. get collisionMask(): number;
  114661. /**
  114662. * Set the mask that the camera ignores in collision events.
  114663. */
  114664. set collisionMask(mask: number);
  114665. /** @hidden */
  114666. _collideWithWorld(displacement: Vector3): void;
  114667. /** @hidden */
  114668. private _onCollisionPositionChange;
  114669. /** @hidden */
  114670. _checkInputs(): void;
  114671. /** @hidden */
  114672. _decideIfNeedsToMove(): boolean;
  114673. /** @hidden */
  114674. _updatePosition(): void;
  114675. /**
  114676. * Restore the Roll to its target value at the rate specified.
  114677. * @param rate - Higher means slower restoring.
  114678. * @hidden
  114679. */
  114680. restoreRoll(rate: number): void;
  114681. /**
  114682. * Destroy the camera and release the current resources held by it.
  114683. */
  114684. dispose(): void;
  114685. /**
  114686. * Get the current object class name.
  114687. * @returns the class name.
  114688. */
  114689. getClassName(): string;
  114690. }
  114691. }
  114692. declare module BABYLON {
  114693. /**
  114694. * Listen to keyboard events to control the camera.
  114695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114696. */
  114697. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114698. /**
  114699. * Defines the camera the input is attached to.
  114700. */
  114701. camera: FlyCamera;
  114702. /**
  114703. * The list of keyboard keys used to control the forward move of the camera.
  114704. */
  114705. keysForward: number[];
  114706. /**
  114707. * The list of keyboard keys used to control the backward move of the camera.
  114708. */
  114709. keysBackward: number[];
  114710. /**
  114711. * The list of keyboard keys used to control the forward move of the camera.
  114712. */
  114713. keysUp: number[];
  114714. /**
  114715. * The list of keyboard keys used to control the backward move of the camera.
  114716. */
  114717. keysDown: number[];
  114718. /**
  114719. * The list of keyboard keys used to control the right strafe move of the camera.
  114720. */
  114721. keysRight: number[];
  114722. /**
  114723. * The list of keyboard keys used to control the left strafe move of the camera.
  114724. */
  114725. keysLeft: number[];
  114726. private _keys;
  114727. private _onCanvasBlurObserver;
  114728. private _onKeyboardObserver;
  114729. private _engine;
  114730. private _scene;
  114731. /**
  114732. * Attach the input controls to a specific dom element to get the input from.
  114733. * @param element Defines the element the controls should be listened from
  114734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114735. */
  114736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114737. /**
  114738. * Detach the current controls from the specified dom element.
  114739. * @param element Defines the element to stop listening the inputs from
  114740. */
  114741. detachControl(element: Nullable<HTMLElement>): void;
  114742. /**
  114743. * Gets the class name of the current intput.
  114744. * @returns the class name
  114745. */
  114746. getClassName(): string;
  114747. /** @hidden */
  114748. _onLostFocus(e: FocusEvent): void;
  114749. /**
  114750. * Get the friendly name associated with the input class.
  114751. * @returns the input friendly name
  114752. */
  114753. getSimpleName(): string;
  114754. /**
  114755. * Update the current camera state depending on the inputs that have been used this frame.
  114756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114757. */
  114758. checkInputs(): void;
  114759. }
  114760. }
  114761. declare module BABYLON {
  114762. /**
  114763. * Manage the mouse wheel inputs to control a follow camera.
  114764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114765. */
  114766. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114767. /**
  114768. * Defines the camera the input is attached to.
  114769. */
  114770. camera: FollowCamera;
  114771. /**
  114772. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114773. */
  114774. axisControlRadius: boolean;
  114775. /**
  114776. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114777. */
  114778. axisControlHeight: boolean;
  114779. /**
  114780. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114781. */
  114782. axisControlRotation: boolean;
  114783. /**
  114784. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114785. * relation to mouseWheel events.
  114786. */
  114787. wheelPrecision: number;
  114788. /**
  114789. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114790. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114791. */
  114792. wheelDeltaPercentage: number;
  114793. private _wheel;
  114794. private _observer;
  114795. /**
  114796. * Attach the input controls to a specific dom element to get the input from.
  114797. * @param element Defines the element the controls should be listened from
  114798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114799. */
  114800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114801. /**
  114802. * Detach the current controls from the specified dom element.
  114803. * @param element Defines the element to stop listening the inputs from
  114804. */
  114805. detachControl(element: Nullable<HTMLElement>): void;
  114806. /**
  114807. * Gets the class name of the current intput.
  114808. * @returns the class name
  114809. */
  114810. getClassName(): string;
  114811. /**
  114812. * Get the friendly name associated with the input class.
  114813. * @returns the input friendly name
  114814. */
  114815. getSimpleName(): string;
  114816. }
  114817. }
  114818. declare module BABYLON {
  114819. /**
  114820. * Manage the pointers inputs to control an follow camera.
  114821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114822. */
  114823. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114824. /**
  114825. * Defines the camera the input is attached to.
  114826. */
  114827. camera: FollowCamera;
  114828. /**
  114829. * Gets the class name of the current input.
  114830. * @returns the class name
  114831. */
  114832. getClassName(): string;
  114833. /**
  114834. * Defines the pointer angular sensibility along the X axis or how fast is
  114835. * the camera rotating.
  114836. * A negative number will reverse the axis direction.
  114837. */
  114838. angularSensibilityX: number;
  114839. /**
  114840. * Defines the pointer angular sensibility along the Y axis or how fast is
  114841. * the camera rotating.
  114842. * A negative number will reverse the axis direction.
  114843. */
  114844. angularSensibilityY: number;
  114845. /**
  114846. * Defines the pointer pinch precision or how fast is the camera zooming.
  114847. * A negative number will reverse the axis direction.
  114848. */
  114849. pinchPrecision: number;
  114850. /**
  114851. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114852. * from 0.
  114853. * It defines the percentage of current camera.radius to use as delta when
  114854. * pinch zoom is used.
  114855. */
  114856. pinchDeltaPercentage: number;
  114857. /**
  114858. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114859. */
  114860. axisXControlRadius: boolean;
  114861. /**
  114862. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114863. */
  114864. axisXControlHeight: boolean;
  114865. /**
  114866. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114867. */
  114868. axisXControlRotation: boolean;
  114869. /**
  114870. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114871. */
  114872. axisYControlRadius: boolean;
  114873. /**
  114874. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114875. */
  114876. axisYControlHeight: boolean;
  114877. /**
  114878. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114879. */
  114880. axisYControlRotation: boolean;
  114881. /**
  114882. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114883. */
  114884. axisPinchControlRadius: boolean;
  114885. /**
  114886. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114887. */
  114888. axisPinchControlHeight: boolean;
  114889. /**
  114890. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114891. */
  114892. axisPinchControlRotation: boolean;
  114893. /**
  114894. * Log error messages if basic misconfiguration has occurred.
  114895. */
  114896. warningEnable: boolean;
  114897. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114899. private _warningCounter;
  114900. private _warning;
  114901. }
  114902. }
  114903. declare module BABYLON {
  114904. /**
  114905. * Default Inputs manager for the FollowCamera.
  114906. * It groups all the default supported inputs for ease of use.
  114907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114908. */
  114909. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114910. /**
  114911. * Instantiates a new FollowCameraInputsManager.
  114912. * @param camera Defines the camera the inputs belong to
  114913. */
  114914. constructor(camera: FollowCamera);
  114915. /**
  114916. * Add keyboard input support to the input manager.
  114917. * @returns the current input manager
  114918. */
  114919. addKeyboard(): FollowCameraInputsManager;
  114920. /**
  114921. * Add mouse wheel input support to the input manager.
  114922. * @returns the current input manager
  114923. */
  114924. addMouseWheel(): FollowCameraInputsManager;
  114925. /**
  114926. * Add pointers input support to the input manager.
  114927. * @returns the current input manager
  114928. */
  114929. addPointers(): FollowCameraInputsManager;
  114930. /**
  114931. * Add orientation input support to the input manager.
  114932. * @returns the current input manager
  114933. */
  114934. addVRDeviceOrientation(): FollowCameraInputsManager;
  114935. }
  114936. }
  114937. declare module BABYLON {
  114938. /**
  114939. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114940. * an arc rotate version arcFollowCamera are available.
  114941. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114942. */
  114943. export class FollowCamera extends TargetCamera {
  114944. /**
  114945. * Distance the follow camera should follow an object at
  114946. */
  114947. radius: number;
  114948. /**
  114949. * Minimum allowed distance of the camera to the axis of rotation
  114950. * (The camera can not get closer).
  114951. * This can help limiting how the Camera is able to move in the scene.
  114952. */
  114953. lowerRadiusLimit: Nullable<number>;
  114954. /**
  114955. * Maximum allowed distance of the camera to the axis of rotation
  114956. * (The camera can not get further).
  114957. * This can help limiting how the Camera is able to move in the scene.
  114958. */
  114959. upperRadiusLimit: Nullable<number>;
  114960. /**
  114961. * Define a rotation offset between the camera and the object it follows
  114962. */
  114963. rotationOffset: number;
  114964. /**
  114965. * Minimum allowed angle to camera position relative to target object.
  114966. * This can help limiting how the Camera is able to move in the scene.
  114967. */
  114968. lowerRotationOffsetLimit: Nullable<number>;
  114969. /**
  114970. * Maximum allowed angle to camera position relative to target object.
  114971. * This can help limiting how the Camera is able to move in the scene.
  114972. */
  114973. upperRotationOffsetLimit: Nullable<number>;
  114974. /**
  114975. * Define a height offset between the camera and the object it follows.
  114976. * It can help following an object from the top (like a car chaing a plane)
  114977. */
  114978. heightOffset: number;
  114979. /**
  114980. * Minimum allowed height of camera position relative to target object.
  114981. * This can help limiting how the Camera is able to move in the scene.
  114982. */
  114983. lowerHeightOffsetLimit: Nullable<number>;
  114984. /**
  114985. * Maximum allowed height of camera position relative to target object.
  114986. * This can help limiting how the Camera is able to move in the scene.
  114987. */
  114988. upperHeightOffsetLimit: Nullable<number>;
  114989. /**
  114990. * Define how fast the camera can accelerate to follow it s target.
  114991. */
  114992. cameraAcceleration: number;
  114993. /**
  114994. * Define the speed limit of the camera following an object.
  114995. */
  114996. maxCameraSpeed: number;
  114997. /**
  114998. * Define the target of the camera.
  114999. */
  115000. lockedTarget: Nullable<AbstractMesh>;
  115001. /**
  115002. * Defines the input associated with the camera.
  115003. */
  115004. inputs: FollowCameraInputsManager;
  115005. /**
  115006. * Instantiates the follow camera.
  115007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115008. * @param name Define the name of the camera in the scene
  115009. * @param position Define the position of the camera
  115010. * @param scene Define the scene the camera belong to
  115011. * @param lockedTarget Define the target of the camera
  115012. */
  115013. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115014. private _follow;
  115015. /**
  115016. * Attached controls to the current camera.
  115017. * @param element Defines the element the controls should be listened from
  115018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115019. */
  115020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115021. /**
  115022. * Detach the current controls from the camera.
  115023. * The camera will stop reacting to inputs.
  115024. * @param element Defines the element to stop listening the inputs from
  115025. */
  115026. detachControl(element: HTMLElement): void;
  115027. /** @hidden */
  115028. _checkInputs(): void;
  115029. private _checkLimits;
  115030. /**
  115031. * Gets the camera class name.
  115032. * @returns the class name
  115033. */
  115034. getClassName(): string;
  115035. }
  115036. /**
  115037. * Arc Rotate version of the follow camera.
  115038. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115039. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115040. */
  115041. export class ArcFollowCamera extends TargetCamera {
  115042. /** The longitudinal angle of the camera */
  115043. alpha: number;
  115044. /** The latitudinal angle of the camera */
  115045. beta: number;
  115046. /** The radius of the camera from its target */
  115047. radius: number;
  115048. /** Define the camera target (the messh it should follow) */
  115049. target: Nullable<AbstractMesh>;
  115050. private _cartesianCoordinates;
  115051. /**
  115052. * Instantiates a new ArcFollowCamera
  115053. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115054. * @param name Define the name of the camera
  115055. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115056. * @param beta Define the rotation angle of the camera around the elevation axis
  115057. * @param radius Define the radius of the camera from its target point
  115058. * @param target Define the target of the camera
  115059. * @param scene Define the scene the camera belongs to
  115060. */
  115061. constructor(name: string,
  115062. /** The longitudinal angle of the camera */
  115063. alpha: number,
  115064. /** The latitudinal angle of the camera */
  115065. beta: number,
  115066. /** The radius of the camera from its target */
  115067. radius: number,
  115068. /** Define the camera target (the messh it should follow) */
  115069. target: Nullable<AbstractMesh>, scene: Scene);
  115070. private _follow;
  115071. /** @hidden */
  115072. _checkInputs(): void;
  115073. /**
  115074. * Returns the class name of the object.
  115075. * It is mostly used internally for serialization purposes.
  115076. */
  115077. getClassName(): string;
  115078. }
  115079. }
  115080. declare module BABYLON {
  115081. /**
  115082. * Manage the keyboard inputs to control the movement of a follow camera.
  115083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115084. */
  115085. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115086. /**
  115087. * Defines the camera the input is attached to.
  115088. */
  115089. camera: FollowCamera;
  115090. /**
  115091. * Defines the list of key codes associated with the up action (increase heightOffset)
  115092. */
  115093. keysHeightOffsetIncr: number[];
  115094. /**
  115095. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115096. */
  115097. keysHeightOffsetDecr: number[];
  115098. /**
  115099. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115100. */
  115101. keysHeightOffsetModifierAlt: boolean;
  115102. /**
  115103. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115104. */
  115105. keysHeightOffsetModifierCtrl: boolean;
  115106. /**
  115107. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115108. */
  115109. keysHeightOffsetModifierShift: boolean;
  115110. /**
  115111. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115112. */
  115113. keysRotationOffsetIncr: number[];
  115114. /**
  115115. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115116. */
  115117. keysRotationOffsetDecr: number[];
  115118. /**
  115119. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115120. */
  115121. keysRotationOffsetModifierAlt: boolean;
  115122. /**
  115123. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115124. */
  115125. keysRotationOffsetModifierCtrl: boolean;
  115126. /**
  115127. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115128. */
  115129. keysRotationOffsetModifierShift: boolean;
  115130. /**
  115131. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115132. */
  115133. keysRadiusIncr: number[];
  115134. /**
  115135. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115136. */
  115137. keysRadiusDecr: number[];
  115138. /**
  115139. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115140. */
  115141. keysRadiusModifierAlt: boolean;
  115142. /**
  115143. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115144. */
  115145. keysRadiusModifierCtrl: boolean;
  115146. /**
  115147. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115148. */
  115149. keysRadiusModifierShift: boolean;
  115150. /**
  115151. * Defines the rate of change of heightOffset.
  115152. */
  115153. heightSensibility: number;
  115154. /**
  115155. * Defines the rate of change of rotationOffset.
  115156. */
  115157. rotationSensibility: number;
  115158. /**
  115159. * Defines the rate of change of radius.
  115160. */
  115161. radiusSensibility: number;
  115162. private _keys;
  115163. private _ctrlPressed;
  115164. private _altPressed;
  115165. private _shiftPressed;
  115166. private _onCanvasBlurObserver;
  115167. private _onKeyboardObserver;
  115168. private _engine;
  115169. private _scene;
  115170. /**
  115171. * Attach the input controls to a specific dom element to get the input from.
  115172. * @param element Defines the element the controls should be listened from
  115173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115174. */
  115175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115176. /**
  115177. * Detach the current controls from the specified dom element.
  115178. * @param element Defines the element to stop listening the inputs from
  115179. */
  115180. detachControl(element: Nullable<HTMLElement>): void;
  115181. /**
  115182. * Update the current camera state depending on the inputs that have been used this frame.
  115183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115184. */
  115185. checkInputs(): void;
  115186. /**
  115187. * Gets the class name of the current input.
  115188. * @returns the class name
  115189. */
  115190. getClassName(): string;
  115191. /**
  115192. * Get the friendly name associated with the input class.
  115193. * @returns the input friendly name
  115194. */
  115195. getSimpleName(): string;
  115196. /**
  115197. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115198. * allow modification of the heightOffset value.
  115199. */
  115200. private _modifierHeightOffset;
  115201. /**
  115202. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115203. * allow modification of the rotationOffset value.
  115204. */
  115205. private _modifierRotationOffset;
  115206. /**
  115207. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115208. * allow modification of the radius value.
  115209. */
  115210. private _modifierRadius;
  115211. }
  115212. }
  115213. declare module BABYLON {
  115214. interface FreeCameraInputsManager {
  115215. /**
  115216. * @hidden
  115217. */
  115218. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115219. /**
  115220. * Add orientation input support to the input manager.
  115221. * @returns the current input manager
  115222. */
  115223. addDeviceOrientation(): FreeCameraInputsManager;
  115224. }
  115225. /**
  115226. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115227. * Screen rotation is taken into account.
  115228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115229. */
  115230. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115231. private _camera;
  115232. private _screenOrientationAngle;
  115233. private _constantTranform;
  115234. private _screenQuaternion;
  115235. private _alpha;
  115236. private _beta;
  115237. private _gamma;
  115238. /**
  115239. * Can be used to detect if a device orientation sensor is available on a device
  115240. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115241. * @returns a promise that will resolve on orientation change
  115242. */
  115243. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115244. /**
  115245. * @hidden
  115246. */
  115247. _onDeviceOrientationChangedObservable: Observable<void>;
  115248. /**
  115249. * Instantiates a new input
  115250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115251. */
  115252. constructor();
  115253. /**
  115254. * Define the camera controlled by the input.
  115255. */
  115256. get camera(): FreeCamera;
  115257. set camera(camera: FreeCamera);
  115258. /**
  115259. * Attach the input controls to a specific dom element to get the input from.
  115260. * @param element Defines the element the controls should be listened from
  115261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115262. */
  115263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115264. private _orientationChanged;
  115265. private _deviceOrientation;
  115266. /**
  115267. * Detach the current controls from the specified dom element.
  115268. * @param element Defines the element to stop listening the inputs from
  115269. */
  115270. detachControl(element: Nullable<HTMLElement>): void;
  115271. /**
  115272. * Update the current camera state depending on the inputs that have been used this frame.
  115273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115274. */
  115275. checkInputs(): void;
  115276. /**
  115277. * Gets the class name of the current intput.
  115278. * @returns the class name
  115279. */
  115280. getClassName(): string;
  115281. /**
  115282. * Get the friendly name associated with the input class.
  115283. * @returns the input friendly name
  115284. */
  115285. getSimpleName(): string;
  115286. }
  115287. }
  115288. declare module BABYLON {
  115289. /**
  115290. * Manage the gamepad inputs to control a free camera.
  115291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115292. */
  115293. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115294. /**
  115295. * Define the camera the input is attached to.
  115296. */
  115297. camera: FreeCamera;
  115298. /**
  115299. * Define the Gamepad controlling the input
  115300. */
  115301. gamepad: Nullable<Gamepad>;
  115302. /**
  115303. * Defines the gamepad rotation sensiblity.
  115304. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115305. */
  115306. gamepadAngularSensibility: number;
  115307. /**
  115308. * Defines the gamepad move sensiblity.
  115309. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115310. */
  115311. gamepadMoveSensibility: number;
  115312. private _yAxisScale;
  115313. /**
  115314. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115315. */
  115316. get invertYAxis(): boolean;
  115317. set invertYAxis(value: boolean);
  115318. private _onGamepadConnectedObserver;
  115319. private _onGamepadDisconnectedObserver;
  115320. private _cameraTransform;
  115321. private _deltaTransform;
  115322. private _vector3;
  115323. private _vector2;
  115324. /**
  115325. * Attach the input controls to a specific dom element to get the input from.
  115326. * @param element Defines the element the controls should be listened from
  115327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115328. */
  115329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115330. /**
  115331. * Detach the current controls from the specified dom element.
  115332. * @param element Defines the element to stop listening the inputs from
  115333. */
  115334. detachControl(element: Nullable<HTMLElement>): void;
  115335. /**
  115336. * Update the current camera state depending on the inputs that have been used this frame.
  115337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115338. */
  115339. checkInputs(): void;
  115340. /**
  115341. * Gets the class name of the current intput.
  115342. * @returns the class name
  115343. */
  115344. getClassName(): string;
  115345. /**
  115346. * Get the friendly name associated with the input class.
  115347. * @returns the input friendly name
  115348. */
  115349. getSimpleName(): string;
  115350. }
  115351. }
  115352. declare module BABYLON {
  115353. /**
  115354. * Defines the potential axis of a Joystick
  115355. */
  115356. export enum JoystickAxis {
  115357. /** X axis */
  115358. X = 0,
  115359. /** Y axis */
  115360. Y = 1,
  115361. /** Z axis */
  115362. Z = 2
  115363. }
  115364. /**
  115365. * Class used to define virtual joystick (used in touch mode)
  115366. */
  115367. export class VirtualJoystick {
  115368. /**
  115369. * Gets or sets a boolean indicating that left and right values must be inverted
  115370. */
  115371. reverseLeftRight: boolean;
  115372. /**
  115373. * Gets or sets a boolean indicating that up and down values must be inverted
  115374. */
  115375. reverseUpDown: boolean;
  115376. /**
  115377. * Gets the offset value for the position (ie. the change of the position value)
  115378. */
  115379. deltaPosition: Vector3;
  115380. /**
  115381. * Gets a boolean indicating if the virtual joystick was pressed
  115382. */
  115383. pressed: boolean;
  115384. /**
  115385. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115386. */
  115387. static Canvas: Nullable<HTMLCanvasElement>;
  115388. private static _globalJoystickIndex;
  115389. private static vjCanvasContext;
  115390. private static vjCanvasWidth;
  115391. private static vjCanvasHeight;
  115392. private static halfWidth;
  115393. private _action;
  115394. private _axisTargetedByLeftAndRight;
  115395. private _axisTargetedByUpAndDown;
  115396. private _joystickSensibility;
  115397. private _inversedSensibility;
  115398. private _joystickPointerID;
  115399. private _joystickColor;
  115400. private _joystickPointerPos;
  115401. private _joystickPreviousPointerPos;
  115402. private _joystickPointerStartPos;
  115403. private _deltaJoystickVector;
  115404. private _leftJoystick;
  115405. private _touches;
  115406. private _onPointerDownHandlerRef;
  115407. private _onPointerMoveHandlerRef;
  115408. private _onPointerUpHandlerRef;
  115409. private _onResize;
  115410. /**
  115411. * Creates a new virtual joystick
  115412. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115413. */
  115414. constructor(leftJoystick?: boolean);
  115415. /**
  115416. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115417. * @param newJoystickSensibility defines the new sensibility
  115418. */
  115419. setJoystickSensibility(newJoystickSensibility: number): void;
  115420. private _onPointerDown;
  115421. private _onPointerMove;
  115422. private _onPointerUp;
  115423. /**
  115424. * Change the color of the virtual joystick
  115425. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115426. */
  115427. setJoystickColor(newColor: string): void;
  115428. /**
  115429. * Defines a callback to call when the joystick is touched
  115430. * @param action defines the callback
  115431. */
  115432. setActionOnTouch(action: () => any): void;
  115433. /**
  115434. * Defines which axis you'd like to control for left & right
  115435. * @param axis defines the axis to use
  115436. */
  115437. setAxisForLeftRight(axis: JoystickAxis): void;
  115438. /**
  115439. * Defines which axis you'd like to control for up & down
  115440. * @param axis defines the axis to use
  115441. */
  115442. setAxisForUpDown(axis: JoystickAxis): void;
  115443. private _drawVirtualJoystick;
  115444. /**
  115445. * Release internal HTML canvas
  115446. */
  115447. releaseCanvas(): void;
  115448. }
  115449. }
  115450. declare module BABYLON {
  115451. interface FreeCameraInputsManager {
  115452. /**
  115453. * Add virtual joystick input support to the input manager.
  115454. * @returns the current input manager
  115455. */
  115456. addVirtualJoystick(): FreeCameraInputsManager;
  115457. }
  115458. /**
  115459. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115461. */
  115462. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115463. /**
  115464. * Defines the camera the input is attached to.
  115465. */
  115466. camera: FreeCamera;
  115467. private _leftjoystick;
  115468. private _rightjoystick;
  115469. /**
  115470. * Gets the left stick of the virtual joystick.
  115471. * @returns The virtual Joystick
  115472. */
  115473. getLeftJoystick(): VirtualJoystick;
  115474. /**
  115475. * Gets the right stick of the virtual joystick.
  115476. * @returns The virtual Joystick
  115477. */
  115478. getRightJoystick(): VirtualJoystick;
  115479. /**
  115480. * Update the current camera state depending on the inputs that have been used this frame.
  115481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115482. */
  115483. checkInputs(): void;
  115484. /**
  115485. * Attach the input controls to a specific dom element to get the input from.
  115486. * @param element Defines the element the controls should be listened from
  115487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115488. */
  115489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115490. /**
  115491. * Detach the current controls from the specified dom element.
  115492. * @param element Defines the element to stop listening the inputs from
  115493. */
  115494. detachControl(element: Nullable<HTMLElement>): void;
  115495. /**
  115496. * Gets the class name of the current intput.
  115497. * @returns the class name
  115498. */
  115499. getClassName(): string;
  115500. /**
  115501. * Get the friendly name associated with the input class.
  115502. * @returns the input friendly name
  115503. */
  115504. getSimpleName(): string;
  115505. }
  115506. }
  115507. declare module BABYLON {
  115508. /**
  115509. * This represents a FPS type of camera controlled by touch.
  115510. * This is like a universal camera minus the Gamepad controls.
  115511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115512. */
  115513. export class TouchCamera extends FreeCamera {
  115514. /**
  115515. * Defines the touch sensibility for rotation.
  115516. * The higher the faster.
  115517. */
  115518. get touchAngularSensibility(): number;
  115519. set touchAngularSensibility(value: number);
  115520. /**
  115521. * Defines the touch sensibility for move.
  115522. * The higher the faster.
  115523. */
  115524. get touchMoveSensibility(): number;
  115525. set touchMoveSensibility(value: number);
  115526. /**
  115527. * Instantiates a new touch camera.
  115528. * This represents a FPS type of camera controlled by touch.
  115529. * This is like a universal camera minus the Gamepad controls.
  115530. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115531. * @param name Define the name of the camera in the scene
  115532. * @param position Define the start position of the camera in the scene
  115533. * @param scene Define the scene the camera belongs to
  115534. */
  115535. constructor(name: string, position: Vector3, scene: Scene);
  115536. /**
  115537. * Gets the current object class name.
  115538. * @return the class name
  115539. */
  115540. getClassName(): string;
  115541. /** @hidden */
  115542. _setupInputs(): void;
  115543. }
  115544. }
  115545. declare module BABYLON {
  115546. /**
  115547. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115548. * being tilted forward or back and left or right.
  115549. */
  115550. export class DeviceOrientationCamera extends FreeCamera {
  115551. private _initialQuaternion;
  115552. private _quaternionCache;
  115553. private _tmpDragQuaternion;
  115554. private _disablePointerInputWhenUsingDeviceOrientation;
  115555. /**
  115556. * Creates a new device orientation camera
  115557. * @param name The name of the camera
  115558. * @param position The start position camera
  115559. * @param scene The scene the camera belongs to
  115560. */
  115561. constructor(name: string, position: Vector3, scene: Scene);
  115562. /**
  115563. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115564. */
  115565. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115566. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115567. private _dragFactor;
  115568. /**
  115569. * Enabled turning on the y axis when the orientation sensor is active
  115570. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115571. */
  115572. enableHorizontalDragging(dragFactor?: number): void;
  115573. /**
  115574. * Gets the current instance class name ("DeviceOrientationCamera").
  115575. * This helps avoiding instanceof at run time.
  115576. * @returns the class name
  115577. */
  115578. getClassName(): string;
  115579. /**
  115580. * @hidden
  115581. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115582. */
  115583. _checkInputs(): void;
  115584. /**
  115585. * Reset the camera to its default orientation on the specified axis only.
  115586. * @param axis The axis to reset
  115587. */
  115588. resetToCurrentRotation(axis?: Axis): void;
  115589. }
  115590. }
  115591. declare module BABYLON {
  115592. /**
  115593. * Defines supported buttons for XBox360 compatible gamepads
  115594. */
  115595. export enum Xbox360Button {
  115596. /** A */
  115597. A = 0,
  115598. /** B */
  115599. B = 1,
  115600. /** X */
  115601. X = 2,
  115602. /** Y */
  115603. Y = 3,
  115604. /** Left button */
  115605. LB = 4,
  115606. /** Right button */
  115607. RB = 5,
  115608. /** Back */
  115609. Back = 8,
  115610. /** Start */
  115611. Start = 9,
  115612. /** Left stick */
  115613. LeftStick = 10,
  115614. /** Right stick */
  115615. RightStick = 11
  115616. }
  115617. /** Defines values for XBox360 DPad */
  115618. export enum Xbox360Dpad {
  115619. /** Up */
  115620. Up = 12,
  115621. /** Down */
  115622. Down = 13,
  115623. /** Left */
  115624. Left = 14,
  115625. /** Right */
  115626. Right = 15
  115627. }
  115628. /**
  115629. * Defines a XBox360 gamepad
  115630. */
  115631. export class Xbox360Pad extends Gamepad {
  115632. private _leftTrigger;
  115633. private _rightTrigger;
  115634. private _onlefttriggerchanged;
  115635. private _onrighttriggerchanged;
  115636. private _onbuttondown;
  115637. private _onbuttonup;
  115638. private _ondpaddown;
  115639. private _ondpadup;
  115640. /** Observable raised when a button is pressed */
  115641. onButtonDownObservable: Observable<Xbox360Button>;
  115642. /** Observable raised when a button is released */
  115643. onButtonUpObservable: Observable<Xbox360Button>;
  115644. /** Observable raised when a pad is pressed */
  115645. onPadDownObservable: Observable<Xbox360Dpad>;
  115646. /** Observable raised when a pad is released */
  115647. onPadUpObservable: Observable<Xbox360Dpad>;
  115648. private _buttonA;
  115649. private _buttonB;
  115650. private _buttonX;
  115651. private _buttonY;
  115652. private _buttonBack;
  115653. private _buttonStart;
  115654. private _buttonLB;
  115655. private _buttonRB;
  115656. private _buttonLeftStick;
  115657. private _buttonRightStick;
  115658. private _dPadUp;
  115659. private _dPadDown;
  115660. private _dPadLeft;
  115661. private _dPadRight;
  115662. private _isXboxOnePad;
  115663. /**
  115664. * Creates a new XBox360 gamepad object
  115665. * @param id defines the id of this gamepad
  115666. * @param index defines its index
  115667. * @param gamepad defines the internal HTML gamepad object
  115668. * @param xboxOne defines if it is a XBox One gamepad
  115669. */
  115670. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115671. /**
  115672. * Defines the callback to call when left trigger is pressed
  115673. * @param callback defines the callback to use
  115674. */
  115675. onlefttriggerchanged(callback: (value: number) => void): void;
  115676. /**
  115677. * Defines the callback to call when right trigger is pressed
  115678. * @param callback defines the callback to use
  115679. */
  115680. onrighttriggerchanged(callback: (value: number) => void): void;
  115681. /**
  115682. * Gets the left trigger value
  115683. */
  115684. get leftTrigger(): number;
  115685. /**
  115686. * Sets the left trigger value
  115687. */
  115688. set leftTrigger(newValue: number);
  115689. /**
  115690. * Gets the right trigger value
  115691. */
  115692. get rightTrigger(): number;
  115693. /**
  115694. * Sets the right trigger value
  115695. */
  115696. set rightTrigger(newValue: number);
  115697. /**
  115698. * Defines the callback to call when a button is pressed
  115699. * @param callback defines the callback to use
  115700. */
  115701. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115702. /**
  115703. * Defines the callback to call when a button is released
  115704. * @param callback defines the callback to use
  115705. */
  115706. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115707. /**
  115708. * Defines the callback to call when a pad is pressed
  115709. * @param callback defines the callback to use
  115710. */
  115711. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115712. /**
  115713. * Defines the callback to call when a pad is released
  115714. * @param callback defines the callback to use
  115715. */
  115716. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115717. private _setButtonValue;
  115718. private _setDPadValue;
  115719. /**
  115720. * Gets the value of the `A` button
  115721. */
  115722. get buttonA(): number;
  115723. /**
  115724. * Sets the value of the `A` button
  115725. */
  115726. set buttonA(value: number);
  115727. /**
  115728. * Gets the value of the `B` button
  115729. */
  115730. get buttonB(): number;
  115731. /**
  115732. * Sets the value of the `B` button
  115733. */
  115734. set buttonB(value: number);
  115735. /**
  115736. * Gets the value of the `X` button
  115737. */
  115738. get buttonX(): number;
  115739. /**
  115740. * Sets the value of the `X` button
  115741. */
  115742. set buttonX(value: number);
  115743. /**
  115744. * Gets the value of the `Y` button
  115745. */
  115746. get buttonY(): number;
  115747. /**
  115748. * Sets the value of the `Y` button
  115749. */
  115750. set buttonY(value: number);
  115751. /**
  115752. * Gets the value of the `Start` button
  115753. */
  115754. get buttonStart(): number;
  115755. /**
  115756. * Sets the value of the `Start` button
  115757. */
  115758. set buttonStart(value: number);
  115759. /**
  115760. * Gets the value of the `Back` button
  115761. */
  115762. get buttonBack(): number;
  115763. /**
  115764. * Sets the value of the `Back` button
  115765. */
  115766. set buttonBack(value: number);
  115767. /**
  115768. * Gets the value of the `Left` button
  115769. */
  115770. get buttonLB(): number;
  115771. /**
  115772. * Sets the value of the `Left` button
  115773. */
  115774. set buttonLB(value: number);
  115775. /**
  115776. * Gets the value of the `Right` button
  115777. */
  115778. get buttonRB(): number;
  115779. /**
  115780. * Sets the value of the `Right` button
  115781. */
  115782. set buttonRB(value: number);
  115783. /**
  115784. * Gets the value of the Left joystick
  115785. */
  115786. get buttonLeftStick(): number;
  115787. /**
  115788. * Sets the value of the Left joystick
  115789. */
  115790. set buttonLeftStick(value: number);
  115791. /**
  115792. * Gets the value of the Right joystick
  115793. */
  115794. get buttonRightStick(): number;
  115795. /**
  115796. * Sets the value of the Right joystick
  115797. */
  115798. set buttonRightStick(value: number);
  115799. /**
  115800. * Gets the value of D-pad up
  115801. */
  115802. get dPadUp(): number;
  115803. /**
  115804. * Sets the value of D-pad up
  115805. */
  115806. set dPadUp(value: number);
  115807. /**
  115808. * Gets the value of D-pad down
  115809. */
  115810. get dPadDown(): number;
  115811. /**
  115812. * Sets the value of D-pad down
  115813. */
  115814. set dPadDown(value: number);
  115815. /**
  115816. * Gets the value of D-pad left
  115817. */
  115818. get dPadLeft(): number;
  115819. /**
  115820. * Sets the value of D-pad left
  115821. */
  115822. set dPadLeft(value: number);
  115823. /**
  115824. * Gets the value of D-pad right
  115825. */
  115826. get dPadRight(): number;
  115827. /**
  115828. * Sets the value of D-pad right
  115829. */
  115830. set dPadRight(value: number);
  115831. /**
  115832. * Force the gamepad to synchronize with device values
  115833. */
  115834. update(): void;
  115835. /**
  115836. * Disposes the gamepad
  115837. */
  115838. dispose(): void;
  115839. }
  115840. }
  115841. declare module BABYLON {
  115842. /**
  115843. * Defines supported buttons for DualShock compatible gamepads
  115844. */
  115845. export enum DualShockButton {
  115846. /** Cross */
  115847. Cross = 0,
  115848. /** Circle */
  115849. Circle = 1,
  115850. /** Square */
  115851. Square = 2,
  115852. /** Triangle */
  115853. Triangle = 3,
  115854. /** L1 */
  115855. L1 = 4,
  115856. /** R1 */
  115857. R1 = 5,
  115858. /** Share */
  115859. Share = 8,
  115860. /** Options */
  115861. Options = 9,
  115862. /** Left stick */
  115863. LeftStick = 10,
  115864. /** Right stick */
  115865. RightStick = 11
  115866. }
  115867. /** Defines values for DualShock DPad */
  115868. export enum DualShockDpad {
  115869. /** Up */
  115870. Up = 12,
  115871. /** Down */
  115872. Down = 13,
  115873. /** Left */
  115874. Left = 14,
  115875. /** Right */
  115876. Right = 15
  115877. }
  115878. /**
  115879. * Defines a DualShock gamepad
  115880. */
  115881. export class DualShockPad extends Gamepad {
  115882. private _leftTrigger;
  115883. private _rightTrigger;
  115884. private _onlefttriggerchanged;
  115885. private _onrighttriggerchanged;
  115886. private _onbuttondown;
  115887. private _onbuttonup;
  115888. private _ondpaddown;
  115889. private _ondpadup;
  115890. /** Observable raised when a button is pressed */
  115891. onButtonDownObservable: Observable<DualShockButton>;
  115892. /** Observable raised when a button is released */
  115893. onButtonUpObservable: Observable<DualShockButton>;
  115894. /** Observable raised when a pad is pressed */
  115895. onPadDownObservable: Observable<DualShockDpad>;
  115896. /** Observable raised when a pad is released */
  115897. onPadUpObservable: Observable<DualShockDpad>;
  115898. private _buttonCross;
  115899. private _buttonCircle;
  115900. private _buttonSquare;
  115901. private _buttonTriangle;
  115902. private _buttonShare;
  115903. private _buttonOptions;
  115904. private _buttonL1;
  115905. private _buttonR1;
  115906. private _buttonLeftStick;
  115907. private _buttonRightStick;
  115908. private _dPadUp;
  115909. private _dPadDown;
  115910. private _dPadLeft;
  115911. private _dPadRight;
  115912. /**
  115913. * Creates a new DualShock gamepad object
  115914. * @param id defines the id of this gamepad
  115915. * @param index defines its index
  115916. * @param gamepad defines the internal HTML gamepad object
  115917. */
  115918. constructor(id: string, index: number, gamepad: any);
  115919. /**
  115920. * Defines the callback to call when left trigger is pressed
  115921. * @param callback defines the callback to use
  115922. */
  115923. onlefttriggerchanged(callback: (value: number) => void): void;
  115924. /**
  115925. * Defines the callback to call when right trigger is pressed
  115926. * @param callback defines the callback to use
  115927. */
  115928. onrighttriggerchanged(callback: (value: number) => void): void;
  115929. /**
  115930. * Gets the left trigger value
  115931. */
  115932. get leftTrigger(): number;
  115933. /**
  115934. * Sets the left trigger value
  115935. */
  115936. set leftTrigger(newValue: number);
  115937. /**
  115938. * Gets the right trigger value
  115939. */
  115940. get rightTrigger(): number;
  115941. /**
  115942. * Sets the right trigger value
  115943. */
  115944. set rightTrigger(newValue: number);
  115945. /**
  115946. * Defines the callback to call when a button is pressed
  115947. * @param callback defines the callback to use
  115948. */
  115949. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115950. /**
  115951. * Defines the callback to call when a button is released
  115952. * @param callback defines the callback to use
  115953. */
  115954. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115955. /**
  115956. * Defines the callback to call when a pad is pressed
  115957. * @param callback defines the callback to use
  115958. */
  115959. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115960. /**
  115961. * Defines the callback to call when a pad is released
  115962. * @param callback defines the callback to use
  115963. */
  115964. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115965. private _setButtonValue;
  115966. private _setDPadValue;
  115967. /**
  115968. * Gets the value of the `Cross` button
  115969. */
  115970. get buttonCross(): number;
  115971. /**
  115972. * Sets the value of the `Cross` button
  115973. */
  115974. set buttonCross(value: number);
  115975. /**
  115976. * Gets the value of the `Circle` button
  115977. */
  115978. get buttonCircle(): number;
  115979. /**
  115980. * Sets the value of the `Circle` button
  115981. */
  115982. set buttonCircle(value: number);
  115983. /**
  115984. * Gets the value of the `Square` button
  115985. */
  115986. get buttonSquare(): number;
  115987. /**
  115988. * Sets the value of the `Square` button
  115989. */
  115990. set buttonSquare(value: number);
  115991. /**
  115992. * Gets the value of the `Triangle` button
  115993. */
  115994. get buttonTriangle(): number;
  115995. /**
  115996. * Sets the value of the `Triangle` button
  115997. */
  115998. set buttonTriangle(value: number);
  115999. /**
  116000. * Gets the value of the `Options` button
  116001. */
  116002. get buttonOptions(): number;
  116003. /**
  116004. * Sets the value of the `Options` button
  116005. */
  116006. set buttonOptions(value: number);
  116007. /**
  116008. * Gets the value of the `Share` button
  116009. */
  116010. get buttonShare(): number;
  116011. /**
  116012. * Sets the value of the `Share` button
  116013. */
  116014. set buttonShare(value: number);
  116015. /**
  116016. * Gets the value of the `L1` button
  116017. */
  116018. get buttonL1(): number;
  116019. /**
  116020. * Sets the value of the `L1` button
  116021. */
  116022. set buttonL1(value: number);
  116023. /**
  116024. * Gets the value of the `R1` button
  116025. */
  116026. get buttonR1(): number;
  116027. /**
  116028. * Sets the value of the `R1` button
  116029. */
  116030. set buttonR1(value: number);
  116031. /**
  116032. * Gets the value of the Left joystick
  116033. */
  116034. get buttonLeftStick(): number;
  116035. /**
  116036. * Sets the value of the Left joystick
  116037. */
  116038. set buttonLeftStick(value: number);
  116039. /**
  116040. * Gets the value of the Right joystick
  116041. */
  116042. get buttonRightStick(): number;
  116043. /**
  116044. * Sets the value of the Right joystick
  116045. */
  116046. set buttonRightStick(value: number);
  116047. /**
  116048. * Gets the value of D-pad up
  116049. */
  116050. get dPadUp(): number;
  116051. /**
  116052. * Sets the value of D-pad up
  116053. */
  116054. set dPadUp(value: number);
  116055. /**
  116056. * Gets the value of D-pad down
  116057. */
  116058. get dPadDown(): number;
  116059. /**
  116060. * Sets the value of D-pad down
  116061. */
  116062. set dPadDown(value: number);
  116063. /**
  116064. * Gets the value of D-pad left
  116065. */
  116066. get dPadLeft(): number;
  116067. /**
  116068. * Sets the value of D-pad left
  116069. */
  116070. set dPadLeft(value: number);
  116071. /**
  116072. * Gets the value of D-pad right
  116073. */
  116074. get dPadRight(): number;
  116075. /**
  116076. * Sets the value of D-pad right
  116077. */
  116078. set dPadRight(value: number);
  116079. /**
  116080. * Force the gamepad to synchronize with device values
  116081. */
  116082. update(): void;
  116083. /**
  116084. * Disposes the gamepad
  116085. */
  116086. dispose(): void;
  116087. }
  116088. }
  116089. declare module BABYLON {
  116090. /**
  116091. * Manager for handling gamepads
  116092. */
  116093. export class GamepadManager {
  116094. private _scene?;
  116095. private _babylonGamepads;
  116096. private _oneGamepadConnected;
  116097. /** @hidden */
  116098. _isMonitoring: boolean;
  116099. private _gamepadEventSupported;
  116100. private _gamepadSupport?;
  116101. /**
  116102. * observable to be triggered when the gamepad controller has been connected
  116103. */
  116104. onGamepadConnectedObservable: Observable<Gamepad>;
  116105. /**
  116106. * observable to be triggered when the gamepad controller has been disconnected
  116107. */
  116108. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116109. private _onGamepadConnectedEvent;
  116110. private _onGamepadDisconnectedEvent;
  116111. /**
  116112. * Initializes the gamepad manager
  116113. * @param _scene BabylonJS scene
  116114. */
  116115. constructor(_scene?: Scene | undefined);
  116116. /**
  116117. * The gamepads in the game pad manager
  116118. */
  116119. get gamepads(): Gamepad[];
  116120. /**
  116121. * Get the gamepad controllers based on type
  116122. * @param type The type of gamepad controller
  116123. * @returns Nullable gamepad
  116124. */
  116125. getGamepadByType(type?: number): Nullable<Gamepad>;
  116126. /**
  116127. * Disposes the gamepad manager
  116128. */
  116129. dispose(): void;
  116130. private _addNewGamepad;
  116131. private _startMonitoringGamepads;
  116132. private _stopMonitoringGamepads;
  116133. /** @hidden */
  116134. _checkGamepadsStatus(): void;
  116135. private _updateGamepadObjects;
  116136. }
  116137. }
  116138. declare module BABYLON {
  116139. interface Scene {
  116140. /** @hidden */
  116141. _gamepadManager: Nullable<GamepadManager>;
  116142. /**
  116143. * Gets the gamepad manager associated with the scene
  116144. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116145. */
  116146. gamepadManager: GamepadManager;
  116147. }
  116148. /**
  116149. * Interface representing a free camera inputs manager
  116150. */
  116151. interface FreeCameraInputsManager {
  116152. /**
  116153. * Adds gamepad input support to the FreeCameraInputsManager.
  116154. * @returns the FreeCameraInputsManager
  116155. */
  116156. addGamepad(): FreeCameraInputsManager;
  116157. }
  116158. /**
  116159. * Interface representing an arc rotate camera inputs manager
  116160. */
  116161. interface ArcRotateCameraInputsManager {
  116162. /**
  116163. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116164. * @returns the camera inputs manager
  116165. */
  116166. addGamepad(): ArcRotateCameraInputsManager;
  116167. }
  116168. /**
  116169. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116170. */
  116171. export class GamepadSystemSceneComponent implements ISceneComponent {
  116172. /**
  116173. * The component name helpfull to identify the component in the list of scene components.
  116174. */
  116175. readonly name: string;
  116176. /**
  116177. * The scene the component belongs to.
  116178. */
  116179. scene: Scene;
  116180. /**
  116181. * Creates a new instance of the component for the given scene
  116182. * @param scene Defines the scene to register the component in
  116183. */
  116184. constructor(scene: Scene);
  116185. /**
  116186. * Registers the component in a given scene
  116187. */
  116188. register(): void;
  116189. /**
  116190. * Rebuilds the elements related to this component in case of
  116191. * context lost for instance.
  116192. */
  116193. rebuild(): void;
  116194. /**
  116195. * Disposes the component and the associated ressources
  116196. */
  116197. dispose(): void;
  116198. private _beforeCameraUpdate;
  116199. }
  116200. }
  116201. declare module BABYLON {
  116202. /**
  116203. * 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,
  116204. * which still works and will still be found in many Playgrounds.
  116205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116206. */
  116207. export class UniversalCamera extends TouchCamera {
  116208. /**
  116209. * Defines the gamepad rotation sensiblity.
  116210. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116211. */
  116212. get gamepadAngularSensibility(): number;
  116213. set gamepadAngularSensibility(value: number);
  116214. /**
  116215. * Defines the gamepad move sensiblity.
  116216. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116217. */
  116218. get gamepadMoveSensibility(): number;
  116219. set gamepadMoveSensibility(value: number);
  116220. /**
  116221. * 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,
  116222. * which still works and will still be found in many Playgrounds.
  116223. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116224. * @param name Define the name of the camera in the scene
  116225. * @param position Define the start position of the camera in the scene
  116226. * @param scene Define the scene the camera belongs to
  116227. */
  116228. constructor(name: string, position: Vector3, scene: Scene);
  116229. /**
  116230. * Gets the current object class name.
  116231. * @return the class name
  116232. */
  116233. getClassName(): string;
  116234. }
  116235. }
  116236. declare module BABYLON {
  116237. /**
  116238. * This represents a FPS type of camera. This is only here for back compat purpose.
  116239. * Please use the UniversalCamera instead as both are identical.
  116240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116241. */
  116242. export class GamepadCamera extends UniversalCamera {
  116243. /**
  116244. * Instantiates a new Gamepad Camera
  116245. * This represents a FPS type of camera. This is only here for back compat purpose.
  116246. * Please use the UniversalCamera instead as both are identical.
  116247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116248. * @param name Define the name of the camera in the scene
  116249. * @param position Define the start position of the camera in the scene
  116250. * @param scene Define the scene the camera belongs to
  116251. */
  116252. constructor(name: string, position: Vector3, scene: Scene);
  116253. /**
  116254. * Gets the current object class name.
  116255. * @return the class name
  116256. */
  116257. getClassName(): string;
  116258. }
  116259. }
  116260. declare module BABYLON {
  116261. /** @hidden */
  116262. export var passPixelShader: {
  116263. name: string;
  116264. shader: string;
  116265. };
  116266. }
  116267. declare module BABYLON {
  116268. /** @hidden */
  116269. export var passCubePixelShader: {
  116270. name: string;
  116271. shader: string;
  116272. };
  116273. }
  116274. declare module BABYLON {
  116275. /**
  116276. * PassPostProcess which produces an output the same as it's input
  116277. */
  116278. export class PassPostProcess extends PostProcess {
  116279. /**
  116280. * Creates the PassPostProcess
  116281. * @param name The name of the effect.
  116282. * @param options The required width/height ratio to downsize to before computing the render pass.
  116283. * @param camera The camera to apply the render pass to.
  116284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116285. * @param engine The engine which the post process will be applied. (default: current engine)
  116286. * @param reusable If the post process can be reused on the same frame. (default: false)
  116287. * @param textureType The type of texture to be used when performing the post processing.
  116288. * @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)
  116289. */
  116290. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116291. }
  116292. /**
  116293. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116294. */
  116295. export class PassCubePostProcess extends PostProcess {
  116296. private _face;
  116297. /**
  116298. * Gets or sets the cube face to display.
  116299. * * 0 is +X
  116300. * * 1 is -X
  116301. * * 2 is +Y
  116302. * * 3 is -Y
  116303. * * 4 is +Z
  116304. * * 5 is -Z
  116305. */
  116306. get face(): number;
  116307. set face(value: number);
  116308. /**
  116309. * Creates the PassCubePostProcess
  116310. * @param name The name of the effect.
  116311. * @param options The required width/height ratio to downsize to before computing the render pass.
  116312. * @param camera The camera to apply the render pass to.
  116313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116314. * @param engine The engine which the post process will be applied. (default: current engine)
  116315. * @param reusable If the post process can be reused on the same frame. (default: false)
  116316. * @param textureType The type of texture to be used when performing the post processing.
  116317. * @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)
  116318. */
  116319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116320. }
  116321. }
  116322. declare module BABYLON {
  116323. /** @hidden */
  116324. export var anaglyphPixelShader: {
  116325. name: string;
  116326. shader: string;
  116327. };
  116328. }
  116329. declare module BABYLON {
  116330. /**
  116331. * Postprocess used to generate anaglyphic rendering
  116332. */
  116333. export class AnaglyphPostProcess extends PostProcess {
  116334. private _passedProcess;
  116335. /**
  116336. * Creates a new AnaglyphPostProcess
  116337. * @param name defines postprocess name
  116338. * @param options defines creation options or target ratio scale
  116339. * @param rigCameras defines cameras using this postprocess
  116340. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116341. * @param engine defines hosting engine
  116342. * @param reusable defines if the postprocess will be reused multiple times per frame
  116343. */
  116344. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116345. }
  116346. }
  116347. declare module BABYLON {
  116348. /**
  116349. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116350. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116351. */
  116352. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116353. /**
  116354. * Creates a new AnaglyphArcRotateCamera
  116355. * @param name defines camera name
  116356. * @param alpha defines alpha angle (in radians)
  116357. * @param beta defines beta angle (in radians)
  116358. * @param radius defines radius
  116359. * @param target defines camera target
  116360. * @param interaxialDistance defines distance between each color axis
  116361. * @param scene defines the hosting scene
  116362. */
  116363. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116364. /**
  116365. * Gets camera class name
  116366. * @returns AnaglyphArcRotateCamera
  116367. */
  116368. getClassName(): string;
  116369. }
  116370. }
  116371. declare module BABYLON {
  116372. /**
  116373. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116374. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116375. */
  116376. export class AnaglyphFreeCamera extends FreeCamera {
  116377. /**
  116378. * Creates a new AnaglyphFreeCamera
  116379. * @param name defines camera name
  116380. * @param position defines initial position
  116381. * @param interaxialDistance defines distance between each color axis
  116382. * @param scene defines the hosting scene
  116383. */
  116384. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116385. /**
  116386. * Gets camera class name
  116387. * @returns AnaglyphFreeCamera
  116388. */
  116389. getClassName(): string;
  116390. }
  116391. }
  116392. declare module BABYLON {
  116393. /**
  116394. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116395. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116396. */
  116397. export class AnaglyphGamepadCamera extends GamepadCamera {
  116398. /**
  116399. * Creates a new AnaglyphGamepadCamera
  116400. * @param name defines camera name
  116401. * @param position defines initial position
  116402. * @param interaxialDistance defines distance between each color axis
  116403. * @param scene defines the hosting scene
  116404. */
  116405. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116406. /**
  116407. * Gets camera class name
  116408. * @returns AnaglyphGamepadCamera
  116409. */
  116410. getClassName(): string;
  116411. }
  116412. }
  116413. declare module BABYLON {
  116414. /**
  116415. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116416. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116417. */
  116418. export class AnaglyphUniversalCamera extends UniversalCamera {
  116419. /**
  116420. * Creates a new AnaglyphUniversalCamera
  116421. * @param name defines camera name
  116422. * @param position defines initial position
  116423. * @param interaxialDistance defines distance between each color axis
  116424. * @param scene defines the hosting scene
  116425. */
  116426. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116427. /**
  116428. * Gets camera class name
  116429. * @returns AnaglyphUniversalCamera
  116430. */
  116431. getClassName(): string;
  116432. }
  116433. }
  116434. declare module BABYLON {
  116435. /** @hidden */
  116436. export var stereoscopicInterlacePixelShader: {
  116437. name: string;
  116438. shader: string;
  116439. };
  116440. }
  116441. declare module BABYLON {
  116442. /**
  116443. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116444. */
  116445. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116446. private _stepSize;
  116447. private _passedProcess;
  116448. /**
  116449. * Initializes a StereoscopicInterlacePostProcessI
  116450. * @param name The name of the effect.
  116451. * @param rigCameras The rig cameras to be appled to the post process
  116452. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116453. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116455. * @param engine The engine which the post process will be applied. (default: current engine)
  116456. * @param reusable If the post process can be reused on the same frame. (default: false)
  116457. */
  116458. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116459. }
  116460. /**
  116461. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116462. */
  116463. export class StereoscopicInterlacePostProcess extends PostProcess {
  116464. private _stepSize;
  116465. private _passedProcess;
  116466. /**
  116467. * Initializes a StereoscopicInterlacePostProcess
  116468. * @param name The name of the effect.
  116469. * @param rigCameras The rig cameras to be appled to the post process
  116470. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116472. * @param engine The engine which the post process will be applied. (default: current engine)
  116473. * @param reusable If the post process can be reused on the same frame. (default: false)
  116474. */
  116475. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116476. }
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116481. * @see http://doc.babylonjs.com/features/cameras
  116482. */
  116483. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116484. /**
  116485. * Creates a new StereoscopicArcRotateCamera
  116486. * @param name defines camera name
  116487. * @param alpha defines alpha angle (in radians)
  116488. * @param beta defines beta angle (in radians)
  116489. * @param radius defines radius
  116490. * @param target defines camera target
  116491. * @param interaxialDistance defines distance between each color axis
  116492. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116493. * @param scene defines the hosting scene
  116494. */
  116495. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116496. /**
  116497. * Gets camera class name
  116498. * @returns StereoscopicArcRotateCamera
  116499. */
  116500. getClassName(): string;
  116501. }
  116502. }
  116503. declare module BABYLON {
  116504. /**
  116505. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116506. * @see http://doc.babylonjs.com/features/cameras
  116507. */
  116508. export class StereoscopicFreeCamera extends FreeCamera {
  116509. /**
  116510. * Creates a new StereoscopicFreeCamera
  116511. * @param name defines camera name
  116512. * @param position defines initial position
  116513. * @param interaxialDistance defines distance between each color axis
  116514. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116515. * @param scene defines the hosting scene
  116516. */
  116517. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116518. /**
  116519. * Gets camera class name
  116520. * @returns StereoscopicFreeCamera
  116521. */
  116522. getClassName(): string;
  116523. }
  116524. }
  116525. declare module BABYLON {
  116526. /**
  116527. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116528. * @see http://doc.babylonjs.com/features/cameras
  116529. */
  116530. export class StereoscopicGamepadCamera extends GamepadCamera {
  116531. /**
  116532. * Creates a new StereoscopicGamepadCamera
  116533. * @param name defines camera name
  116534. * @param position defines initial position
  116535. * @param interaxialDistance defines distance between each color axis
  116536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116537. * @param scene defines the hosting scene
  116538. */
  116539. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116540. /**
  116541. * Gets camera class name
  116542. * @returns StereoscopicGamepadCamera
  116543. */
  116544. getClassName(): string;
  116545. }
  116546. }
  116547. declare module BABYLON {
  116548. /**
  116549. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116550. * @see http://doc.babylonjs.com/features/cameras
  116551. */
  116552. export class StereoscopicUniversalCamera extends UniversalCamera {
  116553. /**
  116554. * Creates a new StereoscopicUniversalCamera
  116555. * @param name defines camera name
  116556. * @param position defines initial position
  116557. * @param interaxialDistance defines distance between each color axis
  116558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116559. * @param scene defines the hosting scene
  116560. */
  116561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116562. /**
  116563. * Gets camera class name
  116564. * @returns StereoscopicUniversalCamera
  116565. */
  116566. getClassName(): string;
  116567. }
  116568. }
  116569. declare module BABYLON {
  116570. /**
  116571. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116572. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116573. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116574. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116575. */
  116576. export class VirtualJoysticksCamera extends FreeCamera {
  116577. /**
  116578. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116579. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116580. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116581. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116582. * @param name Define the name of the camera in the scene
  116583. * @param position Define the start position of the camera in the scene
  116584. * @param scene Define the scene the camera belongs to
  116585. */
  116586. constructor(name: string, position: Vector3, scene: Scene);
  116587. /**
  116588. * Gets the current object class name.
  116589. * @return the class name
  116590. */
  116591. getClassName(): string;
  116592. }
  116593. }
  116594. declare module BABYLON {
  116595. /**
  116596. * This represents all the required metrics to create a VR camera.
  116597. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116598. */
  116599. export class VRCameraMetrics {
  116600. /**
  116601. * Define the horizontal resolution off the screen.
  116602. */
  116603. hResolution: number;
  116604. /**
  116605. * Define the vertical resolution off the screen.
  116606. */
  116607. vResolution: number;
  116608. /**
  116609. * Define the horizontal screen size.
  116610. */
  116611. hScreenSize: number;
  116612. /**
  116613. * Define the vertical screen size.
  116614. */
  116615. vScreenSize: number;
  116616. /**
  116617. * Define the vertical screen center position.
  116618. */
  116619. vScreenCenter: number;
  116620. /**
  116621. * Define the distance of the eyes to the screen.
  116622. */
  116623. eyeToScreenDistance: number;
  116624. /**
  116625. * Define the distance between both lenses
  116626. */
  116627. lensSeparationDistance: number;
  116628. /**
  116629. * Define the distance between both viewer's eyes.
  116630. */
  116631. interpupillaryDistance: number;
  116632. /**
  116633. * Define the distortion factor of the VR postprocess.
  116634. * Please, touch with care.
  116635. */
  116636. distortionK: number[];
  116637. /**
  116638. * Define the chromatic aberration correction factors for the VR post process.
  116639. */
  116640. chromaAbCorrection: number[];
  116641. /**
  116642. * Define the scale factor of the post process.
  116643. * The smaller the better but the slower.
  116644. */
  116645. postProcessScaleFactor: number;
  116646. /**
  116647. * Define an offset for the lens center.
  116648. */
  116649. lensCenterOffset: number;
  116650. /**
  116651. * Define if the current vr camera should compensate the distortion of the lense or not.
  116652. */
  116653. compensateDistortion: boolean;
  116654. /**
  116655. * Defines if multiview should be enabled when rendering (Default: false)
  116656. */
  116657. multiviewEnabled: boolean;
  116658. /**
  116659. * Gets the rendering aspect ratio based on the provided resolutions.
  116660. */
  116661. get aspectRatio(): number;
  116662. /**
  116663. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116664. */
  116665. get aspectRatioFov(): number;
  116666. /**
  116667. * @hidden
  116668. */
  116669. get leftHMatrix(): Matrix;
  116670. /**
  116671. * @hidden
  116672. */
  116673. get rightHMatrix(): Matrix;
  116674. /**
  116675. * @hidden
  116676. */
  116677. get leftPreViewMatrix(): Matrix;
  116678. /**
  116679. * @hidden
  116680. */
  116681. get rightPreViewMatrix(): Matrix;
  116682. /**
  116683. * Get the default VRMetrics based on the most generic setup.
  116684. * @returns the default vr metrics
  116685. */
  116686. static GetDefault(): VRCameraMetrics;
  116687. }
  116688. }
  116689. declare module BABYLON {
  116690. /** @hidden */
  116691. export var vrDistortionCorrectionPixelShader: {
  116692. name: string;
  116693. shader: string;
  116694. };
  116695. }
  116696. declare module BABYLON {
  116697. /**
  116698. * VRDistortionCorrectionPostProcess used for mobile VR
  116699. */
  116700. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116701. private _isRightEye;
  116702. private _distortionFactors;
  116703. private _postProcessScaleFactor;
  116704. private _lensCenterOffset;
  116705. private _scaleIn;
  116706. private _scaleFactor;
  116707. private _lensCenter;
  116708. /**
  116709. * Initializes the VRDistortionCorrectionPostProcess
  116710. * @param name The name of the effect.
  116711. * @param camera The camera to apply the render pass to.
  116712. * @param isRightEye If this is for the right eye distortion
  116713. * @param vrMetrics All the required metrics for the VR camera
  116714. */
  116715. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116716. }
  116717. }
  116718. declare module BABYLON {
  116719. /**
  116720. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116721. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116722. */
  116723. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116724. /**
  116725. * Creates a new VRDeviceOrientationArcRotateCamera
  116726. * @param name defines camera name
  116727. * @param alpha defines the camera rotation along the logitudinal axis
  116728. * @param beta defines the camera rotation along the latitudinal axis
  116729. * @param radius defines the camera distance from its target
  116730. * @param target defines the camera target
  116731. * @param scene defines the scene the camera belongs to
  116732. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116733. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116734. */
  116735. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116736. /**
  116737. * Gets camera class name
  116738. * @returns VRDeviceOrientationArcRotateCamera
  116739. */
  116740. getClassName(): string;
  116741. }
  116742. }
  116743. declare module BABYLON {
  116744. /**
  116745. * Camera used to simulate VR rendering (based on FreeCamera)
  116746. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116747. */
  116748. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116749. /**
  116750. * Creates a new VRDeviceOrientationFreeCamera
  116751. * @param name defines camera name
  116752. * @param position defines the start position of the camera
  116753. * @param scene defines the scene the camera belongs to
  116754. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116755. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116756. */
  116757. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116758. /**
  116759. * Gets camera class name
  116760. * @returns VRDeviceOrientationFreeCamera
  116761. */
  116762. getClassName(): string;
  116763. }
  116764. }
  116765. declare module BABYLON {
  116766. /**
  116767. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116768. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116769. */
  116770. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116771. /**
  116772. * Creates a new VRDeviceOrientationGamepadCamera
  116773. * @param name defines camera name
  116774. * @param position defines the start position of the camera
  116775. * @param scene defines the scene the camera belongs to
  116776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116778. */
  116779. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116780. /**
  116781. * Gets camera class name
  116782. * @returns VRDeviceOrientationGamepadCamera
  116783. */
  116784. getClassName(): string;
  116785. }
  116786. }
  116787. declare module BABYLON {
  116788. /** @hidden */
  116789. export var imageProcessingPixelShader: {
  116790. name: string;
  116791. shader: string;
  116792. };
  116793. }
  116794. declare module BABYLON {
  116795. /**
  116796. * ImageProcessingPostProcess
  116797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116798. */
  116799. export class ImageProcessingPostProcess extends PostProcess {
  116800. /**
  116801. * Default configuration related to image processing available in the PBR Material.
  116802. */
  116803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116804. /**
  116805. * Gets the image processing configuration used either in this material.
  116806. */
  116807. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116808. /**
  116809. * Sets the Default image processing configuration used either in the this material.
  116810. *
  116811. * If sets to null, the scene one is in use.
  116812. */
  116813. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116814. /**
  116815. * Keep track of the image processing observer to allow dispose and replace.
  116816. */
  116817. private _imageProcessingObserver;
  116818. /**
  116819. * Attaches a new image processing configuration to the PBR Material.
  116820. * @param configuration
  116821. */
  116822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116823. /**
  116824. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116825. */
  116826. get colorCurves(): Nullable<ColorCurves>;
  116827. /**
  116828. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116829. */
  116830. set colorCurves(value: Nullable<ColorCurves>);
  116831. /**
  116832. * Gets wether the color curves effect is enabled.
  116833. */
  116834. get colorCurvesEnabled(): boolean;
  116835. /**
  116836. * Sets wether the color curves effect is enabled.
  116837. */
  116838. set colorCurvesEnabled(value: boolean);
  116839. /**
  116840. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116841. */
  116842. get colorGradingTexture(): Nullable<BaseTexture>;
  116843. /**
  116844. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116845. */
  116846. set colorGradingTexture(value: Nullable<BaseTexture>);
  116847. /**
  116848. * Gets wether the color grading effect is enabled.
  116849. */
  116850. get colorGradingEnabled(): boolean;
  116851. /**
  116852. * Gets wether the color grading effect is enabled.
  116853. */
  116854. set colorGradingEnabled(value: boolean);
  116855. /**
  116856. * Gets exposure used in the effect.
  116857. */
  116858. get exposure(): number;
  116859. /**
  116860. * Sets exposure used in the effect.
  116861. */
  116862. set exposure(value: number);
  116863. /**
  116864. * Gets wether tonemapping is enabled or not.
  116865. */
  116866. get toneMappingEnabled(): boolean;
  116867. /**
  116868. * Sets wether tonemapping is enabled or not
  116869. */
  116870. set toneMappingEnabled(value: boolean);
  116871. /**
  116872. * Gets the type of tone mapping effect.
  116873. */
  116874. get toneMappingType(): number;
  116875. /**
  116876. * Sets the type of tone mapping effect.
  116877. */
  116878. set toneMappingType(value: number);
  116879. /**
  116880. * Gets contrast used in the effect.
  116881. */
  116882. get contrast(): number;
  116883. /**
  116884. * Sets contrast used in the effect.
  116885. */
  116886. set contrast(value: number);
  116887. /**
  116888. * Gets Vignette stretch size.
  116889. */
  116890. get vignetteStretch(): number;
  116891. /**
  116892. * Sets Vignette stretch size.
  116893. */
  116894. set vignetteStretch(value: number);
  116895. /**
  116896. * Gets Vignette centre X Offset.
  116897. */
  116898. get vignetteCentreX(): number;
  116899. /**
  116900. * Sets Vignette centre X Offset.
  116901. */
  116902. set vignetteCentreX(value: number);
  116903. /**
  116904. * Gets Vignette centre Y Offset.
  116905. */
  116906. get vignetteCentreY(): number;
  116907. /**
  116908. * Sets Vignette centre Y Offset.
  116909. */
  116910. set vignetteCentreY(value: number);
  116911. /**
  116912. * Gets Vignette weight or intensity of the vignette effect.
  116913. */
  116914. get vignetteWeight(): number;
  116915. /**
  116916. * Sets Vignette weight or intensity of the vignette effect.
  116917. */
  116918. set vignetteWeight(value: number);
  116919. /**
  116920. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116921. * if vignetteEnabled is set to true.
  116922. */
  116923. get vignetteColor(): Color4;
  116924. /**
  116925. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116926. * if vignetteEnabled is set to true.
  116927. */
  116928. set vignetteColor(value: Color4);
  116929. /**
  116930. * Gets Camera field of view used by the Vignette effect.
  116931. */
  116932. get vignetteCameraFov(): number;
  116933. /**
  116934. * Sets Camera field of view used by the Vignette effect.
  116935. */
  116936. set vignetteCameraFov(value: number);
  116937. /**
  116938. * Gets the vignette blend mode allowing different kind of effect.
  116939. */
  116940. get vignetteBlendMode(): number;
  116941. /**
  116942. * Sets the vignette blend mode allowing different kind of effect.
  116943. */
  116944. set vignetteBlendMode(value: number);
  116945. /**
  116946. * Gets wether the vignette effect is enabled.
  116947. */
  116948. get vignetteEnabled(): boolean;
  116949. /**
  116950. * Sets wether the vignette effect is enabled.
  116951. */
  116952. set vignetteEnabled(value: boolean);
  116953. private _fromLinearSpace;
  116954. /**
  116955. * Gets wether the input of the processing is in Gamma or Linear Space.
  116956. */
  116957. get fromLinearSpace(): boolean;
  116958. /**
  116959. * Sets wether the input of the processing is in Gamma or Linear Space.
  116960. */
  116961. set fromLinearSpace(value: boolean);
  116962. /**
  116963. * Defines cache preventing GC.
  116964. */
  116965. private _defines;
  116966. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116967. /**
  116968. * "ImageProcessingPostProcess"
  116969. * @returns "ImageProcessingPostProcess"
  116970. */
  116971. getClassName(): string;
  116972. protected _updateParameters(): void;
  116973. dispose(camera?: Camera): void;
  116974. }
  116975. }
  116976. declare module BABYLON {
  116977. /**
  116978. * Class containing static functions to help procedurally build meshes
  116979. */
  116980. export class GroundBuilder {
  116981. /**
  116982. * Creates a ground mesh
  116983. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116984. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116986. * @param name defines the name of the mesh
  116987. * @param options defines the options used to create the mesh
  116988. * @param scene defines the hosting scene
  116989. * @returns the ground mesh
  116990. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116991. */
  116992. static CreateGround(name: string, options: {
  116993. width?: number;
  116994. height?: number;
  116995. subdivisions?: number;
  116996. subdivisionsX?: number;
  116997. subdivisionsY?: number;
  116998. updatable?: boolean;
  116999. }, scene: any): Mesh;
  117000. /**
  117001. * Creates a tiled ground mesh
  117002. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117003. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117004. * * 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
  117005. * * 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
  117006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117007. * @param name defines the name of the mesh
  117008. * @param options defines the options used to create the mesh
  117009. * @param scene defines the hosting scene
  117010. * @returns the tiled ground mesh
  117011. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117012. */
  117013. static CreateTiledGround(name: string, options: {
  117014. xmin: number;
  117015. zmin: number;
  117016. xmax: number;
  117017. zmax: number;
  117018. subdivisions?: {
  117019. w: number;
  117020. h: number;
  117021. };
  117022. precision?: {
  117023. w: number;
  117024. h: number;
  117025. };
  117026. updatable?: boolean;
  117027. }, scene?: Nullable<Scene>): Mesh;
  117028. /**
  117029. * Creates a ground mesh from a height map
  117030. * * The parameter `url` sets the URL of the height map image resource.
  117031. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117032. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117033. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117034. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117035. * * 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.
  117036. * * 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).
  117037. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117039. * @param name defines the name of the mesh
  117040. * @param url defines the url to the height map
  117041. * @param options defines the options used to create the mesh
  117042. * @param scene defines the hosting scene
  117043. * @returns the ground mesh
  117044. * @see https://doc.babylonjs.com/babylon101/height_map
  117045. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117046. */
  117047. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117048. width?: number;
  117049. height?: number;
  117050. subdivisions?: number;
  117051. minHeight?: number;
  117052. maxHeight?: number;
  117053. colorFilter?: Color3;
  117054. alphaFilter?: number;
  117055. updatable?: boolean;
  117056. onReady?: (mesh: GroundMesh) => void;
  117057. }, scene?: Nullable<Scene>): GroundMesh;
  117058. }
  117059. }
  117060. declare module BABYLON {
  117061. /**
  117062. * Class containing static functions to help procedurally build meshes
  117063. */
  117064. export class TorusBuilder {
  117065. /**
  117066. * Creates a torus mesh
  117067. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117068. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117069. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117073. * @param name defines the name of the mesh
  117074. * @param options defines the options used to create the mesh
  117075. * @param scene defines the hosting scene
  117076. * @returns the torus mesh
  117077. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117078. */
  117079. static CreateTorus(name: string, options: {
  117080. diameter?: number;
  117081. thickness?: number;
  117082. tessellation?: number;
  117083. updatable?: boolean;
  117084. sideOrientation?: number;
  117085. frontUVs?: Vector4;
  117086. backUVs?: Vector4;
  117087. }, scene: any): Mesh;
  117088. }
  117089. }
  117090. declare module BABYLON {
  117091. /**
  117092. * Class containing static functions to help procedurally build meshes
  117093. */
  117094. export class CylinderBuilder {
  117095. /**
  117096. * Creates a cylinder or a cone mesh
  117097. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117098. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117099. * * 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.
  117100. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117101. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117102. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117103. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117104. * * 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).
  117105. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117106. * * 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).
  117107. * * 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
  117108. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117109. * * 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
  117110. * * 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.
  117111. * * If `enclose` is false, a ring surface is one element.
  117112. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117113. * * 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
  117114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117117. * @param name defines the name of the mesh
  117118. * @param options defines the options used to create the mesh
  117119. * @param scene defines the hosting scene
  117120. * @returns the cylinder mesh
  117121. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117122. */
  117123. static CreateCylinder(name: string, options: {
  117124. height?: number;
  117125. diameterTop?: number;
  117126. diameterBottom?: number;
  117127. diameter?: number;
  117128. tessellation?: number;
  117129. subdivisions?: number;
  117130. arc?: number;
  117131. faceColors?: Color4[];
  117132. faceUV?: Vector4[];
  117133. updatable?: boolean;
  117134. hasRings?: boolean;
  117135. enclose?: boolean;
  117136. cap?: number;
  117137. sideOrientation?: number;
  117138. frontUVs?: Vector4;
  117139. backUVs?: Vector4;
  117140. }, scene: any): Mesh;
  117141. }
  117142. }
  117143. declare module BABYLON {
  117144. /**
  117145. * States of the webXR experience
  117146. */
  117147. export enum WebXRState {
  117148. /**
  117149. * Transitioning to being in XR mode
  117150. */
  117151. ENTERING_XR = 0,
  117152. /**
  117153. * Transitioning to non XR mode
  117154. */
  117155. EXITING_XR = 1,
  117156. /**
  117157. * In XR mode and presenting
  117158. */
  117159. IN_XR = 2,
  117160. /**
  117161. * Not entered XR mode
  117162. */
  117163. NOT_IN_XR = 3
  117164. }
  117165. /**
  117166. * Abstraction of the XR render target
  117167. */
  117168. export interface WebXRRenderTarget extends IDisposable {
  117169. /**
  117170. * xrpresent context of the canvas which can be used to display/mirror xr content
  117171. */
  117172. canvasContext: WebGLRenderingContext;
  117173. /**
  117174. * xr layer for the canvas
  117175. */
  117176. xrLayer: Nullable<XRWebGLLayer>;
  117177. /**
  117178. * Initializes the xr layer for the session
  117179. * @param xrSession xr session
  117180. * @returns a promise that will resolve once the XR Layer has been created
  117181. */
  117182. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117183. }
  117184. }
  117185. declare module BABYLON {
  117186. /**
  117187. * COnfiguration object for WebXR output canvas
  117188. */
  117189. export class WebXRManagedOutputCanvasOptions {
  117190. /**
  117191. * An optional canvas in case you wish to create it yourself and provide it here.
  117192. * If not provided, a new canvas will be created
  117193. */
  117194. canvasElement?: HTMLCanvasElement;
  117195. /**
  117196. * Options for this XR Layer output
  117197. */
  117198. canvasOptions?: XRWebGLLayerOptions;
  117199. /**
  117200. * CSS styling for a newly created canvas (if not provided)
  117201. */
  117202. newCanvasCssStyle?: string;
  117203. /**
  117204. * Get the default values of the configuration object
  117205. * @returns default values of this configuration object
  117206. */
  117207. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117208. }
  117209. /**
  117210. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117211. */
  117212. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117213. private _options;
  117214. private _canvas;
  117215. private _engine;
  117216. /**
  117217. * Rendering context of the canvas which can be used to display/mirror xr content
  117218. */
  117219. canvasContext: WebGLRenderingContext;
  117220. /**
  117221. * xr layer for the canvas
  117222. */
  117223. xrLayer: Nullable<XRWebGLLayer>;
  117224. /**
  117225. * Initializes the canvas to be added/removed upon entering/exiting xr
  117226. * @param _xrSessionManager The XR Session manager
  117227. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117228. */
  117229. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117230. /**
  117231. * Disposes of the object
  117232. */
  117233. dispose(): void;
  117234. /**
  117235. * Initializes the xr layer for the session
  117236. * @param xrSession xr session
  117237. * @returns a promise that will resolve once the XR Layer has been created
  117238. */
  117239. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117240. private _addCanvas;
  117241. private _removeCanvas;
  117242. private _setManagedOutputCanvas;
  117243. }
  117244. }
  117245. declare module BABYLON {
  117246. /**
  117247. * Manages an XRSession to work with Babylon's engine
  117248. * @see https://doc.babylonjs.com/how_to/webxr
  117249. */
  117250. export class WebXRSessionManager implements IDisposable {
  117251. /** The scene which the session should be created for */
  117252. scene: Scene;
  117253. private _referenceSpace;
  117254. private _rttProvider;
  117255. private _sessionEnded;
  117256. private _xrNavigator;
  117257. private baseLayer;
  117258. /**
  117259. * The base reference space from which the session started. good if you want to reset your
  117260. * reference space
  117261. */
  117262. baseReferenceSpace: XRReferenceSpace;
  117263. /**
  117264. * Current XR frame
  117265. */
  117266. currentFrame: Nullable<XRFrame>;
  117267. /** WebXR timestamp updated every frame */
  117268. currentTimestamp: number;
  117269. /**
  117270. * Used just in case of a failure to initialize an immersive session.
  117271. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117272. */
  117273. defaultHeightCompensation: number;
  117274. /**
  117275. * Fires every time a new xrFrame arrives which can be used to update the camera
  117276. */
  117277. onXRFrameObservable: Observable<XRFrame>;
  117278. /**
  117279. * Fires when the reference space changed
  117280. */
  117281. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117282. /**
  117283. * Fires when the xr session is ended either by the device or manually done
  117284. */
  117285. onXRSessionEnded: Observable<any>;
  117286. /**
  117287. * Fires when the xr session is ended either by the device or manually done
  117288. */
  117289. onXRSessionInit: Observable<XRSession>;
  117290. /**
  117291. * Underlying xr session
  117292. */
  117293. session: XRSession;
  117294. /**
  117295. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117296. * or get the offset the player is currently at.
  117297. */
  117298. viewerReferenceSpace: XRReferenceSpace;
  117299. /**
  117300. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117301. * @param scene The scene which the session should be created for
  117302. */
  117303. constructor(
  117304. /** The scene which the session should be created for */
  117305. scene: Scene);
  117306. /**
  117307. * The current reference space used in this session. This reference space can constantly change!
  117308. * It is mainly used to offset the camera's position.
  117309. */
  117310. get referenceSpace(): XRReferenceSpace;
  117311. /**
  117312. * Set a new reference space and triggers the observable
  117313. */
  117314. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117315. /**
  117316. * Disposes of the session manager
  117317. */
  117318. dispose(): void;
  117319. /**
  117320. * Stops the xrSession and restores the render loop
  117321. * @returns Promise which resolves after it exits XR
  117322. */
  117323. exitXRAsync(): Promise<void>;
  117324. /**
  117325. * Gets the correct render target texture to be rendered this frame for this eye
  117326. * @param eye the eye for which to get the render target
  117327. * @returns the render target for the specified eye
  117328. */
  117329. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117330. /**
  117331. * Creates a WebXRRenderTarget object for the XR session
  117332. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117333. * @param options optional options to provide when creating a new render target
  117334. * @returns a WebXR render target to which the session can render
  117335. */
  117336. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117337. /**
  117338. * Initializes the manager
  117339. * After initialization enterXR can be called to start an XR session
  117340. * @returns Promise which resolves after it is initialized
  117341. */
  117342. initializeAsync(): Promise<void>;
  117343. /**
  117344. * Initializes an xr session
  117345. * @param xrSessionMode mode to initialize
  117346. * @param xrSessionInit defines optional and required values to pass to the session builder
  117347. * @returns a promise which will resolve once the session has been initialized
  117348. */
  117349. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117350. /**
  117351. * Checks if a session would be supported for the creation options specified
  117352. * @param sessionMode session mode to check if supported eg. immersive-vr
  117353. * @returns A Promise that resolves to true if supported and false if not
  117354. */
  117355. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117356. /**
  117357. * Resets the reference space to the one started the session
  117358. */
  117359. resetReferenceSpace(): void;
  117360. /**
  117361. * Starts rendering to the xr layer
  117362. */
  117363. runXRRenderLoop(): void;
  117364. /**
  117365. * Sets the reference space on the xr session
  117366. * @param referenceSpaceType space to set
  117367. * @returns a promise that will resolve once the reference space has been set
  117368. */
  117369. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117370. /**
  117371. * Updates the render state of the session
  117372. * @param state state to set
  117373. * @returns a promise that resolves once the render state has been updated
  117374. */
  117375. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117376. /**
  117377. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117378. * @param sessionMode defines the session to test
  117379. * @returns a promise with boolean as final value
  117380. */
  117381. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117382. private _createRenderTargetTexture;
  117383. }
  117384. }
  117385. declare module BABYLON {
  117386. /**
  117387. * WebXR Camera which holds the views for the xrSession
  117388. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117389. */
  117390. export class WebXRCamera extends FreeCamera {
  117391. private _xrSessionManager;
  117392. private _firstFrame;
  117393. private _referenceQuaternion;
  117394. private _referencedPosition;
  117395. private _xrInvPositionCache;
  117396. private _xrInvQuaternionCache;
  117397. /**
  117398. * Should position compensation execute on first frame.
  117399. * This is used when copying the position from a native (non XR) camera
  117400. */
  117401. compensateOnFirstFrame: boolean;
  117402. /**
  117403. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117404. * @param name the name of the camera
  117405. * @param scene the scene to add the camera to
  117406. * @param _xrSessionManager a constructed xr session manager
  117407. */
  117408. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117409. /**
  117410. * Return the user's height, unrelated to the current ground.
  117411. * This will be the y position of this camera, when ground level is 0.
  117412. */
  117413. get realWorldHeight(): number;
  117414. /** @hidden */
  117415. _updateForDualEyeDebugging(): void;
  117416. /**
  117417. * Sets this camera's transformation based on a non-vr camera
  117418. * @param otherCamera the non-vr camera to copy the transformation from
  117419. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117420. */
  117421. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117422. /**
  117423. * Gets the current instance class name ("WebXRCamera").
  117424. * @returns the class name
  117425. */
  117426. getClassName(): string;
  117427. private _updateFromXRSession;
  117428. private _updateNumberOfRigCameras;
  117429. private _updateReferenceSpace;
  117430. private _updateReferenceSpaceOffset;
  117431. }
  117432. }
  117433. declare module BABYLON {
  117434. /**
  117435. * Defining the interface required for a (webxr) feature
  117436. */
  117437. export interface IWebXRFeature extends IDisposable {
  117438. /**
  117439. * Is this feature attached
  117440. */
  117441. attached: boolean;
  117442. /**
  117443. * Should auto-attach be disabled?
  117444. */
  117445. disableAutoAttach: boolean;
  117446. /**
  117447. * Attach the feature to the session
  117448. * Will usually be called by the features manager
  117449. *
  117450. * @param force should attachment be forced (even when already attached)
  117451. * @returns true if successful.
  117452. */
  117453. attach(force?: boolean): boolean;
  117454. /**
  117455. * Detach the feature from the session
  117456. * Will usually be called by the features manager
  117457. *
  117458. * @returns true if successful.
  117459. */
  117460. detach(): boolean;
  117461. }
  117462. /**
  117463. * A list of the currently available features without referencing them
  117464. */
  117465. export class WebXRFeatureName {
  117466. /**
  117467. * The name of the anchor system feature
  117468. */
  117469. static ANCHOR_SYSTEM: string;
  117470. /**
  117471. * The name of the background remover feature
  117472. */
  117473. static BACKGROUND_REMOVER: string;
  117474. /**
  117475. * The name of the hit test feature
  117476. */
  117477. static HIT_TEST: string;
  117478. /**
  117479. * physics impostors for xr controllers feature
  117480. */
  117481. static PHYSICS_CONTROLLERS: string;
  117482. /**
  117483. * The name of the plane detection feature
  117484. */
  117485. static PLANE_DETECTION: string;
  117486. /**
  117487. * The name of the pointer selection feature
  117488. */
  117489. static POINTER_SELECTION: string;
  117490. /**
  117491. * The name of the teleportation feature
  117492. */
  117493. static TELEPORTATION: string;
  117494. }
  117495. /**
  117496. * Defining the constructor of a feature. Used to register the modules.
  117497. */
  117498. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117499. /**
  117500. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117501. * It is mainly used in AR sessions.
  117502. *
  117503. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117504. */
  117505. export class WebXRFeaturesManager implements IDisposable {
  117506. private _xrSessionManager;
  117507. private static readonly _AvailableFeatures;
  117508. private _features;
  117509. /**
  117510. * constructs a new features manages.
  117511. *
  117512. * @param _xrSessionManager an instance of WebXRSessionManager
  117513. */
  117514. constructor(_xrSessionManager: WebXRSessionManager);
  117515. /**
  117516. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117517. * Mainly used internally.
  117518. *
  117519. * @param featureName the name of the feature to register
  117520. * @param constructorFunction the function used to construct the module
  117521. * @param version the (babylon) version of the module
  117522. * @param stable is that a stable version of this module
  117523. */
  117524. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117525. /**
  117526. * Returns a constructor of a specific feature.
  117527. *
  117528. * @param featureName the name of the feature to construct
  117529. * @param version the version of the feature to load
  117530. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117531. * @param options optional options provided to the module.
  117532. * @returns a function that, when called, will return a new instance of this feature
  117533. */
  117534. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117535. /**
  117536. * Can be used to return the list of features currently registered
  117537. *
  117538. * @returns an Array of available features
  117539. */
  117540. static GetAvailableFeatures(): string[];
  117541. /**
  117542. * Gets the versions available for a specific feature
  117543. * @param featureName the name of the feature
  117544. * @returns an array with the available versions
  117545. */
  117546. static GetAvailableVersions(featureName: string): string[];
  117547. /**
  117548. * Return the latest unstable version of this feature
  117549. * @param featureName the name of the feature to search
  117550. * @returns the version number. if not found will return -1
  117551. */
  117552. static GetLatestVersionOfFeature(featureName: string): number;
  117553. /**
  117554. * Return the latest stable version of this feature
  117555. * @param featureName the name of the feature to search
  117556. * @returns the version number. if not found will return -1
  117557. */
  117558. static GetStableVersionOfFeature(featureName: string): number;
  117559. /**
  117560. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117561. * Can be used during a session to start a feature
  117562. * @param featureName the name of feature to attach
  117563. */
  117564. attachFeature(featureName: string): void;
  117565. /**
  117566. * Can be used inside a session or when the session ends to detach a specific feature
  117567. * @param featureName the name of the feature to detach
  117568. */
  117569. detachFeature(featureName: string): void;
  117570. /**
  117571. * Used to disable an already-enabled feature
  117572. * The feature will be disposed and will be recreated once enabled.
  117573. * @param featureName the feature to disable
  117574. * @returns true if disable was successful
  117575. */
  117576. disableFeature(featureName: string | {
  117577. Name: string;
  117578. }): boolean;
  117579. /**
  117580. * dispose this features manager
  117581. */
  117582. dispose(): void;
  117583. /**
  117584. * 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.
  117585. * 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.
  117586. *
  117587. * @param featureName the name of the feature to load or the class of the feature
  117588. * @param version optional version to load. if not provided the latest version will be enabled
  117589. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117590. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117591. * @returns a new constructed feature or throws an error if feature not found.
  117592. */
  117593. enableFeature(featureName: string | {
  117594. Name: string;
  117595. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117596. /**
  117597. * get the implementation of an enabled feature.
  117598. * @param featureName the name of the feature to load
  117599. * @returns the feature class, if found
  117600. */
  117601. getEnabledFeature(featureName: string): IWebXRFeature;
  117602. /**
  117603. * Get the list of enabled features
  117604. * @returns an array of enabled features
  117605. */
  117606. getEnabledFeatures(): string[];
  117607. }
  117608. }
  117609. declare module BABYLON {
  117610. /**
  117611. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117612. * @see https://doc.babylonjs.com/how_to/webxr
  117613. */
  117614. export class WebXRExperienceHelper implements IDisposable {
  117615. private scene;
  117616. private _nonVRCamera;
  117617. private _originalSceneAutoClear;
  117618. private _supported;
  117619. /**
  117620. * Camera used to render xr content
  117621. */
  117622. camera: WebXRCamera;
  117623. /** A features manager for this xr session */
  117624. featuresManager: WebXRFeaturesManager;
  117625. /**
  117626. * Observers registered here will be triggered after the camera's initial transformation is set
  117627. * This can be used to set a different ground level or an extra rotation.
  117628. *
  117629. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117630. * to the position set after this observable is done executing.
  117631. */
  117632. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117633. /**
  117634. * Fires when the state of the experience helper has changed
  117635. */
  117636. onStateChangedObservable: Observable<WebXRState>;
  117637. /** Session manager used to keep track of xr session */
  117638. sessionManager: WebXRSessionManager;
  117639. /**
  117640. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117641. */
  117642. state: WebXRState;
  117643. /**
  117644. * Creates a WebXRExperienceHelper
  117645. * @param scene The scene the helper should be created in
  117646. */
  117647. private constructor();
  117648. /**
  117649. * Creates the experience helper
  117650. * @param scene the scene to attach the experience helper to
  117651. * @returns a promise for the experience helper
  117652. */
  117653. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117654. /**
  117655. * Disposes of the experience helper
  117656. */
  117657. dispose(): void;
  117658. /**
  117659. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117660. * @param sessionMode options for the XR session
  117661. * @param referenceSpaceType frame of reference of the XR session
  117662. * @param renderTarget the output canvas that will be used to enter XR mode
  117663. * @returns promise that resolves after xr mode has entered
  117664. */
  117665. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117666. /**
  117667. * Exits XR mode and returns the scene to its original state
  117668. * @returns promise that resolves after xr mode has exited
  117669. */
  117670. exitXRAsync(): Promise<void>;
  117671. private _nonXRToXRCamera;
  117672. private _setState;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /**
  117677. * X-Y values for axes in WebXR
  117678. */
  117679. export interface IWebXRMotionControllerAxesValue {
  117680. /**
  117681. * The value of the x axis
  117682. */
  117683. x: number;
  117684. /**
  117685. * The value of the y-axis
  117686. */
  117687. y: number;
  117688. }
  117689. /**
  117690. * changed / previous values for the values of this component
  117691. */
  117692. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117693. /**
  117694. * current (this frame) value
  117695. */
  117696. current: T;
  117697. /**
  117698. * previous (last change) value
  117699. */
  117700. previous: T;
  117701. }
  117702. /**
  117703. * Represents changes in the component between current frame and last values recorded
  117704. */
  117705. export interface IWebXRMotionControllerComponentChanges {
  117706. /**
  117707. * will be populated with previous and current values if axes changed
  117708. */
  117709. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117710. /**
  117711. * will be populated with previous and current values if pressed changed
  117712. */
  117713. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117714. /**
  117715. * will be populated with previous and current values if touched changed
  117716. */
  117717. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117718. /**
  117719. * will be populated with previous and current values if value changed
  117720. */
  117721. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117722. }
  117723. /**
  117724. * This class represents a single component (for example button or thumbstick) of a motion controller
  117725. */
  117726. export class WebXRControllerComponent implements IDisposable {
  117727. /**
  117728. * the id of this component
  117729. */
  117730. id: string;
  117731. /**
  117732. * the type of the component
  117733. */
  117734. type: MotionControllerComponentType;
  117735. private _buttonIndex;
  117736. private _axesIndices;
  117737. private _axes;
  117738. private _changes;
  117739. private _currentValue;
  117740. private _hasChanges;
  117741. private _pressed;
  117742. private _touched;
  117743. /**
  117744. * button component type
  117745. */
  117746. static BUTTON_TYPE: MotionControllerComponentType;
  117747. /**
  117748. * squeeze component type
  117749. */
  117750. static SQUEEZE_TYPE: MotionControllerComponentType;
  117751. /**
  117752. * Thumbstick component type
  117753. */
  117754. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117755. /**
  117756. * Touchpad component type
  117757. */
  117758. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117759. /**
  117760. * trigger component type
  117761. */
  117762. static TRIGGER_TYPE: MotionControllerComponentType;
  117763. /**
  117764. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117765. * the axes data changes
  117766. */
  117767. onAxisValueChangedObservable: Observable<{
  117768. x: number;
  117769. y: number;
  117770. }>;
  117771. /**
  117772. * Observers registered here will be triggered when the state of a button changes
  117773. * State change is either pressed / touched / value
  117774. */
  117775. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117776. /**
  117777. * Creates a new component for a motion controller.
  117778. * It is created by the motion controller itself
  117779. *
  117780. * @param id the id of this component
  117781. * @param type the type of the component
  117782. * @param _buttonIndex index in the buttons array of the gamepad
  117783. * @param _axesIndices indices of the values in the axes array of the gamepad
  117784. */
  117785. constructor(
  117786. /**
  117787. * the id of this component
  117788. */
  117789. id: string,
  117790. /**
  117791. * the type of the component
  117792. */
  117793. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117794. /**
  117795. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117796. */
  117797. get axes(): IWebXRMotionControllerAxesValue;
  117798. /**
  117799. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117800. */
  117801. get changes(): IWebXRMotionControllerComponentChanges;
  117802. /**
  117803. * Return whether or not the component changed the last frame
  117804. */
  117805. get hasChanges(): boolean;
  117806. /**
  117807. * is the button currently pressed
  117808. */
  117809. get pressed(): boolean;
  117810. /**
  117811. * is the button currently touched
  117812. */
  117813. get touched(): boolean;
  117814. /**
  117815. * Get the current value of this component
  117816. */
  117817. get value(): number;
  117818. /**
  117819. * Dispose this component
  117820. */
  117821. dispose(): void;
  117822. /**
  117823. * Are there axes correlating to this component
  117824. * @return true is axes data is available
  117825. */
  117826. isAxes(): boolean;
  117827. /**
  117828. * Is this component a button (hence - pressable)
  117829. * @returns true if can be pressed
  117830. */
  117831. isButton(): boolean;
  117832. /**
  117833. * update this component using the gamepad object it is in. Called on every frame
  117834. * @param nativeController the native gamepad controller object
  117835. */
  117836. update(nativeController: IMinimalMotionControllerObject): void;
  117837. }
  117838. }
  117839. declare module BABYLON {
  117840. /**
  117841. * Class used to represent data loading progression
  117842. */
  117843. export class SceneLoaderProgressEvent {
  117844. /** defines if data length to load can be evaluated */
  117845. readonly lengthComputable: boolean;
  117846. /** defines the loaded data length */
  117847. readonly loaded: number;
  117848. /** defines the data length to load */
  117849. readonly total: number;
  117850. /**
  117851. * Create a new progress event
  117852. * @param lengthComputable defines if data length to load can be evaluated
  117853. * @param loaded defines the loaded data length
  117854. * @param total defines the data length to load
  117855. */
  117856. constructor(
  117857. /** defines if data length to load can be evaluated */
  117858. lengthComputable: boolean,
  117859. /** defines the loaded data length */
  117860. loaded: number,
  117861. /** defines the data length to load */
  117862. total: number);
  117863. /**
  117864. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117865. * @param event defines the source event
  117866. * @returns a new SceneLoaderProgressEvent
  117867. */
  117868. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117869. }
  117870. /**
  117871. * Interface used by SceneLoader plugins to define supported file extensions
  117872. */
  117873. export interface ISceneLoaderPluginExtensions {
  117874. /**
  117875. * Defines the list of supported extensions
  117876. */
  117877. [extension: string]: {
  117878. isBinary: boolean;
  117879. };
  117880. }
  117881. /**
  117882. * Interface used by SceneLoader plugin factory
  117883. */
  117884. export interface ISceneLoaderPluginFactory {
  117885. /**
  117886. * Defines the name of the factory
  117887. */
  117888. name: string;
  117889. /**
  117890. * Function called to create a new plugin
  117891. * @return the new plugin
  117892. */
  117893. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117894. /**
  117895. * The callback that returns true if the data can be directly loaded.
  117896. * @param data string containing the file data
  117897. * @returns if the data can be loaded directly
  117898. */
  117899. canDirectLoad?(data: string): boolean;
  117900. }
  117901. /**
  117902. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117903. */
  117904. export interface ISceneLoaderPluginBase {
  117905. /**
  117906. * The friendly name of this plugin.
  117907. */
  117908. name: string;
  117909. /**
  117910. * The file extensions supported by this plugin.
  117911. */
  117912. extensions: string | ISceneLoaderPluginExtensions;
  117913. /**
  117914. * The callback called when loading from a url.
  117915. * @param scene scene loading this url
  117916. * @param url url to load
  117917. * @param onSuccess callback called when the file successfully loads
  117918. * @param onProgress callback called while file is loading (if the server supports this mode)
  117919. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117920. * @param onError callback called when the file fails to load
  117921. * @returns a file request object
  117922. */
  117923. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117924. /**
  117925. * The callback called when loading from a file object.
  117926. * @param scene scene loading this file
  117927. * @param file defines the file to load
  117928. * @param onSuccess defines the callback to call when data is loaded
  117929. * @param onProgress defines the callback to call during loading process
  117930. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117931. * @param onError defines the callback to call when an error occurs
  117932. * @returns a file request object
  117933. */
  117934. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117935. /**
  117936. * The callback that returns true if the data can be directly loaded.
  117937. * @param data string containing the file data
  117938. * @returns if the data can be loaded directly
  117939. */
  117940. canDirectLoad?(data: string): boolean;
  117941. /**
  117942. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117943. * @param scene scene loading this data
  117944. * @param data string containing the data
  117945. * @returns data to pass to the plugin
  117946. */
  117947. directLoad?(scene: Scene, data: string): any;
  117948. /**
  117949. * The callback that allows custom handling of the root url based on the response url.
  117950. * @param rootUrl the original root url
  117951. * @param responseURL the response url if available
  117952. * @returns the new root url
  117953. */
  117954. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117955. }
  117956. /**
  117957. * Interface used to define a SceneLoader plugin
  117958. */
  117959. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117960. /**
  117961. * Import meshes into a scene.
  117962. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117963. * @param scene The scene to import into
  117964. * @param data The data to import
  117965. * @param rootUrl The root url for scene and resources
  117966. * @param meshes The meshes array to import into
  117967. * @param particleSystems The particle systems array to import into
  117968. * @param skeletons The skeletons array to import into
  117969. * @param onError The callback when import fails
  117970. * @returns True if successful or false otherwise
  117971. */
  117972. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117973. /**
  117974. * Load into a scene.
  117975. * @param scene The scene to load into
  117976. * @param data The data to import
  117977. * @param rootUrl The root url for scene and resources
  117978. * @param onError The callback when import fails
  117979. * @returns True if successful or false otherwise
  117980. */
  117981. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117982. /**
  117983. * Load into an asset container.
  117984. * @param scene The scene to load into
  117985. * @param data The data to import
  117986. * @param rootUrl The root url for scene and resources
  117987. * @param onError The callback when import fails
  117988. * @returns The loaded asset container
  117989. */
  117990. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117991. }
  117992. /**
  117993. * Interface used to define an async SceneLoader plugin
  117994. */
  117995. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  117996. /**
  117997. * Import meshes into a scene.
  117998. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117999. * @param scene The scene to import into
  118000. * @param data The data to import
  118001. * @param rootUrl The root url for scene and resources
  118002. * @param onProgress The callback when the load progresses
  118003. * @param fileName Defines the name of the file to load
  118004. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118005. */
  118006. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118007. meshes: AbstractMesh[];
  118008. particleSystems: IParticleSystem[];
  118009. skeletons: Skeleton[];
  118010. animationGroups: AnimationGroup[];
  118011. }>;
  118012. /**
  118013. * Load into a scene.
  118014. * @param scene The scene to load into
  118015. * @param data The data to import
  118016. * @param rootUrl The root url for scene and resources
  118017. * @param onProgress The callback when the load progresses
  118018. * @param fileName Defines the name of the file to load
  118019. * @returns Nothing
  118020. */
  118021. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118022. /**
  118023. * Load into an asset container.
  118024. * @param scene The scene to load into
  118025. * @param data The data to import
  118026. * @param rootUrl The root url for scene and resources
  118027. * @param onProgress The callback when the load progresses
  118028. * @param fileName Defines the name of the file to load
  118029. * @returns The loaded asset container
  118030. */
  118031. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118032. }
  118033. /**
  118034. * Mode that determines how to handle old animation groups before loading new ones.
  118035. */
  118036. export enum SceneLoaderAnimationGroupLoadingMode {
  118037. /**
  118038. * Reset all old animations to initial state then dispose them.
  118039. */
  118040. Clean = 0,
  118041. /**
  118042. * Stop all old animations.
  118043. */
  118044. Stop = 1,
  118045. /**
  118046. * Restart old animations from first frame.
  118047. */
  118048. Sync = 2,
  118049. /**
  118050. * Old animations remains untouched.
  118051. */
  118052. NoSync = 3
  118053. }
  118054. /**
  118055. * Class used to load scene from various file formats using registered plugins
  118056. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118057. */
  118058. export class SceneLoader {
  118059. /**
  118060. * No logging while loading
  118061. */
  118062. static readonly NO_LOGGING: number;
  118063. /**
  118064. * Minimal logging while loading
  118065. */
  118066. static readonly MINIMAL_LOGGING: number;
  118067. /**
  118068. * Summary logging while loading
  118069. */
  118070. static readonly SUMMARY_LOGGING: number;
  118071. /**
  118072. * Detailled logging while loading
  118073. */
  118074. static readonly DETAILED_LOGGING: number;
  118075. /**
  118076. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118077. */
  118078. static get ForceFullSceneLoadingForIncremental(): boolean;
  118079. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118080. /**
  118081. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118082. */
  118083. static get ShowLoadingScreen(): boolean;
  118084. static set ShowLoadingScreen(value: boolean);
  118085. /**
  118086. * Defines the current logging level (while loading the scene)
  118087. * @ignorenaming
  118088. */
  118089. static get loggingLevel(): number;
  118090. static set loggingLevel(value: number);
  118091. /**
  118092. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118093. */
  118094. static get CleanBoneMatrixWeights(): boolean;
  118095. static set CleanBoneMatrixWeights(value: boolean);
  118096. /**
  118097. * Event raised when a plugin is used to load a scene
  118098. */
  118099. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118100. private static _registeredPlugins;
  118101. private static _getDefaultPlugin;
  118102. private static _getPluginForExtension;
  118103. private static _getPluginForDirectLoad;
  118104. private static _getPluginForFilename;
  118105. private static _getDirectLoad;
  118106. private static _loadData;
  118107. private static _getFileInfo;
  118108. /**
  118109. * Gets a plugin that can load the given extension
  118110. * @param extension defines the extension to load
  118111. * @returns a plugin or null if none works
  118112. */
  118113. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118114. /**
  118115. * Gets a boolean indicating that the given extension can be loaded
  118116. * @param extension defines the extension to load
  118117. * @returns true if the extension is supported
  118118. */
  118119. static IsPluginForExtensionAvailable(extension: string): boolean;
  118120. /**
  118121. * Adds a new plugin to the list of registered plugins
  118122. * @param plugin defines the plugin to add
  118123. */
  118124. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118125. /**
  118126. * Import meshes into a scene
  118127. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118128. * @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)
  118129. * @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)
  118130. * @param scene the instance of BABYLON.Scene to append to
  118131. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118132. * @param onProgress a callback with a progress event for each file being loaded
  118133. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118134. * @param pluginExtension the extension used to determine the plugin
  118135. * @returns The loaded plugin
  118136. */
  118137. 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>;
  118138. /**
  118139. * Import meshes into a scene
  118140. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118141. * @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)
  118142. * @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)
  118143. * @param scene the instance of BABYLON.Scene to append to
  118144. * @param onProgress a callback with a progress event for each file being loaded
  118145. * @param pluginExtension the extension used to determine the plugin
  118146. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118147. */
  118148. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118149. meshes: AbstractMesh[];
  118150. particleSystems: IParticleSystem[];
  118151. skeletons: Skeleton[];
  118152. animationGroups: AnimationGroup[];
  118153. }>;
  118154. /**
  118155. * Load a scene
  118156. * @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)
  118157. * @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)
  118158. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118159. * @param onSuccess a callback with the scene when import succeeds
  118160. * @param onProgress a callback with a progress event for each file being loaded
  118161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118162. * @param pluginExtension the extension used to determine the plugin
  118163. * @returns The loaded plugin
  118164. */
  118165. 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>;
  118166. /**
  118167. * Load a scene
  118168. * @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)
  118169. * @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)
  118170. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118171. * @param onProgress a callback with a progress event for each file being loaded
  118172. * @param pluginExtension the extension used to determine the plugin
  118173. * @returns The loaded scene
  118174. */
  118175. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118176. /**
  118177. * Append a scene
  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 is the instance of BABYLON.Scene to append to
  118181. * @param onSuccess a callback with the scene when import succeeds
  118182. * @param onProgress a callback with a progress event for each file being loaded
  118183. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118184. * @param pluginExtension the extension used to determine the plugin
  118185. * @returns The loaded plugin
  118186. */
  118187. 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>;
  118188. /**
  118189. * Append a scene
  118190. * @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)
  118191. * @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)
  118192. * @param scene is the instance of BABYLON.Scene to append to
  118193. * @param onProgress a callback with a progress event for each file being loaded
  118194. * @param pluginExtension the extension used to determine the plugin
  118195. * @returns The given scene
  118196. */
  118197. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118198. /**
  118199. * Load a scene into an asset container
  118200. * @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)
  118201. * @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)
  118202. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118203. * @param onSuccess a callback with the scene when import succeeds
  118204. * @param onProgress a callback with a progress event for each file being loaded
  118205. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118206. * @param pluginExtension the extension used to determine the plugin
  118207. * @returns The loaded plugin
  118208. */
  118209. 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>;
  118210. /**
  118211. * Load a scene into an asset container
  118212. * @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)
  118213. * @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)
  118214. * @param scene is the instance of Scene to append to
  118215. * @param onProgress a callback with a progress event for each file being loaded
  118216. * @param pluginExtension the extension used to determine the plugin
  118217. * @returns The loaded asset container
  118218. */
  118219. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118220. /**
  118221. * Import animations from a file into a scene
  118222. * @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)
  118223. * @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)
  118224. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118225. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118226. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118227. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118228. * @param onSuccess a callback with the scene when import succeeds
  118229. * @param onProgress a callback with a progress event for each file being loaded
  118230. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118231. */
  118232. 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;
  118233. /**
  118234. * Import animations from a file into a scene
  118235. * @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)
  118236. * @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)
  118237. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118238. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118239. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118240. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118241. * @param onSuccess a callback with the scene when import succeeds
  118242. * @param onProgress a callback with a progress event for each file being loaded
  118243. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118244. * @returns the updated scene with imported animations
  118245. */
  118246. 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>;
  118247. }
  118248. }
  118249. declare module BABYLON {
  118250. /**
  118251. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118252. */
  118253. export type MotionControllerHandness = "none" | "left" | "right";
  118254. /**
  118255. * The type of components available in motion controllers.
  118256. * This is not the name of the component.
  118257. */
  118258. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118259. /**
  118260. * The state of a controller component
  118261. */
  118262. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118263. /**
  118264. * The schema of motion controller layout.
  118265. * No object will be initialized using this interface
  118266. * This is used just to define the profile.
  118267. */
  118268. export interface IMotionControllerLayout {
  118269. /**
  118270. * Path to load the assets. Usually relative to the base path
  118271. */
  118272. assetPath: string;
  118273. /**
  118274. * Available components (unsorted)
  118275. */
  118276. components: {
  118277. /**
  118278. * A map of component Ids
  118279. */
  118280. [componentId: string]: {
  118281. /**
  118282. * The type of input the component outputs
  118283. */
  118284. type: MotionControllerComponentType;
  118285. /**
  118286. * The indices of this component in the gamepad object
  118287. */
  118288. gamepadIndices: {
  118289. /**
  118290. * Index of button
  118291. */
  118292. button?: number;
  118293. /**
  118294. * If available, index of x-axis
  118295. */
  118296. xAxis?: number;
  118297. /**
  118298. * If available, index of y-axis
  118299. */
  118300. yAxis?: number;
  118301. };
  118302. /**
  118303. * The mesh's root node name
  118304. */
  118305. rootNodeName: string;
  118306. /**
  118307. * Animation definitions for this model
  118308. */
  118309. visualResponses: {
  118310. [stateKey: string]: {
  118311. /**
  118312. * What property will be animated
  118313. */
  118314. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118315. /**
  118316. * What states influence this visual response
  118317. */
  118318. states: MotionControllerComponentStateType[];
  118319. /**
  118320. * Type of animation - movement or visibility
  118321. */
  118322. valueNodeProperty: "transform" | "visibility";
  118323. /**
  118324. * Base node name to move. Its position will be calculated according to the min and max nodes
  118325. */
  118326. valueNodeName?: string;
  118327. /**
  118328. * Minimum movement node
  118329. */
  118330. minNodeName?: string;
  118331. /**
  118332. * Max movement node
  118333. */
  118334. maxNodeName?: string;
  118335. };
  118336. };
  118337. /**
  118338. * If touch enabled, what is the name of node to display user feedback
  118339. */
  118340. touchPointNodeName?: string;
  118341. };
  118342. };
  118343. /**
  118344. * Is it xr standard mapping or not
  118345. */
  118346. gamepadMapping: "" | "xr-standard";
  118347. /**
  118348. * Base root node of this entire model
  118349. */
  118350. rootNodeName: string;
  118351. /**
  118352. * Defines the main button component id
  118353. */
  118354. selectComponentId: string;
  118355. }
  118356. /**
  118357. * A definition for the layout map in the input profile
  118358. */
  118359. export interface IMotionControllerLayoutMap {
  118360. /**
  118361. * Layouts with handness type as a key
  118362. */
  118363. [handness: string]: IMotionControllerLayout;
  118364. }
  118365. /**
  118366. * The XR Input profile schema
  118367. * Profiles can be found here:
  118368. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118369. */
  118370. export interface IMotionControllerProfile {
  118371. /**
  118372. * fallback profiles for this profileId
  118373. */
  118374. fallbackProfileIds: string[];
  118375. /**
  118376. * The layout map, with handness as key
  118377. */
  118378. layouts: IMotionControllerLayoutMap;
  118379. /**
  118380. * The id of this profile
  118381. * correlates to the profile(s) in the xrInput.profiles array
  118382. */
  118383. profileId: string;
  118384. }
  118385. /**
  118386. * A helper-interface for the 3 meshes needed for controller button animation
  118387. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118388. */
  118389. export interface IMotionControllerButtonMeshMap {
  118390. /**
  118391. * the mesh that defines the pressed value mesh position.
  118392. * This is used to find the max-position of this button
  118393. */
  118394. pressedMesh: AbstractMesh;
  118395. /**
  118396. * the mesh that defines the unpressed value mesh position.
  118397. * This is used to find the min (or initial) position of this button
  118398. */
  118399. unpressedMesh: AbstractMesh;
  118400. /**
  118401. * The mesh that will be changed when value changes
  118402. */
  118403. valueMesh: AbstractMesh;
  118404. }
  118405. /**
  118406. * A helper-interface for the 3 meshes needed for controller axis animation.
  118407. * This will be expanded when touchpad animations are fully supported
  118408. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118409. */
  118410. export interface IMotionControllerMeshMap {
  118411. /**
  118412. * the mesh that defines the maximum value mesh position.
  118413. */
  118414. maxMesh?: AbstractMesh;
  118415. /**
  118416. * the mesh that defines the minimum value mesh position.
  118417. */
  118418. minMesh?: AbstractMesh;
  118419. /**
  118420. * The mesh that will be changed when axis value changes
  118421. */
  118422. valueMesh: AbstractMesh;
  118423. }
  118424. /**
  118425. * The elements needed for change-detection of the gamepad objects in motion controllers
  118426. */
  118427. export interface IMinimalMotionControllerObject {
  118428. /**
  118429. * Available axes of this controller
  118430. */
  118431. axes: number[];
  118432. /**
  118433. * An array of available buttons
  118434. */
  118435. buttons: Array<{
  118436. /**
  118437. * Value of the button/trigger
  118438. */
  118439. value: number;
  118440. /**
  118441. * If the button/trigger is currently touched
  118442. */
  118443. touched: boolean;
  118444. /**
  118445. * If the button/trigger is currently pressed
  118446. */
  118447. pressed: boolean;
  118448. }>;
  118449. }
  118450. /**
  118451. * An Abstract Motion controller
  118452. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118453. * Each component has an observable to check for changes in value and state
  118454. */
  118455. export abstract class WebXRAbstractMotionController implements IDisposable {
  118456. protected scene: Scene;
  118457. protected layout: IMotionControllerLayout;
  118458. /**
  118459. * The gamepad object correlating to this controller
  118460. */
  118461. gamepadObject: IMinimalMotionControllerObject;
  118462. /**
  118463. * handness (left/right/none) of this controller
  118464. */
  118465. handness: MotionControllerHandness;
  118466. private _initComponent;
  118467. private _modelReady;
  118468. /**
  118469. * A map of components (WebXRControllerComponent) in this motion controller
  118470. * Components have a ComponentType and can also have both button and axis definitions
  118471. */
  118472. readonly components: {
  118473. [id: string]: WebXRControllerComponent;
  118474. };
  118475. /**
  118476. * Disable the model's animation. Can be set at any time.
  118477. */
  118478. disableAnimation: boolean;
  118479. /**
  118480. * Observers registered here will be triggered when the model of this controller is done loading
  118481. */
  118482. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118483. /**
  118484. * The profile id of this motion controller
  118485. */
  118486. abstract profileId: string;
  118487. /**
  118488. * The root mesh of the model. It is null if the model was not yet initialized
  118489. */
  118490. rootMesh: Nullable<AbstractMesh>;
  118491. /**
  118492. * constructs a new abstract motion controller
  118493. * @param scene the scene to which the model of the controller will be added
  118494. * @param layout The profile layout to load
  118495. * @param gamepadObject The gamepad object correlating to this controller
  118496. * @param handness handness (left/right/none) of this controller
  118497. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118498. */
  118499. constructor(scene: Scene, layout: IMotionControllerLayout,
  118500. /**
  118501. * The gamepad object correlating to this controller
  118502. */
  118503. gamepadObject: IMinimalMotionControllerObject,
  118504. /**
  118505. * handness (left/right/none) of this controller
  118506. */
  118507. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118508. /**
  118509. * Dispose this controller, the model mesh and all its components
  118510. */
  118511. dispose(): void;
  118512. /**
  118513. * Returns all components of specific type
  118514. * @param type the type to search for
  118515. * @return an array of components with this type
  118516. */
  118517. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118518. /**
  118519. * get a component based an its component id as defined in layout.components
  118520. * @param id the id of the component
  118521. * @returns the component correlates to the id or undefined if not found
  118522. */
  118523. getComponent(id: string): WebXRControllerComponent;
  118524. /**
  118525. * Get the list of components available in this motion controller
  118526. * @returns an array of strings correlating to available components
  118527. */
  118528. getComponentIds(): string[];
  118529. /**
  118530. * Get the first component of specific type
  118531. * @param type type of component to find
  118532. * @return a controller component or null if not found
  118533. */
  118534. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118535. /**
  118536. * Get the main (Select) component of this controller as defined in the layout
  118537. * @returns the main component of this controller
  118538. */
  118539. getMainComponent(): WebXRControllerComponent;
  118540. /**
  118541. * Loads the model correlating to this controller
  118542. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118543. * @returns A promise fulfilled with the result of the model loading
  118544. */
  118545. loadModel(): Promise<boolean>;
  118546. /**
  118547. * Update this model using the current XRFrame
  118548. * @param xrFrame the current xr frame to use and update the model
  118549. */
  118550. updateFromXRFrame(xrFrame: XRFrame): void;
  118551. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118552. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118553. /**
  118554. * Moves the axis on the controller mesh based on its current state
  118555. * @param axis the index of the axis
  118556. * @param axisValue the value of the axis which determines the meshes new position
  118557. * @hidden
  118558. */
  118559. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118560. /**
  118561. * Update the model itself with the current frame data
  118562. * @param xrFrame the frame to use for updating the model mesh
  118563. */
  118564. protected updateModel(xrFrame: XRFrame): void;
  118565. /**
  118566. * Get the filename and path for this controller's model
  118567. * @returns a map of filename and path
  118568. */
  118569. protected abstract _getFilenameAndPath(): {
  118570. filename: string;
  118571. path: string;
  118572. };
  118573. /**
  118574. * This function is called before the mesh is loaded. It checks for loading constraints.
  118575. * For example, this function can check if the GLB loader is available
  118576. * If this function returns false, the generic controller will be loaded instead
  118577. * @returns Is the client ready to load the mesh
  118578. */
  118579. protected abstract _getModelLoadingConstraints(): boolean;
  118580. /**
  118581. * This function will be called after the model was successfully loaded and can be used
  118582. * for mesh transformations before it is available for the user
  118583. * @param meshes the loaded meshes
  118584. */
  118585. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118586. /**
  118587. * Set the root mesh for this controller. Important for the WebXR controller class
  118588. * @param meshes the loaded meshes
  118589. */
  118590. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118591. /**
  118592. * A function executed each frame that updates the mesh (if needed)
  118593. * @param xrFrame the current xrFrame
  118594. */
  118595. protected abstract _updateModel(xrFrame: XRFrame): void;
  118596. private _getGenericFilenameAndPath;
  118597. private _getGenericParentMesh;
  118598. }
  118599. }
  118600. declare module BABYLON {
  118601. /**
  118602. * A generic trigger-only motion controller for WebXR
  118603. */
  118604. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118605. /**
  118606. * Static version of the profile id of this controller
  118607. */
  118608. static ProfileId: string;
  118609. profileId: string;
  118610. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118611. protected _getFilenameAndPath(): {
  118612. filename: string;
  118613. path: string;
  118614. };
  118615. protected _getModelLoadingConstraints(): boolean;
  118616. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118617. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118618. protected _updateModel(): void;
  118619. }
  118620. }
  118621. declare module BABYLON {
  118622. /**
  118623. * Class containing static functions to help procedurally build meshes
  118624. */
  118625. export class SphereBuilder {
  118626. /**
  118627. * Creates a sphere mesh
  118628. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118629. * * 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`)
  118630. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118631. * * 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
  118632. * * 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)
  118633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118636. * @param name defines the name of the mesh
  118637. * @param options defines the options used to create the mesh
  118638. * @param scene defines the hosting scene
  118639. * @returns the sphere mesh
  118640. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118641. */
  118642. static CreateSphere(name: string, options: {
  118643. segments?: number;
  118644. diameter?: number;
  118645. diameterX?: number;
  118646. diameterY?: number;
  118647. diameterZ?: number;
  118648. arc?: number;
  118649. slice?: number;
  118650. sideOrientation?: number;
  118651. frontUVs?: Vector4;
  118652. backUVs?: Vector4;
  118653. updatable?: boolean;
  118654. }, scene?: Nullable<Scene>): Mesh;
  118655. }
  118656. }
  118657. declare module BABYLON {
  118658. /**
  118659. * A profiled motion controller has its profile loaded from an online repository.
  118660. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118661. */
  118662. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118663. private _repositoryUrl;
  118664. private _buttonMeshMapping;
  118665. private _touchDots;
  118666. /**
  118667. * The profile ID of this controller. Will be populated when the controller initializes.
  118668. */
  118669. profileId: string;
  118670. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118671. dispose(): void;
  118672. protected _getFilenameAndPath(): {
  118673. filename: string;
  118674. path: string;
  118675. };
  118676. protected _getModelLoadingConstraints(): boolean;
  118677. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118678. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118679. protected _updateModel(_xrFrame: XRFrame): void;
  118680. }
  118681. }
  118682. declare module BABYLON {
  118683. /**
  118684. * A construction function type to create a new controller based on an xrInput object
  118685. */
  118686. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118687. /**
  118688. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118689. *
  118690. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118691. * it should be replaced with auto-loaded controllers.
  118692. *
  118693. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118694. */
  118695. export class WebXRMotionControllerManager {
  118696. private static _AvailableControllers;
  118697. private static _Fallbacks;
  118698. private static _ProfileLoadingPromises;
  118699. private static _ProfilesList;
  118700. /**
  118701. * The base URL of the online controller repository. Can be changed at any time.
  118702. */
  118703. static BaseRepositoryUrl: string;
  118704. /**
  118705. * Which repository gets priority - local or online
  118706. */
  118707. static PrioritizeOnlineRepository: boolean;
  118708. /**
  118709. * Use the online repository, or use only locally-defined controllers
  118710. */
  118711. static UseOnlineRepository: boolean;
  118712. /**
  118713. * Clear the cache used for profile loading and reload when requested again
  118714. */
  118715. static ClearProfilesCache(): void;
  118716. /**
  118717. * Register the default fallbacks.
  118718. * This function is called automatically when this file is imported.
  118719. */
  118720. static DefaultFallbacks(): void;
  118721. /**
  118722. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118723. * @param profileId the profile to which a fallback needs to be found
  118724. * @return an array with corresponding fallback profiles
  118725. */
  118726. static FindFallbackWithProfileId(profileId: string): string[];
  118727. /**
  118728. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118729. * The order of search:
  118730. *
  118731. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118732. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118733. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118734. * 4) return the generic trigger controller if none were found
  118735. *
  118736. * @param xrInput the xrInput to which a new controller is initialized
  118737. * @param scene the scene to which the model will be added
  118738. * @param forceProfile force a certain profile for this controller
  118739. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118740. */
  118741. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118742. /**
  118743. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118744. *
  118745. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118746. *
  118747. * @param type the profile type to register
  118748. * @param constructFunction the function to be called when loading this profile
  118749. */
  118750. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118751. /**
  118752. * Register a fallback to a specific profile.
  118753. * @param profileId the profileId that will receive the fallbacks
  118754. * @param fallbacks A list of fallback profiles
  118755. */
  118756. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118757. /**
  118758. * Will update the list of profiles available in the repository
  118759. * @return a promise that resolves to a map of profiles available online
  118760. */
  118761. static UpdateProfilesList(): Promise<{
  118762. [profile: string]: string;
  118763. }>;
  118764. private static _LoadProfileFromRepository;
  118765. private static _LoadProfilesFromAvailableControllers;
  118766. }
  118767. }
  118768. declare module BABYLON {
  118769. /**
  118770. * Configuration options for the WebXR controller creation
  118771. */
  118772. export interface IWebXRControllerOptions {
  118773. /**
  118774. * Should the controller mesh be animated when a user interacts with it
  118775. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118776. */
  118777. disableMotionControllerAnimation?: boolean;
  118778. /**
  118779. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118780. */
  118781. doNotLoadControllerMesh?: boolean;
  118782. /**
  118783. * Force a specific controller type for this controller.
  118784. * This can be used when creating your own profile or when testing different controllers
  118785. */
  118786. forceControllerProfile?: string;
  118787. }
  118788. /**
  118789. * Represents an XR controller
  118790. */
  118791. export class WebXRInputSource {
  118792. private _scene;
  118793. /** The underlying input source for the controller */
  118794. inputSource: XRInputSource;
  118795. private _options;
  118796. private _tmpQuaternion;
  118797. private _tmpVector;
  118798. private _uniqueId;
  118799. /**
  118800. * 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
  118801. */
  118802. grip?: AbstractMesh;
  118803. /**
  118804. * If available, this is the gamepad object related to this controller.
  118805. * Using this object it is possible to get click events and trackpad changes of the
  118806. * webxr controller that is currently being used.
  118807. */
  118808. motionController?: WebXRAbstractMotionController;
  118809. /**
  118810. * Event that fires when the controller is removed/disposed.
  118811. * The object provided as event data is this controller, after associated assets were disposed.
  118812. * uniqueId is still available.
  118813. */
  118814. onDisposeObservable: Observable<WebXRInputSource>;
  118815. /**
  118816. * Will be triggered when the mesh associated with the motion controller is done loading.
  118817. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118818. * A shortened version of controller -> motion controller -> on mesh loaded.
  118819. */
  118820. onMeshLoadedObservable: Observable<AbstractMesh>;
  118821. /**
  118822. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118823. */
  118824. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118825. /**
  118826. * Pointer which can be used to select objects or attach a visible laser to
  118827. */
  118828. pointer: AbstractMesh;
  118829. /**
  118830. * Creates the controller
  118831. * @see https://doc.babylonjs.com/how_to/webxr
  118832. * @param _scene the scene which the controller should be associated to
  118833. * @param inputSource the underlying input source for the controller
  118834. * @param _options options for this controller creation
  118835. */
  118836. constructor(_scene: Scene,
  118837. /** The underlying input source for the controller */
  118838. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118839. /**
  118840. * Get this controllers unique id
  118841. */
  118842. get uniqueId(): string;
  118843. /**
  118844. * Disposes of the object
  118845. */
  118846. dispose(): void;
  118847. /**
  118848. * Gets a world space ray coming from the pointer or grip
  118849. * @param result the resulting ray
  118850. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118851. */
  118852. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118853. /**
  118854. * Updates the controller pose based on the given XRFrame
  118855. * @param xrFrame xr frame to update the pose with
  118856. * @param referenceSpace reference space to use
  118857. */
  118858. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118859. }
  118860. }
  118861. declare module BABYLON {
  118862. /**
  118863. * The schema for initialization options of the XR Input class
  118864. */
  118865. export interface IWebXRInputOptions {
  118866. /**
  118867. * If set to true no model will be automatically loaded
  118868. */
  118869. doNotLoadControllerMeshes?: boolean;
  118870. /**
  118871. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118872. * If not found, the xr input profile data will be used.
  118873. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118874. */
  118875. forceInputProfile?: string;
  118876. /**
  118877. * Do not send a request to the controller repository to load the profile.
  118878. *
  118879. * Instead, use the controllers available in babylon itself.
  118880. */
  118881. disableOnlineControllerRepository?: boolean;
  118882. /**
  118883. * A custom URL for the controllers repository
  118884. */
  118885. customControllersRepositoryURL?: string;
  118886. /**
  118887. * Should the controller model's components not move according to the user input
  118888. */
  118889. disableControllerAnimation?: boolean;
  118890. }
  118891. /**
  118892. * XR input used to track XR inputs such as controllers/rays
  118893. */
  118894. export class WebXRInput implements IDisposable {
  118895. /**
  118896. * the xr session manager for this session
  118897. */
  118898. xrSessionManager: WebXRSessionManager;
  118899. /**
  118900. * the WebXR camera for this session. Mainly used for teleportation
  118901. */
  118902. xrCamera: WebXRCamera;
  118903. private readonly options;
  118904. /**
  118905. * XR controllers being tracked
  118906. */
  118907. controllers: Array<WebXRInputSource>;
  118908. private _frameObserver;
  118909. private _sessionEndedObserver;
  118910. private _sessionInitObserver;
  118911. /**
  118912. * Event when a controller has been connected/added
  118913. */
  118914. onControllerAddedObservable: Observable<WebXRInputSource>;
  118915. /**
  118916. * Event when a controller has been removed/disconnected
  118917. */
  118918. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118919. /**
  118920. * Initializes the WebXRInput
  118921. * @param xrSessionManager the xr session manager for this session
  118922. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118923. * @param options = initialization options for this xr input
  118924. */
  118925. constructor(
  118926. /**
  118927. * the xr session manager for this session
  118928. */
  118929. xrSessionManager: WebXRSessionManager,
  118930. /**
  118931. * the WebXR camera for this session. Mainly used for teleportation
  118932. */
  118933. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118934. private _onInputSourcesChange;
  118935. private _addAndRemoveControllers;
  118936. /**
  118937. * Disposes of the object
  118938. */
  118939. dispose(): void;
  118940. }
  118941. }
  118942. declare module BABYLON {
  118943. /**
  118944. * This is the base class for all WebXR features.
  118945. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118946. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118947. */
  118948. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118949. protected _xrSessionManager: WebXRSessionManager;
  118950. private _attached;
  118951. private _removeOnDetach;
  118952. /**
  118953. * Should auto-attach be disabled?
  118954. */
  118955. disableAutoAttach: boolean;
  118956. /**
  118957. * Construct a new (abstract) WebXR feature
  118958. * @param _xrSessionManager the xr session manager for this feature
  118959. */
  118960. constructor(_xrSessionManager: WebXRSessionManager);
  118961. /**
  118962. * Is this feature attached
  118963. */
  118964. get attached(): boolean;
  118965. /**
  118966. * attach this feature
  118967. *
  118968. * @param force should attachment be forced (even when already attached)
  118969. * @returns true if successful, false is failed or already attached
  118970. */
  118971. attach(force?: boolean): boolean;
  118972. /**
  118973. * detach this feature.
  118974. *
  118975. * @returns true if successful, false if failed or already detached
  118976. */
  118977. detach(): boolean;
  118978. /**
  118979. * Dispose this feature and all of the resources attached
  118980. */
  118981. dispose(): void;
  118982. /**
  118983. * This is used to register callbacks that will automatically be removed when detach is called.
  118984. * @param observable the observable to which the observer will be attached
  118985. * @param callback the callback to register
  118986. */
  118987. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118988. /**
  118989. * Code in this function will be executed on each xrFrame received from the browser.
  118990. * This function will not execute after the feature is detached.
  118991. * @param _xrFrame the current frame
  118992. */
  118993. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  118994. }
  118995. }
  118996. declare module BABYLON {
  118997. /**
  118998. * Renders a layer on top of an existing scene
  118999. */
  119000. export class UtilityLayerRenderer implements IDisposable {
  119001. /** the original scene that will be rendered on top of */
  119002. originalScene: Scene;
  119003. private _pointerCaptures;
  119004. private _lastPointerEvents;
  119005. private static _DefaultUtilityLayer;
  119006. private static _DefaultKeepDepthUtilityLayer;
  119007. private _sharedGizmoLight;
  119008. private _renderCamera;
  119009. /**
  119010. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119011. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119012. * @returns the camera that is used when rendering the utility layer
  119013. */
  119014. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119015. /**
  119016. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119017. * @param cam the camera that should be used when rendering the utility layer
  119018. */
  119019. setRenderCamera(cam: Nullable<Camera>): void;
  119020. /**
  119021. * @hidden
  119022. * Light which used by gizmos to get light shading
  119023. */
  119024. _getSharedGizmoLight(): HemisphericLight;
  119025. /**
  119026. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119027. */
  119028. pickUtilitySceneFirst: boolean;
  119029. /**
  119030. * 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)
  119031. */
  119032. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119033. /**
  119034. * 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)
  119035. */
  119036. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119037. /**
  119038. * The scene that is rendered on top of the original scene
  119039. */
  119040. utilityLayerScene: Scene;
  119041. /**
  119042. * If the utility layer should automatically be rendered on top of existing scene
  119043. */
  119044. shouldRender: boolean;
  119045. /**
  119046. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119047. */
  119048. onlyCheckPointerDownEvents: boolean;
  119049. /**
  119050. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119051. */
  119052. processAllEvents: boolean;
  119053. /**
  119054. * Observable raised when the pointer move from the utility layer scene to the main scene
  119055. */
  119056. onPointerOutObservable: Observable<number>;
  119057. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119058. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119059. private _afterRenderObserver;
  119060. private _sceneDisposeObserver;
  119061. private _originalPointerObserver;
  119062. /**
  119063. * Instantiates a UtilityLayerRenderer
  119064. * @param originalScene the original scene that will be rendered on top of
  119065. * @param handleEvents boolean indicating if the utility layer should handle events
  119066. */
  119067. constructor(
  119068. /** the original scene that will be rendered on top of */
  119069. originalScene: Scene, handleEvents?: boolean);
  119070. private _notifyObservers;
  119071. /**
  119072. * Renders the utility layers scene on top of the original scene
  119073. */
  119074. render(): void;
  119075. /**
  119076. * Disposes of the renderer
  119077. */
  119078. dispose(): void;
  119079. private _updateCamera;
  119080. }
  119081. }
  119082. declare module BABYLON {
  119083. /**
  119084. * Options interface for the pointer selection module
  119085. */
  119086. export interface IWebXRControllerPointerSelectionOptions {
  119087. /**
  119088. * if provided, this scene will be used to render meshes.
  119089. */
  119090. customUtilityLayerScene?: Scene;
  119091. /**
  119092. * 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)
  119093. * If not disabled, the last picked point will be used to execute a pointer up event
  119094. * If disabled, pointer up event will be triggered right after the pointer down event.
  119095. * Used in screen and gaze target ray mode only
  119096. */
  119097. disablePointerUpOnTouchOut: boolean;
  119098. /**
  119099. * For gaze mode (time to select instead of press)
  119100. */
  119101. forceGazeMode: boolean;
  119102. /**
  119103. * 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
  119104. * to start a new countdown to the pointer down event.
  119105. * Defaults to 1.
  119106. */
  119107. gazeModePointerMovedFactor?: number;
  119108. /**
  119109. * Different button type to use instead of the main component
  119110. */
  119111. overrideButtonId?: string;
  119112. /**
  119113. * use this rendering group id for the meshes (optional)
  119114. */
  119115. renderingGroupId?: number;
  119116. /**
  119117. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119118. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119119. * 3000 means 3 seconds between pointing at something and selecting it
  119120. */
  119121. timeToSelect?: number;
  119122. /**
  119123. * Should meshes created here be added to a utility layer or the main scene
  119124. */
  119125. useUtilityLayer?: boolean;
  119126. /**
  119127. * the xr input to use with this pointer selection
  119128. */
  119129. xrInput: WebXRInput;
  119130. }
  119131. /**
  119132. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119133. */
  119134. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119135. private readonly _options;
  119136. private static _idCounter;
  119137. private _attachController;
  119138. private _controllers;
  119139. private _scene;
  119140. private _tmpVectorForPickCompare;
  119141. /**
  119142. * The module's name
  119143. */
  119144. static readonly Name: string;
  119145. /**
  119146. * The (Babylon) version of this module.
  119147. * This is an integer representing the implementation version.
  119148. * This number does not correspond to the WebXR specs version
  119149. */
  119150. static readonly Version: number;
  119151. /**
  119152. * Disable lighting on the laser pointer (so it will always be visible)
  119153. */
  119154. disablePointerLighting: boolean;
  119155. /**
  119156. * Disable lighting on the selection mesh (so it will always be visible)
  119157. */
  119158. disableSelectionMeshLighting: boolean;
  119159. /**
  119160. * Should the laser pointer be displayed
  119161. */
  119162. displayLaserPointer: boolean;
  119163. /**
  119164. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119165. */
  119166. displaySelectionMesh: boolean;
  119167. /**
  119168. * This color will be set to the laser pointer when selection is triggered
  119169. */
  119170. laserPointerPickedColor: Color3;
  119171. /**
  119172. * Default color of the laser pointer
  119173. */
  119174. lasterPointerDefaultColor: Color3;
  119175. /**
  119176. * default color of the selection ring
  119177. */
  119178. selectionMeshDefaultColor: Color3;
  119179. /**
  119180. * This color will be applied to the selection ring when selection is triggered
  119181. */
  119182. selectionMeshPickedColor: Color3;
  119183. /**
  119184. * Optional filter to be used for ray selection. This predicate shares behavior with
  119185. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119186. */
  119187. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119188. /**
  119189. * constructs a new background remover module
  119190. * @param _xrSessionManager the session manager for this module
  119191. * @param _options read-only options to be used in this module
  119192. */
  119193. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119194. /**
  119195. * attach this feature
  119196. * Will usually be called by the features manager
  119197. *
  119198. * @returns true if successful.
  119199. */
  119200. attach(): boolean;
  119201. /**
  119202. * detach this feature.
  119203. * Will usually be called by the features manager
  119204. *
  119205. * @returns true if successful.
  119206. */
  119207. detach(): boolean;
  119208. /**
  119209. * Will get the mesh under a specific pointer.
  119210. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119211. * @param controllerId the controllerId to check
  119212. * @returns The mesh under pointer or null if no mesh is under the pointer
  119213. */
  119214. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119215. /**
  119216. * Get the xr controller that correlates to the pointer id in the pointer event
  119217. *
  119218. * @param id the pointer id to search for
  119219. * @returns the controller that correlates to this id or null if not found
  119220. */
  119221. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119222. protected _onXRFrame(_xrFrame: XRFrame): void;
  119223. private _attachGazeMode;
  119224. private _attachScreenRayMode;
  119225. private _attachTrackedPointerRayMode;
  119226. private _convertNormalToDirectionOfRay;
  119227. private _detachController;
  119228. private _generateNewMeshPair;
  119229. private _pickingMoved;
  119230. private _updatePointerDistance;
  119231. }
  119232. }
  119233. declare module BABYLON {
  119234. /**
  119235. * Button which can be used to enter a different mode of XR
  119236. */
  119237. export class WebXREnterExitUIButton {
  119238. /** button element */
  119239. element: HTMLElement;
  119240. /** XR initialization options for the button */
  119241. sessionMode: XRSessionMode;
  119242. /** Reference space type */
  119243. referenceSpaceType: XRReferenceSpaceType;
  119244. /**
  119245. * Creates a WebXREnterExitUIButton
  119246. * @param element button element
  119247. * @param sessionMode XR initialization session mode
  119248. * @param referenceSpaceType the type of reference space to be used
  119249. */
  119250. constructor(
  119251. /** button element */
  119252. element: HTMLElement,
  119253. /** XR initialization options for the button */
  119254. sessionMode: XRSessionMode,
  119255. /** Reference space type */
  119256. referenceSpaceType: XRReferenceSpaceType);
  119257. /**
  119258. * Extendable function which can be used to update the button's visuals when the state changes
  119259. * @param activeButton the current active button in the UI
  119260. */
  119261. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119262. }
  119263. /**
  119264. * Options to create the webXR UI
  119265. */
  119266. export class WebXREnterExitUIOptions {
  119267. /**
  119268. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119269. */
  119270. customButtons?: Array<WebXREnterExitUIButton>;
  119271. /**
  119272. * A reference space type to use when creating the default button.
  119273. * Default is local-floor
  119274. */
  119275. referenceSpaceType?: XRReferenceSpaceType;
  119276. /**
  119277. * Context to enter xr with
  119278. */
  119279. renderTarget?: Nullable<WebXRRenderTarget>;
  119280. /**
  119281. * A session mode to use when creating the default button.
  119282. * Default is immersive-vr
  119283. */
  119284. sessionMode?: XRSessionMode;
  119285. }
  119286. /**
  119287. * UI to allow the user to enter/exit XR mode
  119288. */
  119289. export class WebXREnterExitUI implements IDisposable {
  119290. private scene;
  119291. /** version of the options passed to this UI */
  119292. options: WebXREnterExitUIOptions;
  119293. private _activeButton;
  119294. private _buttons;
  119295. private _overlay;
  119296. /**
  119297. * Fired every time the active button is changed.
  119298. *
  119299. * When xr is entered via a button that launches xr that button will be the callback parameter
  119300. *
  119301. * When exiting xr the callback parameter will be null)
  119302. */
  119303. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119304. /**
  119305. *
  119306. * @param scene babylon scene object to use
  119307. * @param options (read-only) version of the options passed to this UI
  119308. */
  119309. private constructor();
  119310. /**
  119311. * Creates UI to allow the user to enter/exit XR mode
  119312. * @param scene the scene to add the ui to
  119313. * @param helper the xr experience helper to enter/exit xr with
  119314. * @param options options to configure the UI
  119315. * @returns the created ui
  119316. */
  119317. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119318. /**
  119319. * Disposes of the XR UI component
  119320. */
  119321. dispose(): void;
  119322. private _updateButtons;
  119323. }
  119324. }
  119325. declare module BABYLON {
  119326. /**
  119327. * Class containing static functions to help procedurally build meshes
  119328. */
  119329. export class LinesBuilder {
  119330. /**
  119331. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119332. * * 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
  119333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119334. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119335. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119336. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119338. * * 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
  119339. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119342. * @param name defines the name of the new line system
  119343. * @param options defines the options used to create the line system
  119344. * @param scene defines the hosting scene
  119345. * @returns a new line system mesh
  119346. */
  119347. static CreateLineSystem(name: string, options: {
  119348. lines: Vector3[][];
  119349. updatable?: boolean;
  119350. instance?: Nullable<LinesMesh>;
  119351. colors?: Nullable<Color4[][]>;
  119352. useVertexAlpha?: boolean;
  119353. }, scene: Nullable<Scene>): LinesMesh;
  119354. /**
  119355. * Creates a line mesh
  119356. * 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
  119357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119358. * * The parameter `points` is an array successive Vector3
  119359. * * 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
  119360. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119362. * * When updating an instance, remember that only point positions can change, not the number of points
  119363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119365. * @param name defines the name of the new line system
  119366. * @param options defines the options used to create the line system
  119367. * @param scene defines the hosting scene
  119368. * @returns a new line mesh
  119369. */
  119370. static CreateLines(name: string, options: {
  119371. points: Vector3[];
  119372. updatable?: boolean;
  119373. instance?: Nullable<LinesMesh>;
  119374. colors?: Color4[];
  119375. useVertexAlpha?: boolean;
  119376. }, scene?: Nullable<Scene>): LinesMesh;
  119377. /**
  119378. * Creates a dashed line mesh
  119379. * * 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
  119380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119381. * * The parameter `points` is an array successive Vector3
  119382. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119383. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119384. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119385. * * 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
  119386. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119387. * * When updating an instance, remember that only point positions can change, not the number of points
  119388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119389. * @param name defines the name of the mesh
  119390. * @param options defines the options used to create the mesh
  119391. * @param scene defines the hosting scene
  119392. * @returns the dashed line mesh
  119393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119394. */
  119395. static CreateDashedLines(name: string, options: {
  119396. points: Vector3[];
  119397. dashSize?: number;
  119398. gapSize?: number;
  119399. dashNb?: number;
  119400. updatable?: boolean;
  119401. instance?: LinesMesh;
  119402. useVertexAlpha?: boolean;
  119403. }, scene?: Nullable<Scene>): LinesMesh;
  119404. }
  119405. }
  119406. declare module BABYLON {
  119407. /**
  119408. * The options container for the teleportation module
  119409. */
  119410. export interface IWebXRTeleportationOptions {
  119411. /**
  119412. * if provided, this scene will be used to render meshes.
  119413. */
  119414. customUtilityLayerScene?: Scene;
  119415. /**
  119416. * Values to configure the default target mesh
  119417. */
  119418. defaultTargetMeshOptions?: {
  119419. /**
  119420. * Fill color of the teleportation area
  119421. */
  119422. teleportationFillColor?: string;
  119423. /**
  119424. * Border color for the teleportation area
  119425. */
  119426. teleportationBorderColor?: string;
  119427. /**
  119428. * Disable the mesh's animation sequence
  119429. */
  119430. disableAnimation?: boolean;
  119431. /**
  119432. * Disable lighting on the material or the ring and arrow
  119433. */
  119434. disableLighting?: boolean;
  119435. /**
  119436. * Override the default material of the torus and arrow
  119437. */
  119438. torusArrowMaterial?: Material;
  119439. };
  119440. /**
  119441. * A list of meshes to use as floor meshes.
  119442. * Meshes can be added and removed after initializing the feature using the
  119443. * addFloorMesh and removeFloorMesh functions
  119444. * If empty, rotation will still work
  119445. */
  119446. floorMeshes?: AbstractMesh[];
  119447. /**
  119448. * use this rendering group id for the meshes (optional)
  119449. */
  119450. renderingGroupId?: number;
  119451. /**
  119452. * Should teleportation move only to snap points
  119453. */
  119454. snapPointsOnly?: boolean;
  119455. /**
  119456. * An array of points to which the teleportation will snap to.
  119457. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119458. */
  119459. snapPositions?: Vector3[];
  119460. /**
  119461. * How close should the teleportation ray be in order to snap to position.
  119462. * Default to 0.8 units (meters)
  119463. */
  119464. snapToPositionRadius?: number;
  119465. /**
  119466. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119467. * If you want to support rotation, make sure your mesh has a direction indicator.
  119468. *
  119469. * When left untouched, the default mesh will be initialized.
  119470. */
  119471. teleportationTargetMesh?: AbstractMesh;
  119472. /**
  119473. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119474. */
  119475. timeToTeleport?: number;
  119476. /**
  119477. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119478. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119479. */
  119480. useMainComponentOnly?: boolean;
  119481. /**
  119482. * Should meshes created here be added to a utility layer or the main scene
  119483. */
  119484. useUtilityLayer?: boolean;
  119485. /**
  119486. * Babylon XR Input class for controller
  119487. */
  119488. xrInput: WebXRInput;
  119489. }
  119490. /**
  119491. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119492. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119493. * the input of the attached controllers.
  119494. */
  119495. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119496. private _options;
  119497. private _controllers;
  119498. private _currentTeleportationControllerId;
  119499. private _floorMeshes;
  119500. private _quadraticBezierCurve;
  119501. private _selectionFeature;
  119502. private _snapToPositions;
  119503. private _snappedToPoint;
  119504. private _teleportationRingMaterial?;
  119505. private _tmpRay;
  119506. private _tmpVector;
  119507. /**
  119508. * The module's name
  119509. */
  119510. static readonly Name: string;
  119511. /**
  119512. * The (Babylon) version of this module.
  119513. * This is an integer representing the implementation version.
  119514. * This number does not correspond to the webxr specs version
  119515. */
  119516. static readonly Version: number;
  119517. /**
  119518. * Is movement backwards enabled
  119519. */
  119520. backwardsMovementEnabled: boolean;
  119521. /**
  119522. * Distance to travel when moving backwards
  119523. */
  119524. backwardsTeleportationDistance: number;
  119525. /**
  119526. * The distance from the user to the inspection point in the direction of the controller
  119527. * A higher number will allow the user to move further
  119528. * defaults to 5 (meters, in xr units)
  119529. */
  119530. parabolicCheckRadius: number;
  119531. /**
  119532. * Should the module support parabolic ray on top of direct ray
  119533. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119534. * Very helpful when moving between floors / different heights
  119535. */
  119536. parabolicRayEnabled: boolean;
  119537. /**
  119538. * How much rotation should be applied when rotating right and left
  119539. */
  119540. rotationAngle: number;
  119541. /**
  119542. * Is rotation enabled when moving forward?
  119543. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119544. */
  119545. rotationEnabled: boolean;
  119546. /**
  119547. * constructs a new anchor system
  119548. * @param _xrSessionManager an instance of WebXRSessionManager
  119549. * @param _options configuration object for this feature
  119550. */
  119551. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119552. /**
  119553. * Get the snapPointsOnly flag
  119554. */
  119555. get snapPointsOnly(): boolean;
  119556. /**
  119557. * Sets the snapPointsOnly flag
  119558. * @param snapToPoints should teleportation be exclusively to snap points
  119559. */
  119560. set snapPointsOnly(snapToPoints: boolean);
  119561. /**
  119562. * Add a new mesh to the floor meshes array
  119563. * @param mesh the mesh to use as floor mesh
  119564. */
  119565. addFloorMesh(mesh: AbstractMesh): void;
  119566. /**
  119567. * Add a new snap-to point to fix teleportation to this position
  119568. * @param newSnapPoint The new Snap-To point
  119569. */
  119570. addSnapPoint(newSnapPoint: Vector3): void;
  119571. attach(): boolean;
  119572. detach(): boolean;
  119573. dispose(): void;
  119574. /**
  119575. * Remove a mesh from the floor meshes array
  119576. * @param mesh the mesh to remove
  119577. */
  119578. removeFloorMesh(mesh: AbstractMesh): void;
  119579. /**
  119580. * Remove a mesh from the floor meshes array using its name
  119581. * @param name the mesh name to remove
  119582. */
  119583. removeFloorMeshByName(name: string): void;
  119584. /**
  119585. * 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
  119586. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119587. * @returns was the point found and removed or not
  119588. */
  119589. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119590. /**
  119591. * This function sets a selection feature that will be disabled when
  119592. * the forward ray is shown and will be reattached when hidden.
  119593. * This is used to remove the selection rays when moving.
  119594. * @param selectionFeature the feature to disable when forward movement is enabled
  119595. */
  119596. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119597. protected _onXRFrame(_xrFrame: XRFrame): void;
  119598. private _attachController;
  119599. private _createDefaultTargetMesh;
  119600. private _detachController;
  119601. private _findClosestSnapPointWithRadius;
  119602. private _setTargetMeshPosition;
  119603. private _setTargetMeshVisibility;
  119604. private _showParabolicPath;
  119605. private _teleportForward;
  119606. }
  119607. }
  119608. declare module BABYLON {
  119609. /**
  119610. * Options for the default xr helper
  119611. */
  119612. export class WebXRDefaultExperienceOptions {
  119613. /**
  119614. * Enable or disable default UI to enter XR
  119615. */
  119616. disableDefaultUI?: boolean;
  119617. /**
  119618. * Should teleportation not initialize. defaults to false.
  119619. */
  119620. disableTeleportation?: boolean;
  119621. /**
  119622. * Floor meshes that will be used for teleport
  119623. */
  119624. floorMeshes?: Array<AbstractMesh>;
  119625. /**
  119626. * If set to true, the first frame will not be used to reset position
  119627. * The first frame is mainly used when copying transformation from the old camera
  119628. * Mainly used in AR
  119629. */
  119630. ignoreNativeCameraTransformation?: boolean;
  119631. /**
  119632. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119633. */
  119634. inputOptions?: IWebXRInputOptions;
  119635. /**
  119636. * optional configuration for the output canvas
  119637. */
  119638. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119639. /**
  119640. * optional UI options. This can be used among other to change session mode and reference space type
  119641. */
  119642. uiOptions?: WebXREnterExitUIOptions;
  119643. /**
  119644. * When loading teleportation and pointer select, use stable versions instead of latest.
  119645. */
  119646. useStablePlugins?: boolean;
  119647. }
  119648. /**
  119649. * Default experience which provides a similar setup to the previous webVRExperience
  119650. */
  119651. export class WebXRDefaultExperience {
  119652. /**
  119653. * Base experience
  119654. */
  119655. baseExperience: WebXRExperienceHelper;
  119656. /**
  119657. * Enables ui for entering/exiting xr
  119658. */
  119659. enterExitUI: WebXREnterExitUI;
  119660. /**
  119661. * Input experience extension
  119662. */
  119663. input: WebXRInput;
  119664. /**
  119665. * Enables laser pointer and selection
  119666. */
  119667. pointerSelection: WebXRControllerPointerSelection;
  119668. /**
  119669. * Default target xr should render to
  119670. */
  119671. renderTarget: WebXRRenderTarget;
  119672. /**
  119673. * Enables teleportation
  119674. */
  119675. teleportation: WebXRMotionControllerTeleportation;
  119676. private constructor();
  119677. /**
  119678. * Creates the default xr experience
  119679. * @param scene scene
  119680. * @param options options for basic configuration
  119681. * @returns resulting WebXRDefaultExperience
  119682. */
  119683. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119684. /**
  119685. * DIsposes of the experience helper
  119686. */
  119687. dispose(): void;
  119688. }
  119689. }
  119690. declare module BABYLON {
  119691. /**
  119692. * Options to modify the vr teleportation behavior.
  119693. */
  119694. export interface VRTeleportationOptions {
  119695. /**
  119696. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119697. */
  119698. floorMeshName?: string;
  119699. /**
  119700. * A list of meshes to be used as the teleportation floor. (default: empty)
  119701. */
  119702. floorMeshes?: Mesh[];
  119703. /**
  119704. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119705. */
  119706. teleportationMode?: number;
  119707. /**
  119708. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119709. */
  119710. teleportationTime?: number;
  119711. /**
  119712. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119713. */
  119714. teleportationSpeed?: number;
  119715. /**
  119716. * The easing function used in the animation or null for Linear. (default CircleEase)
  119717. */
  119718. easingFunction?: EasingFunction;
  119719. }
  119720. /**
  119721. * Options to modify the vr experience helper's behavior.
  119722. */
  119723. export interface VRExperienceHelperOptions extends WebVROptions {
  119724. /**
  119725. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119726. */
  119727. createDeviceOrientationCamera?: boolean;
  119728. /**
  119729. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119730. */
  119731. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119732. /**
  119733. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119734. */
  119735. laserToggle?: boolean;
  119736. /**
  119737. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119738. */
  119739. floorMeshes?: Mesh[];
  119740. /**
  119741. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119742. */
  119743. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119744. /**
  119745. * Defines if WebXR should be used instead of WebVR (if available)
  119746. */
  119747. useXR?: boolean;
  119748. }
  119749. /**
  119750. * Event containing information after VR has been entered
  119751. */
  119752. export class OnAfterEnteringVRObservableEvent {
  119753. /**
  119754. * If entering vr was successful
  119755. */
  119756. success: boolean;
  119757. }
  119758. /**
  119759. * Helps to quickly add VR support to an existing scene.
  119760. * See http://doc.babylonjs.com/how_to/webvr_helper
  119761. */
  119762. export class VRExperienceHelper {
  119763. /** Options to modify the vr experience helper's behavior. */
  119764. webVROptions: VRExperienceHelperOptions;
  119765. private _scene;
  119766. private _position;
  119767. private _btnVR;
  119768. private _btnVRDisplayed;
  119769. private _webVRsupported;
  119770. private _webVRready;
  119771. private _webVRrequesting;
  119772. private _webVRpresenting;
  119773. private _hasEnteredVR;
  119774. private _fullscreenVRpresenting;
  119775. private _inputElement;
  119776. private _webVRCamera;
  119777. private _vrDeviceOrientationCamera;
  119778. private _deviceOrientationCamera;
  119779. private _existingCamera;
  119780. private _onKeyDown;
  119781. private _onVrDisplayPresentChange;
  119782. private _onVRDisplayChanged;
  119783. private _onVRRequestPresentStart;
  119784. private _onVRRequestPresentComplete;
  119785. /**
  119786. * 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)
  119787. */
  119788. enableGazeEvenWhenNoPointerLock: boolean;
  119789. /**
  119790. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119791. */
  119792. exitVROnDoubleTap: boolean;
  119793. /**
  119794. * Observable raised right before entering VR.
  119795. */
  119796. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119797. /**
  119798. * Observable raised when entering VR has completed.
  119799. */
  119800. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119801. /**
  119802. * Observable raised when exiting VR.
  119803. */
  119804. onExitingVRObservable: Observable<VRExperienceHelper>;
  119805. /**
  119806. * Observable raised when controller mesh is loaded.
  119807. */
  119808. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119809. /** Return this.onEnteringVRObservable
  119810. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119811. */
  119812. get onEnteringVR(): Observable<VRExperienceHelper>;
  119813. /** Return this.onExitingVRObservable
  119814. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119815. */
  119816. get onExitingVR(): Observable<VRExperienceHelper>;
  119817. /** Return this.onControllerMeshLoadedObservable
  119818. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119819. */
  119820. get onControllerMeshLoaded(): Observable<WebVRController>;
  119821. private _rayLength;
  119822. private _useCustomVRButton;
  119823. private _teleportationRequested;
  119824. private _teleportActive;
  119825. private _floorMeshName;
  119826. private _floorMeshesCollection;
  119827. private _teleportationMode;
  119828. private _teleportationTime;
  119829. private _teleportationSpeed;
  119830. private _teleportationEasing;
  119831. private _rotationAllowed;
  119832. private _teleportBackwardsVector;
  119833. private _teleportationTarget;
  119834. private _isDefaultTeleportationTarget;
  119835. private _postProcessMove;
  119836. private _teleportationFillColor;
  119837. private _teleportationBorderColor;
  119838. private _rotationAngle;
  119839. private _haloCenter;
  119840. private _cameraGazer;
  119841. private _padSensibilityUp;
  119842. private _padSensibilityDown;
  119843. private _leftController;
  119844. private _rightController;
  119845. private _gazeColor;
  119846. private _laserColor;
  119847. private _pickedLaserColor;
  119848. private _pickedGazeColor;
  119849. /**
  119850. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119851. */
  119852. onNewMeshSelected: Observable<AbstractMesh>;
  119853. /**
  119854. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119855. * This observable will provide the mesh and the controller used to select the mesh
  119856. */
  119857. onMeshSelectedWithController: Observable<{
  119858. mesh: AbstractMesh;
  119859. controller: WebVRController;
  119860. }>;
  119861. /**
  119862. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119863. */
  119864. onNewMeshPicked: Observable<PickingInfo>;
  119865. private _circleEase;
  119866. /**
  119867. * Observable raised before camera teleportation
  119868. */
  119869. onBeforeCameraTeleport: Observable<Vector3>;
  119870. /**
  119871. * Observable raised after camera teleportation
  119872. */
  119873. onAfterCameraTeleport: Observable<Vector3>;
  119874. /**
  119875. * Observable raised when current selected mesh gets unselected
  119876. */
  119877. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119878. private _raySelectionPredicate;
  119879. /**
  119880. * To be optionaly changed by user to define custom ray selection
  119881. */
  119882. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119883. /**
  119884. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119885. */
  119886. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119887. /**
  119888. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119889. */
  119890. teleportationEnabled: boolean;
  119891. private _defaultHeight;
  119892. private _teleportationInitialized;
  119893. private _interactionsEnabled;
  119894. private _interactionsRequested;
  119895. private _displayGaze;
  119896. private _displayLaserPointer;
  119897. /**
  119898. * The mesh used to display where the user is going to teleport.
  119899. */
  119900. get teleportationTarget(): Mesh;
  119901. /**
  119902. * Sets the mesh to be used to display where the user is going to teleport.
  119903. */
  119904. set teleportationTarget(value: Mesh);
  119905. /**
  119906. * 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
  119907. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119908. * See http://doc.babylonjs.com/resources/baking_transformations
  119909. */
  119910. get gazeTrackerMesh(): Mesh;
  119911. set gazeTrackerMesh(value: Mesh);
  119912. /**
  119913. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119914. */
  119915. updateGazeTrackerScale: boolean;
  119916. /**
  119917. * If the gaze trackers color should be updated when selecting meshes
  119918. */
  119919. updateGazeTrackerColor: boolean;
  119920. /**
  119921. * If the controller laser color should be updated when selecting meshes
  119922. */
  119923. updateControllerLaserColor: boolean;
  119924. /**
  119925. * The gaze tracking mesh corresponding to the left controller
  119926. */
  119927. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119928. /**
  119929. * The gaze tracking mesh corresponding to the right controller
  119930. */
  119931. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119932. /**
  119933. * If the ray of the gaze should be displayed.
  119934. */
  119935. get displayGaze(): boolean;
  119936. /**
  119937. * Sets if the ray of the gaze should be displayed.
  119938. */
  119939. set displayGaze(value: boolean);
  119940. /**
  119941. * If the ray of the LaserPointer should be displayed.
  119942. */
  119943. get displayLaserPointer(): boolean;
  119944. /**
  119945. * Sets if the ray of the LaserPointer should be displayed.
  119946. */
  119947. set displayLaserPointer(value: boolean);
  119948. /**
  119949. * The deviceOrientationCamera used as the camera when not in VR.
  119950. */
  119951. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119952. /**
  119953. * Based on the current WebVR support, returns the current VR camera used.
  119954. */
  119955. get currentVRCamera(): Nullable<Camera>;
  119956. /**
  119957. * The webVRCamera which is used when in VR.
  119958. */
  119959. get webVRCamera(): WebVRFreeCamera;
  119960. /**
  119961. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119962. */
  119963. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119964. /**
  119965. * The html button that is used to trigger entering into VR.
  119966. */
  119967. get vrButton(): Nullable<HTMLButtonElement>;
  119968. private get _teleportationRequestInitiated();
  119969. /**
  119970. * Defines whether or not Pointer lock should be requested when switching to
  119971. * full screen.
  119972. */
  119973. requestPointerLockOnFullScreen: boolean;
  119974. /**
  119975. * If asking to force XR, this will be populated with the default xr experience
  119976. */
  119977. xr: WebXRDefaultExperience;
  119978. /**
  119979. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119980. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119981. */
  119982. xrTestDone: boolean;
  119983. /**
  119984. * Instantiates a VRExperienceHelper.
  119985. * Helps to quickly add VR support to an existing scene.
  119986. * @param scene The scene the VRExperienceHelper belongs to.
  119987. * @param webVROptions Options to modify the vr experience helper's behavior.
  119988. */
  119989. constructor(scene: Scene,
  119990. /** Options to modify the vr experience helper's behavior. */
  119991. webVROptions?: VRExperienceHelperOptions);
  119992. private completeVRInit;
  119993. private _onDefaultMeshLoaded;
  119994. private _onResize;
  119995. private _onFullscreenChange;
  119996. /**
  119997. * Gets a value indicating if we are currently in VR mode.
  119998. */
  119999. get isInVRMode(): boolean;
  120000. private onVrDisplayPresentChange;
  120001. private onVRDisplayChanged;
  120002. private moveButtonToBottomRight;
  120003. private displayVRButton;
  120004. private updateButtonVisibility;
  120005. private _cachedAngularSensibility;
  120006. /**
  120007. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120008. * Otherwise, will use the fullscreen API.
  120009. */
  120010. enterVR(): void;
  120011. /**
  120012. * Attempt to exit VR, or fullscreen.
  120013. */
  120014. exitVR(): void;
  120015. /**
  120016. * The position of the vr experience helper.
  120017. */
  120018. get position(): Vector3;
  120019. /**
  120020. * Sets the position of the vr experience helper.
  120021. */
  120022. set position(value: Vector3);
  120023. /**
  120024. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120025. */
  120026. enableInteractions(): void;
  120027. private get _noControllerIsActive();
  120028. private beforeRender;
  120029. private _isTeleportationFloor;
  120030. /**
  120031. * Adds a floor mesh to be used for teleportation.
  120032. * @param floorMesh the mesh to be used for teleportation.
  120033. */
  120034. addFloorMesh(floorMesh: Mesh): void;
  120035. /**
  120036. * Removes a floor mesh from being used for teleportation.
  120037. * @param floorMesh the mesh to be removed.
  120038. */
  120039. removeFloorMesh(floorMesh: Mesh): void;
  120040. /**
  120041. * Enables interactions and teleportation using the VR controllers and gaze.
  120042. * @param vrTeleportationOptions options to modify teleportation behavior.
  120043. */
  120044. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120045. private _onNewGamepadConnected;
  120046. private _tryEnableInteractionOnController;
  120047. private _onNewGamepadDisconnected;
  120048. private _enableInteractionOnController;
  120049. private _checkTeleportWithRay;
  120050. private _checkRotate;
  120051. private _checkTeleportBackwards;
  120052. private _enableTeleportationOnController;
  120053. private _createTeleportationCircles;
  120054. private _displayTeleportationTarget;
  120055. private _hideTeleportationTarget;
  120056. private _rotateCamera;
  120057. private _moveTeleportationSelectorTo;
  120058. private _workingVector;
  120059. private _workingQuaternion;
  120060. private _workingMatrix;
  120061. /**
  120062. * Time Constant Teleportation Mode
  120063. */
  120064. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120065. /**
  120066. * Speed Constant Teleportation Mode
  120067. */
  120068. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120069. /**
  120070. * Teleports the users feet to the desired location
  120071. * @param location The location where the user's feet should be placed
  120072. */
  120073. teleportCamera(location: Vector3): void;
  120074. private _convertNormalToDirectionOfRay;
  120075. private _castRayAndSelectObject;
  120076. private _notifySelectedMeshUnselected;
  120077. /**
  120078. * Permanently set new colors for the laser pointer
  120079. * @param color the new laser color
  120080. * @param pickedColor the new laser color when picked mesh detected
  120081. */
  120082. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120083. /**
  120084. * Set lighting enabled / disabled on the laser pointer of both controllers
  120085. * @param enabled should the lighting be enabled on the laser pointer
  120086. */
  120087. setLaserLightingState(enabled?: boolean): void;
  120088. /**
  120089. * Permanently set new colors for the gaze pointer
  120090. * @param color the new gaze color
  120091. * @param pickedColor the new gaze color when picked mesh detected
  120092. */
  120093. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120094. /**
  120095. * Sets the color of the laser ray from the vr controllers.
  120096. * @param color new color for the ray.
  120097. */
  120098. changeLaserColor(color: Color3): void;
  120099. /**
  120100. * Sets the color of the ray from the vr headsets gaze.
  120101. * @param color new color for the ray.
  120102. */
  120103. changeGazeColor(color: Color3): void;
  120104. /**
  120105. * Exits VR and disposes of the vr experience helper
  120106. */
  120107. dispose(): void;
  120108. /**
  120109. * Gets the name of the VRExperienceHelper class
  120110. * @returns "VRExperienceHelper"
  120111. */
  120112. getClassName(): string;
  120113. }
  120114. }
  120115. declare module BABYLON {
  120116. /**
  120117. * Contains an array of blocks representing the octree
  120118. */
  120119. export interface IOctreeContainer<T> {
  120120. /**
  120121. * Blocks within the octree
  120122. */
  120123. blocks: Array<OctreeBlock<T>>;
  120124. }
  120125. /**
  120126. * Class used to store a cell in an octree
  120127. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120128. */
  120129. export class OctreeBlock<T> {
  120130. /**
  120131. * Gets the content of the current block
  120132. */
  120133. entries: T[];
  120134. /**
  120135. * Gets the list of block children
  120136. */
  120137. blocks: Array<OctreeBlock<T>>;
  120138. private _depth;
  120139. private _maxDepth;
  120140. private _capacity;
  120141. private _minPoint;
  120142. private _maxPoint;
  120143. private _boundingVectors;
  120144. private _creationFunc;
  120145. /**
  120146. * Creates a new block
  120147. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120148. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120149. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120150. * @param depth defines the current depth of this block in the octree
  120151. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120152. * @param creationFunc defines a callback to call when an element is added to the block
  120153. */
  120154. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120155. /**
  120156. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120157. */
  120158. get capacity(): number;
  120159. /**
  120160. * Gets the minimum vector (in world space) of the block's bounding box
  120161. */
  120162. get minPoint(): Vector3;
  120163. /**
  120164. * Gets the maximum vector (in world space) of the block's bounding box
  120165. */
  120166. get maxPoint(): Vector3;
  120167. /**
  120168. * Add a new element to this block
  120169. * @param entry defines the element to add
  120170. */
  120171. addEntry(entry: T): void;
  120172. /**
  120173. * Remove an element from this block
  120174. * @param entry defines the element to remove
  120175. */
  120176. removeEntry(entry: T): void;
  120177. /**
  120178. * Add an array of elements to this block
  120179. * @param entries defines the array of elements to add
  120180. */
  120181. addEntries(entries: T[]): void;
  120182. /**
  120183. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120184. * @param frustumPlanes defines the frustum planes to test
  120185. * @param selection defines the array to store current content if selection is positive
  120186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120187. */
  120188. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120189. /**
  120190. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120191. * @param sphereCenter defines the bounding sphere center
  120192. * @param sphereRadius defines the bounding sphere radius
  120193. * @param selection defines the array to store current content if selection is positive
  120194. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120195. */
  120196. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120197. /**
  120198. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120199. * @param ray defines the ray to test with
  120200. * @param selection defines the array to store current content if selection is positive
  120201. */
  120202. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120203. /**
  120204. * Subdivide the content into child blocks (this block will then be empty)
  120205. */
  120206. createInnerBlocks(): void;
  120207. /**
  120208. * @hidden
  120209. */
  120210. 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;
  120211. }
  120212. }
  120213. declare module BABYLON {
  120214. /**
  120215. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120216. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120217. */
  120218. export class Octree<T> {
  120219. /** 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.) */
  120220. maxDepth: number;
  120221. /**
  120222. * Blocks within the octree containing objects
  120223. */
  120224. blocks: Array<OctreeBlock<T>>;
  120225. /**
  120226. * Content stored in the octree
  120227. */
  120228. dynamicContent: T[];
  120229. private _maxBlockCapacity;
  120230. private _selectionContent;
  120231. private _creationFunc;
  120232. /**
  120233. * Creates a octree
  120234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120235. * @param creationFunc function to be used to instatiate the octree
  120236. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120237. * @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.)
  120238. */
  120239. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120240. /** 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.) */
  120241. maxDepth?: number);
  120242. /**
  120243. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120244. * @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);
  120245. * @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);
  120246. * @param entries meshes to be added to the octree blocks
  120247. */
  120248. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120249. /**
  120250. * Adds a mesh to the octree
  120251. * @param entry Mesh to add to the octree
  120252. */
  120253. addMesh(entry: T): void;
  120254. /**
  120255. * Remove an element from the octree
  120256. * @param entry defines the element to remove
  120257. */
  120258. removeMesh(entry: T): void;
  120259. /**
  120260. * Selects an array of meshes within the frustum
  120261. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120262. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120263. * @returns array of meshes within the frustum
  120264. */
  120265. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120266. /**
  120267. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120268. * @param sphereCenter defines the bounding sphere center
  120269. * @param sphereRadius defines the bounding sphere radius
  120270. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120271. * @returns an array of objects that intersect the sphere
  120272. */
  120273. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120274. /**
  120275. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120276. * @param ray defines the ray to test with
  120277. * @returns array of intersected objects
  120278. */
  120279. intersectsRay(ray: Ray): SmartArray<T>;
  120280. /**
  120281. * Adds a mesh into the octree block if it intersects the block
  120282. */
  120283. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120284. /**
  120285. * Adds a submesh into the octree block if it intersects the block
  120286. */
  120287. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120288. }
  120289. }
  120290. declare module BABYLON {
  120291. interface Scene {
  120292. /**
  120293. * @hidden
  120294. * Backing Filed
  120295. */
  120296. _selectionOctree: Octree<AbstractMesh>;
  120297. /**
  120298. * Gets the octree used to boost mesh selection (picking)
  120299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120300. */
  120301. selectionOctree: Octree<AbstractMesh>;
  120302. /**
  120303. * Creates or updates the octree used to boost selection (picking)
  120304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120305. * @param maxCapacity defines the maximum capacity per leaf
  120306. * @param maxDepth defines the maximum depth of the octree
  120307. * @returns an octree of AbstractMesh
  120308. */
  120309. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120310. }
  120311. interface AbstractMesh {
  120312. /**
  120313. * @hidden
  120314. * Backing Field
  120315. */
  120316. _submeshesOctree: Octree<SubMesh>;
  120317. /**
  120318. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120320. * @param maxCapacity defines the maximum size of each block (64 by default)
  120321. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120322. * @returns the new octree
  120323. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120325. */
  120326. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120327. }
  120328. /**
  120329. * Defines the octree scene component responsible to manage any octrees
  120330. * in a given scene.
  120331. */
  120332. export class OctreeSceneComponent {
  120333. /**
  120334. * The component name help to identify the component in the list of scene components.
  120335. */
  120336. readonly name: string;
  120337. /**
  120338. * The scene the component belongs to.
  120339. */
  120340. scene: Scene;
  120341. /**
  120342. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120343. */
  120344. readonly checksIsEnabled: boolean;
  120345. /**
  120346. * Creates a new instance of the component for the given scene
  120347. * @param scene Defines the scene to register the component in
  120348. */
  120349. constructor(scene: Scene);
  120350. /**
  120351. * Registers the component in a given scene
  120352. */
  120353. register(): void;
  120354. /**
  120355. * Return the list of active meshes
  120356. * @returns the list of active meshes
  120357. */
  120358. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120359. /**
  120360. * Return the list of active sub meshes
  120361. * @param mesh The mesh to get the candidates sub meshes from
  120362. * @returns the list of active sub meshes
  120363. */
  120364. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120365. private _tempRay;
  120366. /**
  120367. * Return the list of sub meshes intersecting with a given local ray
  120368. * @param mesh defines the mesh to find the submesh for
  120369. * @param localRay defines the ray in local space
  120370. * @returns the list of intersecting sub meshes
  120371. */
  120372. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120373. /**
  120374. * Return the list of sub meshes colliding with a collider
  120375. * @param mesh defines the mesh to find the submesh for
  120376. * @param collider defines the collider to evaluate the collision against
  120377. * @returns the list of colliding sub meshes
  120378. */
  120379. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120380. /**
  120381. * Rebuilds the elements related to this component in case of
  120382. * context lost for instance.
  120383. */
  120384. rebuild(): void;
  120385. /**
  120386. * Disposes the component and the associated ressources.
  120387. */
  120388. dispose(): void;
  120389. }
  120390. }
  120391. declare module BABYLON {
  120392. /**
  120393. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120394. */
  120395. export class Gizmo implements IDisposable {
  120396. /** The utility layer the gizmo will be added to */
  120397. gizmoLayer: UtilityLayerRenderer;
  120398. /**
  120399. * The root mesh of the gizmo
  120400. */
  120401. _rootMesh: Mesh;
  120402. private _attachedMesh;
  120403. /**
  120404. * Ratio for the scale of the gizmo (Default: 1)
  120405. */
  120406. scaleRatio: number;
  120407. /**
  120408. * If a custom mesh has been set (Default: false)
  120409. */
  120410. protected _customMeshSet: boolean;
  120411. /**
  120412. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120413. * * When set, interactions will be enabled
  120414. */
  120415. get attachedMesh(): Nullable<AbstractMesh>;
  120416. set attachedMesh(value: Nullable<AbstractMesh>);
  120417. /**
  120418. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120419. * @param mesh The mesh to replace the default mesh of the gizmo
  120420. */
  120421. setCustomMesh(mesh: Mesh): void;
  120422. /**
  120423. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120424. */
  120425. updateGizmoRotationToMatchAttachedMesh: boolean;
  120426. /**
  120427. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120428. */
  120429. updateGizmoPositionToMatchAttachedMesh: boolean;
  120430. /**
  120431. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120432. */
  120433. updateScale: boolean;
  120434. protected _interactionsEnabled: boolean;
  120435. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120436. private _beforeRenderObserver;
  120437. private _tempVector;
  120438. /**
  120439. * Creates a gizmo
  120440. * @param gizmoLayer The utility layer the gizmo will be added to
  120441. */
  120442. constructor(
  120443. /** The utility layer the gizmo will be added to */
  120444. gizmoLayer?: UtilityLayerRenderer);
  120445. /**
  120446. * Updates the gizmo to match the attached mesh's position/rotation
  120447. */
  120448. protected _update(): void;
  120449. /**
  120450. * Disposes of the gizmo
  120451. */
  120452. dispose(): void;
  120453. }
  120454. }
  120455. declare module BABYLON {
  120456. /**
  120457. * Single plane drag gizmo
  120458. */
  120459. export class PlaneDragGizmo extends Gizmo {
  120460. /**
  120461. * Drag behavior responsible for the gizmos dragging interactions
  120462. */
  120463. dragBehavior: PointerDragBehavior;
  120464. private _pointerObserver;
  120465. /**
  120466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120467. */
  120468. snapDistance: number;
  120469. /**
  120470. * Event that fires each time the gizmo snaps to a new location.
  120471. * * snapDistance is the the change in distance
  120472. */
  120473. onSnapObservable: Observable<{
  120474. snapDistance: number;
  120475. }>;
  120476. private _plane;
  120477. private _coloredMaterial;
  120478. private _hoverMaterial;
  120479. private _isEnabled;
  120480. private _parent;
  120481. /** @hidden */
  120482. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120483. /** @hidden */
  120484. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120485. /**
  120486. * Creates a PlaneDragGizmo
  120487. * @param gizmoLayer The utility layer the gizmo will be added to
  120488. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120489. * @param color The color of the gizmo
  120490. */
  120491. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120492. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120493. /**
  120494. * If the gizmo is enabled
  120495. */
  120496. set isEnabled(value: boolean);
  120497. get isEnabled(): boolean;
  120498. /**
  120499. * Disposes of the gizmo
  120500. */
  120501. dispose(): void;
  120502. }
  120503. }
  120504. declare module BABYLON {
  120505. /**
  120506. * Gizmo that enables dragging a mesh along 3 axis
  120507. */
  120508. export class PositionGizmo extends Gizmo {
  120509. /**
  120510. * Internal gizmo used for interactions on the x axis
  120511. */
  120512. xGizmo: AxisDragGizmo;
  120513. /**
  120514. * Internal gizmo used for interactions on the y axis
  120515. */
  120516. yGizmo: AxisDragGizmo;
  120517. /**
  120518. * Internal gizmo used for interactions on the z axis
  120519. */
  120520. zGizmo: AxisDragGizmo;
  120521. /**
  120522. * Internal gizmo used for interactions on the yz plane
  120523. */
  120524. xPlaneGizmo: PlaneDragGizmo;
  120525. /**
  120526. * Internal gizmo used for interactions on the xz plane
  120527. */
  120528. yPlaneGizmo: PlaneDragGizmo;
  120529. /**
  120530. * Internal gizmo used for interactions on the xy plane
  120531. */
  120532. zPlaneGizmo: PlaneDragGizmo;
  120533. /**
  120534. * private variables
  120535. */
  120536. private _meshAttached;
  120537. private _updateGizmoRotationToMatchAttachedMesh;
  120538. private _snapDistance;
  120539. private _scaleRatio;
  120540. /** Fires an event when any of it's sub gizmos are dragged */
  120541. onDragStartObservable: Observable<unknown>;
  120542. /** Fires an event when any of it's sub gizmos are released from dragging */
  120543. onDragEndObservable: Observable<unknown>;
  120544. /**
  120545. * If set to true, planar drag is enabled
  120546. */
  120547. private _planarGizmoEnabled;
  120548. get attachedMesh(): Nullable<AbstractMesh>;
  120549. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120550. /**
  120551. * Creates a PositionGizmo
  120552. * @param gizmoLayer The utility layer the gizmo will be added to
  120553. */
  120554. constructor(gizmoLayer?: UtilityLayerRenderer);
  120555. /**
  120556. * If the planar drag gizmo is enabled
  120557. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120558. */
  120559. set planarGizmoEnabled(value: boolean);
  120560. get planarGizmoEnabled(): boolean;
  120561. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120562. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120563. /**
  120564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120565. */
  120566. set snapDistance(value: number);
  120567. get snapDistance(): number;
  120568. /**
  120569. * Ratio for the scale of the gizmo (Default: 1)
  120570. */
  120571. set scaleRatio(value: number);
  120572. get scaleRatio(): number;
  120573. /**
  120574. * Disposes of the gizmo
  120575. */
  120576. dispose(): void;
  120577. /**
  120578. * CustomMeshes are not supported by this gizmo
  120579. * @param mesh The mesh to replace the default mesh of the gizmo
  120580. */
  120581. setCustomMesh(mesh: Mesh): void;
  120582. }
  120583. }
  120584. declare module BABYLON {
  120585. /**
  120586. * Single axis drag gizmo
  120587. */
  120588. export class AxisDragGizmo extends Gizmo {
  120589. /**
  120590. * Drag behavior responsible for the gizmos dragging interactions
  120591. */
  120592. dragBehavior: PointerDragBehavior;
  120593. private _pointerObserver;
  120594. /**
  120595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120596. */
  120597. snapDistance: number;
  120598. /**
  120599. * Event that fires each time the gizmo snaps to a new location.
  120600. * * snapDistance is the the change in distance
  120601. */
  120602. onSnapObservable: Observable<{
  120603. snapDistance: number;
  120604. }>;
  120605. private _isEnabled;
  120606. private _parent;
  120607. private _arrow;
  120608. private _coloredMaterial;
  120609. private _hoverMaterial;
  120610. /** @hidden */
  120611. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120612. /** @hidden */
  120613. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120614. /**
  120615. * Creates an AxisDragGizmo
  120616. * @param gizmoLayer The utility layer the gizmo will be added to
  120617. * @param dragAxis The axis which the gizmo will be able to drag on
  120618. * @param color The color of the gizmo
  120619. */
  120620. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120622. /**
  120623. * If the gizmo is enabled
  120624. */
  120625. set isEnabled(value: boolean);
  120626. get isEnabled(): boolean;
  120627. /**
  120628. * Disposes of the gizmo
  120629. */
  120630. dispose(): void;
  120631. }
  120632. }
  120633. declare module BABYLON.Debug {
  120634. /**
  120635. * The Axes viewer will show 3 axes in a specific point in space
  120636. */
  120637. export class AxesViewer {
  120638. private _xAxis;
  120639. private _yAxis;
  120640. private _zAxis;
  120641. private _scaleLinesFactor;
  120642. private _instanced;
  120643. /**
  120644. * Gets the hosting scene
  120645. */
  120646. scene: Scene;
  120647. /**
  120648. * Gets or sets a number used to scale line length
  120649. */
  120650. scaleLines: number;
  120651. /** Gets the node hierarchy used to render x-axis */
  120652. get xAxis(): TransformNode;
  120653. /** Gets the node hierarchy used to render y-axis */
  120654. get yAxis(): TransformNode;
  120655. /** Gets the node hierarchy used to render z-axis */
  120656. get zAxis(): TransformNode;
  120657. /**
  120658. * Creates a new AxesViewer
  120659. * @param scene defines the hosting scene
  120660. * @param scaleLines defines a number used to scale line length (1 by default)
  120661. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120662. * @param xAxis defines the node hierarchy used to render the x-axis
  120663. * @param yAxis defines the node hierarchy used to render the y-axis
  120664. * @param zAxis defines the node hierarchy used to render the z-axis
  120665. */
  120666. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120667. /**
  120668. * Force the viewer to update
  120669. * @param position defines the position of the viewer
  120670. * @param xaxis defines the x axis of the viewer
  120671. * @param yaxis defines the y axis of the viewer
  120672. * @param zaxis defines the z axis of the viewer
  120673. */
  120674. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120675. /**
  120676. * Creates an instance of this axes viewer.
  120677. * @returns a new axes viewer with instanced meshes
  120678. */
  120679. createInstance(): AxesViewer;
  120680. /** Releases resources */
  120681. dispose(): void;
  120682. private static _SetRenderingGroupId;
  120683. }
  120684. }
  120685. declare module BABYLON.Debug {
  120686. /**
  120687. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120688. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120689. */
  120690. export class BoneAxesViewer extends AxesViewer {
  120691. /**
  120692. * Gets or sets the target mesh where to display the axes viewer
  120693. */
  120694. mesh: Nullable<Mesh>;
  120695. /**
  120696. * Gets or sets the target bone where to display the axes viewer
  120697. */
  120698. bone: Nullable<Bone>;
  120699. /** Gets current position */
  120700. pos: Vector3;
  120701. /** Gets direction of X axis */
  120702. xaxis: Vector3;
  120703. /** Gets direction of Y axis */
  120704. yaxis: Vector3;
  120705. /** Gets direction of Z axis */
  120706. zaxis: Vector3;
  120707. /**
  120708. * Creates a new BoneAxesViewer
  120709. * @param scene defines the hosting scene
  120710. * @param bone defines the target bone
  120711. * @param mesh defines the target mesh
  120712. * @param scaleLines defines a scaling factor for line length (1 by default)
  120713. */
  120714. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120715. /**
  120716. * Force the viewer to update
  120717. */
  120718. update(): void;
  120719. /** Releases resources */
  120720. dispose(): void;
  120721. }
  120722. }
  120723. declare module BABYLON {
  120724. /**
  120725. * Interface used to define scene explorer extensibility option
  120726. */
  120727. export interface IExplorerExtensibilityOption {
  120728. /**
  120729. * Define the option label
  120730. */
  120731. label: string;
  120732. /**
  120733. * Defines the action to execute on click
  120734. */
  120735. action: (entity: any) => void;
  120736. }
  120737. /**
  120738. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120739. */
  120740. export interface IExplorerExtensibilityGroup {
  120741. /**
  120742. * Defines a predicate to test if a given type mut be extended
  120743. */
  120744. predicate: (entity: any) => boolean;
  120745. /**
  120746. * Gets the list of options added to a type
  120747. */
  120748. entries: IExplorerExtensibilityOption[];
  120749. }
  120750. /**
  120751. * Interface used to define the options to use to create the Inspector
  120752. */
  120753. export interface IInspectorOptions {
  120754. /**
  120755. * Display in overlay mode (default: false)
  120756. */
  120757. overlay?: boolean;
  120758. /**
  120759. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120760. */
  120761. globalRoot?: HTMLElement;
  120762. /**
  120763. * Display the Scene explorer
  120764. */
  120765. showExplorer?: boolean;
  120766. /**
  120767. * Display the property inspector
  120768. */
  120769. showInspector?: boolean;
  120770. /**
  120771. * Display in embed mode (both panes on the right)
  120772. */
  120773. embedMode?: boolean;
  120774. /**
  120775. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120776. */
  120777. handleResize?: boolean;
  120778. /**
  120779. * Allow the panes to popup (default: true)
  120780. */
  120781. enablePopup?: boolean;
  120782. /**
  120783. * Allow the panes to be closed by users (default: true)
  120784. */
  120785. enableClose?: boolean;
  120786. /**
  120787. * Optional list of extensibility entries
  120788. */
  120789. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120790. /**
  120791. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120792. */
  120793. inspectorURL?: string;
  120794. /**
  120795. * Optional initial tab (default to DebugLayerTab.Properties)
  120796. */
  120797. initialTab?: DebugLayerTab;
  120798. }
  120799. interface Scene {
  120800. /**
  120801. * @hidden
  120802. * Backing field
  120803. */
  120804. _debugLayer: DebugLayer;
  120805. /**
  120806. * Gets the debug layer (aka Inspector) associated with the scene
  120807. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120808. */
  120809. debugLayer: DebugLayer;
  120810. }
  120811. /**
  120812. * Enum of inspector action tab
  120813. */
  120814. export enum DebugLayerTab {
  120815. /**
  120816. * Properties tag (default)
  120817. */
  120818. Properties = 0,
  120819. /**
  120820. * Debug tab
  120821. */
  120822. Debug = 1,
  120823. /**
  120824. * Statistics tab
  120825. */
  120826. Statistics = 2,
  120827. /**
  120828. * Tools tab
  120829. */
  120830. Tools = 3,
  120831. /**
  120832. * Settings tab
  120833. */
  120834. Settings = 4
  120835. }
  120836. /**
  120837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120838. * what is happening in your scene
  120839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120840. */
  120841. export class DebugLayer {
  120842. /**
  120843. * Define the url to get the inspector script from.
  120844. * By default it uses the babylonjs CDN.
  120845. * @ignoreNaming
  120846. */
  120847. static InspectorURL: string;
  120848. private _scene;
  120849. private BJSINSPECTOR;
  120850. private _onPropertyChangedObservable?;
  120851. /**
  120852. * Observable triggered when a property is changed through the inspector.
  120853. */
  120854. get onPropertyChangedObservable(): any;
  120855. /**
  120856. * Instantiates a new debug layer.
  120857. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120858. * what is happening in your scene
  120859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120860. * @param scene Defines the scene to inspect
  120861. */
  120862. constructor(scene: Scene);
  120863. /** Creates the inspector window. */
  120864. private _createInspector;
  120865. /**
  120866. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120867. * @param entity defines the entity to select
  120868. * @param lineContainerTitle defines the specific block to highlight
  120869. */
  120870. select(entity: any, lineContainerTitle?: string): void;
  120871. /** Get the inspector from bundle or global */
  120872. private _getGlobalInspector;
  120873. /**
  120874. * Get if the inspector is visible or not.
  120875. * @returns true if visible otherwise, false
  120876. */
  120877. isVisible(): boolean;
  120878. /**
  120879. * Hide the inspector and close its window.
  120880. */
  120881. hide(): void;
  120882. /**
  120883. * Launch the debugLayer.
  120884. * @param config Define the configuration of the inspector
  120885. * @return a promise fulfilled when the debug layer is visible
  120886. */
  120887. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120888. }
  120889. }
  120890. declare module BABYLON {
  120891. /**
  120892. * Class containing static functions to help procedurally build meshes
  120893. */
  120894. export class BoxBuilder {
  120895. /**
  120896. * Creates a box mesh
  120897. * * The parameter `size` sets the size (float) of each box side (default 1)
  120898. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120899. * * 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)
  120900. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120904. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120905. * @param name defines the name of the mesh
  120906. * @param options defines the options used to create the mesh
  120907. * @param scene defines the hosting scene
  120908. * @returns the box mesh
  120909. */
  120910. static CreateBox(name: string, options: {
  120911. size?: number;
  120912. width?: number;
  120913. height?: number;
  120914. depth?: number;
  120915. faceUV?: Vector4[];
  120916. faceColors?: Color4[];
  120917. sideOrientation?: number;
  120918. frontUVs?: Vector4;
  120919. backUVs?: Vector4;
  120920. wrap?: boolean;
  120921. topBaseAt?: number;
  120922. bottomBaseAt?: number;
  120923. updatable?: boolean;
  120924. }, scene?: Nullable<Scene>): Mesh;
  120925. }
  120926. }
  120927. declare module BABYLON.Debug {
  120928. /**
  120929. * Used to show the physics impostor around the specific mesh
  120930. */
  120931. export class PhysicsViewer {
  120932. /** @hidden */
  120933. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120934. /** @hidden */
  120935. protected _meshes: Array<Nullable<AbstractMesh>>;
  120936. /** @hidden */
  120937. protected _scene: Nullable<Scene>;
  120938. /** @hidden */
  120939. protected _numMeshes: number;
  120940. /** @hidden */
  120941. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120942. private _renderFunction;
  120943. private _utilityLayer;
  120944. private _debugBoxMesh;
  120945. private _debugSphereMesh;
  120946. private _debugCylinderMesh;
  120947. private _debugMaterial;
  120948. private _debugMeshMeshes;
  120949. /**
  120950. * Creates a new PhysicsViewer
  120951. * @param scene defines the hosting scene
  120952. */
  120953. constructor(scene: Scene);
  120954. /** @hidden */
  120955. protected _updateDebugMeshes(): void;
  120956. /**
  120957. * Renders a specified physic impostor
  120958. * @param impostor defines the impostor to render
  120959. * @param targetMesh defines the mesh represented by the impostor
  120960. * @returns the new debug mesh used to render the impostor
  120961. */
  120962. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120963. /**
  120964. * Hides a specified physic impostor
  120965. * @param impostor defines the impostor to hide
  120966. */
  120967. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120968. private _getDebugMaterial;
  120969. private _getDebugBoxMesh;
  120970. private _getDebugSphereMesh;
  120971. private _getDebugCylinderMesh;
  120972. private _getDebugMeshMesh;
  120973. private _getDebugMesh;
  120974. /** Releases all resources */
  120975. dispose(): void;
  120976. }
  120977. }
  120978. declare module BABYLON {
  120979. /**
  120980. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120981. * in order to better appreciate the issue one might have.
  120982. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120983. */
  120984. export class RayHelper {
  120985. /**
  120986. * Defines the ray we are currently tryin to visualize.
  120987. */
  120988. ray: Nullable<Ray>;
  120989. private _renderPoints;
  120990. private _renderLine;
  120991. private _renderFunction;
  120992. private _scene;
  120993. private _updateToMeshFunction;
  120994. private _attachedToMesh;
  120995. private _meshSpaceDirection;
  120996. private _meshSpaceOrigin;
  120997. /**
  120998. * Helper function to create a colored helper in a scene in one line.
  120999. * @param ray Defines the ray we are currently tryin to visualize
  121000. * @param scene Defines the scene the ray is used in
  121001. * @param color Defines the color we want to see the ray in
  121002. * @returns The newly created ray helper.
  121003. */
  121004. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121005. /**
  121006. * Instantiate a new ray helper.
  121007. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121008. * in order to better appreciate the issue one might have.
  121009. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121010. * @param ray Defines the ray we are currently tryin to visualize
  121011. */
  121012. constructor(ray: Ray);
  121013. /**
  121014. * Shows the ray we are willing to debug.
  121015. * @param scene Defines the scene the ray needs to be rendered in
  121016. * @param color Defines the color the ray needs to be rendered in
  121017. */
  121018. show(scene: Scene, color?: Color3): void;
  121019. /**
  121020. * Hides the ray we are debugging.
  121021. */
  121022. hide(): void;
  121023. private _render;
  121024. /**
  121025. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121026. * @param mesh Defines the mesh we want the helper attached to
  121027. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121028. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121029. * @param length Defines the length of the ray
  121030. */
  121031. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121032. /**
  121033. * Detach the ray helper from the mesh it has previously been attached to.
  121034. */
  121035. detachFromMesh(): void;
  121036. private _updateToMesh;
  121037. /**
  121038. * Dispose the helper and release its associated resources.
  121039. */
  121040. dispose(): void;
  121041. }
  121042. }
  121043. declare module BABYLON.Debug {
  121044. /**
  121045. * Class used to render a debug view of a given skeleton
  121046. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121047. */
  121048. export class SkeletonViewer {
  121049. /** defines the skeleton to render */
  121050. skeleton: Skeleton;
  121051. /** defines the mesh attached to the skeleton */
  121052. mesh: AbstractMesh;
  121053. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121054. autoUpdateBonesMatrices: boolean;
  121055. /** defines the rendering group id to use with the viewer */
  121056. renderingGroupId: number;
  121057. /** Gets or sets the color used to render the skeleton */
  121058. color: Color3;
  121059. private _scene;
  121060. private _debugLines;
  121061. private _debugMesh;
  121062. private _isEnabled;
  121063. private _renderFunction;
  121064. private _utilityLayer;
  121065. /**
  121066. * Returns the mesh used to render the bones
  121067. */
  121068. get debugMesh(): Nullable<LinesMesh>;
  121069. /**
  121070. * Creates a new SkeletonViewer
  121071. * @param skeleton defines the skeleton to render
  121072. * @param mesh defines the mesh attached to the skeleton
  121073. * @param scene defines the hosting scene
  121074. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121075. * @param renderingGroupId defines the rendering group id to use with the viewer
  121076. */
  121077. constructor(
  121078. /** defines the skeleton to render */
  121079. skeleton: Skeleton,
  121080. /** defines the mesh attached to the skeleton */
  121081. mesh: AbstractMesh, scene: Scene,
  121082. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121083. autoUpdateBonesMatrices?: boolean,
  121084. /** defines the rendering group id to use with the viewer */
  121085. renderingGroupId?: number);
  121086. /** Gets or sets a boolean indicating if the viewer is enabled */
  121087. set isEnabled(value: boolean);
  121088. get isEnabled(): boolean;
  121089. private _getBonePosition;
  121090. private _getLinesForBonesWithLength;
  121091. private _getLinesForBonesNoLength;
  121092. /** Update the viewer to sync with current skeleton state */
  121093. update(): void;
  121094. /** Release associated resources */
  121095. dispose(): void;
  121096. }
  121097. }
  121098. declare module BABYLON {
  121099. /**
  121100. * Options to create the null engine
  121101. */
  121102. export class NullEngineOptions {
  121103. /**
  121104. * Render width (Default: 512)
  121105. */
  121106. renderWidth: number;
  121107. /**
  121108. * Render height (Default: 256)
  121109. */
  121110. renderHeight: number;
  121111. /**
  121112. * Texture size (Default: 512)
  121113. */
  121114. textureSize: number;
  121115. /**
  121116. * If delta time between frames should be constant
  121117. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121118. */
  121119. deterministicLockstep: boolean;
  121120. /**
  121121. * Maximum about of steps between frames (Default: 4)
  121122. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121123. */
  121124. lockstepMaxSteps: number;
  121125. }
  121126. /**
  121127. * The null engine class provides support for headless version of babylon.js.
  121128. * This can be used in server side scenario or for testing purposes
  121129. */
  121130. export class NullEngine extends Engine {
  121131. private _options;
  121132. /**
  121133. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121135. * @returns true if engine is in deterministic lock step mode
  121136. */
  121137. isDeterministicLockStep(): boolean;
  121138. /**
  121139. * Gets the max steps when engine is running in deterministic lock step
  121140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121141. * @returns the max steps
  121142. */
  121143. getLockstepMaxSteps(): number;
  121144. /**
  121145. * Gets the current hardware scaling level.
  121146. * By default the hardware scaling level is computed from the window device ratio.
  121147. * 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.
  121148. * @returns a number indicating the current hardware scaling level
  121149. */
  121150. getHardwareScalingLevel(): number;
  121151. constructor(options?: NullEngineOptions);
  121152. /**
  121153. * Creates a vertex buffer
  121154. * @param vertices the data for the vertex buffer
  121155. * @returns the new WebGL static buffer
  121156. */
  121157. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121158. /**
  121159. * Creates a new index buffer
  121160. * @param indices defines the content of the index buffer
  121161. * @param updatable defines if the index buffer must be updatable
  121162. * @returns a new webGL buffer
  121163. */
  121164. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121165. /**
  121166. * Clear the current render buffer or the current render target (if any is set up)
  121167. * @param color defines the color to use
  121168. * @param backBuffer defines if the back buffer must be cleared
  121169. * @param depth defines if the depth buffer must be cleared
  121170. * @param stencil defines if the stencil buffer must be cleared
  121171. */
  121172. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121173. /**
  121174. * Gets the current render width
  121175. * @param useScreen defines if screen size must be used (or the current render target if any)
  121176. * @returns a number defining the current render width
  121177. */
  121178. getRenderWidth(useScreen?: boolean): number;
  121179. /**
  121180. * Gets the current render height
  121181. * @param useScreen defines if screen size must be used (or the current render target if any)
  121182. * @returns a number defining the current render height
  121183. */
  121184. getRenderHeight(useScreen?: boolean): number;
  121185. /**
  121186. * Set the WebGL's viewport
  121187. * @param viewport defines the viewport element to be used
  121188. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121189. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121190. */
  121191. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121192. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121193. /**
  121194. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121195. * @param pipelineContext defines the pipeline context to use
  121196. * @param uniformsNames defines the list of uniform names
  121197. * @returns an array of webGL uniform locations
  121198. */
  121199. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121200. /**
  121201. * Gets the lsit of active attributes for a given webGL program
  121202. * @param pipelineContext defines the pipeline context to use
  121203. * @param attributesNames defines the list of attribute names to get
  121204. * @returns an array of indices indicating the offset of each attribute
  121205. */
  121206. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121207. /**
  121208. * Binds an effect to the webGL context
  121209. * @param effect defines the effect to bind
  121210. */
  121211. bindSamplers(effect: Effect): void;
  121212. /**
  121213. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121214. * @param effect defines the effect to activate
  121215. */
  121216. enableEffect(effect: Effect): void;
  121217. /**
  121218. * Set various states to the webGL context
  121219. * @param culling defines backface culling state
  121220. * @param zOffset defines the value to apply to zOffset (0 by default)
  121221. * @param force defines if states must be applied even if cache is up to date
  121222. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121223. */
  121224. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121225. /**
  121226. * Set the value of an uniform to an array of int32
  121227. * @param uniform defines the webGL uniform location where to store the value
  121228. * @param array defines the array of int32 to store
  121229. */
  121230. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121231. /**
  121232. * Set the value of an uniform to an array of int32 (stored as vec2)
  121233. * @param uniform defines the webGL uniform location where to store the value
  121234. * @param array defines the array of int32 to store
  121235. */
  121236. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121237. /**
  121238. * Set the value of an uniform to an array of int32 (stored as vec3)
  121239. * @param uniform defines the webGL uniform location where to store the value
  121240. * @param array defines the array of int32 to store
  121241. */
  121242. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121243. /**
  121244. * Set the value of an uniform to an array of int32 (stored as vec4)
  121245. * @param uniform defines the webGL uniform location where to store the value
  121246. * @param array defines the array of int32 to store
  121247. */
  121248. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121249. /**
  121250. * Set the value of an uniform to an array of float32
  121251. * @param uniform defines the webGL uniform location where to store the value
  121252. * @param array defines the array of float32 to store
  121253. */
  121254. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121255. /**
  121256. * Set the value of an uniform to an array of float32 (stored as vec2)
  121257. * @param uniform defines the webGL uniform location where to store the value
  121258. * @param array defines the array of float32 to store
  121259. */
  121260. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121261. /**
  121262. * Set the value of an uniform to an array of float32 (stored as vec3)
  121263. * @param uniform defines the webGL uniform location where to store the value
  121264. * @param array defines the array of float32 to store
  121265. */
  121266. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121267. /**
  121268. * Set the value of an uniform to an array of float32 (stored as vec4)
  121269. * @param uniform defines the webGL uniform location where to store the value
  121270. * @param array defines the array of float32 to store
  121271. */
  121272. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121273. /**
  121274. * Set the value of an uniform to an array of number
  121275. * @param uniform defines the webGL uniform location where to store the value
  121276. * @param array defines the array of number to store
  121277. */
  121278. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121279. /**
  121280. * Set the value of an uniform to an array of number (stored as vec2)
  121281. * @param uniform defines the webGL uniform location where to store the value
  121282. * @param array defines the array of number to store
  121283. */
  121284. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121285. /**
  121286. * Set the value of an uniform to an array of number (stored as vec3)
  121287. * @param uniform defines the webGL uniform location where to store the value
  121288. * @param array defines the array of number to store
  121289. */
  121290. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121291. /**
  121292. * Set the value of an uniform to an array of number (stored as vec4)
  121293. * @param uniform defines the webGL uniform location where to store the value
  121294. * @param array defines the array of number to store
  121295. */
  121296. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121297. /**
  121298. * Set the value of an uniform to an array of float32 (stored as matrices)
  121299. * @param uniform defines the webGL uniform location where to store the value
  121300. * @param matrices defines the array of float32 to store
  121301. */
  121302. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121303. /**
  121304. * Set the value of an uniform to a matrix (3x3)
  121305. * @param uniform defines the webGL uniform location where to store the value
  121306. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121307. */
  121308. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121309. /**
  121310. * Set the value of an uniform to a matrix (2x2)
  121311. * @param uniform defines the webGL uniform location where to store the value
  121312. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121313. */
  121314. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121315. /**
  121316. * Set the value of an uniform to a number (float)
  121317. * @param uniform defines the webGL uniform location where to store the value
  121318. * @param value defines the float number to store
  121319. */
  121320. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121321. /**
  121322. * Set the value of an uniform to a vec2
  121323. * @param uniform defines the webGL uniform location where to store the value
  121324. * @param x defines the 1st component of the value
  121325. * @param y defines the 2nd component of the value
  121326. */
  121327. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121328. /**
  121329. * Set the value of an uniform to a vec3
  121330. * @param uniform defines the webGL uniform location where to store the value
  121331. * @param x defines the 1st component of the value
  121332. * @param y defines the 2nd component of the value
  121333. * @param z defines the 3rd component of the value
  121334. */
  121335. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121336. /**
  121337. * Set the value of an uniform to a boolean
  121338. * @param uniform defines the webGL uniform location where to store the value
  121339. * @param bool defines the boolean to store
  121340. */
  121341. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121342. /**
  121343. * Set the value of an uniform to a vec4
  121344. * @param uniform defines the webGL uniform location where to store the value
  121345. * @param x defines the 1st component of the value
  121346. * @param y defines the 2nd component of the value
  121347. * @param z defines the 3rd component of the value
  121348. * @param w defines the 4th component of the value
  121349. */
  121350. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121351. /**
  121352. * Sets the current alpha mode
  121353. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121354. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121355. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121356. */
  121357. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121358. /**
  121359. * Bind webGl buffers directly to the webGL context
  121360. * @param vertexBuffers defines the vertex buffer to bind
  121361. * @param indexBuffer defines the index buffer to bind
  121362. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121363. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121364. * @param effect defines the effect associated with the vertex buffer
  121365. */
  121366. bindBuffers(vertexBuffers: {
  121367. [key: string]: VertexBuffer;
  121368. }, indexBuffer: DataBuffer, effect: Effect): void;
  121369. /**
  121370. * Force the entire cache to be cleared
  121371. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121372. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121373. */
  121374. wipeCaches(bruteForce?: boolean): void;
  121375. /**
  121376. * Send a draw order
  121377. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121378. * @param indexStart defines the starting index
  121379. * @param indexCount defines the number of index to draw
  121380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121381. */
  121382. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121383. /**
  121384. * Draw a list of indexed primitives
  121385. * @param fillMode defines the primitive to use
  121386. * @param indexStart defines the starting index
  121387. * @param indexCount defines the number of index to draw
  121388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121389. */
  121390. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121391. /**
  121392. * Draw a list of unindexed primitives
  121393. * @param fillMode defines the primitive to use
  121394. * @param verticesStart defines the index of first vertex to draw
  121395. * @param verticesCount defines the count of vertices to draw
  121396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121397. */
  121398. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121399. /** @hidden */
  121400. _createTexture(): WebGLTexture;
  121401. /** @hidden */
  121402. _releaseTexture(texture: InternalTexture): void;
  121403. /**
  121404. * Usually called from Texture.ts.
  121405. * Passed information to create a WebGLTexture
  121406. * @param urlArg defines a value which contains one of the following:
  121407. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121408. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121409. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121410. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121411. * @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)
  121412. * @param scene needed for loading to the correct scene
  121413. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121414. * @param onLoad optional callback to be called upon successful completion
  121415. * @param onError optional callback to be called upon failure
  121416. * @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
  121417. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121418. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121419. * @param forcedExtension defines the extension to use to pick the right loader
  121420. * @param mimeType defines an optional mime type
  121421. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121422. */
  121423. 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;
  121424. /**
  121425. * Creates a new render target texture
  121426. * @param size defines the size of the texture
  121427. * @param options defines the options used to create the texture
  121428. * @returns a new render target texture stored in an InternalTexture
  121429. */
  121430. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121431. /**
  121432. * Update the sampling mode of a given texture
  121433. * @param samplingMode defines the required sampling mode
  121434. * @param texture defines the texture to update
  121435. */
  121436. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121437. /**
  121438. * Binds the frame buffer to the specified texture.
  121439. * @param texture The texture to render to or null for the default canvas
  121440. * @param faceIndex The face of the texture to render to in case of cube texture
  121441. * @param requiredWidth The width of the target to render to
  121442. * @param requiredHeight The height of the target to render to
  121443. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121444. * @param lodLevel defines le lod level to bind to the frame buffer
  121445. */
  121446. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121447. /**
  121448. * Unbind the current render target texture from the webGL context
  121449. * @param texture defines the render target texture to unbind
  121450. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121451. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121452. */
  121453. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121454. /**
  121455. * Creates a dynamic vertex buffer
  121456. * @param vertices the data for the dynamic vertex buffer
  121457. * @returns the new WebGL dynamic buffer
  121458. */
  121459. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121460. /**
  121461. * Update the content of a dynamic texture
  121462. * @param texture defines the texture to update
  121463. * @param canvas defines the canvas containing the source
  121464. * @param invertY defines if data must be stored with Y axis inverted
  121465. * @param premulAlpha defines if alpha is stored as premultiplied
  121466. * @param format defines the format of the data
  121467. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121468. */
  121469. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121470. /**
  121471. * Gets a boolean indicating if all created effects are ready
  121472. * @returns true if all effects are ready
  121473. */
  121474. areAllEffectsReady(): boolean;
  121475. /**
  121476. * @hidden
  121477. * Get the current error code of the webGL context
  121478. * @returns the error code
  121479. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121480. */
  121481. getError(): number;
  121482. /** @hidden */
  121483. _getUnpackAlignement(): number;
  121484. /** @hidden */
  121485. _unpackFlipY(value: boolean): void;
  121486. /**
  121487. * Update a dynamic index buffer
  121488. * @param indexBuffer defines the target index buffer
  121489. * @param indices defines the data to update
  121490. * @param offset defines the offset in the target index buffer where update should start
  121491. */
  121492. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121493. /**
  121494. * Updates a dynamic vertex buffer.
  121495. * @param vertexBuffer the vertex buffer to update
  121496. * @param vertices the data used to update the vertex buffer
  121497. * @param byteOffset the byte offset of the data (optional)
  121498. * @param byteLength the byte length of the data (optional)
  121499. */
  121500. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121501. /** @hidden */
  121502. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121503. /** @hidden */
  121504. _bindTexture(channel: number, texture: InternalTexture): void;
  121505. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121506. /**
  121507. * 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
  121508. */
  121509. releaseEffects(): void;
  121510. displayLoadingUI(): void;
  121511. hideLoadingUI(): void;
  121512. /** @hidden */
  121513. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121514. /** @hidden */
  121515. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121516. /** @hidden */
  121517. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121518. /** @hidden */
  121519. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121520. }
  121521. }
  121522. declare module BABYLON {
  121523. /**
  121524. * @hidden
  121525. **/
  121526. export class _TimeToken {
  121527. _startTimeQuery: Nullable<WebGLQuery>;
  121528. _endTimeQuery: Nullable<WebGLQuery>;
  121529. _timeElapsedQuery: Nullable<WebGLQuery>;
  121530. _timeElapsedQueryEnded: boolean;
  121531. }
  121532. }
  121533. declare module BABYLON {
  121534. /** @hidden */
  121535. export class _OcclusionDataStorage {
  121536. /** @hidden */
  121537. occlusionInternalRetryCounter: number;
  121538. /** @hidden */
  121539. isOcclusionQueryInProgress: boolean;
  121540. /** @hidden */
  121541. isOccluded: boolean;
  121542. /** @hidden */
  121543. occlusionRetryCount: number;
  121544. /** @hidden */
  121545. occlusionType: number;
  121546. /** @hidden */
  121547. occlusionQueryAlgorithmType: number;
  121548. }
  121549. interface Engine {
  121550. /**
  121551. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121552. * @return the new query
  121553. */
  121554. createQuery(): WebGLQuery;
  121555. /**
  121556. * Delete and release a webGL query
  121557. * @param query defines the query to delete
  121558. * @return the current engine
  121559. */
  121560. deleteQuery(query: WebGLQuery): Engine;
  121561. /**
  121562. * Check if a given query has resolved and got its value
  121563. * @param query defines the query to check
  121564. * @returns true if the query got its value
  121565. */
  121566. isQueryResultAvailable(query: WebGLQuery): boolean;
  121567. /**
  121568. * Gets the value of a given query
  121569. * @param query defines the query to check
  121570. * @returns the value of the query
  121571. */
  121572. getQueryResult(query: WebGLQuery): number;
  121573. /**
  121574. * Initiates an occlusion query
  121575. * @param algorithmType defines the algorithm to use
  121576. * @param query defines the query to use
  121577. * @returns the current engine
  121578. * @see http://doc.babylonjs.com/features/occlusionquery
  121579. */
  121580. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121581. /**
  121582. * Ends an occlusion query
  121583. * @see http://doc.babylonjs.com/features/occlusionquery
  121584. * @param algorithmType defines the algorithm to use
  121585. * @returns the current engine
  121586. */
  121587. endOcclusionQuery(algorithmType: number): Engine;
  121588. /**
  121589. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121590. * Please note that only one query can be issued at a time
  121591. * @returns a time token used to track the time span
  121592. */
  121593. startTimeQuery(): Nullable<_TimeToken>;
  121594. /**
  121595. * Ends a time query
  121596. * @param token defines the token used to measure the time span
  121597. * @returns the time spent (in ns)
  121598. */
  121599. endTimeQuery(token: _TimeToken): int;
  121600. /** @hidden */
  121601. _currentNonTimestampToken: Nullable<_TimeToken>;
  121602. /** @hidden */
  121603. _createTimeQuery(): WebGLQuery;
  121604. /** @hidden */
  121605. _deleteTimeQuery(query: WebGLQuery): void;
  121606. /** @hidden */
  121607. _getGlAlgorithmType(algorithmType: number): number;
  121608. /** @hidden */
  121609. _getTimeQueryResult(query: WebGLQuery): any;
  121610. /** @hidden */
  121611. _getTimeQueryAvailability(query: WebGLQuery): any;
  121612. }
  121613. interface AbstractMesh {
  121614. /**
  121615. * Backing filed
  121616. * @hidden
  121617. */
  121618. __occlusionDataStorage: _OcclusionDataStorage;
  121619. /**
  121620. * Access property
  121621. * @hidden
  121622. */
  121623. _occlusionDataStorage: _OcclusionDataStorage;
  121624. /**
  121625. * 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.
  121626. * The default value is -1 which means don't break the query and wait till the result
  121627. * @see http://doc.babylonjs.com/features/occlusionquery
  121628. */
  121629. occlusionRetryCount: number;
  121630. /**
  121631. * 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:
  121632. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121633. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121634. * * 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.
  121635. * @see http://doc.babylonjs.com/features/occlusionquery
  121636. */
  121637. occlusionType: number;
  121638. /**
  121639. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121640. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121641. * * 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.
  121642. * @see http://doc.babylonjs.com/features/occlusionquery
  121643. */
  121644. occlusionQueryAlgorithmType: number;
  121645. /**
  121646. * 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
  121647. * @see http://doc.babylonjs.com/features/occlusionquery
  121648. */
  121649. isOccluded: boolean;
  121650. /**
  121651. * Flag to check the progress status of the query
  121652. * @see http://doc.babylonjs.com/features/occlusionquery
  121653. */
  121654. isOcclusionQueryInProgress: boolean;
  121655. }
  121656. }
  121657. declare module BABYLON {
  121658. /** @hidden */
  121659. export var _forceTransformFeedbackToBundle: boolean;
  121660. interface Engine {
  121661. /**
  121662. * Creates a webGL transform feedback object
  121663. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121664. * @returns the webGL transform feedback object
  121665. */
  121666. createTransformFeedback(): WebGLTransformFeedback;
  121667. /**
  121668. * Delete a webGL transform feedback object
  121669. * @param value defines the webGL transform feedback object to delete
  121670. */
  121671. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121672. /**
  121673. * Bind a webGL transform feedback object to the webgl context
  121674. * @param value defines the webGL transform feedback object to bind
  121675. */
  121676. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121677. /**
  121678. * Begins a transform feedback operation
  121679. * @param usePoints defines if points or triangles must be used
  121680. */
  121681. beginTransformFeedback(usePoints: boolean): void;
  121682. /**
  121683. * Ends a transform feedback operation
  121684. */
  121685. endTransformFeedback(): void;
  121686. /**
  121687. * Specify the varyings to use with transform feedback
  121688. * @param program defines the associated webGL program
  121689. * @param value defines the list of strings representing the varying names
  121690. */
  121691. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121692. /**
  121693. * Bind a webGL buffer for a transform feedback operation
  121694. * @param value defines the webGL buffer to bind
  121695. */
  121696. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121697. }
  121698. }
  121699. declare module BABYLON {
  121700. /**
  121701. * Creation options of the multi render target texture.
  121702. */
  121703. export interface IMultiRenderTargetOptions {
  121704. /**
  121705. * Define if the texture needs to create mip maps after render.
  121706. */
  121707. generateMipMaps?: boolean;
  121708. /**
  121709. * Define the types of all the draw buffers we want to create
  121710. */
  121711. types?: number[];
  121712. /**
  121713. * Define the sampling modes of all the draw buffers we want to create
  121714. */
  121715. samplingModes?: number[];
  121716. /**
  121717. * Define if a depth buffer is required
  121718. */
  121719. generateDepthBuffer?: boolean;
  121720. /**
  121721. * Define if a stencil buffer is required
  121722. */
  121723. generateStencilBuffer?: boolean;
  121724. /**
  121725. * Define if a depth texture is required instead of a depth buffer
  121726. */
  121727. generateDepthTexture?: boolean;
  121728. /**
  121729. * Define the number of desired draw buffers
  121730. */
  121731. textureCount?: number;
  121732. /**
  121733. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121734. */
  121735. doNotChangeAspectRatio?: boolean;
  121736. /**
  121737. * Define the default type of the buffers we are creating
  121738. */
  121739. defaultType?: number;
  121740. }
  121741. /**
  121742. * A multi render target, like a render target provides the ability to render to a texture.
  121743. * Unlike the render target, it can render to several draw buffers in one draw.
  121744. * This is specially interesting in deferred rendering or for any effects requiring more than
  121745. * just one color from a single pass.
  121746. */
  121747. export class MultiRenderTarget extends RenderTargetTexture {
  121748. private _internalTextures;
  121749. private _textures;
  121750. private _multiRenderTargetOptions;
  121751. /**
  121752. * Get if draw buffers are currently supported by the used hardware and browser.
  121753. */
  121754. get isSupported(): boolean;
  121755. /**
  121756. * Get the list of textures generated by the multi render target.
  121757. */
  121758. get textures(): Texture[];
  121759. /**
  121760. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121761. */
  121762. get depthTexture(): Texture;
  121763. /**
  121764. * Set the wrapping mode on U of all the textures we are rendering to.
  121765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121766. */
  121767. set wrapU(wrap: number);
  121768. /**
  121769. * Set the wrapping mode on V of all the textures we are rendering to.
  121770. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121771. */
  121772. set wrapV(wrap: number);
  121773. /**
  121774. * Instantiate a new multi render target texture.
  121775. * A multi render target, like a render target provides the ability to render to a texture.
  121776. * Unlike the render target, it can render to several draw buffers in one draw.
  121777. * This is specially interesting in deferred rendering or for any effects requiring more than
  121778. * just one color from a single pass.
  121779. * @param name Define the name of the texture
  121780. * @param size Define the size of the buffers to render to
  121781. * @param count Define the number of target we are rendering into
  121782. * @param scene Define the scene the texture belongs to
  121783. * @param options Define the options used to create the multi render target
  121784. */
  121785. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121786. /** @hidden */
  121787. _rebuild(): void;
  121788. private _createInternalTextures;
  121789. private _createTextures;
  121790. /**
  121791. * Define the number of samples used if MSAA is enabled.
  121792. */
  121793. get samples(): number;
  121794. set samples(value: number);
  121795. /**
  121796. * Resize all the textures in the multi render target.
  121797. * Be carrefull as it will recreate all the data in the new texture.
  121798. * @param size Define the new size
  121799. */
  121800. resize(size: any): void;
  121801. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121802. /**
  121803. * Dispose the render targets and their associated resources
  121804. */
  121805. dispose(): void;
  121806. /**
  121807. * Release all the underlying texture used as draw buffers.
  121808. */
  121809. releaseInternalTextures(): void;
  121810. }
  121811. }
  121812. declare module BABYLON {
  121813. interface ThinEngine {
  121814. /**
  121815. * Unbind a list of render target textures from the webGL context
  121816. * This is used only when drawBuffer extension or webGL2 are active
  121817. * @param textures defines the render target textures to unbind
  121818. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121819. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121820. */
  121821. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121822. /**
  121823. * Create a multi render target texture
  121824. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121825. * @param size defines the size of the texture
  121826. * @param options defines the creation options
  121827. * @returns the cube texture as an InternalTexture
  121828. */
  121829. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121830. /**
  121831. * Update the sample count for a given multiple render target texture
  121832. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121833. * @param textures defines the textures to update
  121834. * @param samples defines the sample count to set
  121835. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121836. */
  121837. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121838. }
  121839. }
  121840. declare module BABYLON {
  121841. /**
  121842. * Class used to define an additional view for the engine
  121843. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121844. */
  121845. export class EngineView {
  121846. /** Defines the canvas where to render the view */
  121847. target: HTMLCanvasElement;
  121848. /** Defines an optional camera used to render the view (will use active camera else) */
  121849. camera?: Camera;
  121850. }
  121851. interface Engine {
  121852. /**
  121853. * Gets or sets the HTML element to use for attaching events
  121854. */
  121855. inputElement: Nullable<HTMLElement>;
  121856. /**
  121857. * Gets the current engine view
  121858. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121859. */
  121860. activeView: Nullable<EngineView>;
  121861. /** Gets or sets the list of views */
  121862. views: EngineView[];
  121863. /**
  121864. * Register a new child canvas
  121865. * @param canvas defines the canvas to register
  121866. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121867. * @returns the associated view
  121868. */
  121869. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121870. /**
  121871. * Remove a registered child canvas
  121872. * @param canvas defines the canvas to remove
  121873. * @returns the current engine
  121874. */
  121875. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121876. }
  121877. }
  121878. declare module BABYLON {
  121879. interface Engine {
  121880. /** @hidden */
  121881. _excludedCompressedTextures: string[];
  121882. /** @hidden */
  121883. _textureFormatInUse: string;
  121884. /**
  121885. * Gets the list of texture formats supported
  121886. */
  121887. readonly texturesSupported: Array<string>;
  121888. /**
  121889. * Gets the texture format in use
  121890. */
  121891. readonly textureFormatInUse: Nullable<string>;
  121892. /**
  121893. * Set the compressed texture extensions or file names to skip.
  121894. *
  121895. * @param skippedFiles defines the list of those texture files you want to skip
  121896. * Example: [".dds", ".env", "myfile.png"]
  121897. */
  121898. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121899. /**
  121900. * Set the compressed texture format to use, based on the formats you have, and the formats
  121901. * supported by the hardware / browser.
  121902. *
  121903. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121904. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121905. * to API arguments needed to compressed textures. This puts the burden on the container
  121906. * generator to house the arcane code for determining these for current & future formats.
  121907. *
  121908. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121909. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121910. *
  121911. * Note: The result of this call is not taken into account when a texture is base64.
  121912. *
  121913. * @param formatsAvailable defines the list of those format families you have created
  121914. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121915. *
  121916. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121917. * @returns The extension selected.
  121918. */
  121919. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121920. }
  121921. }
  121922. declare module BABYLON {
  121923. /**
  121924. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121925. */
  121926. export interface CubeMapInfo {
  121927. /**
  121928. * The pixel array for the front face.
  121929. * This is stored in format, left to right, up to down format.
  121930. */
  121931. front: Nullable<ArrayBufferView>;
  121932. /**
  121933. * The pixel array for the back face.
  121934. * This is stored in format, left to right, up to down format.
  121935. */
  121936. back: Nullable<ArrayBufferView>;
  121937. /**
  121938. * The pixel array for the left face.
  121939. * This is stored in format, left to right, up to down format.
  121940. */
  121941. left: Nullable<ArrayBufferView>;
  121942. /**
  121943. * The pixel array for the right face.
  121944. * This is stored in format, left to right, up to down format.
  121945. */
  121946. right: Nullable<ArrayBufferView>;
  121947. /**
  121948. * The pixel array for the up face.
  121949. * This is stored in format, left to right, up to down format.
  121950. */
  121951. up: Nullable<ArrayBufferView>;
  121952. /**
  121953. * The pixel array for the down face.
  121954. * This is stored in format, left to right, up to down format.
  121955. */
  121956. down: Nullable<ArrayBufferView>;
  121957. /**
  121958. * The size of the cubemap stored.
  121959. *
  121960. * Each faces will be size * size pixels.
  121961. */
  121962. size: number;
  121963. /**
  121964. * The format of the texture.
  121965. *
  121966. * RGBA, RGB.
  121967. */
  121968. format: number;
  121969. /**
  121970. * The type of the texture data.
  121971. *
  121972. * UNSIGNED_INT, FLOAT.
  121973. */
  121974. type: number;
  121975. /**
  121976. * Specifies whether the texture is in gamma space.
  121977. */
  121978. gammaSpace: boolean;
  121979. }
  121980. /**
  121981. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  121982. */
  121983. export class PanoramaToCubeMapTools {
  121984. private static FACE_FRONT;
  121985. private static FACE_BACK;
  121986. private static FACE_RIGHT;
  121987. private static FACE_LEFT;
  121988. private static FACE_DOWN;
  121989. private static FACE_UP;
  121990. /**
  121991. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  121992. *
  121993. * @param float32Array The source data.
  121994. * @param inputWidth The width of the input panorama.
  121995. * @param inputHeight The height of the input panorama.
  121996. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  121997. * @return The cubemap data
  121998. */
  121999. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122000. private static CreateCubemapTexture;
  122001. private static CalcProjectionSpherical;
  122002. }
  122003. }
  122004. declare module BABYLON {
  122005. /**
  122006. * Helper class dealing with the extraction of spherical polynomial dataArray
  122007. * from a cube map.
  122008. */
  122009. export class CubeMapToSphericalPolynomialTools {
  122010. private static FileFaces;
  122011. /**
  122012. * Converts a texture to the according Spherical Polynomial data.
  122013. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122014. *
  122015. * @param texture The texture to extract the information from.
  122016. * @return The Spherical Polynomial data.
  122017. */
  122018. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122019. /**
  122020. * Converts a cubemap to the according Spherical Polynomial data.
  122021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122022. *
  122023. * @param cubeInfo The Cube map to extract the information from.
  122024. * @return The Spherical Polynomial data.
  122025. */
  122026. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122027. }
  122028. }
  122029. declare module BABYLON {
  122030. interface BaseTexture {
  122031. /**
  122032. * Get the polynomial representation of the texture data.
  122033. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122034. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122035. */
  122036. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122037. }
  122038. }
  122039. declare module BABYLON {
  122040. /** @hidden */
  122041. export var rgbdEncodePixelShader: {
  122042. name: string;
  122043. shader: string;
  122044. };
  122045. }
  122046. declare module BABYLON {
  122047. /** @hidden */
  122048. export var rgbdDecodePixelShader: {
  122049. name: string;
  122050. shader: string;
  122051. };
  122052. }
  122053. declare module BABYLON {
  122054. /**
  122055. * Raw texture data and descriptor sufficient for WebGL texture upload
  122056. */
  122057. export interface EnvironmentTextureInfo {
  122058. /**
  122059. * Version of the environment map
  122060. */
  122061. version: number;
  122062. /**
  122063. * Width of image
  122064. */
  122065. width: number;
  122066. /**
  122067. * Irradiance information stored in the file.
  122068. */
  122069. irradiance: any;
  122070. /**
  122071. * Specular information stored in the file.
  122072. */
  122073. specular: any;
  122074. }
  122075. /**
  122076. * Defines One Image in the file. It requires only the position in the file
  122077. * as well as the length.
  122078. */
  122079. interface BufferImageData {
  122080. /**
  122081. * Length of the image data.
  122082. */
  122083. length: number;
  122084. /**
  122085. * Position of the data from the null terminator delimiting the end of the JSON.
  122086. */
  122087. position: number;
  122088. }
  122089. /**
  122090. * Defines the specular data enclosed in the file.
  122091. * This corresponds to the version 1 of the data.
  122092. */
  122093. export interface EnvironmentTextureSpecularInfoV1 {
  122094. /**
  122095. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122096. */
  122097. specularDataPosition?: number;
  122098. /**
  122099. * This contains all the images data needed to reconstruct the cubemap.
  122100. */
  122101. mipmaps: Array<BufferImageData>;
  122102. /**
  122103. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122104. */
  122105. lodGenerationScale: number;
  122106. }
  122107. /**
  122108. * Sets of helpers addressing the serialization and deserialization of environment texture
  122109. * stored in a BabylonJS env file.
  122110. * Those files are usually stored as .env files.
  122111. */
  122112. export class EnvironmentTextureTools {
  122113. /**
  122114. * Magic number identifying the env file.
  122115. */
  122116. private static _MagicBytes;
  122117. /**
  122118. * Gets the environment info from an env file.
  122119. * @param data The array buffer containing the .env bytes.
  122120. * @returns the environment file info (the json header) if successfully parsed.
  122121. */
  122122. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122123. /**
  122124. * Creates an environment texture from a loaded cube texture.
  122125. * @param texture defines the cube texture to convert in env file
  122126. * @return a promise containing the environment data if succesfull.
  122127. */
  122128. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122129. /**
  122130. * Creates a JSON representation of the spherical data.
  122131. * @param texture defines the texture containing the polynomials
  122132. * @return the JSON representation of the spherical info
  122133. */
  122134. private static _CreateEnvTextureIrradiance;
  122135. /**
  122136. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122137. * @param data the image data
  122138. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122139. * @return the views described by info providing access to the underlying buffer
  122140. */
  122141. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122142. /**
  122143. * Uploads the texture info contained in the env file to the GPU.
  122144. * @param texture defines the internal texture to upload to
  122145. * @param data defines the data to load
  122146. * @param info defines the texture info retrieved through the GetEnvInfo method
  122147. * @returns a promise
  122148. */
  122149. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122150. private static _OnImageReadyAsync;
  122151. /**
  122152. * Uploads the levels of image data to the GPU.
  122153. * @param texture defines the internal texture to upload to
  122154. * @param imageData defines the array buffer views of image data [mipmap][face]
  122155. * @returns a promise
  122156. */
  122157. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122158. /**
  122159. * Uploads spherical polynomials information to the texture.
  122160. * @param texture defines the texture we are trying to upload the information to
  122161. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122162. */
  122163. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122164. /** @hidden */
  122165. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122166. }
  122167. }
  122168. declare module BABYLON {
  122169. /**
  122170. * Contains position and normal vectors for a vertex
  122171. */
  122172. export class PositionNormalVertex {
  122173. /** the position of the vertex (defaut: 0,0,0) */
  122174. position: Vector3;
  122175. /** the normal of the vertex (defaut: 0,1,0) */
  122176. normal: Vector3;
  122177. /**
  122178. * Creates a PositionNormalVertex
  122179. * @param position the position of the vertex (defaut: 0,0,0)
  122180. * @param normal the normal of the vertex (defaut: 0,1,0)
  122181. */
  122182. constructor(
  122183. /** the position of the vertex (defaut: 0,0,0) */
  122184. position?: Vector3,
  122185. /** the normal of the vertex (defaut: 0,1,0) */
  122186. normal?: Vector3);
  122187. /**
  122188. * Clones the PositionNormalVertex
  122189. * @returns the cloned PositionNormalVertex
  122190. */
  122191. clone(): PositionNormalVertex;
  122192. }
  122193. /**
  122194. * Contains position, normal and uv vectors for a vertex
  122195. */
  122196. export class PositionNormalTextureVertex {
  122197. /** the position of the vertex (defaut: 0,0,0) */
  122198. position: Vector3;
  122199. /** the normal of the vertex (defaut: 0,1,0) */
  122200. normal: Vector3;
  122201. /** the uv of the vertex (default: 0,0) */
  122202. uv: Vector2;
  122203. /**
  122204. * Creates a PositionNormalTextureVertex
  122205. * @param position the position of the vertex (defaut: 0,0,0)
  122206. * @param normal the normal of the vertex (defaut: 0,1,0)
  122207. * @param uv the uv of the vertex (default: 0,0)
  122208. */
  122209. constructor(
  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. /** the uv of the vertex (default: 0,0) */
  122215. uv?: Vector2);
  122216. /**
  122217. * Clones the PositionNormalTextureVertex
  122218. * @returns the cloned PositionNormalTextureVertex
  122219. */
  122220. clone(): PositionNormalTextureVertex;
  122221. }
  122222. }
  122223. declare module BABYLON {
  122224. /** @hidden */
  122225. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122226. private _genericAttributeLocation;
  122227. private _varyingLocationCount;
  122228. private _varyingLocationMap;
  122229. private _replacements;
  122230. private _textureCount;
  122231. private _uniforms;
  122232. lineProcessor(line: string): string;
  122233. attributeProcessor(attribute: string): string;
  122234. varyingProcessor(varying: string, isFragment: boolean): string;
  122235. uniformProcessor(uniform: string): string;
  122236. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122237. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122238. }
  122239. }
  122240. declare module BABYLON {
  122241. /**
  122242. * Container for accessors for natively-stored mesh data buffers.
  122243. */
  122244. class NativeDataBuffer extends DataBuffer {
  122245. /**
  122246. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122247. */
  122248. nativeIndexBuffer?: any;
  122249. /**
  122250. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122251. */
  122252. nativeVertexBuffer?: any;
  122253. }
  122254. /** @hidden */
  122255. class NativeTexture extends InternalTexture {
  122256. getInternalTexture(): InternalTexture;
  122257. getViewCount(): number;
  122258. }
  122259. /** @hidden */
  122260. export class NativeEngine extends Engine {
  122261. private readonly _native;
  122262. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122263. private readonly INVALID_HANDLE;
  122264. getHardwareScalingLevel(): number;
  122265. constructor();
  122266. /**
  122267. * Can be used to override the current requestAnimationFrame requester.
  122268. * @hidden
  122269. */
  122270. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122271. /**
  122272. * Override default engine behavior.
  122273. * @param color
  122274. * @param backBuffer
  122275. * @param depth
  122276. * @param stencil
  122277. */
  122278. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122279. /**
  122280. * Gets host document
  122281. * @returns the host document object
  122282. */
  122283. getHostDocument(): Nullable<Document>;
  122284. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122285. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122286. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122287. recordVertexArrayObject(vertexBuffers: {
  122288. [key: string]: VertexBuffer;
  122289. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122290. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122291. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122292. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122293. /**
  122294. * Draw a list of indexed primitives
  122295. * @param fillMode defines the primitive to use
  122296. * @param indexStart defines the starting index
  122297. * @param indexCount defines the number of index to draw
  122298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122299. */
  122300. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122301. /**
  122302. * Draw a list of unindexed primitives
  122303. * @param fillMode defines the primitive to use
  122304. * @param verticesStart defines the index of first vertex to draw
  122305. * @param verticesCount defines the count of vertices to draw
  122306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122307. */
  122308. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122309. createPipelineContext(): IPipelineContext;
  122310. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122311. /** @hidden */
  122312. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122313. /** @hidden */
  122314. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122315. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122316. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122317. protected _setProgram(program: WebGLProgram): void;
  122318. _releaseEffect(effect: Effect): void;
  122319. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122320. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122322. bindSamplers(effect: Effect): void;
  122323. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122324. getRenderWidth(useScreen?: boolean): number;
  122325. getRenderHeight(useScreen?: boolean): number;
  122326. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122327. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122328. /**
  122329. * Set the z offset to apply to current rendering
  122330. * @param value defines the offset to apply
  122331. */
  122332. setZOffset(value: number): void;
  122333. /**
  122334. * Gets the current value of the zOffset
  122335. * @returns the current zOffset state
  122336. */
  122337. getZOffset(): number;
  122338. /**
  122339. * Enable or disable depth buffering
  122340. * @param enable defines the state to set
  122341. */
  122342. setDepthBuffer(enable: boolean): void;
  122343. /**
  122344. * Gets a boolean indicating if depth writing is enabled
  122345. * @returns the current depth writing state
  122346. */
  122347. getDepthWrite(): boolean;
  122348. /**
  122349. * Enable or disable depth writing
  122350. * @param enable defines the state to set
  122351. */
  122352. setDepthWrite(enable: boolean): void;
  122353. /**
  122354. * Enable or disable color writing
  122355. * @param enable defines the state to set
  122356. */
  122357. setColorWrite(enable: boolean): void;
  122358. /**
  122359. * Gets a boolean indicating if color writing is enabled
  122360. * @returns the current color writing state
  122361. */
  122362. getColorWrite(): boolean;
  122363. /**
  122364. * Sets alpha constants used by some alpha blending modes
  122365. * @param r defines the red component
  122366. * @param g defines the green component
  122367. * @param b defines the blue component
  122368. * @param a defines the alpha component
  122369. */
  122370. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122371. /**
  122372. * Sets the current alpha mode
  122373. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122374. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122376. */
  122377. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122378. /**
  122379. * Gets the current alpha mode
  122380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122381. * @returns the current alpha mode
  122382. */
  122383. getAlphaMode(): number;
  122384. setInt(uniform: WebGLUniformLocation, int: number): void;
  122385. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122386. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122387. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122388. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122389. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122390. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122391. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122392. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122393. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122394. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122395. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122396. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122397. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122398. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122399. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122400. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122401. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122402. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122403. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122404. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122405. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122406. wipeCaches(bruteForce?: boolean): void;
  122407. _createTexture(): WebGLTexture;
  122408. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122409. /**
  122410. * Usually called from Texture.ts.
  122411. * Passed information to create a WebGLTexture
  122412. * @param urlArg defines a value which contains one of the following:
  122413. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122414. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122415. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122417. * @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)
  122418. * @param scene needed for loading to the correct scene
  122419. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122420. * @param onLoad optional callback to be called upon successful completion
  122421. * @param onError optional callback to be called upon failure
  122422. * @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
  122423. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122424. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122425. * @param forcedExtension defines the extension to use to pick the right loader
  122426. * @param mimeType defines an optional mime type
  122427. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122428. */
  122429. 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;
  122430. /**
  122431. * Creates a cube texture
  122432. * @param rootUrl defines the url where the files to load is located
  122433. * @param scene defines the current scene
  122434. * @param files defines the list of files to load (1 per face)
  122435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122436. * @param onLoad defines an optional callback raised when the texture is loaded
  122437. * @param onError defines an optional callback raised if there is an issue to load the texture
  122438. * @param format defines the format of the data
  122439. * @param forcedExtension defines the extension to use to pick the right loader
  122440. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122441. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122442. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122443. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122444. * @returns the cube texture as an InternalTexture
  122445. */
  122446. 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;
  122447. private _getSamplingFilter;
  122448. private static _GetNativeTextureFormat;
  122449. createRenderTargetTexture(size: number | {
  122450. width: number;
  122451. height: number;
  122452. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122453. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122455. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122456. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122457. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122458. /**
  122459. * Updates a dynamic vertex buffer.
  122460. * @param vertexBuffer the vertex buffer to update
  122461. * @param data the data used to update the vertex buffer
  122462. * @param byteOffset the byte offset of the data (optional)
  122463. * @param byteLength the byte length of the data (optional)
  122464. */
  122465. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122466. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122467. private _updateAnisotropicLevel;
  122468. private _getAddressMode;
  122469. /** @hidden */
  122470. _bindTexture(channel: number, texture: InternalTexture): void;
  122471. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122472. releaseEffects(): void;
  122473. /** @hidden */
  122474. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122475. /** @hidden */
  122476. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122477. /** @hidden */
  122478. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122479. /** @hidden */
  122480. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122481. }
  122482. }
  122483. declare module BABYLON {
  122484. /**
  122485. * Gather the list of clipboard event types as constants.
  122486. */
  122487. export class ClipboardEventTypes {
  122488. /**
  122489. * The clipboard event is fired when a copy command is active (pressed).
  122490. */
  122491. static readonly COPY: number;
  122492. /**
  122493. * The clipboard event is fired when a cut command is active (pressed).
  122494. */
  122495. static readonly CUT: number;
  122496. /**
  122497. * The clipboard event is fired when a paste command is active (pressed).
  122498. */
  122499. static readonly PASTE: number;
  122500. }
  122501. /**
  122502. * This class is used to store clipboard related info for the onClipboardObservable event.
  122503. */
  122504. export class ClipboardInfo {
  122505. /**
  122506. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122507. */
  122508. type: number;
  122509. /**
  122510. * Defines the related dom event
  122511. */
  122512. event: ClipboardEvent;
  122513. /**
  122514. *Creates an instance of ClipboardInfo.
  122515. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122516. * @param event Defines the related dom event
  122517. */
  122518. constructor(
  122519. /**
  122520. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122521. */
  122522. type: number,
  122523. /**
  122524. * Defines the related dom event
  122525. */
  122526. event: ClipboardEvent);
  122527. /**
  122528. * Get the clipboard event's type from the keycode.
  122529. * @param keyCode Defines the keyCode for the current keyboard event.
  122530. * @return {number}
  122531. */
  122532. static GetTypeFromCharacter(keyCode: number): number;
  122533. }
  122534. }
  122535. declare module BABYLON {
  122536. /**
  122537. * Google Daydream controller
  122538. */
  122539. export class DaydreamController extends WebVRController {
  122540. /**
  122541. * Base Url for the controller model.
  122542. */
  122543. static MODEL_BASE_URL: string;
  122544. /**
  122545. * File name for the controller model.
  122546. */
  122547. static MODEL_FILENAME: string;
  122548. /**
  122549. * Gamepad Id prefix used to identify Daydream Controller.
  122550. */
  122551. static readonly GAMEPAD_ID_PREFIX: string;
  122552. /**
  122553. * Creates a new DaydreamController from a gamepad
  122554. * @param vrGamepad the gamepad that the controller should be created from
  122555. */
  122556. constructor(vrGamepad: any);
  122557. /**
  122558. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122559. * @param scene scene in which to add meshes
  122560. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122561. */
  122562. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122563. /**
  122564. * Called once for each button that changed state since the last frame
  122565. * @param buttonIdx Which button index changed
  122566. * @param state New state of the button
  122567. * @param changes Which properties on the state changed since last frame
  122568. */
  122569. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /**
  122574. * Gear VR Controller
  122575. */
  122576. export class GearVRController extends WebVRController {
  122577. /**
  122578. * Base Url for the controller model.
  122579. */
  122580. static MODEL_BASE_URL: string;
  122581. /**
  122582. * File name for the controller model.
  122583. */
  122584. static MODEL_FILENAME: string;
  122585. /**
  122586. * Gamepad Id prefix used to identify this controller.
  122587. */
  122588. static readonly GAMEPAD_ID_PREFIX: string;
  122589. private readonly _buttonIndexToObservableNameMap;
  122590. /**
  122591. * Creates a new GearVRController 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. * Generic Controller
  122613. */
  122614. export class GenericController extends WebVRController {
  122615. /**
  122616. * Base Url for the controller model.
  122617. */
  122618. static readonly MODEL_BASE_URL: string;
  122619. /**
  122620. * File name for the controller model.
  122621. */
  122622. static readonly MODEL_FILENAME: string;
  122623. /**
  122624. * Creates a new GenericController from a gamepad
  122625. * @param vrGamepad the gamepad that the controller should be created from
  122626. */
  122627. constructor(vrGamepad: any);
  122628. /**
  122629. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122630. * @param scene scene in which to add meshes
  122631. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122632. */
  122633. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122634. /**
  122635. * Called once for each button that changed state since the last frame
  122636. * @param buttonIdx Which button index changed
  122637. * @param state New state of the button
  122638. * @param changes Which properties on the state changed since last frame
  122639. */
  122640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122641. }
  122642. }
  122643. declare module BABYLON {
  122644. /**
  122645. * Oculus Touch Controller
  122646. */
  122647. export class OculusTouchController extends WebVRController {
  122648. /**
  122649. * Base Url for the controller model.
  122650. */
  122651. static MODEL_BASE_URL: string;
  122652. /**
  122653. * File name for the left controller model.
  122654. */
  122655. static MODEL_LEFT_FILENAME: string;
  122656. /**
  122657. * File name for the right controller model.
  122658. */
  122659. static MODEL_RIGHT_FILENAME: string;
  122660. /**
  122661. * Base Url for the Quest controller model.
  122662. */
  122663. static QUEST_MODEL_BASE_URL: string;
  122664. /**
  122665. * @hidden
  122666. * If the controllers are running on a device that needs the updated Quest controller models
  122667. */
  122668. static _IsQuest: boolean;
  122669. /**
  122670. * Fired when the secondary trigger on this controller is modified
  122671. */
  122672. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122673. /**
  122674. * Fired when the thumb rest on this controller is modified
  122675. */
  122676. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122677. /**
  122678. * Creates a new OculusTouchController from a gamepad
  122679. * @param vrGamepad the gamepad that the controller should be created from
  122680. */
  122681. constructor(vrGamepad: any);
  122682. /**
  122683. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122684. * @param scene scene in which to add meshes
  122685. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122686. */
  122687. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122688. /**
  122689. * Fired when the A button on this controller is modified
  122690. */
  122691. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122692. /**
  122693. * Fired when the B button on this controller is modified
  122694. */
  122695. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122696. /**
  122697. * Fired when the X button on this controller is modified
  122698. */
  122699. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122700. /**
  122701. * Fired when the Y button on this controller is modified
  122702. */
  122703. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122704. /**
  122705. * Called once for each button that changed state since the last frame
  122706. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122707. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122708. * 2) secondary trigger (same)
  122709. * 3) A (right) X (left), touch, pressed = value
  122710. * 4) B / Y
  122711. * 5) thumb rest
  122712. * @param buttonIdx Which button index changed
  122713. * @param state New state of the button
  122714. * @param changes Which properties on the state changed since last frame
  122715. */
  122716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122717. }
  122718. }
  122719. declare module BABYLON {
  122720. /**
  122721. * Vive Controller
  122722. */
  122723. export class ViveController extends WebVRController {
  122724. /**
  122725. * Base Url for the controller model.
  122726. */
  122727. static MODEL_BASE_URL: string;
  122728. /**
  122729. * File name for the controller model.
  122730. */
  122731. static MODEL_FILENAME: string;
  122732. /**
  122733. * Creates a new ViveController from a gamepad
  122734. * @param vrGamepad the gamepad that the controller should be created from
  122735. */
  122736. constructor(vrGamepad: any);
  122737. /**
  122738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122739. * @param scene scene in which to add meshes
  122740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122741. */
  122742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122743. /**
  122744. * Fired when the left button on this controller is modified
  122745. */
  122746. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122747. /**
  122748. * Fired when the right button on this controller is modified
  122749. */
  122750. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122751. /**
  122752. * Fired when the menu button on this controller is modified
  122753. */
  122754. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122755. /**
  122756. * Called once for each button that changed state since the last frame
  122757. * Vive mapping:
  122758. * 0: touchpad
  122759. * 1: trigger
  122760. * 2: left AND right buttons
  122761. * 3: menu button
  122762. * @param buttonIdx Which button index changed
  122763. * @param state New state of the button
  122764. * @param changes Which properties on the state changed since last frame
  122765. */
  122766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122767. }
  122768. }
  122769. declare module BABYLON {
  122770. /**
  122771. * Defines the WindowsMotionController object that the state of the windows motion controller
  122772. */
  122773. export class WindowsMotionController extends WebVRController {
  122774. /**
  122775. * The base url used to load the left and right controller models
  122776. */
  122777. static MODEL_BASE_URL: string;
  122778. /**
  122779. * The name of the left controller model file
  122780. */
  122781. static MODEL_LEFT_FILENAME: string;
  122782. /**
  122783. * The name of the right controller model file
  122784. */
  122785. static MODEL_RIGHT_FILENAME: string;
  122786. /**
  122787. * The controller name prefix for this controller type
  122788. */
  122789. static readonly GAMEPAD_ID_PREFIX: string;
  122790. /**
  122791. * The controller id pattern for this controller type
  122792. */
  122793. private static readonly GAMEPAD_ID_PATTERN;
  122794. private _loadedMeshInfo;
  122795. protected readonly _mapping: {
  122796. buttons: string[];
  122797. buttonMeshNames: {
  122798. trigger: string;
  122799. menu: string;
  122800. grip: string;
  122801. thumbstick: string;
  122802. trackpad: string;
  122803. };
  122804. buttonObservableNames: {
  122805. trigger: string;
  122806. menu: string;
  122807. grip: string;
  122808. thumbstick: string;
  122809. trackpad: string;
  122810. };
  122811. axisMeshNames: string[];
  122812. pointingPoseMeshName: string;
  122813. };
  122814. /**
  122815. * Fired when the trackpad on this controller is clicked
  122816. */
  122817. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122818. /**
  122819. * Fired when the trackpad on this controller is modified
  122820. */
  122821. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122822. /**
  122823. * The current x and y values of this controller's trackpad
  122824. */
  122825. trackpad: StickValues;
  122826. /**
  122827. * Creates a new WindowsMotionController from a gamepad
  122828. * @param vrGamepad the gamepad that the controller should be created from
  122829. */
  122830. constructor(vrGamepad: any);
  122831. /**
  122832. * Fired when the trigger on this controller is modified
  122833. */
  122834. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122835. /**
  122836. * Fired when the menu button on this controller is modified
  122837. */
  122838. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122839. /**
  122840. * Fired when the grip button on this controller is modified
  122841. */
  122842. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122843. /**
  122844. * Fired when the thumbstick button on this controller is modified
  122845. */
  122846. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122847. /**
  122848. * Fired when the touchpad button on this controller is modified
  122849. */
  122850. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122851. /**
  122852. * Fired when the touchpad values on this controller are modified
  122853. */
  122854. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122855. protected _updateTrackpad(): void;
  122856. /**
  122857. * Called once per frame by the engine.
  122858. */
  122859. update(): void;
  122860. /**
  122861. * Called once for each button that changed state since the last frame
  122862. * @param buttonIdx Which button index changed
  122863. * @param state New state of the button
  122864. * @param changes Which properties on the state changed since last frame
  122865. */
  122866. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122867. /**
  122868. * Moves the buttons on the controller mesh based on their current state
  122869. * @param buttonName the name of the button to move
  122870. * @param buttonValue the value of the button which determines the buttons new position
  122871. */
  122872. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122873. /**
  122874. * Moves the axis on the controller mesh based on its current state
  122875. * @param axis the index of the axis
  122876. * @param axisValue the value of the axis which determines the meshes new position
  122877. * @hidden
  122878. */
  122879. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122880. /**
  122881. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122882. * @param scene scene in which to add meshes
  122883. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122884. */
  122885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122886. /**
  122887. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122888. * can be transformed by button presses and axes values, based on this._mapping.
  122889. *
  122890. * @param scene scene in which the meshes exist
  122891. * @param meshes list of meshes that make up the controller model to process
  122892. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122893. */
  122894. private processModel;
  122895. private createMeshInfo;
  122896. /**
  122897. * Gets the ray of the controller in the direction the controller is pointing
  122898. * @param length the length the resulting ray should be
  122899. * @returns a ray in the direction the controller is pointing
  122900. */
  122901. getForwardRay(length?: number): Ray;
  122902. /**
  122903. * Disposes of the controller
  122904. */
  122905. dispose(): void;
  122906. }
  122907. /**
  122908. * This class represents a new windows motion controller in XR.
  122909. */
  122910. export class XRWindowsMotionController extends WindowsMotionController {
  122911. /**
  122912. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122913. */
  122914. protected readonly _mapping: {
  122915. buttons: string[];
  122916. buttonMeshNames: {
  122917. trigger: string;
  122918. menu: string;
  122919. grip: string;
  122920. thumbstick: string;
  122921. trackpad: string;
  122922. };
  122923. buttonObservableNames: {
  122924. trigger: string;
  122925. menu: string;
  122926. grip: string;
  122927. thumbstick: string;
  122928. trackpad: string;
  122929. };
  122930. axisMeshNames: string[];
  122931. pointingPoseMeshName: string;
  122932. };
  122933. /**
  122934. * Construct a new XR-Based windows motion controller
  122935. *
  122936. * @param gamepadInfo the gamepad object from the browser
  122937. */
  122938. constructor(gamepadInfo: any);
  122939. /**
  122940. * holds the thumbstick values (X,Y)
  122941. */
  122942. thumbstickValues: StickValues;
  122943. /**
  122944. * Fired when the thumbstick on this controller is clicked
  122945. */
  122946. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122947. /**
  122948. * Fired when the thumbstick on this controller is modified
  122949. */
  122950. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122951. /**
  122952. * Fired when the touchpad button on this controller is modified
  122953. */
  122954. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122955. /**
  122956. * Fired when the touchpad values on this controller are modified
  122957. */
  122958. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122959. /**
  122960. * Fired when the thumbstick button on this controller is modified
  122961. * here to prevent breaking changes
  122962. */
  122963. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122964. /**
  122965. * updating the thumbstick(!) and not the trackpad.
  122966. * This is named this way due to the difference between WebVR and XR and to avoid
  122967. * changing the parent class.
  122968. */
  122969. protected _updateTrackpad(): void;
  122970. /**
  122971. * Disposes the class with joy
  122972. */
  122973. dispose(): void;
  122974. }
  122975. }
  122976. declare module BABYLON {
  122977. /**
  122978. * Class containing static functions to help procedurally build meshes
  122979. */
  122980. export class PolyhedronBuilder {
  122981. /**
  122982. * Creates a polyhedron mesh
  122983. * * 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
  122984. * * The parameter `size` (positive float, default 1) sets the polygon size
  122985. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122986. * * 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`
  122987. * * 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
  122988. * * 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)`)
  122989. * * 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
  122990. * * 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
  122991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122994. * @param name defines the name of the mesh
  122995. * @param options defines the options used to create the mesh
  122996. * @param scene defines the hosting scene
  122997. * @returns the polyhedron mesh
  122998. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122999. */
  123000. static CreatePolyhedron(name: string, options: {
  123001. type?: number;
  123002. size?: number;
  123003. sizeX?: number;
  123004. sizeY?: number;
  123005. sizeZ?: number;
  123006. custom?: any;
  123007. faceUV?: Vector4[];
  123008. faceColors?: Color4[];
  123009. flat?: boolean;
  123010. updatable?: boolean;
  123011. sideOrientation?: number;
  123012. frontUVs?: Vector4;
  123013. backUVs?: Vector4;
  123014. }, scene?: Nullable<Scene>): Mesh;
  123015. }
  123016. }
  123017. declare module BABYLON {
  123018. /**
  123019. * Gizmo that enables scaling a mesh along 3 axis
  123020. */
  123021. export class ScaleGizmo extends Gizmo {
  123022. /**
  123023. * Internal gizmo used for interactions on the x axis
  123024. */
  123025. xGizmo: AxisScaleGizmo;
  123026. /**
  123027. * Internal gizmo used for interactions on the y axis
  123028. */
  123029. yGizmo: AxisScaleGizmo;
  123030. /**
  123031. * Internal gizmo used for interactions on the z axis
  123032. */
  123033. zGizmo: AxisScaleGizmo;
  123034. /**
  123035. * Internal gizmo used to scale all axis equally
  123036. */
  123037. uniformScaleGizmo: AxisScaleGizmo;
  123038. private _meshAttached;
  123039. private _updateGizmoRotationToMatchAttachedMesh;
  123040. private _snapDistance;
  123041. private _scaleRatio;
  123042. private _uniformScalingMesh;
  123043. private _octahedron;
  123044. private _sensitivity;
  123045. /** Fires an event when any of it's sub gizmos are dragged */
  123046. onDragStartObservable: Observable<unknown>;
  123047. /** Fires an event when any of it's sub gizmos are released from dragging */
  123048. onDragEndObservable: Observable<unknown>;
  123049. get attachedMesh(): Nullable<AbstractMesh>;
  123050. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123051. /**
  123052. * Creates a ScaleGizmo
  123053. * @param gizmoLayer The utility layer the gizmo will be added to
  123054. */
  123055. constructor(gizmoLayer?: UtilityLayerRenderer);
  123056. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123057. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123058. /**
  123059. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123060. */
  123061. set snapDistance(value: number);
  123062. get snapDistance(): number;
  123063. /**
  123064. * Ratio for the scale of the gizmo (Default: 1)
  123065. */
  123066. set scaleRatio(value: number);
  123067. get scaleRatio(): number;
  123068. /**
  123069. * Sensitivity factor for dragging (Default: 1)
  123070. */
  123071. set sensitivity(value: number);
  123072. get sensitivity(): number;
  123073. /**
  123074. * Disposes of the gizmo
  123075. */
  123076. dispose(): void;
  123077. }
  123078. }
  123079. declare module BABYLON {
  123080. /**
  123081. * Single axis scale gizmo
  123082. */
  123083. export class AxisScaleGizmo extends Gizmo {
  123084. /**
  123085. * Drag behavior responsible for the gizmos dragging interactions
  123086. */
  123087. dragBehavior: PointerDragBehavior;
  123088. private _pointerObserver;
  123089. /**
  123090. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123091. */
  123092. snapDistance: number;
  123093. /**
  123094. * Event that fires each time the gizmo snaps to a new location.
  123095. * * snapDistance is the the change in distance
  123096. */
  123097. onSnapObservable: Observable<{
  123098. snapDistance: number;
  123099. }>;
  123100. /**
  123101. * If the scaling operation should be done on all axis (default: false)
  123102. */
  123103. uniformScaling: boolean;
  123104. /**
  123105. * Custom sensitivity value for the drag strength
  123106. */
  123107. sensitivity: number;
  123108. private _isEnabled;
  123109. private _parent;
  123110. private _arrow;
  123111. private _coloredMaterial;
  123112. private _hoverMaterial;
  123113. /**
  123114. * Creates an AxisScaleGizmo
  123115. * @param gizmoLayer The utility layer the gizmo will be added to
  123116. * @param dragAxis The axis which the gizmo will be able to scale on
  123117. * @param color The color of the gizmo
  123118. */
  123119. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123120. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123121. /**
  123122. * If the gizmo is enabled
  123123. */
  123124. set isEnabled(value: boolean);
  123125. get isEnabled(): boolean;
  123126. /**
  123127. * Disposes of the gizmo
  123128. */
  123129. dispose(): void;
  123130. /**
  123131. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123132. * @param mesh The mesh to replace the default mesh of the gizmo
  123133. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123134. */
  123135. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123136. }
  123137. }
  123138. declare module BABYLON {
  123139. /**
  123140. * Bounding box gizmo
  123141. */
  123142. export class BoundingBoxGizmo extends Gizmo {
  123143. private _lineBoundingBox;
  123144. private _rotateSpheresParent;
  123145. private _scaleBoxesParent;
  123146. private _boundingDimensions;
  123147. private _renderObserver;
  123148. private _pointerObserver;
  123149. private _scaleDragSpeed;
  123150. private _tmpQuaternion;
  123151. private _tmpVector;
  123152. private _tmpRotationMatrix;
  123153. /**
  123154. * 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)
  123155. */
  123156. ignoreChildren: boolean;
  123157. /**
  123158. * 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)
  123159. */
  123160. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123161. /**
  123162. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123163. */
  123164. rotationSphereSize: number;
  123165. /**
  123166. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123167. */
  123168. scaleBoxSize: number;
  123169. /**
  123170. * 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)
  123171. */
  123172. fixedDragMeshScreenSize: boolean;
  123173. /**
  123174. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123175. */
  123176. fixedDragMeshScreenSizeDistanceFactor: number;
  123177. /**
  123178. * Fired when a rotation sphere or scale box is dragged
  123179. */
  123180. onDragStartObservable: Observable<{}>;
  123181. /**
  123182. * Fired when a scale box is dragged
  123183. */
  123184. onScaleBoxDragObservable: Observable<{}>;
  123185. /**
  123186. * Fired when a scale box drag is ended
  123187. */
  123188. onScaleBoxDragEndObservable: Observable<{}>;
  123189. /**
  123190. * Fired when a rotation sphere is dragged
  123191. */
  123192. onRotationSphereDragObservable: Observable<{}>;
  123193. /**
  123194. * Fired when a rotation sphere drag is ended
  123195. */
  123196. onRotationSphereDragEndObservable: Observable<{}>;
  123197. /**
  123198. * 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)
  123199. */
  123200. scalePivot: Nullable<Vector3>;
  123201. /**
  123202. * Mesh used as a pivot to rotate the attached mesh
  123203. */
  123204. private _anchorMesh;
  123205. private _existingMeshScale;
  123206. private _dragMesh;
  123207. private pointerDragBehavior;
  123208. private coloredMaterial;
  123209. private hoverColoredMaterial;
  123210. /**
  123211. * Sets the color of the bounding box gizmo
  123212. * @param color the color to set
  123213. */
  123214. setColor(color: Color3): void;
  123215. /**
  123216. * Creates an BoundingBoxGizmo
  123217. * @param gizmoLayer The utility layer the gizmo will be added to
  123218. * @param color The color of the gizmo
  123219. */
  123220. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123222. private _selectNode;
  123223. /**
  123224. * Updates the bounding box information for the Gizmo
  123225. */
  123226. updateBoundingBox(): void;
  123227. private _updateRotationSpheres;
  123228. private _updateScaleBoxes;
  123229. /**
  123230. * Enables rotation on the specified axis and disables rotation on the others
  123231. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123232. */
  123233. setEnabledRotationAxis(axis: string): void;
  123234. /**
  123235. * Enables/disables scaling
  123236. * @param enable if scaling should be enabled
  123237. * @param homogeneousScaling defines if scaling should only be homogeneous
  123238. */
  123239. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123240. private _updateDummy;
  123241. /**
  123242. * Enables a pointer drag behavior on the bounding box of the gizmo
  123243. */
  123244. enableDragBehavior(): void;
  123245. /**
  123246. * Disposes of the gizmo
  123247. */
  123248. dispose(): void;
  123249. /**
  123250. * 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)
  123251. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123252. * @returns the bounding box mesh with the passed in mesh as a child
  123253. */
  123254. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123255. /**
  123256. * CustomMeshes are not supported by this gizmo
  123257. * @param mesh The mesh to replace the default mesh of the gizmo
  123258. */
  123259. setCustomMesh(mesh: Mesh): void;
  123260. }
  123261. }
  123262. declare module BABYLON {
  123263. /**
  123264. * Single plane rotation gizmo
  123265. */
  123266. export class PlaneRotationGizmo extends Gizmo {
  123267. /**
  123268. * Drag behavior responsible for the gizmos dragging interactions
  123269. */
  123270. dragBehavior: PointerDragBehavior;
  123271. private _pointerObserver;
  123272. /**
  123273. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123274. */
  123275. snapDistance: number;
  123276. /**
  123277. * Event that fires each time the gizmo snaps to a new location.
  123278. * * snapDistance is the the change in distance
  123279. */
  123280. onSnapObservable: Observable<{
  123281. snapDistance: number;
  123282. }>;
  123283. private _isEnabled;
  123284. private _parent;
  123285. /**
  123286. * Creates a PlaneRotationGizmo
  123287. * @param gizmoLayer The utility layer the gizmo will be added to
  123288. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123289. * @param color The color of the gizmo
  123290. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123291. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123292. */
  123293. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123294. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123295. /**
  123296. * If the gizmo is enabled
  123297. */
  123298. set isEnabled(value: boolean);
  123299. get isEnabled(): boolean;
  123300. /**
  123301. * Disposes of the gizmo
  123302. */
  123303. dispose(): void;
  123304. }
  123305. }
  123306. declare module BABYLON {
  123307. /**
  123308. * Gizmo that enables rotating a mesh along 3 axis
  123309. */
  123310. export class RotationGizmo extends Gizmo {
  123311. /**
  123312. * Internal gizmo used for interactions on the x axis
  123313. */
  123314. xGizmo: PlaneRotationGizmo;
  123315. /**
  123316. * Internal gizmo used for interactions on the y axis
  123317. */
  123318. yGizmo: PlaneRotationGizmo;
  123319. /**
  123320. * Internal gizmo used for interactions on the z axis
  123321. */
  123322. zGizmo: PlaneRotationGizmo;
  123323. /** Fires an event when any of it's sub gizmos are dragged */
  123324. onDragStartObservable: Observable<unknown>;
  123325. /** Fires an event when any of it's sub gizmos are released from dragging */
  123326. onDragEndObservable: Observable<unknown>;
  123327. private _meshAttached;
  123328. get attachedMesh(): Nullable<AbstractMesh>;
  123329. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123330. /**
  123331. * Creates a RotationGizmo
  123332. * @param gizmoLayer The utility layer the gizmo will be added to
  123333. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123334. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123335. */
  123336. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123337. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123338. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123339. /**
  123340. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123341. */
  123342. set snapDistance(value: number);
  123343. get snapDistance(): number;
  123344. /**
  123345. * Ratio for the scale of the gizmo (Default: 1)
  123346. */
  123347. set scaleRatio(value: number);
  123348. get scaleRatio(): number;
  123349. /**
  123350. * Disposes of the gizmo
  123351. */
  123352. dispose(): void;
  123353. /**
  123354. * CustomMeshes are not supported by this gizmo
  123355. * @param mesh The mesh to replace the default mesh of the gizmo
  123356. */
  123357. setCustomMesh(mesh: Mesh): void;
  123358. }
  123359. }
  123360. declare module BABYLON {
  123361. /**
  123362. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123363. */
  123364. export class GizmoManager implements IDisposable {
  123365. private scene;
  123366. /**
  123367. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123368. */
  123369. gizmos: {
  123370. positionGizmo: Nullable<PositionGizmo>;
  123371. rotationGizmo: Nullable<RotationGizmo>;
  123372. scaleGizmo: Nullable<ScaleGizmo>;
  123373. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123374. };
  123375. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123376. clearGizmoOnEmptyPointerEvent: boolean;
  123377. /** Fires an event when the manager is attached to a mesh */
  123378. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123379. private _gizmosEnabled;
  123380. private _pointerObserver;
  123381. private _attachedMesh;
  123382. private _boundingBoxColor;
  123383. private _defaultUtilityLayer;
  123384. private _defaultKeepDepthUtilityLayer;
  123385. /**
  123386. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123387. */
  123388. boundingBoxDragBehavior: SixDofDragBehavior;
  123389. /**
  123390. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123391. */
  123392. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123393. /**
  123394. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123395. */
  123396. usePointerToAttachGizmos: boolean;
  123397. /**
  123398. * Utility layer that the bounding box gizmo belongs to
  123399. */
  123400. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123401. /**
  123402. * Utility layer that all gizmos besides bounding box belong to
  123403. */
  123404. get utilityLayer(): UtilityLayerRenderer;
  123405. /**
  123406. * Instatiates a gizmo manager
  123407. * @param scene the scene to overlay the gizmos on top of
  123408. */
  123409. constructor(scene: Scene);
  123410. /**
  123411. * Attaches a set of gizmos to the specified mesh
  123412. * @param mesh The mesh the gizmo's should be attached to
  123413. */
  123414. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123415. /**
  123416. * If the position gizmo is enabled
  123417. */
  123418. set positionGizmoEnabled(value: boolean);
  123419. get positionGizmoEnabled(): boolean;
  123420. /**
  123421. * If the rotation gizmo is enabled
  123422. */
  123423. set rotationGizmoEnabled(value: boolean);
  123424. get rotationGizmoEnabled(): boolean;
  123425. /**
  123426. * If the scale gizmo is enabled
  123427. */
  123428. set scaleGizmoEnabled(value: boolean);
  123429. get scaleGizmoEnabled(): boolean;
  123430. /**
  123431. * If the boundingBox gizmo is enabled
  123432. */
  123433. set boundingBoxGizmoEnabled(value: boolean);
  123434. get boundingBoxGizmoEnabled(): boolean;
  123435. /**
  123436. * Disposes of the gizmo manager
  123437. */
  123438. dispose(): void;
  123439. }
  123440. }
  123441. declare module BABYLON {
  123442. /**
  123443. * A directional light is defined by a direction (what a surprise!).
  123444. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123445. * 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.
  123446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123447. */
  123448. export class DirectionalLight extends ShadowLight {
  123449. private _shadowFrustumSize;
  123450. /**
  123451. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123452. */
  123453. get shadowFrustumSize(): number;
  123454. /**
  123455. * Specifies a fix frustum size for the shadow generation.
  123456. */
  123457. set shadowFrustumSize(value: number);
  123458. private _shadowOrthoScale;
  123459. /**
  123460. * Gets the shadow projection scale against the optimal computed one.
  123461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123463. */
  123464. get shadowOrthoScale(): number;
  123465. /**
  123466. * Sets the shadow projection scale against the optimal computed one.
  123467. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123468. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123469. */
  123470. set shadowOrthoScale(value: number);
  123471. /**
  123472. * Automatically compute the projection matrix to best fit (including all the casters)
  123473. * on each frame.
  123474. */
  123475. autoUpdateExtends: boolean;
  123476. /**
  123477. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123478. * on each frame. autoUpdateExtends must be set to true for this to work
  123479. */
  123480. autoCalcShadowZBounds: boolean;
  123481. private _orthoLeft;
  123482. private _orthoRight;
  123483. private _orthoTop;
  123484. private _orthoBottom;
  123485. /**
  123486. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123487. * The directional light is emitted from everywhere in the given direction.
  123488. * It can cast shadows.
  123489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123490. * @param name The friendly name of the light
  123491. * @param direction The direction of the light
  123492. * @param scene The scene the light belongs to
  123493. */
  123494. constructor(name: string, direction: Vector3, scene: Scene);
  123495. /**
  123496. * Returns the string "DirectionalLight".
  123497. * @return The class name
  123498. */
  123499. getClassName(): string;
  123500. /**
  123501. * Returns the integer 1.
  123502. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123503. */
  123504. getTypeID(): number;
  123505. /**
  123506. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123507. * Returns the DirectionalLight Shadow projection matrix.
  123508. */
  123509. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123510. /**
  123511. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123512. * Returns the DirectionalLight Shadow projection matrix.
  123513. */
  123514. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123515. /**
  123516. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123517. * Returns the DirectionalLight Shadow projection matrix.
  123518. */
  123519. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123520. protected _buildUniformLayout(): void;
  123521. /**
  123522. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123523. * @param effect The effect to update
  123524. * @param lightIndex The index of the light in the effect to update
  123525. * @returns The directional light
  123526. */
  123527. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123529. /**
  123530. * Gets the minZ used for shadow according to both the scene and the light.
  123531. *
  123532. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123533. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123534. * @param activeCamera The camera we are returning the min for
  123535. * @returns the depth min z
  123536. */
  123537. getDepthMinZ(activeCamera: Camera): number;
  123538. /**
  123539. * Gets the maxZ used for shadow according to both the scene and the light.
  123540. *
  123541. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123542. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123543. * @param activeCamera The camera we are returning the max for
  123544. * @returns the depth max z
  123545. */
  123546. getDepthMaxZ(activeCamera: Camera): number;
  123547. /**
  123548. * Prepares the list of defines specific to the light type.
  123549. * @param defines the list of defines
  123550. * @param lightIndex defines the index of the light for the effect
  123551. */
  123552. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123553. }
  123554. }
  123555. declare module BABYLON {
  123556. /**
  123557. * Class containing static functions to help procedurally build meshes
  123558. */
  123559. export class HemisphereBuilder {
  123560. /**
  123561. * Creates a hemisphere mesh
  123562. * @param name defines the name of the mesh
  123563. * @param options defines the options used to create the mesh
  123564. * @param scene defines the hosting scene
  123565. * @returns the hemisphere mesh
  123566. */
  123567. static CreateHemisphere(name: string, options: {
  123568. segments?: number;
  123569. diameter?: number;
  123570. sideOrientation?: number;
  123571. }, scene: any): Mesh;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123577. * These values define a cone of light starting from the position, emitting toward the direction.
  123578. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123579. * and the exponent defines the speed of the decay of the light with distance (reach).
  123580. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123581. */
  123582. export class SpotLight extends ShadowLight {
  123583. private _angle;
  123584. private _innerAngle;
  123585. private _cosHalfAngle;
  123586. private _lightAngleScale;
  123587. private _lightAngleOffset;
  123588. /**
  123589. * Gets the cone angle of the spot light in Radians.
  123590. */
  123591. get angle(): number;
  123592. /**
  123593. * Sets the cone angle of the spot light in Radians.
  123594. */
  123595. set angle(value: number);
  123596. /**
  123597. * Only used in gltf falloff mode, this defines the angle where
  123598. * the directional falloff will start before cutting at angle which could be seen
  123599. * as outer angle.
  123600. */
  123601. get innerAngle(): number;
  123602. /**
  123603. * Only used in gltf falloff mode, this defines the angle where
  123604. * the directional falloff will start before cutting at angle which could be seen
  123605. * as outer angle.
  123606. */
  123607. set innerAngle(value: number);
  123608. private _shadowAngleScale;
  123609. /**
  123610. * Allows scaling the angle of the light for shadow generation only.
  123611. */
  123612. get shadowAngleScale(): number;
  123613. /**
  123614. * Allows scaling the angle of the light for shadow generation only.
  123615. */
  123616. set shadowAngleScale(value: number);
  123617. /**
  123618. * The light decay speed with the distance from the emission spot.
  123619. */
  123620. exponent: number;
  123621. private _projectionTextureMatrix;
  123622. /**
  123623. * Allows reading the projecton texture
  123624. */
  123625. get projectionTextureMatrix(): Matrix;
  123626. protected _projectionTextureLightNear: number;
  123627. /**
  123628. * Gets the near clip of the Spotlight for texture projection.
  123629. */
  123630. get projectionTextureLightNear(): number;
  123631. /**
  123632. * Sets the near clip of the Spotlight for texture projection.
  123633. */
  123634. set projectionTextureLightNear(value: number);
  123635. protected _projectionTextureLightFar: number;
  123636. /**
  123637. * Gets the far clip of the Spotlight for texture projection.
  123638. */
  123639. get projectionTextureLightFar(): number;
  123640. /**
  123641. * Sets the far clip of the Spotlight for texture projection.
  123642. */
  123643. set projectionTextureLightFar(value: number);
  123644. protected _projectionTextureUpDirection: Vector3;
  123645. /**
  123646. * Gets the Up vector of the Spotlight for texture projection.
  123647. */
  123648. get projectionTextureUpDirection(): Vector3;
  123649. /**
  123650. * Sets the Up vector of the Spotlight for texture projection.
  123651. */
  123652. set projectionTextureUpDirection(value: Vector3);
  123653. private _projectionTexture;
  123654. /**
  123655. * Gets the projection texture of the light.
  123656. */
  123657. get projectionTexture(): Nullable<BaseTexture>;
  123658. /**
  123659. * Sets the projection texture of the light.
  123660. */
  123661. set projectionTexture(value: Nullable<BaseTexture>);
  123662. private _projectionTextureViewLightDirty;
  123663. private _projectionTextureProjectionLightDirty;
  123664. private _projectionTextureDirty;
  123665. private _projectionTextureViewTargetVector;
  123666. private _projectionTextureViewLightMatrix;
  123667. private _projectionTextureProjectionLightMatrix;
  123668. private _projectionTextureScalingMatrix;
  123669. /**
  123670. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123671. * It can cast shadows.
  123672. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123673. * @param name The light friendly name
  123674. * @param position The position of the spot light in the scene
  123675. * @param direction The direction of the light in the scene
  123676. * @param angle The cone angle of the light in Radians
  123677. * @param exponent The light decay speed with the distance from the emission spot
  123678. * @param scene The scene the lights belongs to
  123679. */
  123680. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123681. /**
  123682. * Returns the string "SpotLight".
  123683. * @returns the class name
  123684. */
  123685. getClassName(): string;
  123686. /**
  123687. * Returns the integer 2.
  123688. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123689. */
  123690. getTypeID(): number;
  123691. /**
  123692. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123693. */
  123694. protected _setDirection(value: Vector3): void;
  123695. /**
  123696. * Overrides the position setter to recompute the projection texture view light Matrix.
  123697. */
  123698. protected _setPosition(value: Vector3): void;
  123699. /**
  123700. * 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.
  123701. * Returns the SpotLight.
  123702. */
  123703. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123704. protected _computeProjectionTextureViewLightMatrix(): void;
  123705. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123706. /**
  123707. * Main function for light texture projection matrix computing.
  123708. */
  123709. protected _computeProjectionTextureMatrix(): void;
  123710. protected _buildUniformLayout(): void;
  123711. private _computeAngleValues;
  123712. /**
  123713. * Sets the passed Effect "effect" with the Light textures.
  123714. * @param effect The effect to update
  123715. * @param lightIndex The index of the light in the effect to update
  123716. * @returns The light
  123717. */
  123718. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123719. /**
  123720. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123721. * @param effect The effect to update
  123722. * @param lightIndex The index of the light in the effect to update
  123723. * @returns The spot light
  123724. */
  123725. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123727. /**
  123728. * Disposes the light and the associated resources.
  123729. */
  123730. dispose(): void;
  123731. /**
  123732. * Prepares the list of defines specific to the light type.
  123733. * @param defines the list of defines
  123734. * @param lightIndex defines the index of the light for the effect
  123735. */
  123736. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123737. }
  123738. }
  123739. declare module BABYLON {
  123740. /**
  123741. * Gizmo that enables viewing a light
  123742. */
  123743. export class LightGizmo extends Gizmo {
  123744. private _lightMesh;
  123745. private _material;
  123746. private _cachedPosition;
  123747. private _cachedForward;
  123748. private _attachedMeshParent;
  123749. /**
  123750. * Creates a LightGizmo
  123751. * @param gizmoLayer The utility layer the gizmo will be added to
  123752. */
  123753. constructor(gizmoLayer?: UtilityLayerRenderer);
  123754. private _light;
  123755. /**
  123756. * The light that the gizmo is attached to
  123757. */
  123758. set light(light: Nullable<Light>);
  123759. get light(): Nullable<Light>;
  123760. /**
  123761. * Gets the material used to render the light gizmo
  123762. */
  123763. get material(): StandardMaterial;
  123764. /**
  123765. * @hidden
  123766. * Updates the gizmo to match the attached mesh's position/rotation
  123767. */
  123768. protected _update(): void;
  123769. private static _Scale;
  123770. /**
  123771. * Creates the lines for a light mesh
  123772. */
  123773. private static _CreateLightLines;
  123774. /**
  123775. * Disposes of the light gizmo
  123776. */
  123777. dispose(): void;
  123778. private static _CreateHemisphericLightMesh;
  123779. private static _CreatePointLightMesh;
  123780. private static _CreateSpotLightMesh;
  123781. private static _CreateDirectionalLightMesh;
  123782. }
  123783. }
  123784. declare module BABYLON {
  123785. /** @hidden */
  123786. export var backgroundFragmentDeclaration: {
  123787. name: string;
  123788. shader: string;
  123789. };
  123790. }
  123791. declare module BABYLON {
  123792. /** @hidden */
  123793. export var backgroundUboDeclaration: {
  123794. name: string;
  123795. shader: string;
  123796. };
  123797. }
  123798. declare module BABYLON {
  123799. /** @hidden */
  123800. export var backgroundPixelShader: {
  123801. name: string;
  123802. shader: string;
  123803. };
  123804. }
  123805. declare module BABYLON {
  123806. /** @hidden */
  123807. export var backgroundVertexDeclaration: {
  123808. name: string;
  123809. shader: string;
  123810. };
  123811. }
  123812. declare module BABYLON {
  123813. /** @hidden */
  123814. export var backgroundVertexShader: {
  123815. name: string;
  123816. shader: string;
  123817. };
  123818. }
  123819. declare module BABYLON {
  123820. /**
  123821. * Background material used to create an efficient environement around your scene.
  123822. */
  123823. export class BackgroundMaterial extends PushMaterial {
  123824. /**
  123825. * Standard reflectance value at parallel view angle.
  123826. */
  123827. static StandardReflectance0: number;
  123828. /**
  123829. * Standard reflectance value at grazing angle.
  123830. */
  123831. static StandardReflectance90: number;
  123832. protected _primaryColor: Color3;
  123833. /**
  123834. * Key light Color (multiply against the environement texture)
  123835. */
  123836. primaryColor: Color3;
  123837. protected __perceptualColor: Nullable<Color3>;
  123838. /**
  123839. * Experimental Internal Use Only.
  123840. *
  123841. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123842. * This acts as a helper to set the primary color to a more "human friendly" value.
  123843. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123844. * output color as close as possible from the chosen value.
  123845. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123846. * part of lighting setup.)
  123847. */
  123848. get _perceptualColor(): Nullable<Color3>;
  123849. set _perceptualColor(value: Nullable<Color3>);
  123850. protected _primaryColorShadowLevel: float;
  123851. /**
  123852. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123853. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123854. */
  123855. get primaryColorShadowLevel(): float;
  123856. set primaryColorShadowLevel(value: float);
  123857. protected _primaryColorHighlightLevel: float;
  123858. /**
  123859. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123860. * The primary color is used at the level chosen to define what the white area would look.
  123861. */
  123862. get primaryColorHighlightLevel(): float;
  123863. set primaryColorHighlightLevel(value: float);
  123864. protected _reflectionTexture: Nullable<BaseTexture>;
  123865. /**
  123866. * Reflection Texture used in the material.
  123867. * Should be author in a specific way for the best result (refer to the documentation).
  123868. */
  123869. reflectionTexture: Nullable<BaseTexture>;
  123870. protected _reflectionBlur: float;
  123871. /**
  123872. * Reflection Texture level of blur.
  123873. *
  123874. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123875. * texture twice.
  123876. */
  123877. reflectionBlur: float;
  123878. protected _diffuseTexture: Nullable<BaseTexture>;
  123879. /**
  123880. * Diffuse Texture used in the material.
  123881. * Should be author in a specific way for the best result (refer to the documentation).
  123882. */
  123883. diffuseTexture: Nullable<BaseTexture>;
  123884. protected _shadowLights: Nullable<IShadowLight[]>;
  123885. /**
  123886. * Specify the list of lights casting shadow on the material.
  123887. * All scene shadow lights will be included if null.
  123888. */
  123889. shadowLights: Nullable<IShadowLight[]>;
  123890. protected _shadowLevel: float;
  123891. /**
  123892. * Helps adjusting the shadow to a softer level if required.
  123893. * 0 means black shadows and 1 means no shadows.
  123894. */
  123895. shadowLevel: float;
  123896. protected _sceneCenter: Vector3;
  123897. /**
  123898. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123899. * It is usually zero but might be interesting to modify according to your setup.
  123900. */
  123901. sceneCenter: Vector3;
  123902. protected _opacityFresnel: boolean;
  123903. /**
  123904. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123905. * This helps ensuring a nice transition when the camera goes under the ground.
  123906. */
  123907. opacityFresnel: boolean;
  123908. protected _reflectionFresnel: boolean;
  123909. /**
  123910. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123911. * This helps adding a mirror texture on the ground.
  123912. */
  123913. reflectionFresnel: boolean;
  123914. protected _reflectionFalloffDistance: number;
  123915. /**
  123916. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123917. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123918. */
  123919. reflectionFalloffDistance: number;
  123920. protected _reflectionAmount: number;
  123921. /**
  123922. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123923. */
  123924. reflectionAmount: number;
  123925. protected _reflectionReflectance0: number;
  123926. /**
  123927. * This specifies the weight of the reflection at grazing angle.
  123928. */
  123929. reflectionReflectance0: number;
  123930. protected _reflectionReflectance90: number;
  123931. /**
  123932. * This specifies the weight of the reflection at a perpendicular point of view.
  123933. */
  123934. reflectionReflectance90: number;
  123935. /**
  123936. * Sets the reflection reflectance fresnel values according to the default standard
  123937. * empirically know to work well :-)
  123938. */
  123939. set reflectionStandardFresnelWeight(value: number);
  123940. protected _useRGBColor: boolean;
  123941. /**
  123942. * Helps to directly use the maps channels instead of their level.
  123943. */
  123944. useRGBColor: boolean;
  123945. protected _enableNoise: boolean;
  123946. /**
  123947. * This helps reducing the banding effect that could occur on the background.
  123948. */
  123949. enableNoise: boolean;
  123950. /**
  123951. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123952. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123953. * Recommended to be keep at 1.0 except for special cases.
  123954. */
  123955. get fovMultiplier(): number;
  123956. set fovMultiplier(value: number);
  123957. private _fovMultiplier;
  123958. /**
  123959. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123960. */
  123961. useEquirectangularFOV: boolean;
  123962. private _maxSimultaneousLights;
  123963. /**
  123964. * Number of Simultaneous lights allowed on the material.
  123965. */
  123966. maxSimultaneousLights: int;
  123967. /**
  123968. * Default configuration related to image processing available in the Background Material.
  123969. */
  123970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123971. /**
  123972. * Keep track of the image processing observer to allow dispose and replace.
  123973. */
  123974. private _imageProcessingObserver;
  123975. /**
  123976. * Attaches a new image processing configuration to the PBR Material.
  123977. * @param configuration (if null the scene configuration will be use)
  123978. */
  123979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123980. /**
  123981. * Gets the image processing configuration used either in this material.
  123982. */
  123983. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  123984. /**
  123985. * Sets the Default image processing configuration used either in the this material.
  123986. *
  123987. * If sets to null, the scene one is in use.
  123988. */
  123989. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  123990. /**
  123991. * Gets wether the color curves effect is enabled.
  123992. */
  123993. get cameraColorCurvesEnabled(): boolean;
  123994. /**
  123995. * Sets wether the color curves effect is enabled.
  123996. */
  123997. set cameraColorCurvesEnabled(value: boolean);
  123998. /**
  123999. * Gets wether the color grading effect is enabled.
  124000. */
  124001. get cameraColorGradingEnabled(): boolean;
  124002. /**
  124003. * Gets wether the color grading effect is enabled.
  124004. */
  124005. set cameraColorGradingEnabled(value: boolean);
  124006. /**
  124007. * Gets wether tonemapping is enabled or not.
  124008. */
  124009. get cameraToneMappingEnabled(): boolean;
  124010. /**
  124011. * Sets wether tonemapping is enabled or not
  124012. */
  124013. set cameraToneMappingEnabled(value: boolean);
  124014. /**
  124015. * The camera exposure used on this material.
  124016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124017. * This corresponds to a photographic exposure.
  124018. */
  124019. get cameraExposure(): float;
  124020. /**
  124021. * The camera exposure used on this material.
  124022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124023. * This corresponds to a photographic exposure.
  124024. */
  124025. set cameraExposure(value: float);
  124026. /**
  124027. * Gets The camera contrast used on this material.
  124028. */
  124029. get cameraContrast(): float;
  124030. /**
  124031. * Sets The camera contrast used on this material.
  124032. */
  124033. set cameraContrast(value: float);
  124034. /**
  124035. * Gets the Color Grading 2D Lookup Texture.
  124036. */
  124037. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124038. /**
  124039. * Sets the Color Grading 2D Lookup Texture.
  124040. */
  124041. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124042. /**
  124043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124045. * 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;
  124046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124047. */
  124048. get cameraColorCurves(): Nullable<ColorCurves>;
  124049. /**
  124050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124052. * 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;
  124053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124054. */
  124055. set cameraColorCurves(value: Nullable<ColorCurves>);
  124056. /**
  124057. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124058. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124059. */
  124060. switchToBGR: boolean;
  124061. private _renderTargets;
  124062. private _reflectionControls;
  124063. private _white;
  124064. private _primaryShadowColor;
  124065. private _primaryHighlightColor;
  124066. /**
  124067. * Instantiates a Background Material in the given scene
  124068. * @param name The friendly name of the material
  124069. * @param scene The scene to add the material to
  124070. */
  124071. constructor(name: string, scene: Scene);
  124072. /**
  124073. * Gets a boolean indicating that current material needs to register RTT
  124074. */
  124075. get hasRenderTargetTextures(): boolean;
  124076. /**
  124077. * The entire material has been created in order to prevent overdraw.
  124078. * @returns false
  124079. */
  124080. needAlphaTesting(): boolean;
  124081. /**
  124082. * The entire material has been created in order to prevent overdraw.
  124083. * @returns true if blending is enable
  124084. */
  124085. needAlphaBlending(): boolean;
  124086. /**
  124087. * Checks wether the material is ready to be rendered for a given mesh.
  124088. * @param mesh The mesh to render
  124089. * @param subMesh The submesh to check against
  124090. * @param useInstances Specify wether or not the material is used with instances
  124091. * @returns true if all the dependencies are ready (Textures, Effects...)
  124092. */
  124093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124094. /**
  124095. * Compute the primary color according to the chosen perceptual color.
  124096. */
  124097. private _computePrimaryColorFromPerceptualColor;
  124098. /**
  124099. * Compute the highlights and shadow colors according to their chosen levels.
  124100. */
  124101. private _computePrimaryColors;
  124102. /**
  124103. * Build the uniform buffer used in the material.
  124104. */
  124105. buildUniformLayout(): void;
  124106. /**
  124107. * Unbind the material.
  124108. */
  124109. unbind(): void;
  124110. /**
  124111. * Bind only the world matrix to the material.
  124112. * @param world The world matrix to bind.
  124113. */
  124114. bindOnlyWorldMatrix(world: Matrix): void;
  124115. /**
  124116. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124117. * @param world The world matrix to bind.
  124118. * @param subMesh The submesh to bind for.
  124119. */
  124120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124121. /**
  124122. * Checks to see if a texture is used in the material.
  124123. * @param texture - Base texture to use.
  124124. * @returns - Boolean specifying if a texture is used in the material.
  124125. */
  124126. hasTexture(texture: BaseTexture): boolean;
  124127. /**
  124128. * Dispose the material.
  124129. * @param forceDisposeEffect Force disposal of the associated effect.
  124130. * @param forceDisposeTextures Force disposal of the associated textures.
  124131. */
  124132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124133. /**
  124134. * Clones the material.
  124135. * @param name The cloned name.
  124136. * @returns The cloned material.
  124137. */
  124138. clone(name: string): BackgroundMaterial;
  124139. /**
  124140. * Serializes the current material to its JSON representation.
  124141. * @returns The JSON representation.
  124142. */
  124143. serialize(): any;
  124144. /**
  124145. * Gets the class name of the material
  124146. * @returns "BackgroundMaterial"
  124147. */
  124148. getClassName(): string;
  124149. /**
  124150. * Parse a JSON input to create back a background material.
  124151. * @param source The JSON data to parse
  124152. * @param scene The scene to create the parsed material in
  124153. * @param rootUrl The root url of the assets the material depends upon
  124154. * @returns the instantiated BackgroundMaterial.
  124155. */
  124156. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124157. }
  124158. }
  124159. declare module BABYLON {
  124160. /**
  124161. * Represents the different options available during the creation of
  124162. * a Environment helper.
  124163. *
  124164. * This can control the default ground, skybox and image processing setup of your scene.
  124165. */
  124166. export interface IEnvironmentHelperOptions {
  124167. /**
  124168. * Specifies whether or not to create a ground.
  124169. * True by default.
  124170. */
  124171. createGround: boolean;
  124172. /**
  124173. * Specifies the ground size.
  124174. * 15 by default.
  124175. */
  124176. groundSize: number;
  124177. /**
  124178. * The texture used on the ground for the main color.
  124179. * Comes from the BabylonJS CDN by default.
  124180. *
  124181. * Remarks: Can be either a texture or a url.
  124182. */
  124183. groundTexture: string | BaseTexture;
  124184. /**
  124185. * The color mixed in the ground texture by default.
  124186. * BabylonJS clearColor by default.
  124187. */
  124188. groundColor: Color3;
  124189. /**
  124190. * Specifies the ground opacity.
  124191. * 1 by default.
  124192. */
  124193. groundOpacity: number;
  124194. /**
  124195. * Enables the ground to receive shadows.
  124196. * True by default.
  124197. */
  124198. enableGroundShadow: boolean;
  124199. /**
  124200. * Helps preventing the shadow to be fully black on the ground.
  124201. * 0.5 by default.
  124202. */
  124203. groundShadowLevel: number;
  124204. /**
  124205. * Creates a mirror texture attach to the ground.
  124206. * false by default.
  124207. */
  124208. enableGroundMirror: boolean;
  124209. /**
  124210. * Specifies the ground mirror size ratio.
  124211. * 0.3 by default as the default kernel is 64.
  124212. */
  124213. groundMirrorSizeRatio: number;
  124214. /**
  124215. * Specifies the ground mirror blur kernel size.
  124216. * 64 by default.
  124217. */
  124218. groundMirrorBlurKernel: number;
  124219. /**
  124220. * Specifies the ground mirror visibility amount.
  124221. * 1 by default
  124222. */
  124223. groundMirrorAmount: number;
  124224. /**
  124225. * Specifies the ground mirror reflectance weight.
  124226. * This uses the standard weight of the background material to setup the fresnel effect
  124227. * of the mirror.
  124228. * 1 by default.
  124229. */
  124230. groundMirrorFresnelWeight: number;
  124231. /**
  124232. * Specifies the ground mirror Falloff distance.
  124233. * This can helps reducing the size of the reflection.
  124234. * 0 by Default.
  124235. */
  124236. groundMirrorFallOffDistance: number;
  124237. /**
  124238. * Specifies the ground mirror texture type.
  124239. * Unsigned Int by Default.
  124240. */
  124241. groundMirrorTextureType: number;
  124242. /**
  124243. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124244. * the shown objects.
  124245. */
  124246. groundYBias: number;
  124247. /**
  124248. * Specifies whether or not to create a skybox.
  124249. * True by default.
  124250. */
  124251. createSkybox: boolean;
  124252. /**
  124253. * Specifies the skybox size.
  124254. * 20 by default.
  124255. */
  124256. skyboxSize: number;
  124257. /**
  124258. * The texture used on the skybox for the main color.
  124259. * Comes from the BabylonJS CDN by default.
  124260. *
  124261. * Remarks: Can be either a texture or a url.
  124262. */
  124263. skyboxTexture: string | BaseTexture;
  124264. /**
  124265. * The color mixed in the skybox texture by default.
  124266. * BabylonJS clearColor by default.
  124267. */
  124268. skyboxColor: Color3;
  124269. /**
  124270. * The background rotation around the Y axis of the scene.
  124271. * This helps aligning the key lights of your scene with the background.
  124272. * 0 by default.
  124273. */
  124274. backgroundYRotation: number;
  124275. /**
  124276. * Compute automatically the size of the elements to best fit with the scene.
  124277. */
  124278. sizeAuto: boolean;
  124279. /**
  124280. * Default position of the rootMesh if autoSize is not true.
  124281. */
  124282. rootPosition: Vector3;
  124283. /**
  124284. * Sets up the image processing in the scene.
  124285. * true by default.
  124286. */
  124287. setupImageProcessing: boolean;
  124288. /**
  124289. * The texture used as your environment texture in the scene.
  124290. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124291. *
  124292. * Remarks: Can be either a texture or a url.
  124293. */
  124294. environmentTexture: string | BaseTexture;
  124295. /**
  124296. * The value of the exposure to apply to the scene.
  124297. * 0.6 by default if setupImageProcessing is true.
  124298. */
  124299. cameraExposure: number;
  124300. /**
  124301. * The value of the contrast to apply to the scene.
  124302. * 1.6 by default if setupImageProcessing is true.
  124303. */
  124304. cameraContrast: number;
  124305. /**
  124306. * Specifies whether or not tonemapping should be enabled in the scene.
  124307. * true by default if setupImageProcessing is true.
  124308. */
  124309. toneMappingEnabled: boolean;
  124310. }
  124311. /**
  124312. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124313. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124314. * It also helps with the default setup of your imageProcessing configuration.
  124315. */
  124316. export class EnvironmentHelper {
  124317. /**
  124318. * Default ground texture URL.
  124319. */
  124320. private static _groundTextureCDNUrl;
  124321. /**
  124322. * Default skybox texture URL.
  124323. */
  124324. private static _skyboxTextureCDNUrl;
  124325. /**
  124326. * Default environment texture URL.
  124327. */
  124328. private static _environmentTextureCDNUrl;
  124329. /**
  124330. * Creates the default options for the helper.
  124331. */
  124332. private static _getDefaultOptions;
  124333. private _rootMesh;
  124334. /**
  124335. * Gets the root mesh created by the helper.
  124336. */
  124337. get rootMesh(): Mesh;
  124338. private _skybox;
  124339. /**
  124340. * Gets the skybox created by the helper.
  124341. */
  124342. get skybox(): Nullable<Mesh>;
  124343. private _skyboxTexture;
  124344. /**
  124345. * Gets the skybox texture created by the helper.
  124346. */
  124347. get skyboxTexture(): Nullable<BaseTexture>;
  124348. private _skyboxMaterial;
  124349. /**
  124350. * Gets the skybox material created by the helper.
  124351. */
  124352. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124353. private _ground;
  124354. /**
  124355. * Gets the ground mesh created by the helper.
  124356. */
  124357. get ground(): Nullable<Mesh>;
  124358. private _groundTexture;
  124359. /**
  124360. * Gets the ground texture created by the helper.
  124361. */
  124362. get groundTexture(): Nullable<BaseTexture>;
  124363. private _groundMirror;
  124364. /**
  124365. * Gets the ground mirror created by the helper.
  124366. */
  124367. get groundMirror(): Nullable<MirrorTexture>;
  124368. /**
  124369. * Gets the ground mirror render list to helps pushing the meshes
  124370. * you wish in the ground reflection.
  124371. */
  124372. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124373. private _groundMaterial;
  124374. /**
  124375. * Gets the ground material created by the helper.
  124376. */
  124377. get groundMaterial(): Nullable<BackgroundMaterial>;
  124378. /**
  124379. * Stores the creation options.
  124380. */
  124381. private readonly _scene;
  124382. private _options;
  124383. /**
  124384. * This observable will be notified with any error during the creation of the environment,
  124385. * mainly texture creation errors.
  124386. */
  124387. onErrorObservable: Observable<{
  124388. message?: string;
  124389. exception?: any;
  124390. }>;
  124391. /**
  124392. * constructor
  124393. * @param options Defines the options we want to customize the helper
  124394. * @param scene The scene to add the material to
  124395. */
  124396. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124397. /**
  124398. * Updates the background according to the new options
  124399. * @param options
  124400. */
  124401. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124402. /**
  124403. * Sets the primary color of all the available elements.
  124404. * @param color the main color to affect to the ground and the background
  124405. */
  124406. setMainColor(color: Color3): void;
  124407. /**
  124408. * Setup the image processing according to the specified options.
  124409. */
  124410. private _setupImageProcessing;
  124411. /**
  124412. * Setup the environment texture according to the specified options.
  124413. */
  124414. private _setupEnvironmentTexture;
  124415. /**
  124416. * Setup the background according to the specified options.
  124417. */
  124418. private _setupBackground;
  124419. /**
  124420. * Get the scene sizes according to the setup.
  124421. */
  124422. private _getSceneSize;
  124423. /**
  124424. * Setup the ground according to the specified options.
  124425. */
  124426. private _setupGround;
  124427. /**
  124428. * Setup the ground material according to the specified options.
  124429. */
  124430. private _setupGroundMaterial;
  124431. /**
  124432. * Setup the ground diffuse texture according to the specified options.
  124433. */
  124434. private _setupGroundDiffuseTexture;
  124435. /**
  124436. * Setup the ground mirror texture according to the specified options.
  124437. */
  124438. private _setupGroundMirrorTexture;
  124439. /**
  124440. * Setup the ground to receive the mirror texture.
  124441. */
  124442. private _setupMirrorInGroundMaterial;
  124443. /**
  124444. * Setup the skybox according to the specified options.
  124445. */
  124446. private _setupSkybox;
  124447. /**
  124448. * Setup the skybox material according to the specified options.
  124449. */
  124450. private _setupSkyboxMaterial;
  124451. /**
  124452. * Setup the skybox reflection texture according to the specified options.
  124453. */
  124454. private _setupSkyboxReflectionTexture;
  124455. private _errorHandler;
  124456. /**
  124457. * Dispose all the elements created by the Helper.
  124458. */
  124459. dispose(): void;
  124460. }
  124461. }
  124462. declare module BABYLON {
  124463. /**
  124464. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124465. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124466. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124467. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124468. */
  124469. export class PhotoDome extends TransformNode {
  124470. /**
  124471. * Define the image as a Monoscopic panoramic 360 image.
  124472. */
  124473. static readonly MODE_MONOSCOPIC: number;
  124474. /**
  124475. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124476. */
  124477. static readonly MODE_TOPBOTTOM: number;
  124478. /**
  124479. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124480. */
  124481. static readonly MODE_SIDEBYSIDE: number;
  124482. private _useDirectMapping;
  124483. /**
  124484. * The texture being displayed on the sphere
  124485. */
  124486. protected _photoTexture: Texture;
  124487. /**
  124488. * Gets or sets the texture being displayed on the sphere
  124489. */
  124490. get photoTexture(): Texture;
  124491. set photoTexture(value: Texture);
  124492. /**
  124493. * Observable raised when an error occured while loading the 360 image
  124494. */
  124495. onLoadErrorObservable: Observable<string>;
  124496. /**
  124497. * The skybox material
  124498. */
  124499. protected _material: BackgroundMaterial;
  124500. /**
  124501. * The surface used for the skybox
  124502. */
  124503. protected _mesh: Mesh;
  124504. /**
  124505. * Gets the mesh used for the skybox.
  124506. */
  124507. get mesh(): Mesh;
  124508. /**
  124509. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124510. * Also see the options.resolution property.
  124511. */
  124512. get fovMultiplier(): number;
  124513. set fovMultiplier(value: number);
  124514. private _imageMode;
  124515. /**
  124516. * Gets or set the current video mode for the video. It can be:
  124517. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124518. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124519. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124520. */
  124521. get imageMode(): number;
  124522. set imageMode(value: number);
  124523. /**
  124524. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124525. * @param name Element's name, child elements will append suffixes for their own names.
  124526. * @param urlsOfPhoto defines the url of the photo to display
  124527. * @param options defines an object containing optional or exposed sub element properties
  124528. * @param onError defines a callback called when an error occured while loading the texture
  124529. */
  124530. constructor(name: string, urlOfPhoto: string, options: {
  124531. resolution?: number;
  124532. size?: number;
  124533. useDirectMapping?: boolean;
  124534. faceForward?: boolean;
  124535. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124536. private _onBeforeCameraRenderObserver;
  124537. private _changeImageMode;
  124538. /**
  124539. * Releases resources associated with this node.
  124540. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124541. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124542. */
  124543. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124544. }
  124545. }
  124546. declare module BABYLON {
  124547. /**
  124548. * Class used to host RGBD texture specific utilities
  124549. */
  124550. export class RGBDTextureTools {
  124551. /**
  124552. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124553. * @param texture the texture to expand.
  124554. */
  124555. static ExpandRGBDTexture(texture: Texture): void;
  124556. }
  124557. }
  124558. declare module BABYLON {
  124559. /**
  124560. * Class used to host texture specific utilities
  124561. */
  124562. export class BRDFTextureTools {
  124563. /**
  124564. * Prevents texture cache collision
  124565. */
  124566. private static _instanceNumber;
  124567. /**
  124568. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124569. * @param scene defines the hosting scene
  124570. * @returns the environment BRDF texture
  124571. */
  124572. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124573. private static _environmentBRDFBase64Texture;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. /**
  124578. * @hidden
  124579. */
  124580. export interface IMaterialClearCoatDefines {
  124581. CLEARCOAT: boolean;
  124582. CLEARCOAT_DEFAULTIOR: boolean;
  124583. CLEARCOAT_TEXTURE: boolean;
  124584. CLEARCOAT_TEXTUREDIRECTUV: number;
  124585. CLEARCOAT_BUMP: boolean;
  124586. CLEARCOAT_BUMPDIRECTUV: number;
  124587. CLEARCOAT_TINT: boolean;
  124588. CLEARCOAT_TINT_TEXTURE: boolean;
  124589. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124590. /** @hidden */
  124591. _areTexturesDirty: boolean;
  124592. }
  124593. /**
  124594. * Define the code related to the clear coat parameters of the pbr material.
  124595. */
  124596. export class PBRClearCoatConfiguration {
  124597. /**
  124598. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124599. * The default fits with a polyurethane material.
  124600. */
  124601. private static readonly _DefaultIndexOfRefraction;
  124602. private _isEnabled;
  124603. /**
  124604. * Defines if the clear coat is enabled in the material.
  124605. */
  124606. isEnabled: boolean;
  124607. /**
  124608. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124609. */
  124610. intensity: number;
  124611. /**
  124612. * Defines the clear coat layer roughness.
  124613. */
  124614. roughness: number;
  124615. private _indexOfRefraction;
  124616. /**
  124617. * Defines the index of refraction of the clear coat.
  124618. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124619. * The default fits with a polyurethane material.
  124620. * Changing the default value is more performance intensive.
  124621. */
  124622. indexOfRefraction: number;
  124623. private _texture;
  124624. /**
  124625. * Stores the clear coat values in a texture.
  124626. */
  124627. texture: Nullable<BaseTexture>;
  124628. private _bumpTexture;
  124629. /**
  124630. * Define the clear coat specific bump texture.
  124631. */
  124632. bumpTexture: Nullable<BaseTexture>;
  124633. private _isTintEnabled;
  124634. /**
  124635. * Defines if the clear coat tint is enabled in the material.
  124636. */
  124637. isTintEnabled: boolean;
  124638. /**
  124639. * Defines the clear coat tint of the material.
  124640. * This is only use if tint is enabled
  124641. */
  124642. tintColor: Color3;
  124643. /**
  124644. * Defines the distance at which the tint color should be found in the
  124645. * clear coat media.
  124646. * This is only use if tint is enabled
  124647. */
  124648. tintColorAtDistance: number;
  124649. /**
  124650. * Defines the clear coat layer thickness.
  124651. * This is only use if tint is enabled
  124652. */
  124653. tintThickness: number;
  124654. private _tintTexture;
  124655. /**
  124656. * Stores the clear tint values in a texture.
  124657. * rgb is tint
  124658. * a is a thickness factor
  124659. */
  124660. tintTexture: Nullable<BaseTexture>;
  124661. /** @hidden */
  124662. private _internalMarkAllSubMeshesAsTexturesDirty;
  124663. /** @hidden */
  124664. _markAllSubMeshesAsTexturesDirty(): void;
  124665. /**
  124666. * Instantiate a new istance of clear coat configuration.
  124667. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124668. */
  124669. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124670. /**
  124671. * Gets wehter the submesh is ready to be used or not.
  124672. * @param defines the list of "defines" to update.
  124673. * @param scene defines the scene the material belongs to.
  124674. * @param engine defines the engine the material belongs to.
  124675. * @param disableBumpMap defines wether the material disables bump or not.
  124676. * @returns - boolean indicating that the submesh is ready or not.
  124677. */
  124678. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124679. /**
  124680. * Checks to see if a texture is used in the material.
  124681. * @param defines the list of "defines" to update.
  124682. * @param scene defines the scene to the material belongs to.
  124683. */
  124684. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124685. /**
  124686. * Binds the material data.
  124687. * @param uniformBuffer defines the Uniform buffer to fill in.
  124688. * @param scene defines the scene the material belongs to.
  124689. * @param engine defines the engine the material belongs to.
  124690. * @param disableBumpMap defines wether the material disables bump or not.
  124691. * @param isFrozen defines wether the material is frozen or not.
  124692. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124693. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124694. */
  124695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124696. /**
  124697. * Checks to see if a texture is used in the material.
  124698. * @param texture - Base texture to use.
  124699. * @returns - Boolean specifying if a texture is used in the material.
  124700. */
  124701. hasTexture(texture: BaseTexture): boolean;
  124702. /**
  124703. * Returns an array of the actively used textures.
  124704. * @param activeTextures Array of BaseTextures
  124705. */
  124706. getActiveTextures(activeTextures: BaseTexture[]): void;
  124707. /**
  124708. * Returns the animatable textures.
  124709. * @param animatables Array of animatable textures.
  124710. */
  124711. getAnimatables(animatables: IAnimatable[]): void;
  124712. /**
  124713. * Disposes the resources of the material.
  124714. * @param forceDisposeTextures - Forces the disposal of all textures.
  124715. */
  124716. dispose(forceDisposeTextures?: boolean): void;
  124717. /**
  124718. * Get the current class name of the texture useful for serialization or dynamic coding.
  124719. * @returns "PBRClearCoatConfiguration"
  124720. */
  124721. getClassName(): string;
  124722. /**
  124723. * Add fallbacks to the effect fallbacks list.
  124724. * @param defines defines the Base texture to use.
  124725. * @param fallbacks defines the current fallback list.
  124726. * @param currentRank defines the current fallback rank.
  124727. * @returns the new fallback rank.
  124728. */
  124729. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124730. /**
  124731. * Add the required uniforms to the current list.
  124732. * @param uniforms defines the current uniform list.
  124733. */
  124734. static AddUniforms(uniforms: string[]): void;
  124735. /**
  124736. * Add the required samplers to the current list.
  124737. * @param samplers defines the current sampler list.
  124738. */
  124739. static AddSamplers(samplers: string[]): void;
  124740. /**
  124741. * Add the required uniforms to the current buffer.
  124742. * @param uniformBuffer defines the current uniform buffer.
  124743. */
  124744. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124745. /**
  124746. * Makes a duplicate of the current configuration into another one.
  124747. * @param clearCoatConfiguration define the config where to copy the info
  124748. */
  124749. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124750. /**
  124751. * Serializes this clear coat configuration.
  124752. * @returns - An object with the serialized config.
  124753. */
  124754. serialize(): any;
  124755. /**
  124756. * Parses a anisotropy Configuration from a serialized object.
  124757. * @param source - Serialized object.
  124758. * @param scene Defines the scene we are parsing for
  124759. * @param rootUrl Defines the rootUrl to load from
  124760. */
  124761. parse(source: any, scene: Scene, rootUrl: string): void;
  124762. }
  124763. }
  124764. declare module BABYLON {
  124765. /**
  124766. * @hidden
  124767. */
  124768. export interface IMaterialAnisotropicDefines {
  124769. ANISOTROPIC: boolean;
  124770. ANISOTROPIC_TEXTURE: boolean;
  124771. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124772. MAINUV1: boolean;
  124773. _areTexturesDirty: boolean;
  124774. _needUVs: boolean;
  124775. }
  124776. /**
  124777. * Define the code related to the anisotropic parameters of the pbr material.
  124778. */
  124779. export class PBRAnisotropicConfiguration {
  124780. private _isEnabled;
  124781. /**
  124782. * Defines if the anisotropy is enabled in the material.
  124783. */
  124784. isEnabled: boolean;
  124785. /**
  124786. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124787. */
  124788. intensity: number;
  124789. /**
  124790. * Defines if the effect is along the tangents, bitangents or in between.
  124791. * By default, the effect is "strectching" the highlights along the tangents.
  124792. */
  124793. direction: Vector2;
  124794. private _texture;
  124795. /**
  124796. * Stores the anisotropy values in a texture.
  124797. * rg is direction (like normal from -1 to 1)
  124798. * b is a intensity
  124799. */
  124800. texture: Nullable<BaseTexture>;
  124801. /** @hidden */
  124802. private _internalMarkAllSubMeshesAsTexturesDirty;
  124803. /** @hidden */
  124804. _markAllSubMeshesAsTexturesDirty(): void;
  124805. /**
  124806. * Instantiate a new istance of anisotropy configuration.
  124807. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124808. */
  124809. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124810. /**
  124811. * Specifies that the submesh is ready to be used.
  124812. * @param defines the list of "defines" to update.
  124813. * @param scene defines the scene the material belongs to.
  124814. * @returns - boolean indicating that the submesh is ready or not.
  124815. */
  124816. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124817. /**
  124818. * Checks to see if a texture is used in the material.
  124819. * @param defines the list of "defines" to update.
  124820. * @param mesh the mesh we are preparing the defines for.
  124821. * @param scene defines the scene the material belongs to.
  124822. */
  124823. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124824. /**
  124825. * Binds the material data.
  124826. * @param uniformBuffer defines the Uniform buffer to fill in.
  124827. * @param scene defines the scene the material belongs to.
  124828. * @param isFrozen defines wether the material is frozen or not.
  124829. */
  124830. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124831. /**
  124832. * Checks to see if a texture is used in the material.
  124833. * @param texture - Base texture to use.
  124834. * @returns - Boolean specifying if a texture is used in the material.
  124835. */
  124836. hasTexture(texture: BaseTexture): boolean;
  124837. /**
  124838. * Returns an array of the actively used textures.
  124839. * @param activeTextures Array of BaseTextures
  124840. */
  124841. getActiveTextures(activeTextures: BaseTexture[]): void;
  124842. /**
  124843. * Returns the animatable textures.
  124844. * @param animatables Array of animatable textures.
  124845. */
  124846. getAnimatables(animatables: IAnimatable[]): void;
  124847. /**
  124848. * Disposes the resources of the material.
  124849. * @param forceDisposeTextures - Forces the disposal of all textures.
  124850. */
  124851. dispose(forceDisposeTextures?: boolean): void;
  124852. /**
  124853. * Get the current class name of the texture useful for serialization or dynamic coding.
  124854. * @returns "PBRAnisotropicConfiguration"
  124855. */
  124856. getClassName(): string;
  124857. /**
  124858. * Add fallbacks to the effect fallbacks list.
  124859. * @param defines defines the Base texture to use.
  124860. * @param fallbacks defines the current fallback list.
  124861. * @param currentRank defines the current fallback rank.
  124862. * @returns the new fallback rank.
  124863. */
  124864. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124865. /**
  124866. * Add the required uniforms to the current list.
  124867. * @param uniforms defines the current uniform list.
  124868. */
  124869. static AddUniforms(uniforms: string[]): void;
  124870. /**
  124871. * Add the required uniforms to the current buffer.
  124872. * @param uniformBuffer defines the current uniform buffer.
  124873. */
  124874. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124875. /**
  124876. * Add the required samplers to the current list.
  124877. * @param samplers defines the current sampler list.
  124878. */
  124879. static AddSamplers(samplers: string[]): void;
  124880. /**
  124881. * Makes a duplicate of the current configuration into another one.
  124882. * @param anisotropicConfiguration define the config where to copy the info
  124883. */
  124884. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124885. /**
  124886. * Serializes this anisotropy configuration.
  124887. * @returns - An object with the serialized config.
  124888. */
  124889. serialize(): any;
  124890. /**
  124891. * Parses a anisotropy Configuration from a serialized object.
  124892. * @param source - Serialized object.
  124893. * @param scene Defines the scene we are parsing for
  124894. * @param rootUrl Defines the rootUrl to load from
  124895. */
  124896. parse(source: any, scene: Scene, rootUrl: string): void;
  124897. }
  124898. }
  124899. declare module BABYLON {
  124900. /**
  124901. * @hidden
  124902. */
  124903. export interface IMaterialBRDFDefines {
  124904. BRDF_V_HEIGHT_CORRELATED: boolean;
  124905. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124906. SPHERICAL_HARMONICS: boolean;
  124907. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124908. /** @hidden */
  124909. _areMiscDirty: boolean;
  124910. }
  124911. /**
  124912. * Define the code related to the BRDF parameters of the pbr material.
  124913. */
  124914. export class PBRBRDFConfiguration {
  124915. /**
  124916. * Default value used for the energy conservation.
  124917. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124918. */
  124919. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124920. /**
  124921. * Default value used for the Smith Visibility Height Correlated mode.
  124922. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124923. */
  124924. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124925. /**
  124926. * Default value used for the IBL diffuse part.
  124927. * This can help switching back to the polynomials mode globally which is a tiny bit
  124928. * less GPU intensive at the drawback of a lower quality.
  124929. */
  124930. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124931. /**
  124932. * Default value used for activating energy conservation for the specular workflow.
  124933. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124934. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124935. */
  124936. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124937. private _useEnergyConservation;
  124938. /**
  124939. * Defines if the material uses energy conservation.
  124940. */
  124941. useEnergyConservation: boolean;
  124942. private _useSmithVisibilityHeightCorrelated;
  124943. /**
  124944. * LEGACY Mode set to false
  124945. * Defines if the material uses height smith correlated visibility term.
  124946. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124947. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124948. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124949. * Not relying on height correlated will also disable energy conservation.
  124950. */
  124951. useSmithVisibilityHeightCorrelated: boolean;
  124952. private _useSphericalHarmonics;
  124953. /**
  124954. * LEGACY Mode set to false
  124955. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124956. * diffuse part of the IBL.
  124957. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124958. * to the ground truth.
  124959. */
  124960. useSphericalHarmonics: boolean;
  124961. private _useSpecularGlossinessInputEnergyConservation;
  124962. /**
  124963. * Defines if the material uses energy conservation, when the specular workflow is active.
  124964. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124965. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124966. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124967. */
  124968. useSpecularGlossinessInputEnergyConservation: boolean;
  124969. /** @hidden */
  124970. private _internalMarkAllSubMeshesAsMiscDirty;
  124971. /** @hidden */
  124972. _markAllSubMeshesAsMiscDirty(): void;
  124973. /**
  124974. * Instantiate a new istance of clear coat configuration.
  124975. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124976. */
  124977. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124978. /**
  124979. * Checks to see if a texture is used in the material.
  124980. * @param defines the list of "defines" to update.
  124981. */
  124982. prepareDefines(defines: IMaterialBRDFDefines): void;
  124983. /**
  124984. * Get the current class name of the texture useful for serialization or dynamic coding.
  124985. * @returns "PBRClearCoatConfiguration"
  124986. */
  124987. getClassName(): string;
  124988. /**
  124989. * Makes a duplicate of the current configuration into another one.
  124990. * @param brdfConfiguration define the config where to copy the info
  124991. */
  124992. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  124993. /**
  124994. * Serializes this BRDF configuration.
  124995. * @returns - An object with the serialized config.
  124996. */
  124997. serialize(): any;
  124998. /**
  124999. * Parses a anisotropy Configuration from a serialized object.
  125000. * @param source - Serialized object.
  125001. * @param scene Defines the scene we are parsing for
  125002. * @param rootUrl Defines the rootUrl to load from
  125003. */
  125004. parse(source: any, scene: Scene, rootUrl: string): void;
  125005. }
  125006. }
  125007. declare module BABYLON {
  125008. /**
  125009. * @hidden
  125010. */
  125011. export interface IMaterialSheenDefines {
  125012. SHEEN: boolean;
  125013. SHEEN_TEXTURE: boolean;
  125014. SHEEN_TEXTUREDIRECTUV: number;
  125015. SHEEN_LINKWITHALBEDO: boolean;
  125016. SHEEN_ROUGHNESS: boolean;
  125017. SHEEN_ALBEDOSCALING: boolean;
  125018. /** @hidden */
  125019. _areTexturesDirty: boolean;
  125020. }
  125021. /**
  125022. * Define the code related to the Sheen parameters of the pbr material.
  125023. */
  125024. export class PBRSheenConfiguration {
  125025. private _isEnabled;
  125026. /**
  125027. * Defines if the material uses sheen.
  125028. */
  125029. isEnabled: boolean;
  125030. private _linkSheenWithAlbedo;
  125031. /**
  125032. * Defines if the sheen is linked to the sheen color.
  125033. */
  125034. linkSheenWithAlbedo: boolean;
  125035. /**
  125036. * Defines the sheen intensity.
  125037. */
  125038. intensity: number;
  125039. /**
  125040. * Defines the sheen color.
  125041. */
  125042. color: Color3;
  125043. private _texture;
  125044. /**
  125045. * Stores the sheen tint values in a texture.
  125046. * rgb is tint
  125047. * a is a intensity
  125048. */
  125049. texture: Nullable<BaseTexture>;
  125050. private _roughness;
  125051. /**
  125052. * Defines the sheen roughness.
  125053. * It is not taken into account if linkSheenWithAlbedo is true.
  125054. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125055. */
  125056. roughness: Nullable<number>;
  125057. private _albedoScaling;
  125058. /**
  125059. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125060. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125061. * making it easier to setup and tweak the effect
  125062. */
  125063. albedoScaling: boolean;
  125064. /** @hidden */
  125065. private _internalMarkAllSubMeshesAsTexturesDirty;
  125066. /** @hidden */
  125067. _markAllSubMeshesAsTexturesDirty(): void;
  125068. /**
  125069. * Instantiate a new istance of clear coat configuration.
  125070. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125071. */
  125072. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125073. /**
  125074. * Specifies that the submesh is ready to be used.
  125075. * @param defines the list of "defines" to update.
  125076. * @param scene defines the scene the material belongs to.
  125077. * @returns - boolean indicating that the submesh is ready or not.
  125078. */
  125079. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125080. /**
  125081. * Checks to see if a texture is used in the material.
  125082. * @param defines the list of "defines" to update.
  125083. * @param scene defines the scene the material belongs to.
  125084. */
  125085. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125086. /**
  125087. * Binds the material data.
  125088. * @param uniformBuffer defines the Uniform buffer to fill in.
  125089. * @param scene defines the scene the material belongs to.
  125090. * @param isFrozen defines wether the material is frozen or not.
  125091. */
  125092. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125093. /**
  125094. * Checks to see if a texture is used in the material.
  125095. * @param texture - Base texture to use.
  125096. * @returns - Boolean specifying if a texture is used in the material.
  125097. */
  125098. hasTexture(texture: BaseTexture): boolean;
  125099. /**
  125100. * Returns an array of the actively used textures.
  125101. * @param activeTextures Array of BaseTextures
  125102. */
  125103. getActiveTextures(activeTextures: BaseTexture[]): void;
  125104. /**
  125105. * Returns the animatable textures.
  125106. * @param animatables Array of animatable textures.
  125107. */
  125108. getAnimatables(animatables: IAnimatable[]): void;
  125109. /**
  125110. * Disposes the resources of the material.
  125111. * @param forceDisposeTextures - Forces the disposal of all textures.
  125112. */
  125113. dispose(forceDisposeTextures?: boolean): void;
  125114. /**
  125115. * Get the current class name of the texture useful for serialization or dynamic coding.
  125116. * @returns "PBRSheenConfiguration"
  125117. */
  125118. getClassName(): string;
  125119. /**
  125120. * Add fallbacks to the effect fallbacks list.
  125121. * @param defines defines the Base texture to use.
  125122. * @param fallbacks defines the current fallback list.
  125123. * @param currentRank defines the current fallback rank.
  125124. * @returns the new fallback rank.
  125125. */
  125126. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125127. /**
  125128. * Add the required uniforms to the current list.
  125129. * @param uniforms defines the current uniform list.
  125130. */
  125131. static AddUniforms(uniforms: string[]): void;
  125132. /**
  125133. * Add the required uniforms to the current buffer.
  125134. * @param uniformBuffer defines the current uniform buffer.
  125135. */
  125136. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125137. /**
  125138. * Add the required samplers to the current list.
  125139. * @param samplers defines the current sampler list.
  125140. */
  125141. static AddSamplers(samplers: string[]): void;
  125142. /**
  125143. * Makes a duplicate of the current configuration into another one.
  125144. * @param sheenConfiguration define the config where to copy the info
  125145. */
  125146. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125147. /**
  125148. * Serializes this BRDF configuration.
  125149. * @returns - An object with the serialized config.
  125150. */
  125151. serialize(): any;
  125152. /**
  125153. * Parses a anisotropy Configuration from a serialized object.
  125154. * @param source - Serialized object.
  125155. * @param scene Defines the scene we are parsing for
  125156. * @param rootUrl Defines the rootUrl to load from
  125157. */
  125158. parse(source: any, scene: Scene, rootUrl: string): void;
  125159. }
  125160. }
  125161. declare module BABYLON {
  125162. /**
  125163. * @hidden
  125164. */
  125165. export interface IMaterialSubSurfaceDefines {
  125166. SUBSURFACE: boolean;
  125167. SS_REFRACTION: boolean;
  125168. SS_TRANSLUCENCY: boolean;
  125169. SS_SCATERRING: boolean;
  125170. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125171. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125172. SS_REFRACTIONMAP_3D: boolean;
  125173. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125174. SS_LODINREFRACTIONALPHA: boolean;
  125175. SS_GAMMAREFRACTION: boolean;
  125176. SS_RGBDREFRACTION: boolean;
  125177. SS_LINEARSPECULARREFRACTION: boolean;
  125178. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125179. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125180. /** @hidden */
  125181. _areTexturesDirty: boolean;
  125182. }
  125183. /**
  125184. * Define the code related to the sub surface parameters of the pbr material.
  125185. */
  125186. export class PBRSubSurfaceConfiguration {
  125187. private _isRefractionEnabled;
  125188. /**
  125189. * Defines if the refraction is enabled in the material.
  125190. */
  125191. isRefractionEnabled: boolean;
  125192. private _isTranslucencyEnabled;
  125193. /**
  125194. * Defines if the translucency is enabled in the material.
  125195. */
  125196. isTranslucencyEnabled: boolean;
  125197. private _isScatteringEnabled;
  125198. /**
  125199. * Defines the refraction intensity of the material.
  125200. * The refraction when enabled replaces the Diffuse part of the material.
  125201. * The intensity helps transitionning between diffuse and refraction.
  125202. */
  125203. refractionIntensity: number;
  125204. /**
  125205. * Defines the translucency intensity of the material.
  125206. * When translucency has been enabled, this defines how much of the "translucency"
  125207. * is addded to the diffuse part of the material.
  125208. */
  125209. translucencyIntensity: number;
  125210. /**
  125211. * Defines the scattering intensity of the material.
  125212. * When scattering has been enabled, this defines how much of the "scattered light"
  125213. * is addded to the diffuse part of the material.
  125214. */
  125215. scatteringIntensity: number;
  125216. private _thicknessTexture;
  125217. /**
  125218. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125219. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125220. * 0 would mean minimumThickness
  125221. * 1 would mean maximumThickness
  125222. * The other channels might be use as a mask to vary the different effects intensity.
  125223. */
  125224. thicknessTexture: Nullable<BaseTexture>;
  125225. private _refractionTexture;
  125226. /**
  125227. * Defines the texture to use for refraction.
  125228. */
  125229. refractionTexture: Nullable<BaseTexture>;
  125230. private _indexOfRefraction;
  125231. /**
  125232. * Defines the index of refraction used in the material.
  125233. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125234. */
  125235. indexOfRefraction: number;
  125236. private _invertRefractionY;
  125237. /**
  125238. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125239. */
  125240. invertRefractionY: boolean;
  125241. private _linkRefractionWithTransparency;
  125242. /**
  125243. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125244. * Materials half opaque for instance using refraction could benefit from this control.
  125245. */
  125246. linkRefractionWithTransparency: boolean;
  125247. /**
  125248. * Defines the minimum thickness stored in the thickness map.
  125249. * If no thickness map is defined, this value will be used to simulate thickness.
  125250. */
  125251. minimumThickness: number;
  125252. /**
  125253. * Defines the maximum thickness stored in the thickness map.
  125254. */
  125255. maximumThickness: number;
  125256. /**
  125257. * Defines the volume tint of the material.
  125258. * This is used for both translucency and scattering.
  125259. */
  125260. tintColor: Color3;
  125261. /**
  125262. * Defines the distance at which the tint color should be found in the media.
  125263. * This is used for refraction only.
  125264. */
  125265. tintColorAtDistance: number;
  125266. /**
  125267. * Defines how far each channel transmit through the media.
  125268. * It is defined as a color to simplify it selection.
  125269. */
  125270. diffusionDistance: Color3;
  125271. private _useMaskFromThicknessTexture;
  125272. /**
  125273. * Stores the intensity of the different subsurface effects in the thickness texture.
  125274. * * the green channel is the translucency intensity.
  125275. * * the blue channel is the scattering intensity.
  125276. * * the alpha channel is the refraction intensity.
  125277. */
  125278. useMaskFromThicknessTexture: boolean;
  125279. /** @hidden */
  125280. private _internalMarkAllSubMeshesAsTexturesDirty;
  125281. /** @hidden */
  125282. _markAllSubMeshesAsTexturesDirty(): void;
  125283. /**
  125284. * Instantiate a new istance of sub surface configuration.
  125285. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125286. */
  125287. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125288. /**
  125289. * Gets wehter the submesh is ready to be used or not.
  125290. * @param defines the list of "defines" to update.
  125291. * @param scene defines the scene the material belongs to.
  125292. * @returns - boolean indicating that the submesh is ready or not.
  125293. */
  125294. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125295. /**
  125296. * Checks to see if a texture is used in the material.
  125297. * @param defines the list of "defines" to update.
  125298. * @param scene defines the scene to the material belongs to.
  125299. */
  125300. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125301. /**
  125302. * Binds the material data.
  125303. * @param uniformBuffer defines the Uniform buffer to fill in.
  125304. * @param scene defines the scene the material belongs to.
  125305. * @param engine defines the engine the material belongs to.
  125306. * @param isFrozen defines wether the material is frozen or not.
  125307. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125308. */
  125309. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125310. /**
  125311. * Unbinds the material from the mesh.
  125312. * @param activeEffect defines the effect that should be unbound from.
  125313. * @returns true if unbound, otherwise false
  125314. */
  125315. unbind(activeEffect: Effect): boolean;
  125316. /**
  125317. * Returns the texture used for refraction or null if none is used.
  125318. * @param scene defines the scene the material belongs to.
  125319. * @returns - Refraction texture if present. If no refraction texture and refraction
  125320. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125321. */
  125322. private _getRefractionTexture;
  125323. /**
  125324. * Returns true if alpha blending should be disabled.
  125325. */
  125326. get disableAlphaBlending(): boolean;
  125327. /**
  125328. * Fills the list of render target textures.
  125329. * @param renderTargets the list of render targets to update
  125330. */
  125331. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125332. /**
  125333. * Checks to see if a texture is used in the material.
  125334. * @param texture - Base texture to use.
  125335. * @returns - Boolean specifying if a texture is used in the material.
  125336. */
  125337. hasTexture(texture: BaseTexture): boolean;
  125338. /**
  125339. * Gets a boolean indicating that current material needs to register RTT
  125340. * @returns true if this uses a render target otherwise false.
  125341. */
  125342. hasRenderTargetTextures(): boolean;
  125343. /**
  125344. * Returns an array of the actively used textures.
  125345. * @param activeTextures Array of BaseTextures
  125346. */
  125347. getActiveTextures(activeTextures: BaseTexture[]): void;
  125348. /**
  125349. * Returns the animatable textures.
  125350. * @param animatables Array of animatable textures.
  125351. */
  125352. getAnimatables(animatables: IAnimatable[]): void;
  125353. /**
  125354. * Disposes the resources of the material.
  125355. * @param forceDisposeTextures - Forces the disposal of all textures.
  125356. */
  125357. dispose(forceDisposeTextures?: boolean): void;
  125358. /**
  125359. * Get the current class name of the texture useful for serialization or dynamic coding.
  125360. * @returns "PBRSubSurfaceConfiguration"
  125361. */
  125362. getClassName(): string;
  125363. /**
  125364. * Add fallbacks to the effect fallbacks list.
  125365. * @param defines defines the Base texture to use.
  125366. * @param fallbacks defines the current fallback list.
  125367. * @param currentRank defines the current fallback rank.
  125368. * @returns the new fallback rank.
  125369. */
  125370. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125371. /**
  125372. * Add the required uniforms to the current list.
  125373. * @param uniforms defines the current uniform list.
  125374. */
  125375. static AddUniforms(uniforms: string[]): void;
  125376. /**
  125377. * Add the required samplers to the current list.
  125378. * @param samplers defines the current sampler list.
  125379. */
  125380. static AddSamplers(samplers: string[]): void;
  125381. /**
  125382. * Add the required uniforms to the current buffer.
  125383. * @param uniformBuffer defines the current uniform buffer.
  125384. */
  125385. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125386. /**
  125387. * Makes a duplicate of the current configuration into another one.
  125388. * @param configuration define the config where to copy the info
  125389. */
  125390. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125391. /**
  125392. * Serializes this Sub Surface configuration.
  125393. * @returns - An object with the serialized config.
  125394. */
  125395. serialize(): any;
  125396. /**
  125397. * Parses a anisotropy Configuration from a serialized object.
  125398. * @param source - Serialized object.
  125399. * @param scene Defines the scene we are parsing for
  125400. * @param rootUrl Defines the rootUrl to load from
  125401. */
  125402. parse(source: any, scene: Scene, rootUrl: string): void;
  125403. }
  125404. }
  125405. declare module BABYLON {
  125406. /** @hidden */
  125407. export var pbrFragmentDeclaration: {
  125408. name: string;
  125409. shader: string;
  125410. };
  125411. }
  125412. declare module BABYLON {
  125413. /** @hidden */
  125414. export var pbrUboDeclaration: {
  125415. name: string;
  125416. shader: string;
  125417. };
  125418. }
  125419. declare module BABYLON {
  125420. /** @hidden */
  125421. export var pbrFragmentExtraDeclaration: {
  125422. name: string;
  125423. shader: string;
  125424. };
  125425. }
  125426. declare module BABYLON {
  125427. /** @hidden */
  125428. export var pbrFragmentSamplersDeclaration: {
  125429. name: string;
  125430. shader: string;
  125431. };
  125432. }
  125433. declare module BABYLON {
  125434. /** @hidden */
  125435. export var pbrHelperFunctions: {
  125436. name: string;
  125437. shader: string;
  125438. };
  125439. }
  125440. declare module BABYLON {
  125441. /** @hidden */
  125442. export var harmonicsFunctions: {
  125443. name: string;
  125444. shader: string;
  125445. };
  125446. }
  125447. declare module BABYLON {
  125448. /** @hidden */
  125449. export var pbrDirectLightingSetupFunctions: {
  125450. name: string;
  125451. shader: string;
  125452. };
  125453. }
  125454. declare module BABYLON {
  125455. /** @hidden */
  125456. export var pbrDirectLightingFalloffFunctions: {
  125457. name: string;
  125458. shader: string;
  125459. };
  125460. }
  125461. declare module BABYLON {
  125462. /** @hidden */
  125463. export var pbrBRDFFunctions: {
  125464. name: string;
  125465. shader: string;
  125466. };
  125467. }
  125468. declare module BABYLON {
  125469. /** @hidden */
  125470. export var pbrDirectLightingFunctions: {
  125471. name: string;
  125472. shader: string;
  125473. };
  125474. }
  125475. declare module BABYLON {
  125476. /** @hidden */
  125477. export var pbrIBLFunctions: {
  125478. name: string;
  125479. shader: string;
  125480. };
  125481. }
  125482. declare module BABYLON {
  125483. /** @hidden */
  125484. export var pbrBlockAlbedoOpacity: {
  125485. name: string;
  125486. shader: string;
  125487. };
  125488. }
  125489. declare module BABYLON {
  125490. /** @hidden */
  125491. export var pbrBlockReflectivity: {
  125492. name: string;
  125493. shader: string;
  125494. };
  125495. }
  125496. declare module BABYLON {
  125497. /** @hidden */
  125498. export var pbrBlockAmbientOcclusion: {
  125499. name: string;
  125500. shader: string;
  125501. };
  125502. }
  125503. declare module BABYLON {
  125504. /** @hidden */
  125505. export var pbrBlockAlphaFresnel: {
  125506. name: string;
  125507. shader: string;
  125508. };
  125509. }
  125510. declare module BABYLON {
  125511. /** @hidden */
  125512. export var pbrBlockAnisotropic: {
  125513. name: string;
  125514. shader: string;
  125515. };
  125516. }
  125517. declare module BABYLON {
  125518. /** @hidden */
  125519. export var pbrBlockReflection: {
  125520. name: string;
  125521. shader: string;
  125522. };
  125523. }
  125524. declare module BABYLON {
  125525. /** @hidden */
  125526. export var pbrBlockSheen: {
  125527. name: string;
  125528. shader: string;
  125529. };
  125530. }
  125531. declare module BABYLON {
  125532. /** @hidden */
  125533. export var pbrBlockClearcoat: {
  125534. name: string;
  125535. shader: string;
  125536. };
  125537. }
  125538. declare module BABYLON {
  125539. /** @hidden */
  125540. export var pbrBlockSubSurface: {
  125541. name: string;
  125542. shader: string;
  125543. };
  125544. }
  125545. declare module BABYLON {
  125546. /** @hidden */
  125547. export var pbrBlockNormalGeometric: {
  125548. name: string;
  125549. shader: string;
  125550. };
  125551. }
  125552. declare module BABYLON {
  125553. /** @hidden */
  125554. export var pbrBlockNormalFinal: {
  125555. name: string;
  125556. shader: string;
  125557. };
  125558. }
  125559. declare module BABYLON {
  125560. /** @hidden */
  125561. export var pbrBlockGeometryInfo: {
  125562. name: string;
  125563. shader: string;
  125564. };
  125565. }
  125566. declare module BABYLON {
  125567. /** @hidden */
  125568. export var pbrBlockReflectance0: {
  125569. name: string;
  125570. shader: string;
  125571. };
  125572. }
  125573. declare module BABYLON {
  125574. /** @hidden */
  125575. export var pbrBlockReflectance: {
  125576. name: string;
  125577. shader: string;
  125578. };
  125579. }
  125580. declare module BABYLON {
  125581. /** @hidden */
  125582. export var pbrBlockDirectLighting: {
  125583. name: string;
  125584. shader: string;
  125585. };
  125586. }
  125587. declare module BABYLON {
  125588. /** @hidden */
  125589. export var pbrBlockFinalLitComponents: {
  125590. name: string;
  125591. shader: string;
  125592. };
  125593. }
  125594. declare module BABYLON {
  125595. /** @hidden */
  125596. export var pbrBlockFinalUnlitComponents: {
  125597. name: string;
  125598. shader: string;
  125599. };
  125600. }
  125601. declare module BABYLON {
  125602. /** @hidden */
  125603. export var pbrBlockFinalColorComposition: {
  125604. name: string;
  125605. shader: string;
  125606. };
  125607. }
  125608. declare module BABYLON {
  125609. /** @hidden */
  125610. export var pbrBlockImageProcessing: {
  125611. name: string;
  125612. shader: string;
  125613. };
  125614. }
  125615. declare module BABYLON {
  125616. /** @hidden */
  125617. export var pbrDebug: {
  125618. name: string;
  125619. shader: string;
  125620. };
  125621. }
  125622. declare module BABYLON {
  125623. /** @hidden */
  125624. export var pbrPixelShader: {
  125625. name: string;
  125626. shader: string;
  125627. };
  125628. }
  125629. declare module BABYLON {
  125630. /** @hidden */
  125631. export var pbrVertexDeclaration: {
  125632. name: string;
  125633. shader: string;
  125634. };
  125635. }
  125636. declare module BABYLON {
  125637. /** @hidden */
  125638. export var pbrVertexShader: {
  125639. name: string;
  125640. shader: string;
  125641. };
  125642. }
  125643. declare module BABYLON {
  125644. /**
  125645. * Manages the defines for the PBR Material.
  125646. * @hidden
  125647. */
  125648. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125649. PBR: boolean;
  125650. MAINUV1: boolean;
  125651. MAINUV2: boolean;
  125652. UV1: boolean;
  125653. UV2: boolean;
  125654. ALBEDO: boolean;
  125655. GAMMAALBEDO: boolean;
  125656. ALBEDODIRECTUV: number;
  125657. VERTEXCOLOR: boolean;
  125658. AMBIENT: boolean;
  125659. AMBIENTDIRECTUV: number;
  125660. AMBIENTINGRAYSCALE: boolean;
  125661. OPACITY: boolean;
  125662. VERTEXALPHA: boolean;
  125663. OPACITYDIRECTUV: number;
  125664. OPACITYRGB: boolean;
  125665. ALPHATEST: boolean;
  125666. DEPTHPREPASS: boolean;
  125667. ALPHABLEND: boolean;
  125668. ALPHAFROMALBEDO: boolean;
  125669. ALPHATESTVALUE: string;
  125670. SPECULAROVERALPHA: boolean;
  125671. RADIANCEOVERALPHA: boolean;
  125672. ALPHAFRESNEL: boolean;
  125673. LINEARALPHAFRESNEL: boolean;
  125674. PREMULTIPLYALPHA: boolean;
  125675. EMISSIVE: boolean;
  125676. EMISSIVEDIRECTUV: number;
  125677. REFLECTIVITY: boolean;
  125678. REFLECTIVITYDIRECTUV: number;
  125679. SPECULARTERM: boolean;
  125680. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125681. MICROSURFACEAUTOMATIC: boolean;
  125682. LODBASEDMICROSFURACE: boolean;
  125683. MICROSURFACEMAP: boolean;
  125684. MICROSURFACEMAPDIRECTUV: number;
  125685. METALLICWORKFLOW: boolean;
  125686. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125687. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125688. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125689. AOSTOREINMETALMAPRED: boolean;
  125690. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125691. ENVIRONMENTBRDF: boolean;
  125692. ENVIRONMENTBRDF_RGBD: boolean;
  125693. NORMAL: boolean;
  125694. TANGENT: boolean;
  125695. BUMP: boolean;
  125696. BUMPDIRECTUV: number;
  125697. OBJECTSPACE_NORMALMAP: boolean;
  125698. PARALLAX: boolean;
  125699. PARALLAXOCCLUSION: boolean;
  125700. NORMALXYSCALE: boolean;
  125701. LIGHTMAP: boolean;
  125702. LIGHTMAPDIRECTUV: number;
  125703. USELIGHTMAPASSHADOWMAP: boolean;
  125704. GAMMALIGHTMAP: boolean;
  125705. RGBDLIGHTMAP: boolean;
  125706. REFLECTION: boolean;
  125707. REFLECTIONMAP_3D: boolean;
  125708. REFLECTIONMAP_SPHERICAL: boolean;
  125709. REFLECTIONMAP_PLANAR: boolean;
  125710. REFLECTIONMAP_CUBIC: boolean;
  125711. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125712. REFLECTIONMAP_PROJECTION: boolean;
  125713. REFLECTIONMAP_SKYBOX: boolean;
  125714. REFLECTIONMAP_EXPLICIT: boolean;
  125715. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125716. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125717. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125718. INVERTCUBICMAP: boolean;
  125719. USESPHERICALFROMREFLECTIONMAP: boolean;
  125720. USEIRRADIANCEMAP: boolean;
  125721. SPHERICAL_HARMONICS: boolean;
  125722. USESPHERICALINVERTEX: boolean;
  125723. REFLECTIONMAP_OPPOSITEZ: boolean;
  125724. LODINREFLECTIONALPHA: boolean;
  125725. GAMMAREFLECTION: boolean;
  125726. RGBDREFLECTION: boolean;
  125727. LINEARSPECULARREFLECTION: boolean;
  125728. RADIANCEOCCLUSION: boolean;
  125729. HORIZONOCCLUSION: boolean;
  125730. INSTANCES: boolean;
  125731. NUM_BONE_INFLUENCERS: number;
  125732. BonesPerMesh: number;
  125733. BONETEXTURE: boolean;
  125734. NONUNIFORMSCALING: boolean;
  125735. MORPHTARGETS: boolean;
  125736. MORPHTARGETS_NORMAL: boolean;
  125737. MORPHTARGETS_TANGENT: boolean;
  125738. MORPHTARGETS_UV: boolean;
  125739. NUM_MORPH_INFLUENCERS: number;
  125740. IMAGEPROCESSING: boolean;
  125741. VIGNETTE: boolean;
  125742. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125743. VIGNETTEBLENDMODEOPAQUE: boolean;
  125744. TONEMAPPING: boolean;
  125745. TONEMAPPING_ACES: boolean;
  125746. CONTRAST: boolean;
  125747. COLORCURVES: boolean;
  125748. COLORGRADING: boolean;
  125749. COLORGRADING3D: boolean;
  125750. SAMPLER3DGREENDEPTH: boolean;
  125751. SAMPLER3DBGRMAP: boolean;
  125752. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125753. EXPOSURE: boolean;
  125754. MULTIVIEW: boolean;
  125755. USEPHYSICALLIGHTFALLOFF: boolean;
  125756. USEGLTFLIGHTFALLOFF: boolean;
  125757. TWOSIDEDLIGHTING: boolean;
  125758. SHADOWFLOAT: boolean;
  125759. CLIPPLANE: boolean;
  125760. CLIPPLANE2: boolean;
  125761. CLIPPLANE3: boolean;
  125762. CLIPPLANE4: boolean;
  125763. CLIPPLANE5: boolean;
  125764. CLIPPLANE6: boolean;
  125765. POINTSIZE: boolean;
  125766. FOG: boolean;
  125767. LOGARITHMICDEPTH: boolean;
  125768. FORCENORMALFORWARD: boolean;
  125769. SPECULARAA: boolean;
  125770. CLEARCOAT: boolean;
  125771. CLEARCOAT_DEFAULTIOR: boolean;
  125772. CLEARCOAT_TEXTURE: boolean;
  125773. CLEARCOAT_TEXTUREDIRECTUV: number;
  125774. CLEARCOAT_BUMP: boolean;
  125775. CLEARCOAT_BUMPDIRECTUV: number;
  125776. CLEARCOAT_TINT: boolean;
  125777. CLEARCOAT_TINT_TEXTURE: boolean;
  125778. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125779. ANISOTROPIC: boolean;
  125780. ANISOTROPIC_TEXTURE: boolean;
  125781. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125782. BRDF_V_HEIGHT_CORRELATED: boolean;
  125783. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125784. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125785. SHEEN: boolean;
  125786. SHEEN_TEXTURE: boolean;
  125787. SHEEN_TEXTUREDIRECTUV: number;
  125788. SHEEN_LINKWITHALBEDO: boolean;
  125789. SHEEN_ROUGHNESS: boolean;
  125790. SHEEN_ALBEDOSCALING: boolean;
  125791. SUBSURFACE: boolean;
  125792. SS_REFRACTION: boolean;
  125793. SS_TRANSLUCENCY: boolean;
  125794. SS_SCATERRING: boolean;
  125795. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125796. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125797. SS_REFRACTIONMAP_3D: boolean;
  125798. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125799. SS_LODINREFRACTIONALPHA: boolean;
  125800. SS_GAMMAREFRACTION: boolean;
  125801. SS_RGBDREFRACTION: boolean;
  125802. SS_LINEARSPECULARREFRACTION: boolean;
  125803. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125804. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125805. UNLIT: boolean;
  125806. DEBUGMODE: number;
  125807. /**
  125808. * Initializes the PBR Material defines.
  125809. */
  125810. constructor();
  125811. /**
  125812. * Resets the PBR Material defines.
  125813. */
  125814. reset(): void;
  125815. }
  125816. /**
  125817. * The Physically based material base class of BJS.
  125818. *
  125819. * This offers the main features of a standard PBR material.
  125820. * For more information, please refer to the documentation :
  125821. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125822. */
  125823. export abstract class PBRBaseMaterial extends PushMaterial {
  125824. /**
  125825. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125826. */
  125827. static readonly PBRMATERIAL_OPAQUE: number;
  125828. /**
  125829. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125830. */
  125831. static readonly PBRMATERIAL_ALPHATEST: number;
  125832. /**
  125833. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125834. */
  125835. static readonly PBRMATERIAL_ALPHABLEND: number;
  125836. /**
  125837. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125838. * They are also discarded below the alpha cutoff threshold to improve performances.
  125839. */
  125840. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125841. /**
  125842. * Defines the default value of how much AO map is occluding the analytical lights
  125843. * (point spot...).
  125844. */
  125845. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125846. /**
  125847. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125848. */
  125849. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125850. /**
  125851. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125852. * to enhance interoperability with other engines.
  125853. */
  125854. static readonly LIGHTFALLOFF_GLTF: number;
  125855. /**
  125856. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125857. * to enhance interoperability with other materials.
  125858. */
  125859. static readonly LIGHTFALLOFF_STANDARD: number;
  125860. /**
  125861. * Intensity of the direct lights e.g. the four lights available in your scene.
  125862. * This impacts both the direct diffuse and specular highlights.
  125863. */
  125864. protected _directIntensity: number;
  125865. /**
  125866. * Intensity of the emissive part of the material.
  125867. * This helps controlling the emissive effect without modifying the emissive color.
  125868. */
  125869. protected _emissiveIntensity: number;
  125870. /**
  125871. * Intensity of the environment e.g. how much the environment will light the object
  125872. * either through harmonics for rough material or through the refelction for shiny ones.
  125873. */
  125874. protected _environmentIntensity: number;
  125875. /**
  125876. * This is a special control allowing the reduction of the specular highlights coming from the
  125877. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125878. */
  125879. protected _specularIntensity: number;
  125880. /**
  125881. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125882. */
  125883. private _lightingInfos;
  125884. /**
  125885. * Debug Control allowing disabling the bump map on this material.
  125886. */
  125887. protected _disableBumpMap: boolean;
  125888. /**
  125889. * AKA Diffuse Texture in standard nomenclature.
  125890. */
  125891. protected _albedoTexture: Nullable<BaseTexture>;
  125892. /**
  125893. * AKA Occlusion Texture in other nomenclature.
  125894. */
  125895. protected _ambientTexture: Nullable<BaseTexture>;
  125896. /**
  125897. * AKA Occlusion Texture Intensity in other nomenclature.
  125898. */
  125899. protected _ambientTextureStrength: number;
  125900. /**
  125901. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125902. * 1 means it completely occludes it
  125903. * 0 mean it has no impact
  125904. */
  125905. protected _ambientTextureImpactOnAnalyticalLights: number;
  125906. /**
  125907. * Stores the alpha values in a texture.
  125908. */
  125909. protected _opacityTexture: Nullable<BaseTexture>;
  125910. /**
  125911. * Stores the reflection values in a texture.
  125912. */
  125913. protected _reflectionTexture: Nullable<BaseTexture>;
  125914. /**
  125915. * Stores the emissive values in a texture.
  125916. */
  125917. protected _emissiveTexture: Nullable<BaseTexture>;
  125918. /**
  125919. * AKA Specular texture in other nomenclature.
  125920. */
  125921. protected _reflectivityTexture: Nullable<BaseTexture>;
  125922. /**
  125923. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125924. */
  125925. protected _metallicTexture: Nullable<BaseTexture>;
  125926. /**
  125927. * Specifies the metallic scalar of the metallic/roughness workflow.
  125928. * Can also be used to scale the metalness values of the metallic texture.
  125929. */
  125930. protected _metallic: Nullable<number>;
  125931. /**
  125932. * Specifies the roughness scalar of the metallic/roughness workflow.
  125933. * Can also be used to scale the roughness values of the metallic texture.
  125934. */
  125935. protected _roughness: Nullable<number>;
  125936. /**
  125937. * Specifies the an F0 factor to help configuring the material F0.
  125938. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125939. * to 0.5 the previously hard coded value stays the same.
  125940. * Can also be used to scale the F0 values of the metallic texture.
  125941. */
  125942. protected _metallicF0Factor: number;
  125943. /**
  125944. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125945. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125946. * your expectation as it multiplies with the texture data.
  125947. */
  125948. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125949. /**
  125950. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125951. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125952. */
  125953. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125954. /**
  125955. * Stores surface normal data used to displace a mesh in a texture.
  125956. */
  125957. protected _bumpTexture: Nullable<BaseTexture>;
  125958. /**
  125959. * Stores the pre-calculated light information of a mesh in a texture.
  125960. */
  125961. protected _lightmapTexture: Nullable<BaseTexture>;
  125962. /**
  125963. * The color of a material in ambient lighting.
  125964. */
  125965. protected _ambientColor: Color3;
  125966. /**
  125967. * AKA Diffuse Color in other nomenclature.
  125968. */
  125969. protected _albedoColor: Color3;
  125970. /**
  125971. * AKA Specular Color in other nomenclature.
  125972. */
  125973. protected _reflectivityColor: Color3;
  125974. /**
  125975. * The color applied when light is reflected from a material.
  125976. */
  125977. protected _reflectionColor: Color3;
  125978. /**
  125979. * The color applied when light is emitted from a material.
  125980. */
  125981. protected _emissiveColor: Color3;
  125982. /**
  125983. * AKA Glossiness in other nomenclature.
  125984. */
  125985. protected _microSurface: number;
  125986. /**
  125987. * Specifies that the material will use the light map as a show map.
  125988. */
  125989. protected _useLightmapAsShadowmap: boolean;
  125990. /**
  125991. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125992. * makes the reflect vector face the model (under horizon).
  125993. */
  125994. protected _useHorizonOcclusion: boolean;
  125995. /**
  125996. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125997. * too much the area relying on ambient texture to define their ambient occlusion.
  125998. */
  125999. protected _useRadianceOcclusion: boolean;
  126000. /**
  126001. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126002. */
  126003. protected _useAlphaFromAlbedoTexture: boolean;
  126004. /**
  126005. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126006. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126007. */
  126008. protected _useSpecularOverAlpha: boolean;
  126009. /**
  126010. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126011. */
  126012. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126013. /**
  126014. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126015. */
  126016. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126017. /**
  126018. * Specifies if the metallic texture contains the roughness information in its green channel.
  126019. */
  126020. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126021. /**
  126022. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126023. */
  126024. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126025. /**
  126026. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126027. */
  126028. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126029. /**
  126030. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126031. */
  126032. protected _useAmbientInGrayScale: boolean;
  126033. /**
  126034. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126035. * The material will try to infer what glossiness each pixel should be.
  126036. */
  126037. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126038. /**
  126039. * Defines the falloff type used in this material.
  126040. * It by default is Physical.
  126041. */
  126042. protected _lightFalloff: number;
  126043. /**
  126044. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126045. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126046. */
  126047. protected _useRadianceOverAlpha: boolean;
  126048. /**
  126049. * Allows using an object space normal map (instead of tangent space).
  126050. */
  126051. protected _useObjectSpaceNormalMap: boolean;
  126052. /**
  126053. * Allows using the bump map in parallax mode.
  126054. */
  126055. protected _useParallax: boolean;
  126056. /**
  126057. * Allows using the bump map in parallax occlusion mode.
  126058. */
  126059. protected _useParallaxOcclusion: boolean;
  126060. /**
  126061. * Controls the scale bias of the parallax mode.
  126062. */
  126063. protected _parallaxScaleBias: number;
  126064. /**
  126065. * If sets to true, disables all the lights affecting the material.
  126066. */
  126067. protected _disableLighting: boolean;
  126068. /**
  126069. * Number of Simultaneous lights allowed on the material.
  126070. */
  126071. protected _maxSimultaneousLights: number;
  126072. /**
  126073. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126074. */
  126075. protected _invertNormalMapX: boolean;
  126076. /**
  126077. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126078. */
  126079. protected _invertNormalMapY: boolean;
  126080. /**
  126081. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126082. */
  126083. protected _twoSidedLighting: boolean;
  126084. /**
  126085. * Defines the alpha limits in alpha test mode.
  126086. */
  126087. protected _alphaCutOff: number;
  126088. /**
  126089. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126090. */
  126091. protected _forceAlphaTest: boolean;
  126092. /**
  126093. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126094. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126095. */
  126096. protected _useAlphaFresnel: boolean;
  126097. /**
  126098. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126099. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126100. */
  126101. protected _useLinearAlphaFresnel: boolean;
  126102. /**
  126103. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126104. * from cos thetav and roughness:
  126105. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126106. */
  126107. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126108. /**
  126109. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126110. */
  126111. protected _forceIrradianceInFragment: boolean;
  126112. /**
  126113. * Force normal to face away from face.
  126114. */
  126115. protected _forceNormalForward: boolean;
  126116. /**
  126117. * Enables specular anti aliasing in the PBR shader.
  126118. * It will both interacts on the Geometry for analytical and IBL lighting.
  126119. * It also prefilter the roughness map based on the bump values.
  126120. */
  126121. protected _enableSpecularAntiAliasing: boolean;
  126122. /**
  126123. * Default configuration related to image processing available in the PBR Material.
  126124. */
  126125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126126. /**
  126127. * Keep track of the image processing observer to allow dispose and replace.
  126128. */
  126129. private _imageProcessingObserver;
  126130. /**
  126131. * Attaches a new image processing configuration to the PBR Material.
  126132. * @param configuration
  126133. */
  126134. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126135. /**
  126136. * Stores the available render targets.
  126137. */
  126138. private _renderTargets;
  126139. /**
  126140. * Sets the global ambient color for the material used in lighting calculations.
  126141. */
  126142. private _globalAmbientColor;
  126143. /**
  126144. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126145. */
  126146. private _useLogarithmicDepth;
  126147. /**
  126148. * If set to true, no lighting calculations will be applied.
  126149. */
  126150. private _unlit;
  126151. private _debugMode;
  126152. /**
  126153. * @hidden
  126154. * This is reserved for the inspector.
  126155. * Defines the material debug mode.
  126156. * It helps seeing only some components of the material while troubleshooting.
  126157. */
  126158. debugMode: number;
  126159. /**
  126160. * @hidden
  126161. * This is reserved for the inspector.
  126162. * Specify from where on screen the debug mode should start.
  126163. * The value goes from -1 (full screen) to 1 (not visible)
  126164. * It helps with side by side comparison against the final render
  126165. * This defaults to -1
  126166. */
  126167. private debugLimit;
  126168. /**
  126169. * @hidden
  126170. * This is reserved for the inspector.
  126171. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126172. * You can use the factor to better multiply the final value.
  126173. */
  126174. private debugFactor;
  126175. /**
  126176. * Defines the clear coat layer parameters for the material.
  126177. */
  126178. readonly clearCoat: PBRClearCoatConfiguration;
  126179. /**
  126180. * Defines the anisotropic parameters for the material.
  126181. */
  126182. readonly anisotropy: PBRAnisotropicConfiguration;
  126183. /**
  126184. * Defines the BRDF parameters for the material.
  126185. */
  126186. readonly brdf: PBRBRDFConfiguration;
  126187. /**
  126188. * Defines the Sheen parameters for the material.
  126189. */
  126190. readonly sheen: PBRSheenConfiguration;
  126191. /**
  126192. * Defines the SubSurface parameters for the material.
  126193. */
  126194. readonly subSurface: PBRSubSurfaceConfiguration;
  126195. /**
  126196. * Custom callback helping to override the default shader used in the material.
  126197. */
  126198. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126199. protected _rebuildInParallel: boolean;
  126200. /**
  126201. * Instantiates a new PBRMaterial instance.
  126202. *
  126203. * @param name The material name
  126204. * @param scene The scene the material will be use in.
  126205. */
  126206. constructor(name: string, scene: Scene);
  126207. /**
  126208. * Gets a boolean indicating that current material needs to register RTT
  126209. */
  126210. get hasRenderTargetTextures(): boolean;
  126211. /**
  126212. * Gets the name of the material class.
  126213. */
  126214. getClassName(): string;
  126215. /**
  126216. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126217. */
  126218. get useLogarithmicDepth(): boolean;
  126219. /**
  126220. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126221. */
  126222. set useLogarithmicDepth(value: boolean);
  126223. /**
  126224. * Returns true if alpha blending should be disabled.
  126225. */
  126226. protected get _disableAlphaBlending(): boolean;
  126227. /**
  126228. * Specifies whether or not this material should be rendered in alpha blend mode.
  126229. */
  126230. needAlphaBlending(): boolean;
  126231. /**
  126232. * Specifies whether or not this material should be rendered in alpha test mode.
  126233. */
  126234. needAlphaTesting(): boolean;
  126235. /**
  126236. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126237. */
  126238. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126239. /**
  126240. * Gets the texture used for the alpha test.
  126241. */
  126242. getAlphaTestTexture(): Nullable<BaseTexture>;
  126243. /**
  126244. * Specifies that the submesh is ready to be used.
  126245. * @param mesh - BJS mesh.
  126246. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126247. * @param useInstances - Specifies that instances should be used.
  126248. * @returns - boolean indicating that the submesh is ready or not.
  126249. */
  126250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126251. /**
  126252. * Specifies if the material uses metallic roughness workflow.
  126253. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126254. */
  126255. isMetallicWorkflow(): boolean;
  126256. private _prepareEffect;
  126257. private _prepareDefines;
  126258. /**
  126259. * Force shader compilation
  126260. */
  126261. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126262. /**
  126263. * Initializes the uniform buffer layout for the shader.
  126264. */
  126265. buildUniformLayout(): void;
  126266. /**
  126267. * Unbinds the material from the mesh
  126268. */
  126269. unbind(): void;
  126270. /**
  126271. * Binds the submesh data.
  126272. * @param world - The world matrix.
  126273. * @param mesh - The BJS mesh.
  126274. * @param subMesh - A submesh of the BJS mesh.
  126275. */
  126276. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126277. /**
  126278. * Returns the animatable textures.
  126279. * @returns - Array of animatable textures.
  126280. */
  126281. getAnimatables(): IAnimatable[];
  126282. /**
  126283. * Returns the texture used for reflections.
  126284. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126285. */
  126286. private _getReflectionTexture;
  126287. /**
  126288. * Returns an array of the actively used textures.
  126289. * @returns - Array of BaseTextures
  126290. */
  126291. getActiveTextures(): BaseTexture[];
  126292. /**
  126293. * Checks to see if a texture is used in the material.
  126294. * @param texture - Base texture to use.
  126295. * @returns - Boolean specifying if a texture is used in the material.
  126296. */
  126297. hasTexture(texture: BaseTexture): boolean;
  126298. /**
  126299. * Disposes the resources of the material.
  126300. * @param forceDisposeEffect - Forces the disposal of effects.
  126301. * @param forceDisposeTextures - Forces the disposal of all textures.
  126302. */
  126303. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126304. }
  126305. }
  126306. declare module BABYLON {
  126307. /**
  126308. * The Physically based material of BJS.
  126309. *
  126310. * This offers the main features of a standard PBR material.
  126311. * For more information, please refer to the documentation :
  126312. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126313. */
  126314. export class PBRMaterial extends PBRBaseMaterial {
  126315. /**
  126316. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126317. */
  126318. static readonly PBRMATERIAL_OPAQUE: number;
  126319. /**
  126320. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126321. */
  126322. static readonly PBRMATERIAL_ALPHATEST: number;
  126323. /**
  126324. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126325. */
  126326. static readonly PBRMATERIAL_ALPHABLEND: number;
  126327. /**
  126328. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126329. * They are also discarded below the alpha cutoff threshold to improve performances.
  126330. */
  126331. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126332. /**
  126333. * Defines the default value of how much AO map is occluding the analytical lights
  126334. * (point spot...).
  126335. */
  126336. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126337. /**
  126338. * Intensity of the direct lights e.g. the four lights available in your scene.
  126339. * This impacts both the direct diffuse and specular highlights.
  126340. */
  126341. directIntensity: number;
  126342. /**
  126343. * Intensity of the emissive part of the material.
  126344. * This helps controlling the emissive effect without modifying the emissive color.
  126345. */
  126346. emissiveIntensity: number;
  126347. /**
  126348. * Intensity of the environment e.g. how much the environment will light the object
  126349. * either through harmonics for rough material or through the refelction for shiny ones.
  126350. */
  126351. environmentIntensity: number;
  126352. /**
  126353. * This is a special control allowing the reduction of the specular highlights coming from the
  126354. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126355. */
  126356. specularIntensity: number;
  126357. /**
  126358. * Debug Control allowing disabling the bump map on this material.
  126359. */
  126360. disableBumpMap: boolean;
  126361. /**
  126362. * AKA Diffuse Texture in standard nomenclature.
  126363. */
  126364. albedoTexture: BaseTexture;
  126365. /**
  126366. * AKA Occlusion Texture in other nomenclature.
  126367. */
  126368. ambientTexture: BaseTexture;
  126369. /**
  126370. * AKA Occlusion Texture Intensity in other nomenclature.
  126371. */
  126372. ambientTextureStrength: number;
  126373. /**
  126374. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126375. * 1 means it completely occludes it
  126376. * 0 mean it has no impact
  126377. */
  126378. ambientTextureImpactOnAnalyticalLights: number;
  126379. /**
  126380. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126381. */
  126382. opacityTexture: BaseTexture;
  126383. /**
  126384. * Stores the reflection values in a texture.
  126385. */
  126386. reflectionTexture: Nullable<BaseTexture>;
  126387. /**
  126388. * Stores the emissive values in a texture.
  126389. */
  126390. emissiveTexture: BaseTexture;
  126391. /**
  126392. * AKA Specular texture in other nomenclature.
  126393. */
  126394. reflectivityTexture: BaseTexture;
  126395. /**
  126396. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126397. */
  126398. metallicTexture: BaseTexture;
  126399. /**
  126400. * Specifies the metallic scalar of the metallic/roughness workflow.
  126401. * Can also be used to scale the metalness values of the metallic texture.
  126402. */
  126403. metallic: Nullable<number>;
  126404. /**
  126405. * Specifies the roughness scalar of the metallic/roughness workflow.
  126406. * Can also be used to scale the roughness values of the metallic texture.
  126407. */
  126408. roughness: Nullable<number>;
  126409. /**
  126410. * Specifies the an F0 factor to help configuring the material F0.
  126411. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126412. * to 0.5 the previously hard coded value stays the same.
  126413. * Can also be used to scale the F0 values of the metallic texture.
  126414. */
  126415. metallicF0Factor: number;
  126416. /**
  126417. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126418. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126419. * your expectation as it multiplies with the texture data.
  126420. */
  126421. useMetallicF0FactorFromMetallicTexture: boolean;
  126422. /**
  126423. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126424. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126425. */
  126426. microSurfaceTexture: BaseTexture;
  126427. /**
  126428. * Stores surface normal data used to displace a mesh in a texture.
  126429. */
  126430. bumpTexture: BaseTexture;
  126431. /**
  126432. * Stores the pre-calculated light information of a mesh in a texture.
  126433. */
  126434. lightmapTexture: BaseTexture;
  126435. /**
  126436. * Stores the refracted light information in a texture.
  126437. */
  126438. get refractionTexture(): Nullable<BaseTexture>;
  126439. set refractionTexture(value: Nullable<BaseTexture>);
  126440. /**
  126441. * The color of a material in ambient lighting.
  126442. */
  126443. ambientColor: Color3;
  126444. /**
  126445. * AKA Diffuse Color in other nomenclature.
  126446. */
  126447. albedoColor: Color3;
  126448. /**
  126449. * AKA Specular Color in other nomenclature.
  126450. */
  126451. reflectivityColor: Color3;
  126452. /**
  126453. * The color reflected from the material.
  126454. */
  126455. reflectionColor: Color3;
  126456. /**
  126457. * The color emitted from the material.
  126458. */
  126459. emissiveColor: Color3;
  126460. /**
  126461. * AKA Glossiness in other nomenclature.
  126462. */
  126463. microSurface: number;
  126464. /**
  126465. * source material index of refraction (IOR)' / 'destination material IOR.
  126466. */
  126467. get indexOfRefraction(): number;
  126468. set indexOfRefraction(value: number);
  126469. /**
  126470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126471. */
  126472. get invertRefractionY(): boolean;
  126473. set invertRefractionY(value: boolean);
  126474. /**
  126475. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126476. * Materials half opaque for instance using refraction could benefit from this control.
  126477. */
  126478. get linkRefractionWithTransparency(): boolean;
  126479. set linkRefractionWithTransparency(value: boolean);
  126480. /**
  126481. * If true, the light map contains occlusion information instead of lighting info.
  126482. */
  126483. useLightmapAsShadowmap: boolean;
  126484. /**
  126485. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126486. */
  126487. useAlphaFromAlbedoTexture: boolean;
  126488. /**
  126489. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126490. */
  126491. forceAlphaTest: boolean;
  126492. /**
  126493. * Defines the alpha limits in alpha test mode.
  126494. */
  126495. alphaCutOff: number;
  126496. /**
  126497. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126498. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126499. */
  126500. useSpecularOverAlpha: boolean;
  126501. /**
  126502. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126503. */
  126504. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126505. /**
  126506. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126507. */
  126508. useRoughnessFromMetallicTextureAlpha: boolean;
  126509. /**
  126510. * Specifies if the metallic texture contains the roughness information in its green channel.
  126511. */
  126512. useRoughnessFromMetallicTextureGreen: boolean;
  126513. /**
  126514. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126515. */
  126516. useMetallnessFromMetallicTextureBlue: boolean;
  126517. /**
  126518. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126519. */
  126520. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126521. /**
  126522. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126523. */
  126524. useAmbientInGrayScale: boolean;
  126525. /**
  126526. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126527. * The material will try to infer what glossiness each pixel should be.
  126528. */
  126529. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126530. /**
  126531. * BJS is using an harcoded light falloff based on a manually sets up range.
  126532. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126533. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126534. */
  126535. get usePhysicalLightFalloff(): boolean;
  126536. /**
  126537. * BJS is using an harcoded light falloff based on a manually sets up range.
  126538. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126539. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126540. */
  126541. set usePhysicalLightFalloff(value: boolean);
  126542. /**
  126543. * In order to support the falloff compatibility with gltf, a special mode has been added
  126544. * to reproduce the gltf light falloff.
  126545. */
  126546. get useGLTFLightFalloff(): boolean;
  126547. /**
  126548. * In order to support the falloff compatibility with gltf, a special mode has been added
  126549. * to reproduce the gltf light falloff.
  126550. */
  126551. set useGLTFLightFalloff(value: boolean);
  126552. /**
  126553. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126554. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126555. */
  126556. useRadianceOverAlpha: boolean;
  126557. /**
  126558. * Allows using an object space normal map (instead of tangent space).
  126559. */
  126560. useObjectSpaceNormalMap: boolean;
  126561. /**
  126562. * Allows using the bump map in parallax mode.
  126563. */
  126564. useParallax: boolean;
  126565. /**
  126566. * Allows using the bump map in parallax occlusion mode.
  126567. */
  126568. useParallaxOcclusion: boolean;
  126569. /**
  126570. * Controls the scale bias of the parallax mode.
  126571. */
  126572. parallaxScaleBias: number;
  126573. /**
  126574. * If sets to true, disables all the lights affecting the material.
  126575. */
  126576. disableLighting: boolean;
  126577. /**
  126578. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126579. */
  126580. forceIrradianceInFragment: boolean;
  126581. /**
  126582. * Number of Simultaneous lights allowed on the material.
  126583. */
  126584. maxSimultaneousLights: number;
  126585. /**
  126586. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126587. */
  126588. invertNormalMapX: boolean;
  126589. /**
  126590. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126591. */
  126592. invertNormalMapY: boolean;
  126593. /**
  126594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126595. */
  126596. twoSidedLighting: boolean;
  126597. /**
  126598. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126599. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126600. */
  126601. useAlphaFresnel: boolean;
  126602. /**
  126603. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126604. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126605. */
  126606. useLinearAlphaFresnel: boolean;
  126607. /**
  126608. * Let user defines the brdf lookup texture used for IBL.
  126609. * A default 8bit version is embedded but you could point at :
  126610. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126611. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126612. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126613. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126614. */
  126615. environmentBRDFTexture: Nullable<BaseTexture>;
  126616. /**
  126617. * Force normal to face away from face.
  126618. */
  126619. forceNormalForward: boolean;
  126620. /**
  126621. * Enables specular anti aliasing in the PBR shader.
  126622. * It will both interacts on the Geometry for analytical and IBL lighting.
  126623. * It also prefilter the roughness map based on the bump values.
  126624. */
  126625. enableSpecularAntiAliasing: boolean;
  126626. /**
  126627. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126628. * makes the reflect vector face the model (under horizon).
  126629. */
  126630. useHorizonOcclusion: boolean;
  126631. /**
  126632. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126633. * too much the area relying on ambient texture to define their ambient occlusion.
  126634. */
  126635. useRadianceOcclusion: boolean;
  126636. /**
  126637. * If set to true, no lighting calculations will be applied.
  126638. */
  126639. unlit: boolean;
  126640. /**
  126641. * Gets the image processing configuration used either in this material.
  126642. */
  126643. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126644. /**
  126645. * Sets the Default image processing configuration used either in the this material.
  126646. *
  126647. * If sets to null, the scene one is in use.
  126648. */
  126649. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126650. /**
  126651. * Gets wether the color curves effect is enabled.
  126652. */
  126653. get cameraColorCurvesEnabled(): boolean;
  126654. /**
  126655. * Sets wether the color curves effect is enabled.
  126656. */
  126657. set cameraColorCurvesEnabled(value: boolean);
  126658. /**
  126659. * Gets wether the color grading effect is enabled.
  126660. */
  126661. get cameraColorGradingEnabled(): boolean;
  126662. /**
  126663. * Gets wether the color grading effect is enabled.
  126664. */
  126665. set cameraColorGradingEnabled(value: boolean);
  126666. /**
  126667. * Gets wether tonemapping is enabled or not.
  126668. */
  126669. get cameraToneMappingEnabled(): boolean;
  126670. /**
  126671. * Sets wether tonemapping is enabled or not
  126672. */
  126673. set cameraToneMappingEnabled(value: boolean);
  126674. /**
  126675. * The camera exposure used on this material.
  126676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126677. * This corresponds to a photographic exposure.
  126678. */
  126679. get cameraExposure(): number;
  126680. /**
  126681. * The camera exposure used on this material.
  126682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126683. * This corresponds to a photographic exposure.
  126684. */
  126685. set cameraExposure(value: number);
  126686. /**
  126687. * Gets The camera contrast used on this material.
  126688. */
  126689. get cameraContrast(): number;
  126690. /**
  126691. * Sets The camera contrast used on this material.
  126692. */
  126693. set cameraContrast(value: number);
  126694. /**
  126695. * Gets the Color Grading 2D Lookup Texture.
  126696. */
  126697. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126698. /**
  126699. * Sets the Color Grading 2D Lookup Texture.
  126700. */
  126701. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126702. /**
  126703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126705. * 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;
  126706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126707. */
  126708. get cameraColorCurves(): Nullable<ColorCurves>;
  126709. /**
  126710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126712. * 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;
  126713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126714. */
  126715. set cameraColorCurves(value: Nullable<ColorCurves>);
  126716. /**
  126717. * Instantiates a new PBRMaterial instance.
  126718. *
  126719. * @param name The material name
  126720. * @param scene The scene the material will be use in.
  126721. */
  126722. constructor(name: string, scene: Scene);
  126723. /**
  126724. * Returns the name of this material class.
  126725. */
  126726. getClassName(): string;
  126727. /**
  126728. * Makes a duplicate of the current material.
  126729. * @param name - name to use for the new material.
  126730. */
  126731. clone(name: string): PBRMaterial;
  126732. /**
  126733. * Serializes this PBR Material.
  126734. * @returns - An object with the serialized material.
  126735. */
  126736. serialize(): any;
  126737. /**
  126738. * Parses a PBR Material from a serialized object.
  126739. * @param source - Serialized object.
  126740. * @param scene - BJS scene instance.
  126741. * @param rootUrl - url for the scene object
  126742. * @returns - PBRMaterial
  126743. */
  126744. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126745. }
  126746. }
  126747. declare module BABYLON {
  126748. /**
  126749. * Direct draw surface info
  126750. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126751. */
  126752. export interface DDSInfo {
  126753. /**
  126754. * Width of the texture
  126755. */
  126756. width: number;
  126757. /**
  126758. * Width of the texture
  126759. */
  126760. height: number;
  126761. /**
  126762. * Number of Mipmaps for the texture
  126763. * @see https://en.wikipedia.org/wiki/Mipmap
  126764. */
  126765. mipmapCount: number;
  126766. /**
  126767. * If the textures format is a known fourCC format
  126768. * @see https://www.fourcc.org/
  126769. */
  126770. isFourCC: boolean;
  126771. /**
  126772. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126773. */
  126774. isRGB: boolean;
  126775. /**
  126776. * If the texture is a lumincance format
  126777. */
  126778. isLuminance: boolean;
  126779. /**
  126780. * If this is a cube texture
  126781. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126782. */
  126783. isCube: boolean;
  126784. /**
  126785. * If the texture is a compressed format eg. FOURCC_DXT1
  126786. */
  126787. isCompressed: boolean;
  126788. /**
  126789. * The dxgiFormat of the texture
  126790. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126791. */
  126792. dxgiFormat: number;
  126793. /**
  126794. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126795. */
  126796. textureType: number;
  126797. /**
  126798. * Sphericle polynomial created for the dds texture
  126799. */
  126800. sphericalPolynomial?: SphericalPolynomial;
  126801. }
  126802. /**
  126803. * Class used to provide DDS decompression tools
  126804. */
  126805. export class DDSTools {
  126806. /**
  126807. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126808. */
  126809. static StoreLODInAlphaChannel: boolean;
  126810. /**
  126811. * Gets DDS information from an array buffer
  126812. * @param data defines the array buffer view to read data from
  126813. * @returns the DDS information
  126814. */
  126815. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126816. private static _FloatView;
  126817. private static _Int32View;
  126818. private static _ToHalfFloat;
  126819. private static _FromHalfFloat;
  126820. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126821. private static _GetHalfFloatRGBAArrayBuffer;
  126822. private static _GetFloatRGBAArrayBuffer;
  126823. private static _GetFloatAsUIntRGBAArrayBuffer;
  126824. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126825. private static _GetRGBAArrayBuffer;
  126826. private static _ExtractLongWordOrder;
  126827. private static _GetRGBArrayBuffer;
  126828. private static _GetLuminanceArrayBuffer;
  126829. /**
  126830. * Uploads DDS Levels to a Babylon Texture
  126831. * @hidden
  126832. */
  126833. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126834. }
  126835. interface ThinEngine {
  126836. /**
  126837. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126838. * @param rootUrl defines the url where the file to load is located
  126839. * @param scene defines the current scene
  126840. * @param lodScale defines scale to apply to the mip map selection
  126841. * @param lodOffset defines offset to apply to the mip map selection
  126842. * @param onLoad defines an optional callback raised when the texture is loaded
  126843. * @param onError defines an optional callback raised if there is an issue to load the texture
  126844. * @param format defines the format of the data
  126845. * @param forcedExtension defines the extension to use to pick the right loader
  126846. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126847. * @returns the cube texture as an InternalTexture
  126848. */
  126849. 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;
  126850. }
  126851. }
  126852. declare module BABYLON {
  126853. /**
  126854. * Implementation of the DDS Texture Loader.
  126855. * @hidden
  126856. */
  126857. export class _DDSTextureLoader implements IInternalTextureLoader {
  126858. /**
  126859. * Defines wether the loader supports cascade loading the different faces.
  126860. */
  126861. readonly supportCascades: boolean;
  126862. /**
  126863. * This returns if the loader support the current file information.
  126864. * @param extension defines the file extension of the file being loaded
  126865. * @returns true if the loader can load the specified file
  126866. */
  126867. canLoad(extension: string): boolean;
  126868. /**
  126869. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126870. * @param data contains the texture data
  126871. * @param texture defines the BabylonJS internal texture
  126872. * @param createPolynomials will be true if polynomials have been requested
  126873. * @param onLoad defines the callback to trigger once the texture is ready
  126874. * @param onError defines the callback to trigger in case of error
  126875. */
  126876. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126877. /**
  126878. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126879. * @param data contains the texture data
  126880. * @param texture defines the BabylonJS internal texture
  126881. * @param callback defines the method to call once ready to upload
  126882. */
  126883. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126884. }
  126885. }
  126886. declare module BABYLON {
  126887. /**
  126888. * Implementation of the ENV Texture Loader.
  126889. * @hidden
  126890. */
  126891. export class _ENVTextureLoader implements IInternalTextureLoader {
  126892. /**
  126893. * Defines wether the loader supports cascade loading the different faces.
  126894. */
  126895. readonly supportCascades: boolean;
  126896. /**
  126897. * This returns if the loader support the current file information.
  126898. * @param extension defines the file extension of the file being loaded
  126899. * @returns true if the loader can load the specified file
  126900. */
  126901. canLoad(extension: string): boolean;
  126902. /**
  126903. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126904. * @param data contains the texture data
  126905. * @param texture defines the BabylonJS internal texture
  126906. * @param createPolynomials will be true if polynomials have been requested
  126907. * @param onLoad defines the callback to trigger once the texture is ready
  126908. * @param onError defines the callback to trigger in case of error
  126909. */
  126910. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126911. /**
  126912. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126913. * @param data contains the texture data
  126914. * @param texture defines the BabylonJS internal texture
  126915. * @param callback defines the method to call once ready to upload
  126916. */
  126917. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126918. }
  126919. }
  126920. declare module BABYLON {
  126921. /**
  126922. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126923. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126924. */
  126925. export class KhronosTextureContainer {
  126926. /** contents of the KTX container file */
  126927. data: ArrayBufferView;
  126928. private static HEADER_LEN;
  126929. private static COMPRESSED_2D;
  126930. private static COMPRESSED_3D;
  126931. private static TEX_2D;
  126932. private static TEX_3D;
  126933. /**
  126934. * Gets the openGL type
  126935. */
  126936. glType: number;
  126937. /**
  126938. * Gets the openGL type size
  126939. */
  126940. glTypeSize: number;
  126941. /**
  126942. * Gets the openGL format
  126943. */
  126944. glFormat: number;
  126945. /**
  126946. * Gets the openGL internal format
  126947. */
  126948. glInternalFormat: number;
  126949. /**
  126950. * Gets the base internal format
  126951. */
  126952. glBaseInternalFormat: number;
  126953. /**
  126954. * Gets image width in pixel
  126955. */
  126956. pixelWidth: number;
  126957. /**
  126958. * Gets image height in pixel
  126959. */
  126960. pixelHeight: number;
  126961. /**
  126962. * Gets image depth in pixels
  126963. */
  126964. pixelDepth: number;
  126965. /**
  126966. * Gets the number of array elements
  126967. */
  126968. numberOfArrayElements: number;
  126969. /**
  126970. * Gets the number of faces
  126971. */
  126972. numberOfFaces: number;
  126973. /**
  126974. * Gets the number of mipmap levels
  126975. */
  126976. numberOfMipmapLevels: number;
  126977. /**
  126978. * Gets the bytes of key value data
  126979. */
  126980. bytesOfKeyValueData: number;
  126981. /**
  126982. * Gets the load type
  126983. */
  126984. loadType: number;
  126985. /**
  126986. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  126987. */
  126988. isInvalid: boolean;
  126989. /**
  126990. * Creates a new KhronosTextureContainer
  126991. * @param data contents of the KTX container file
  126992. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  126993. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  126994. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  126995. */
  126996. constructor(
  126997. /** contents of the KTX container file */
  126998. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  126999. /**
  127000. * Uploads KTX content to a Babylon Texture.
  127001. * It is assumed that the texture has already been created & is currently bound
  127002. * @hidden
  127003. */
  127004. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127005. private _upload2DCompressedLevels;
  127006. /**
  127007. * Checks if the given data starts with a KTX file identifier.
  127008. * @param data the data to check
  127009. * @returns true if the data is a KTX file or false otherwise
  127010. */
  127011. static IsValid(data: ArrayBufferView): boolean;
  127012. }
  127013. }
  127014. declare module BABYLON {
  127015. /**
  127016. * Class for loading KTX2 files
  127017. * !!! Experimental Extension Subject to Changes !!!
  127018. * @hidden
  127019. */
  127020. export class KhronosTextureContainer2 {
  127021. private static _ModulePromise;
  127022. private static _TranscodeFormat;
  127023. constructor(engine: ThinEngine);
  127024. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127025. private _determineTranscodeFormat;
  127026. /**
  127027. * Checks if the given data starts with a KTX2 file identifier.
  127028. * @param data the data to check
  127029. * @returns true if the data is a KTX2 file or false otherwise
  127030. */
  127031. static IsValid(data: ArrayBufferView): boolean;
  127032. }
  127033. }
  127034. declare module BABYLON {
  127035. /**
  127036. * Implementation of the KTX Texture Loader.
  127037. * @hidden
  127038. */
  127039. export class _KTXTextureLoader implements IInternalTextureLoader {
  127040. /**
  127041. * Defines wether the loader supports cascade loading the different faces.
  127042. */
  127043. readonly supportCascades: boolean;
  127044. /**
  127045. * This returns if the loader support the current file information.
  127046. * @param extension defines the file extension of the file being loaded
  127047. * @returns true if the loader can load the specified file
  127048. */
  127049. canLoad(extension: string): boolean;
  127050. /**
  127051. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127052. * @param data contains the texture data
  127053. * @param texture defines the BabylonJS internal texture
  127054. * @param createPolynomials will be true if polynomials have been requested
  127055. * @param onLoad defines the callback to trigger once the texture is ready
  127056. * @param onError defines the callback to trigger in case of error
  127057. */
  127058. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127059. /**
  127060. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127061. * @param data contains the texture data
  127062. * @param texture defines the BabylonJS internal texture
  127063. * @param callback defines the method to call once ready to upload
  127064. */
  127065. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127066. }
  127067. }
  127068. declare module BABYLON {
  127069. /** @hidden */
  127070. export var _forceSceneHelpersToBundle: boolean;
  127071. interface Scene {
  127072. /**
  127073. * Creates a default light for the scene.
  127074. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127075. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127076. */
  127077. createDefaultLight(replace?: boolean): void;
  127078. /**
  127079. * Creates a default camera for the scene.
  127080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127081. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127082. * @param replace has default false, when true replaces the active camera in the scene
  127083. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127084. */
  127085. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127086. /**
  127087. * Creates a default camera and a default light.
  127088. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127089. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127090. * @param replace has the default false, when true replaces the active camera/light in the scene
  127091. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127092. */
  127093. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127094. /**
  127095. * Creates a new sky box
  127096. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127097. * @param environmentTexture defines the texture to use as environment texture
  127098. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127099. * @param scale defines the overall scale of the skybox
  127100. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127101. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127102. * @returns a new mesh holding the sky box
  127103. */
  127104. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127105. /**
  127106. * Creates a new environment
  127107. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127108. * @param options defines the options you can use to configure the environment
  127109. * @returns the new EnvironmentHelper
  127110. */
  127111. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127112. /**
  127113. * Creates a new VREXperienceHelper
  127114. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127115. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127116. * @returns a new VREXperienceHelper
  127117. */
  127118. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127119. /**
  127120. * Creates a new WebXRDefaultExperience
  127121. * @see http://doc.babylonjs.com/how_to/webxr
  127122. * @param options experience options
  127123. * @returns a promise for a new WebXRDefaultExperience
  127124. */
  127125. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127126. }
  127127. }
  127128. declare module BABYLON {
  127129. /**
  127130. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127131. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127132. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127133. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127134. */
  127135. export class VideoDome extends TransformNode {
  127136. /**
  127137. * Define the video source as a Monoscopic panoramic 360 video.
  127138. */
  127139. static readonly MODE_MONOSCOPIC: number;
  127140. /**
  127141. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127142. */
  127143. static readonly MODE_TOPBOTTOM: number;
  127144. /**
  127145. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127146. */
  127147. static readonly MODE_SIDEBYSIDE: number;
  127148. private _halfDome;
  127149. private _useDirectMapping;
  127150. /**
  127151. * The video texture being displayed on the sphere
  127152. */
  127153. protected _videoTexture: VideoTexture;
  127154. /**
  127155. * Gets the video texture being displayed on the sphere
  127156. */
  127157. get videoTexture(): VideoTexture;
  127158. /**
  127159. * The skybox material
  127160. */
  127161. protected _material: BackgroundMaterial;
  127162. /**
  127163. * The surface used for the skybox
  127164. */
  127165. protected _mesh: Mesh;
  127166. /**
  127167. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127168. */
  127169. private _halfDomeMask;
  127170. /**
  127171. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127172. * Also see the options.resolution property.
  127173. */
  127174. get fovMultiplier(): number;
  127175. set fovMultiplier(value: number);
  127176. private _videoMode;
  127177. /**
  127178. * Gets or set the current video mode for the video. It can be:
  127179. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127180. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127181. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127182. */
  127183. get videoMode(): number;
  127184. set videoMode(value: number);
  127185. /**
  127186. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127187. *
  127188. */
  127189. get halfDome(): boolean;
  127190. /**
  127191. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127192. */
  127193. set halfDome(enabled: boolean);
  127194. /**
  127195. * Oberserver used in Stereoscopic VR Mode.
  127196. */
  127197. private _onBeforeCameraRenderObserver;
  127198. /**
  127199. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127200. * @param name Element's name, child elements will append suffixes for their own names.
  127201. * @param urlsOrVideo defines the url(s) or the video element to use
  127202. * @param options An object containing optional or exposed sub element properties
  127203. */
  127204. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127205. resolution?: number;
  127206. clickToPlay?: boolean;
  127207. autoPlay?: boolean;
  127208. loop?: boolean;
  127209. size?: number;
  127210. poster?: string;
  127211. faceForward?: boolean;
  127212. useDirectMapping?: boolean;
  127213. halfDomeMode?: boolean;
  127214. }, scene: Scene);
  127215. private _changeVideoMode;
  127216. /**
  127217. * Releases resources associated with this node.
  127218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127220. */
  127221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127222. }
  127223. }
  127224. declare module BABYLON {
  127225. /**
  127226. * This class can be used to get instrumentation data from a Babylon engine
  127227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127228. */
  127229. export class EngineInstrumentation implements IDisposable {
  127230. /**
  127231. * Define the instrumented engine.
  127232. */
  127233. engine: Engine;
  127234. private _captureGPUFrameTime;
  127235. private _gpuFrameTimeToken;
  127236. private _gpuFrameTime;
  127237. private _captureShaderCompilationTime;
  127238. private _shaderCompilationTime;
  127239. private _onBeginFrameObserver;
  127240. private _onEndFrameObserver;
  127241. private _onBeforeShaderCompilationObserver;
  127242. private _onAfterShaderCompilationObserver;
  127243. /**
  127244. * Gets the perf counter used for GPU frame time
  127245. */
  127246. get gpuFrameTimeCounter(): PerfCounter;
  127247. /**
  127248. * Gets the GPU frame time capture status
  127249. */
  127250. get captureGPUFrameTime(): boolean;
  127251. /**
  127252. * Enable or disable the GPU frame time capture
  127253. */
  127254. set captureGPUFrameTime(value: boolean);
  127255. /**
  127256. * Gets the perf counter used for shader compilation time
  127257. */
  127258. get shaderCompilationTimeCounter(): PerfCounter;
  127259. /**
  127260. * Gets the shader compilation time capture status
  127261. */
  127262. get captureShaderCompilationTime(): boolean;
  127263. /**
  127264. * Enable or disable the shader compilation time capture
  127265. */
  127266. set captureShaderCompilationTime(value: boolean);
  127267. /**
  127268. * Instantiates a new engine instrumentation.
  127269. * This class can be used to get instrumentation data from a Babylon engine
  127270. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127271. * @param engine Defines the engine to instrument
  127272. */
  127273. constructor(
  127274. /**
  127275. * Define the instrumented engine.
  127276. */
  127277. engine: Engine);
  127278. /**
  127279. * Dispose and release associated resources.
  127280. */
  127281. dispose(): void;
  127282. }
  127283. }
  127284. declare module BABYLON {
  127285. /**
  127286. * This class can be used to get instrumentation data from a Babylon engine
  127287. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127288. */
  127289. export class SceneInstrumentation implements IDisposable {
  127290. /**
  127291. * Defines the scene to instrument
  127292. */
  127293. scene: Scene;
  127294. private _captureActiveMeshesEvaluationTime;
  127295. private _activeMeshesEvaluationTime;
  127296. private _captureRenderTargetsRenderTime;
  127297. private _renderTargetsRenderTime;
  127298. private _captureFrameTime;
  127299. private _frameTime;
  127300. private _captureRenderTime;
  127301. private _renderTime;
  127302. private _captureInterFrameTime;
  127303. private _interFrameTime;
  127304. private _captureParticlesRenderTime;
  127305. private _particlesRenderTime;
  127306. private _captureSpritesRenderTime;
  127307. private _spritesRenderTime;
  127308. private _capturePhysicsTime;
  127309. private _physicsTime;
  127310. private _captureAnimationsTime;
  127311. private _animationsTime;
  127312. private _captureCameraRenderTime;
  127313. private _cameraRenderTime;
  127314. private _onBeforeActiveMeshesEvaluationObserver;
  127315. private _onAfterActiveMeshesEvaluationObserver;
  127316. private _onBeforeRenderTargetsRenderObserver;
  127317. private _onAfterRenderTargetsRenderObserver;
  127318. private _onAfterRenderObserver;
  127319. private _onBeforeDrawPhaseObserver;
  127320. private _onAfterDrawPhaseObserver;
  127321. private _onBeforeAnimationsObserver;
  127322. private _onBeforeParticlesRenderingObserver;
  127323. private _onAfterParticlesRenderingObserver;
  127324. private _onBeforeSpritesRenderingObserver;
  127325. private _onAfterSpritesRenderingObserver;
  127326. private _onBeforePhysicsObserver;
  127327. private _onAfterPhysicsObserver;
  127328. private _onAfterAnimationsObserver;
  127329. private _onBeforeCameraRenderObserver;
  127330. private _onAfterCameraRenderObserver;
  127331. /**
  127332. * Gets the perf counter used for active meshes evaluation time
  127333. */
  127334. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127335. /**
  127336. * Gets the active meshes evaluation time capture status
  127337. */
  127338. get captureActiveMeshesEvaluationTime(): boolean;
  127339. /**
  127340. * Enable or disable the active meshes evaluation time capture
  127341. */
  127342. set captureActiveMeshesEvaluationTime(value: boolean);
  127343. /**
  127344. * Gets the perf counter used for render targets render time
  127345. */
  127346. get renderTargetsRenderTimeCounter(): PerfCounter;
  127347. /**
  127348. * Gets the render targets render time capture status
  127349. */
  127350. get captureRenderTargetsRenderTime(): boolean;
  127351. /**
  127352. * Enable or disable the render targets render time capture
  127353. */
  127354. set captureRenderTargetsRenderTime(value: boolean);
  127355. /**
  127356. * Gets the perf counter used for particles render time
  127357. */
  127358. get particlesRenderTimeCounter(): PerfCounter;
  127359. /**
  127360. * Gets the particles render time capture status
  127361. */
  127362. get captureParticlesRenderTime(): boolean;
  127363. /**
  127364. * Enable or disable the particles render time capture
  127365. */
  127366. set captureParticlesRenderTime(value: boolean);
  127367. /**
  127368. * Gets the perf counter used for sprites render time
  127369. */
  127370. get spritesRenderTimeCounter(): PerfCounter;
  127371. /**
  127372. * Gets the sprites render time capture status
  127373. */
  127374. get captureSpritesRenderTime(): boolean;
  127375. /**
  127376. * Enable or disable the sprites render time capture
  127377. */
  127378. set captureSpritesRenderTime(value: boolean);
  127379. /**
  127380. * Gets the perf counter used for physics time
  127381. */
  127382. get physicsTimeCounter(): PerfCounter;
  127383. /**
  127384. * Gets the physics time capture status
  127385. */
  127386. get capturePhysicsTime(): boolean;
  127387. /**
  127388. * Enable or disable the physics time capture
  127389. */
  127390. set capturePhysicsTime(value: boolean);
  127391. /**
  127392. * Gets the perf counter used for animations time
  127393. */
  127394. get animationsTimeCounter(): PerfCounter;
  127395. /**
  127396. * Gets the animations time capture status
  127397. */
  127398. get captureAnimationsTime(): boolean;
  127399. /**
  127400. * Enable or disable the animations time capture
  127401. */
  127402. set captureAnimationsTime(value: boolean);
  127403. /**
  127404. * Gets the perf counter used for frame time capture
  127405. */
  127406. get frameTimeCounter(): PerfCounter;
  127407. /**
  127408. * Gets the frame time capture status
  127409. */
  127410. get captureFrameTime(): boolean;
  127411. /**
  127412. * Enable or disable the frame time capture
  127413. */
  127414. set captureFrameTime(value: boolean);
  127415. /**
  127416. * Gets the perf counter used for inter-frames time capture
  127417. */
  127418. get interFrameTimeCounter(): PerfCounter;
  127419. /**
  127420. * Gets the inter-frames time capture status
  127421. */
  127422. get captureInterFrameTime(): boolean;
  127423. /**
  127424. * Enable or disable the inter-frames time capture
  127425. */
  127426. set captureInterFrameTime(value: boolean);
  127427. /**
  127428. * Gets the perf counter used for render time capture
  127429. */
  127430. get renderTimeCounter(): PerfCounter;
  127431. /**
  127432. * Gets the render time capture status
  127433. */
  127434. get captureRenderTime(): boolean;
  127435. /**
  127436. * Enable or disable the render time capture
  127437. */
  127438. set captureRenderTime(value: boolean);
  127439. /**
  127440. * Gets the perf counter used for camera render time capture
  127441. */
  127442. get cameraRenderTimeCounter(): PerfCounter;
  127443. /**
  127444. * Gets the camera render time capture status
  127445. */
  127446. get captureCameraRenderTime(): boolean;
  127447. /**
  127448. * Enable or disable the camera render time capture
  127449. */
  127450. set captureCameraRenderTime(value: boolean);
  127451. /**
  127452. * Gets the perf counter used for draw calls
  127453. */
  127454. get drawCallsCounter(): PerfCounter;
  127455. /**
  127456. * Instantiates a new scene instrumentation.
  127457. * This class can be used to get instrumentation data from a Babylon engine
  127458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127459. * @param scene Defines the scene to instrument
  127460. */
  127461. constructor(
  127462. /**
  127463. * Defines the scene to instrument
  127464. */
  127465. scene: Scene);
  127466. /**
  127467. * Dispose and release associated resources.
  127468. */
  127469. dispose(): void;
  127470. }
  127471. }
  127472. declare module BABYLON {
  127473. /** @hidden */
  127474. export var glowMapGenerationPixelShader: {
  127475. name: string;
  127476. shader: string;
  127477. };
  127478. }
  127479. declare module BABYLON {
  127480. /** @hidden */
  127481. export var glowMapGenerationVertexShader: {
  127482. name: string;
  127483. shader: string;
  127484. };
  127485. }
  127486. declare module BABYLON {
  127487. /**
  127488. * Effect layer options. This helps customizing the behaviour
  127489. * of the effect layer.
  127490. */
  127491. export interface IEffectLayerOptions {
  127492. /**
  127493. * Multiplication factor apply to the canvas size to compute the render target size
  127494. * used to generated the objects (the smaller the faster).
  127495. */
  127496. mainTextureRatio: number;
  127497. /**
  127498. * Enforces a fixed size texture to ensure effect stability across devices.
  127499. */
  127500. mainTextureFixedSize?: number;
  127501. /**
  127502. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127503. */
  127504. alphaBlendingMode: number;
  127505. /**
  127506. * The camera attached to the layer.
  127507. */
  127508. camera: Nullable<Camera>;
  127509. /**
  127510. * The rendering group to draw the layer in.
  127511. */
  127512. renderingGroupId: number;
  127513. }
  127514. /**
  127515. * The effect layer Helps adding post process effect blended with the main pass.
  127516. *
  127517. * This can be for instance use to generate glow or higlight effects on the scene.
  127518. *
  127519. * The effect layer class can not be used directly and is intented to inherited from to be
  127520. * customized per effects.
  127521. */
  127522. export abstract class EffectLayer {
  127523. private _vertexBuffers;
  127524. private _indexBuffer;
  127525. private _cachedDefines;
  127526. private _effectLayerMapGenerationEffect;
  127527. private _effectLayerOptions;
  127528. private _mergeEffect;
  127529. protected _scene: Scene;
  127530. protected _engine: Engine;
  127531. protected _maxSize: number;
  127532. protected _mainTextureDesiredSize: ISize;
  127533. protected _mainTexture: RenderTargetTexture;
  127534. protected _shouldRender: boolean;
  127535. protected _postProcesses: PostProcess[];
  127536. protected _textures: BaseTexture[];
  127537. protected _emissiveTextureAndColor: {
  127538. texture: Nullable<BaseTexture>;
  127539. color: Color4;
  127540. };
  127541. /**
  127542. * The name of the layer
  127543. */
  127544. name: string;
  127545. /**
  127546. * The clear color of the texture used to generate the glow map.
  127547. */
  127548. neutralColor: Color4;
  127549. /**
  127550. * Specifies whether the highlight layer is enabled or not.
  127551. */
  127552. isEnabled: boolean;
  127553. /**
  127554. * Gets the camera attached to the layer.
  127555. */
  127556. get camera(): Nullable<Camera>;
  127557. /**
  127558. * Gets the rendering group id the layer should render in.
  127559. */
  127560. get renderingGroupId(): number;
  127561. set renderingGroupId(renderingGroupId: number);
  127562. /**
  127563. * An event triggered when the effect layer has been disposed.
  127564. */
  127565. onDisposeObservable: Observable<EffectLayer>;
  127566. /**
  127567. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127568. */
  127569. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127570. /**
  127571. * An event triggered when the generated texture is being merged in the scene.
  127572. */
  127573. onBeforeComposeObservable: Observable<EffectLayer>;
  127574. /**
  127575. * An event triggered when the mesh is rendered into the effect render target.
  127576. */
  127577. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127578. /**
  127579. * An event triggered after the mesh has been rendered into the effect render target.
  127580. */
  127581. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127582. /**
  127583. * An event triggered when the generated texture has been merged in the scene.
  127584. */
  127585. onAfterComposeObservable: Observable<EffectLayer>;
  127586. /**
  127587. * An event triggered when the efffect layer changes its size.
  127588. */
  127589. onSizeChangedObservable: Observable<EffectLayer>;
  127590. /** @hidden */
  127591. static _SceneComponentInitialization: (scene: Scene) => void;
  127592. /**
  127593. * Instantiates a new effect Layer and references it in the scene.
  127594. * @param name The name of the layer
  127595. * @param scene The scene to use the layer in
  127596. */
  127597. constructor(
  127598. /** The Friendly of the effect in the scene */
  127599. name: string, scene: Scene);
  127600. /**
  127601. * Get the effect name of the layer.
  127602. * @return The effect name
  127603. */
  127604. abstract getEffectName(): string;
  127605. /**
  127606. * Checks for the readiness of the element composing the layer.
  127607. * @param subMesh the mesh to check for
  127608. * @param useInstances specify whether or not to use instances to render the mesh
  127609. * @return true if ready otherwise, false
  127610. */
  127611. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127612. /**
  127613. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127614. * @returns true if the effect requires stencil during the main canvas render pass.
  127615. */
  127616. abstract needStencil(): boolean;
  127617. /**
  127618. * Create the merge effect. This is the shader use to blit the information back
  127619. * to the main canvas at the end of the scene rendering.
  127620. * @returns The effect containing the shader used to merge the effect on the main canvas
  127621. */
  127622. protected abstract _createMergeEffect(): Effect;
  127623. /**
  127624. * Creates the render target textures and post processes used in the effect layer.
  127625. */
  127626. protected abstract _createTextureAndPostProcesses(): void;
  127627. /**
  127628. * Implementation specific of rendering the generating effect on the main canvas.
  127629. * @param effect The effect used to render through
  127630. */
  127631. protected abstract _internalRender(effect: Effect): void;
  127632. /**
  127633. * Sets the required values for both the emissive texture and and the main color.
  127634. */
  127635. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127636. /**
  127637. * Free any resources and references associated to a mesh.
  127638. * Internal use
  127639. * @param mesh The mesh to free.
  127640. */
  127641. abstract _disposeMesh(mesh: Mesh): void;
  127642. /**
  127643. * Serializes this layer (Glow or Highlight for example)
  127644. * @returns a serialized layer object
  127645. */
  127646. abstract serialize?(): any;
  127647. /**
  127648. * Initializes the effect layer with the required options.
  127649. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127650. */
  127651. protected _init(options: Partial<IEffectLayerOptions>): void;
  127652. /**
  127653. * Generates the index buffer of the full screen quad blending to the main canvas.
  127654. */
  127655. private _generateIndexBuffer;
  127656. /**
  127657. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127658. */
  127659. private _generateVertexBuffer;
  127660. /**
  127661. * Sets the main texture desired size which is the closest power of two
  127662. * of the engine canvas size.
  127663. */
  127664. private _setMainTextureSize;
  127665. /**
  127666. * Creates the main texture for the effect layer.
  127667. */
  127668. protected _createMainTexture(): void;
  127669. /**
  127670. * Adds specific effects defines.
  127671. * @param defines The defines to add specifics to.
  127672. */
  127673. protected _addCustomEffectDefines(defines: string[]): void;
  127674. /**
  127675. * Checks for the readiness of the element composing the layer.
  127676. * @param subMesh the mesh to check for
  127677. * @param useInstances specify whether or not to use instances to render the mesh
  127678. * @param emissiveTexture the associated emissive texture used to generate the glow
  127679. * @return true if ready otherwise, false
  127680. */
  127681. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127682. /**
  127683. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127684. */
  127685. render(): void;
  127686. /**
  127687. * Determine if a given mesh will be used in the current effect.
  127688. * @param mesh mesh to test
  127689. * @returns true if the mesh will be used
  127690. */
  127691. hasMesh(mesh: AbstractMesh): boolean;
  127692. /**
  127693. * Returns true if the layer contains information to display, otherwise false.
  127694. * @returns true if the glow layer should be rendered
  127695. */
  127696. shouldRender(): boolean;
  127697. /**
  127698. * Returns true if the mesh should render, otherwise false.
  127699. * @param mesh The mesh to render
  127700. * @returns true if it should render otherwise false
  127701. */
  127702. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127703. /**
  127704. * Returns true if the mesh can be rendered, otherwise false.
  127705. * @param mesh The mesh to render
  127706. * @param material The material used on the mesh
  127707. * @returns true if it can be rendered otherwise false
  127708. */
  127709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127710. /**
  127711. * Returns true if the mesh should render, otherwise false.
  127712. * @param mesh The mesh to render
  127713. * @returns true if it should render otherwise false
  127714. */
  127715. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127716. /**
  127717. * Renders the submesh passed in parameter to the generation map.
  127718. */
  127719. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127720. /**
  127721. * Defines whether the current material of the mesh should be use to render the effect.
  127722. * @param mesh defines the current mesh to render
  127723. */
  127724. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127725. /**
  127726. * Rebuild the required buffers.
  127727. * @hidden Internal use only.
  127728. */
  127729. _rebuild(): void;
  127730. /**
  127731. * Dispose only the render target textures and post process.
  127732. */
  127733. private _disposeTextureAndPostProcesses;
  127734. /**
  127735. * Dispose the highlight layer and free resources.
  127736. */
  127737. dispose(): void;
  127738. /**
  127739. * Gets the class name of the effect layer
  127740. * @returns the string with the class name of the effect layer
  127741. */
  127742. getClassName(): string;
  127743. /**
  127744. * Creates an effect layer from parsed effect layer data
  127745. * @param parsedEffectLayer defines effect layer data
  127746. * @param scene defines the current scene
  127747. * @param rootUrl defines the root URL containing the effect layer information
  127748. * @returns a parsed effect Layer
  127749. */
  127750. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127751. }
  127752. }
  127753. declare module BABYLON {
  127754. interface AbstractScene {
  127755. /**
  127756. * The list of effect layers (highlights/glow) added to the scene
  127757. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127758. * @see http://doc.babylonjs.com/how_to/glow_layer
  127759. */
  127760. effectLayers: Array<EffectLayer>;
  127761. /**
  127762. * Removes the given effect layer from this scene.
  127763. * @param toRemove defines the effect layer to remove
  127764. * @returns the index of the removed effect layer
  127765. */
  127766. removeEffectLayer(toRemove: EffectLayer): number;
  127767. /**
  127768. * Adds the given effect layer to this scene
  127769. * @param newEffectLayer defines the effect layer to add
  127770. */
  127771. addEffectLayer(newEffectLayer: EffectLayer): void;
  127772. }
  127773. /**
  127774. * Defines the layer scene component responsible to manage any effect layers
  127775. * in a given scene.
  127776. */
  127777. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127778. /**
  127779. * The component name helpfull to identify the component in the list of scene components.
  127780. */
  127781. readonly name: string;
  127782. /**
  127783. * The scene the component belongs to.
  127784. */
  127785. scene: Scene;
  127786. private _engine;
  127787. private _renderEffects;
  127788. private _needStencil;
  127789. private _previousStencilState;
  127790. /**
  127791. * Creates a new instance of the component for the given scene
  127792. * @param scene Defines the scene to register the component in
  127793. */
  127794. constructor(scene: Scene);
  127795. /**
  127796. * Registers the component in a given scene
  127797. */
  127798. register(): void;
  127799. /**
  127800. * Rebuilds the elements related to this component in case of
  127801. * context lost for instance.
  127802. */
  127803. rebuild(): void;
  127804. /**
  127805. * Serializes the component data to the specified json object
  127806. * @param serializationObject The object to serialize to
  127807. */
  127808. serialize(serializationObject: any): void;
  127809. /**
  127810. * Adds all the elements from the container to the scene
  127811. * @param container the container holding the elements
  127812. */
  127813. addFromContainer(container: AbstractScene): void;
  127814. /**
  127815. * Removes all the elements in the container from the scene
  127816. * @param container contains the elements to remove
  127817. * @param dispose if the removed element should be disposed (default: false)
  127818. */
  127819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127820. /**
  127821. * Disposes the component and the associated ressources.
  127822. */
  127823. dispose(): void;
  127824. private _isReadyForMesh;
  127825. private _renderMainTexture;
  127826. private _setStencil;
  127827. private _setStencilBack;
  127828. private _draw;
  127829. private _drawCamera;
  127830. private _drawRenderingGroup;
  127831. }
  127832. }
  127833. declare module BABYLON {
  127834. /** @hidden */
  127835. export var glowMapMergePixelShader: {
  127836. name: string;
  127837. shader: string;
  127838. };
  127839. }
  127840. declare module BABYLON {
  127841. /** @hidden */
  127842. export var glowMapMergeVertexShader: {
  127843. name: string;
  127844. shader: string;
  127845. };
  127846. }
  127847. declare module BABYLON {
  127848. interface AbstractScene {
  127849. /**
  127850. * Return a the first highlight layer of the scene with a given name.
  127851. * @param name The name of the highlight layer to look for.
  127852. * @return The highlight layer if found otherwise null.
  127853. */
  127854. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127855. }
  127856. /**
  127857. * Glow layer options. This helps customizing the behaviour
  127858. * of the glow layer.
  127859. */
  127860. export interface IGlowLayerOptions {
  127861. /**
  127862. * Multiplication factor apply to the canvas size to compute the render target size
  127863. * used to generated the glowing objects (the smaller the faster).
  127864. */
  127865. mainTextureRatio: number;
  127866. /**
  127867. * Enforces a fixed size texture to ensure resize independant blur.
  127868. */
  127869. mainTextureFixedSize?: number;
  127870. /**
  127871. * How big is the kernel of the blur texture.
  127872. */
  127873. blurKernelSize: number;
  127874. /**
  127875. * The camera attached to the layer.
  127876. */
  127877. camera: Nullable<Camera>;
  127878. /**
  127879. * Enable MSAA by chosing the number of samples.
  127880. */
  127881. mainTextureSamples?: number;
  127882. /**
  127883. * The rendering group to draw the layer in.
  127884. */
  127885. renderingGroupId: number;
  127886. }
  127887. /**
  127888. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127889. *
  127890. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127891. *
  127892. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127893. */
  127894. export class GlowLayer extends EffectLayer {
  127895. /**
  127896. * Effect Name of the layer.
  127897. */
  127898. static readonly EffectName: string;
  127899. /**
  127900. * The default blur kernel size used for the glow.
  127901. */
  127902. static DefaultBlurKernelSize: number;
  127903. /**
  127904. * The default texture size ratio used for the glow.
  127905. */
  127906. static DefaultTextureRatio: number;
  127907. /**
  127908. * Sets the kernel size of the blur.
  127909. */
  127910. set blurKernelSize(value: number);
  127911. /**
  127912. * Gets the kernel size of the blur.
  127913. */
  127914. get blurKernelSize(): number;
  127915. /**
  127916. * Sets the glow intensity.
  127917. */
  127918. set intensity(value: number);
  127919. /**
  127920. * Gets the glow intensity.
  127921. */
  127922. get intensity(): number;
  127923. private _options;
  127924. private _intensity;
  127925. private _horizontalBlurPostprocess1;
  127926. private _verticalBlurPostprocess1;
  127927. private _horizontalBlurPostprocess2;
  127928. private _verticalBlurPostprocess2;
  127929. private _blurTexture1;
  127930. private _blurTexture2;
  127931. private _postProcesses1;
  127932. private _postProcesses2;
  127933. private _includedOnlyMeshes;
  127934. private _excludedMeshes;
  127935. private _meshesUsingTheirOwnMaterials;
  127936. /**
  127937. * Callback used to let the user override the color selection on a per mesh basis
  127938. */
  127939. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127940. /**
  127941. * Callback used to let the user override the texture selection on a per mesh basis
  127942. */
  127943. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127944. /**
  127945. * Instantiates a new glow Layer and references it to the scene.
  127946. * @param name The name of the layer
  127947. * @param scene The scene to use the layer in
  127948. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127949. */
  127950. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127951. /**
  127952. * Get the effect name of the layer.
  127953. * @return The effect name
  127954. */
  127955. getEffectName(): string;
  127956. /**
  127957. * Create the merge effect. This is the shader use to blit the information back
  127958. * to the main canvas at the end of the scene rendering.
  127959. */
  127960. protected _createMergeEffect(): Effect;
  127961. /**
  127962. * Creates the render target textures and post processes used in the glow layer.
  127963. */
  127964. protected _createTextureAndPostProcesses(): void;
  127965. /**
  127966. * Checks for the readiness of the element composing the layer.
  127967. * @param subMesh the mesh to check for
  127968. * @param useInstances specify wether or not to use instances to render the mesh
  127969. * @param emissiveTexture the associated emissive texture used to generate the glow
  127970. * @return true if ready otherwise, false
  127971. */
  127972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127973. /**
  127974. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127975. */
  127976. needStencil(): boolean;
  127977. /**
  127978. * Returns true if the mesh can be rendered, otherwise false.
  127979. * @param mesh The mesh to render
  127980. * @param material The material used on the mesh
  127981. * @returns true if it can be rendered otherwise false
  127982. */
  127983. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127984. /**
  127985. * Implementation specific of rendering the generating effect on the main canvas.
  127986. * @param effect The effect used to render through
  127987. */
  127988. protected _internalRender(effect: Effect): void;
  127989. /**
  127990. * Sets the required values for both the emissive texture and and the main color.
  127991. */
  127992. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127993. /**
  127994. * Returns true if the mesh should render, otherwise false.
  127995. * @param mesh The mesh to render
  127996. * @returns true if it should render otherwise false
  127997. */
  127998. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127999. /**
  128000. * Adds specific effects defines.
  128001. * @param defines The defines to add specifics to.
  128002. */
  128003. protected _addCustomEffectDefines(defines: string[]): void;
  128004. /**
  128005. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128006. * @param mesh The mesh to exclude from the glow layer
  128007. */
  128008. addExcludedMesh(mesh: Mesh): void;
  128009. /**
  128010. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128011. * @param mesh The mesh to remove
  128012. */
  128013. removeExcludedMesh(mesh: Mesh): void;
  128014. /**
  128015. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128016. * @param mesh The mesh to include in the glow layer
  128017. */
  128018. addIncludedOnlyMesh(mesh: Mesh): void;
  128019. /**
  128020. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128021. * @param mesh The mesh to remove
  128022. */
  128023. removeIncludedOnlyMesh(mesh: Mesh): void;
  128024. /**
  128025. * Determine if a given mesh will be used in the glow layer
  128026. * @param mesh The mesh to test
  128027. * @returns true if the mesh will be highlighted by the current glow layer
  128028. */
  128029. hasMesh(mesh: AbstractMesh): boolean;
  128030. /**
  128031. * Defines whether the current material of the mesh should be use to render the effect.
  128032. * @param mesh defines the current mesh to render
  128033. */
  128034. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128035. /**
  128036. * Add a mesh to be rendered through its own material and not with emissive only.
  128037. * @param mesh The mesh for which we need to use its material
  128038. */
  128039. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128040. /**
  128041. * Remove a mesh from being rendered through its own material and not with emissive only.
  128042. * @param mesh The mesh for which we need to not use its material
  128043. */
  128044. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128045. /**
  128046. * Free any resources and references associated to a mesh.
  128047. * Internal use
  128048. * @param mesh The mesh to free.
  128049. * @hidden
  128050. */
  128051. _disposeMesh(mesh: Mesh): void;
  128052. /**
  128053. * Gets the class name of the effect layer
  128054. * @returns the string with the class name of the effect layer
  128055. */
  128056. getClassName(): string;
  128057. /**
  128058. * Serializes this glow layer
  128059. * @returns a serialized glow layer object
  128060. */
  128061. serialize(): any;
  128062. /**
  128063. * Creates a Glow Layer from parsed glow layer data
  128064. * @param parsedGlowLayer defines glow layer data
  128065. * @param scene defines the current scene
  128066. * @param rootUrl defines the root URL containing the glow layer information
  128067. * @returns a parsed Glow Layer
  128068. */
  128069. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128070. }
  128071. }
  128072. declare module BABYLON {
  128073. /** @hidden */
  128074. export var glowBlurPostProcessPixelShader: {
  128075. name: string;
  128076. shader: string;
  128077. };
  128078. }
  128079. declare module BABYLON {
  128080. interface AbstractScene {
  128081. /**
  128082. * Return a the first highlight layer of the scene with a given name.
  128083. * @param name The name of the highlight layer to look for.
  128084. * @return The highlight layer if found otherwise null.
  128085. */
  128086. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128087. }
  128088. /**
  128089. * Highlight layer options. This helps customizing the behaviour
  128090. * of the highlight layer.
  128091. */
  128092. export interface IHighlightLayerOptions {
  128093. /**
  128094. * Multiplication factor apply to the canvas size to compute the render target size
  128095. * used to generated the glowing objects (the smaller the faster).
  128096. */
  128097. mainTextureRatio: number;
  128098. /**
  128099. * Enforces a fixed size texture to ensure resize independant blur.
  128100. */
  128101. mainTextureFixedSize?: number;
  128102. /**
  128103. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128104. * of the picture to blur (the smaller the faster).
  128105. */
  128106. blurTextureSizeRatio: number;
  128107. /**
  128108. * How big in texel of the blur texture is the vertical blur.
  128109. */
  128110. blurVerticalSize: number;
  128111. /**
  128112. * How big in texel of the blur texture is the horizontal blur.
  128113. */
  128114. blurHorizontalSize: number;
  128115. /**
  128116. * Alpha blending mode used to apply the blur. Default is combine.
  128117. */
  128118. alphaBlendingMode: number;
  128119. /**
  128120. * The camera attached to the layer.
  128121. */
  128122. camera: Nullable<Camera>;
  128123. /**
  128124. * Should we display highlight as a solid stroke?
  128125. */
  128126. isStroke?: boolean;
  128127. /**
  128128. * The rendering group to draw the layer in.
  128129. */
  128130. renderingGroupId: number;
  128131. }
  128132. /**
  128133. * The highlight layer Helps adding a glow effect around a mesh.
  128134. *
  128135. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128136. * glowy meshes to your scene.
  128137. *
  128138. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128139. */
  128140. export class HighlightLayer extends EffectLayer {
  128141. name: string;
  128142. /**
  128143. * Effect Name of the highlight layer.
  128144. */
  128145. static readonly EffectName: string;
  128146. /**
  128147. * The neutral color used during the preparation of the glow effect.
  128148. * This is black by default as the blend operation is a blend operation.
  128149. */
  128150. static NeutralColor: Color4;
  128151. /**
  128152. * Stencil value used for glowing meshes.
  128153. */
  128154. static GlowingMeshStencilReference: number;
  128155. /**
  128156. * Stencil value used for the other meshes in the scene.
  128157. */
  128158. static NormalMeshStencilReference: number;
  128159. /**
  128160. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128161. */
  128162. innerGlow: boolean;
  128163. /**
  128164. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128165. */
  128166. outerGlow: boolean;
  128167. /**
  128168. * Specifies the horizontal size of the blur.
  128169. */
  128170. set blurHorizontalSize(value: number);
  128171. /**
  128172. * Specifies the vertical size of the blur.
  128173. */
  128174. set blurVerticalSize(value: number);
  128175. /**
  128176. * Gets the horizontal size of the blur.
  128177. */
  128178. get blurHorizontalSize(): number;
  128179. /**
  128180. * Gets the vertical size of the blur.
  128181. */
  128182. get blurVerticalSize(): number;
  128183. /**
  128184. * An event triggered when the highlight layer is being blurred.
  128185. */
  128186. onBeforeBlurObservable: Observable<HighlightLayer>;
  128187. /**
  128188. * An event triggered when the highlight layer has been blurred.
  128189. */
  128190. onAfterBlurObservable: Observable<HighlightLayer>;
  128191. private _instanceGlowingMeshStencilReference;
  128192. private _options;
  128193. private _downSamplePostprocess;
  128194. private _horizontalBlurPostprocess;
  128195. private _verticalBlurPostprocess;
  128196. private _blurTexture;
  128197. private _meshes;
  128198. private _excludedMeshes;
  128199. /**
  128200. * Instantiates a new highlight Layer and references it to the scene..
  128201. * @param name The name of the layer
  128202. * @param scene The scene to use the layer in
  128203. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128204. */
  128205. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128206. /**
  128207. * Get the effect name of the layer.
  128208. * @return The effect name
  128209. */
  128210. getEffectName(): string;
  128211. /**
  128212. * Create the merge effect. This is the shader use to blit the information back
  128213. * to the main canvas at the end of the scene rendering.
  128214. */
  128215. protected _createMergeEffect(): Effect;
  128216. /**
  128217. * Creates the render target textures and post processes used in the highlight layer.
  128218. */
  128219. protected _createTextureAndPostProcesses(): void;
  128220. /**
  128221. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128222. */
  128223. needStencil(): boolean;
  128224. /**
  128225. * Checks for the readiness of the element composing the layer.
  128226. * @param subMesh the mesh to check for
  128227. * @param useInstances specify wether or not to use instances to render the mesh
  128228. * @param emissiveTexture the associated emissive texture used to generate the glow
  128229. * @return true if ready otherwise, false
  128230. */
  128231. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128232. /**
  128233. * Implementation specific of rendering the generating effect on the main canvas.
  128234. * @param effect The effect used to render through
  128235. */
  128236. protected _internalRender(effect: Effect): void;
  128237. /**
  128238. * Returns true if the layer contains information to display, otherwise false.
  128239. */
  128240. shouldRender(): boolean;
  128241. /**
  128242. * Returns true if the mesh should render, otherwise false.
  128243. * @param mesh The mesh to render
  128244. * @returns true if it should render otherwise false
  128245. */
  128246. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128247. /**
  128248. * Sets the required values for both the emissive texture and and the main color.
  128249. */
  128250. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128251. /**
  128252. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128253. * @param mesh The mesh to exclude from the highlight layer
  128254. */
  128255. addExcludedMesh(mesh: Mesh): void;
  128256. /**
  128257. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128258. * @param mesh The mesh to highlight
  128259. */
  128260. removeExcludedMesh(mesh: Mesh): void;
  128261. /**
  128262. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128263. * @param mesh mesh to test
  128264. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128265. */
  128266. hasMesh(mesh: AbstractMesh): boolean;
  128267. /**
  128268. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128269. * @param mesh The mesh to highlight
  128270. * @param color The color of the highlight
  128271. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128272. */
  128273. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128274. /**
  128275. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128276. * @param mesh The mesh to highlight
  128277. */
  128278. removeMesh(mesh: Mesh): void;
  128279. /**
  128280. * Remove all the meshes currently referenced in the highlight layer
  128281. */
  128282. removeAllMeshes(): void;
  128283. /**
  128284. * Force the stencil to the normal expected value for none glowing parts
  128285. */
  128286. private _defaultStencilReference;
  128287. /**
  128288. * Free any resources and references associated to a mesh.
  128289. * Internal use
  128290. * @param mesh The mesh to free.
  128291. * @hidden
  128292. */
  128293. _disposeMesh(mesh: Mesh): void;
  128294. /**
  128295. * Dispose the highlight layer and free resources.
  128296. */
  128297. dispose(): void;
  128298. /**
  128299. * Gets the class name of the effect layer
  128300. * @returns the string with the class name of the effect layer
  128301. */
  128302. getClassName(): string;
  128303. /**
  128304. * Serializes this Highlight layer
  128305. * @returns a serialized Highlight layer object
  128306. */
  128307. serialize(): any;
  128308. /**
  128309. * Creates a Highlight layer from parsed Highlight layer data
  128310. * @param parsedHightlightLayer defines the Highlight layer data
  128311. * @param scene defines the current scene
  128312. * @param rootUrl defines the root URL containing the Highlight layer information
  128313. * @returns a parsed Highlight layer
  128314. */
  128315. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128316. }
  128317. }
  128318. declare module BABYLON {
  128319. interface AbstractScene {
  128320. /**
  128321. * The list of layers (background and foreground) of the scene
  128322. */
  128323. layers: Array<Layer>;
  128324. }
  128325. /**
  128326. * Defines the layer scene component responsible to manage any layers
  128327. * in a given scene.
  128328. */
  128329. export class LayerSceneComponent implements ISceneComponent {
  128330. /**
  128331. * The component name helpfull to identify the component in the list of scene components.
  128332. */
  128333. readonly name: string;
  128334. /**
  128335. * The scene the component belongs to.
  128336. */
  128337. scene: Scene;
  128338. private _engine;
  128339. /**
  128340. * Creates a new instance of the component for the given scene
  128341. * @param scene Defines the scene to register the component in
  128342. */
  128343. constructor(scene: Scene);
  128344. /**
  128345. * Registers the component in a given scene
  128346. */
  128347. register(): void;
  128348. /**
  128349. * Rebuilds the elements related to this component in case of
  128350. * context lost for instance.
  128351. */
  128352. rebuild(): void;
  128353. /**
  128354. * Disposes the component and the associated ressources.
  128355. */
  128356. dispose(): void;
  128357. private _draw;
  128358. private _drawCameraPredicate;
  128359. private _drawCameraBackground;
  128360. private _drawCameraForeground;
  128361. private _drawRenderTargetPredicate;
  128362. private _drawRenderTargetBackground;
  128363. private _drawRenderTargetForeground;
  128364. /**
  128365. * Adds all the elements from the container to the scene
  128366. * @param container the container holding the elements
  128367. */
  128368. addFromContainer(container: AbstractScene): void;
  128369. /**
  128370. * Removes all the elements in the container from the scene
  128371. * @param container contains the elements to remove
  128372. * @param dispose if the removed element should be disposed (default: false)
  128373. */
  128374. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128375. }
  128376. }
  128377. declare module BABYLON {
  128378. /** @hidden */
  128379. export var layerPixelShader: {
  128380. name: string;
  128381. shader: string;
  128382. };
  128383. }
  128384. declare module BABYLON {
  128385. /** @hidden */
  128386. export var layerVertexShader: {
  128387. name: string;
  128388. shader: string;
  128389. };
  128390. }
  128391. declare module BABYLON {
  128392. /**
  128393. * This represents a full screen 2d layer.
  128394. * This can be useful to display a picture in the background of your scene for instance.
  128395. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128396. */
  128397. export class Layer {
  128398. /**
  128399. * Define the name of the layer.
  128400. */
  128401. name: string;
  128402. /**
  128403. * Define the texture the layer should display.
  128404. */
  128405. texture: Nullable<Texture>;
  128406. /**
  128407. * Is the layer in background or foreground.
  128408. */
  128409. isBackground: boolean;
  128410. /**
  128411. * Define the color of the layer (instead of texture).
  128412. */
  128413. color: Color4;
  128414. /**
  128415. * Define the scale of the layer in order to zoom in out of the texture.
  128416. */
  128417. scale: Vector2;
  128418. /**
  128419. * Define an offset for the layer in order to shift the texture.
  128420. */
  128421. offset: Vector2;
  128422. /**
  128423. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128424. */
  128425. alphaBlendingMode: number;
  128426. /**
  128427. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128428. * Alpha test will not mix with the background color in case of transparency.
  128429. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128430. */
  128431. alphaTest: boolean;
  128432. /**
  128433. * Define a mask to restrict the layer to only some of the scene cameras.
  128434. */
  128435. layerMask: number;
  128436. /**
  128437. * Define the list of render target the layer is visible into.
  128438. */
  128439. renderTargetTextures: RenderTargetTexture[];
  128440. /**
  128441. * Define if the layer is only used in renderTarget or if it also
  128442. * renders in the main frame buffer of the canvas.
  128443. */
  128444. renderOnlyInRenderTargetTextures: boolean;
  128445. private _scene;
  128446. private _vertexBuffers;
  128447. private _indexBuffer;
  128448. private _effect;
  128449. private _previousDefines;
  128450. /**
  128451. * An event triggered when the layer is disposed.
  128452. */
  128453. onDisposeObservable: Observable<Layer>;
  128454. private _onDisposeObserver;
  128455. /**
  128456. * Back compatibility with callback before the onDisposeObservable existed.
  128457. * The set callback will be triggered when the layer has been disposed.
  128458. */
  128459. set onDispose(callback: () => void);
  128460. /**
  128461. * An event triggered before rendering the scene
  128462. */
  128463. onBeforeRenderObservable: Observable<Layer>;
  128464. private _onBeforeRenderObserver;
  128465. /**
  128466. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128467. * The set callback will be triggered just before rendering the layer.
  128468. */
  128469. set onBeforeRender(callback: () => void);
  128470. /**
  128471. * An event triggered after rendering the scene
  128472. */
  128473. onAfterRenderObservable: Observable<Layer>;
  128474. private _onAfterRenderObserver;
  128475. /**
  128476. * Back compatibility with callback before the onAfterRenderObservable existed.
  128477. * The set callback will be triggered just after rendering the layer.
  128478. */
  128479. set onAfterRender(callback: () => void);
  128480. /**
  128481. * Instantiates a new layer.
  128482. * This represents a full screen 2d layer.
  128483. * This can be useful to display a picture in the background of your scene for instance.
  128484. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128485. * @param name Define the name of the layer in the scene
  128486. * @param imgUrl Define the url of the texture to display in the layer
  128487. * @param scene Define the scene the layer belongs to
  128488. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128489. * @param color Defines a color for the layer
  128490. */
  128491. constructor(
  128492. /**
  128493. * Define the name of the layer.
  128494. */
  128495. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128496. private _createIndexBuffer;
  128497. /** @hidden */
  128498. _rebuild(): void;
  128499. /**
  128500. * Renders the layer in the scene.
  128501. */
  128502. render(): void;
  128503. /**
  128504. * Disposes and releases the associated ressources.
  128505. */
  128506. dispose(): void;
  128507. }
  128508. }
  128509. declare module BABYLON {
  128510. /** @hidden */
  128511. export var lensFlarePixelShader: {
  128512. name: string;
  128513. shader: string;
  128514. };
  128515. }
  128516. declare module BABYLON {
  128517. /** @hidden */
  128518. export var lensFlareVertexShader: {
  128519. name: string;
  128520. shader: string;
  128521. };
  128522. }
  128523. declare module BABYLON {
  128524. /**
  128525. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128526. * It is usually composed of several `lensFlare`.
  128527. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128528. */
  128529. export class LensFlareSystem {
  128530. /**
  128531. * Define the name of the lens flare system
  128532. */
  128533. name: string;
  128534. /**
  128535. * List of lens flares used in this system.
  128536. */
  128537. lensFlares: LensFlare[];
  128538. /**
  128539. * Define a limit from the border the lens flare can be visible.
  128540. */
  128541. borderLimit: number;
  128542. /**
  128543. * Define a viewport border we do not want to see the lens flare in.
  128544. */
  128545. viewportBorder: number;
  128546. /**
  128547. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128548. */
  128549. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128550. /**
  128551. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128552. */
  128553. layerMask: number;
  128554. /**
  128555. * Define the id of the lens flare system in the scene.
  128556. * (equal to name by default)
  128557. */
  128558. id: string;
  128559. private _scene;
  128560. private _emitter;
  128561. private _vertexBuffers;
  128562. private _indexBuffer;
  128563. private _effect;
  128564. private _positionX;
  128565. private _positionY;
  128566. private _isEnabled;
  128567. /** @hidden */
  128568. static _SceneComponentInitialization: (scene: Scene) => void;
  128569. /**
  128570. * Instantiates a lens flare system.
  128571. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128572. * It is usually composed of several `lensFlare`.
  128573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128574. * @param name Define the name of the lens flare system in the scene
  128575. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128576. * @param scene Define the scene the lens flare system belongs to
  128577. */
  128578. constructor(
  128579. /**
  128580. * Define the name of the lens flare system
  128581. */
  128582. name: string, emitter: any, scene: Scene);
  128583. /**
  128584. * Define if the lens flare system is enabled.
  128585. */
  128586. get isEnabled(): boolean;
  128587. set isEnabled(value: boolean);
  128588. /**
  128589. * Get the scene the effects belongs to.
  128590. * @returns the scene holding the lens flare system
  128591. */
  128592. getScene(): Scene;
  128593. /**
  128594. * Get the emitter of the lens flare system.
  128595. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128596. * @returns the emitter of the lens flare system
  128597. */
  128598. getEmitter(): any;
  128599. /**
  128600. * Set the emitter of the lens flare system.
  128601. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128602. * @param newEmitter Define the new emitter of the system
  128603. */
  128604. setEmitter(newEmitter: any): void;
  128605. /**
  128606. * Get the lens flare system emitter position.
  128607. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128608. * @returns the position
  128609. */
  128610. getEmitterPosition(): Vector3;
  128611. /**
  128612. * @hidden
  128613. */
  128614. computeEffectivePosition(globalViewport: Viewport): boolean;
  128615. /** @hidden */
  128616. _isVisible(): boolean;
  128617. /**
  128618. * @hidden
  128619. */
  128620. render(): boolean;
  128621. /**
  128622. * Dispose and release the lens flare with its associated resources.
  128623. */
  128624. dispose(): void;
  128625. /**
  128626. * Parse a lens flare system from a JSON repressentation
  128627. * @param parsedLensFlareSystem Define the JSON to parse
  128628. * @param scene Define the scene the parsed system should be instantiated in
  128629. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128630. * @returns the parsed system
  128631. */
  128632. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128633. /**
  128634. * Serialize the current Lens Flare System into a JSON representation.
  128635. * @returns the serialized JSON
  128636. */
  128637. serialize(): any;
  128638. }
  128639. }
  128640. declare module BABYLON {
  128641. /**
  128642. * This represents one of the lens effect in a `lensFlareSystem`.
  128643. * It controls one of the indiviual texture used in the effect.
  128644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128645. */
  128646. export class LensFlare {
  128647. /**
  128648. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128649. */
  128650. size: number;
  128651. /**
  128652. * 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.
  128653. */
  128654. position: number;
  128655. /**
  128656. * Define the lens color.
  128657. */
  128658. color: Color3;
  128659. /**
  128660. * Define the lens texture.
  128661. */
  128662. texture: Nullable<Texture>;
  128663. /**
  128664. * Define the alpha mode to render this particular lens.
  128665. */
  128666. alphaMode: number;
  128667. private _system;
  128668. /**
  128669. * Creates a new Lens Flare.
  128670. * This represents one of the lens effect in a `lensFlareSystem`.
  128671. * It controls one of the indiviual texture used in the effect.
  128672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128673. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128674. * @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.
  128675. * @param color Define the lens color
  128676. * @param imgUrl Define the lens texture url
  128677. * @param system Define the `lensFlareSystem` this flare is part of
  128678. * @returns The newly created Lens Flare
  128679. */
  128680. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128681. /**
  128682. * Instantiates a new Lens Flare.
  128683. * This represents one of the lens effect in a `lensFlareSystem`.
  128684. * It controls one of the indiviual texture used in the effect.
  128685. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128686. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128687. * @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.
  128688. * @param color Define the lens color
  128689. * @param imgUrl Define the lens texture url
  128690. * @param system Define the `lensFlareSystem` this flare is part of
  128691. */
  128692. constructor(
  128693. /**
  128694. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128695. */
  128696. size: number,
  128697. /**
  128698. * 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.
  128699. */
  128700. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128701. /**
  128702. * Dispose and release the lens flare with its associated resources.
  128703. */
  128704. dispose(): void;
  128705. }
  128706. }
  128707. declare module BABYLON {
  128708. interface AbstractScene {
  128709. /**
  128710. * The list of lens flare system added to the scene
  128711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128712. */
  128713. lensFlareSystems: Array<LensFlareSystem>;
  128714. /**
  128715. * Removes the given lens flare system from this scene.
  128716. * @param toRemove The lens flare system to remove
  128717. * @returns The index of the removed lens flare system
  128718. */
  128719. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128720. /**
  128721. * Adds the given lens flare system to this scene
  128722. * @param newLensFlareSystem The lens flare system to add
  128723. */
  128724. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128725. /**
  128726. * Gets a lens flare system using its name
  128727. * @param name defines the name to look for
  128728. * @returns the lens flare system or null if not found
  128729. */
  128730. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128731. /**
  128732. * Gets a lens flare system using its id
  128733. * @param id defines the id to look for
  128734. * @returns the lens flare system or null if not found
  128735. */
  128736. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128737. }
  128738. /**
  128739. * Defines the lens flare scene component responsible to manage any lens flares
  128740. * in a given scene.
  128741. */
  128742. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128743. /**
  128744. * The component name helpfull to identify the component in the list of scene components.
  128745. */
  128746. readonly name: string;
  128747. /**
  128748. * The scene the component belongs to.
  128749. */
  128750. scene: Scene;
  128751. /**
  128752. * Creates a new instance of the component for the given scene
  128753. * @param scene Defines the scene to register the component in
  128754. */
  128755. constructor(scene: Scene);
  128756. /**
  128757. * Registers the component in a given scene
  128758. */
  128759. register(): void;
  128760. /**
  128761. * Rebuilds the elements related to this component in case of
  128762. * context lost for instance.
  128763. */
  128764. rebuild(): void;
  128765. /**
  128766. * Adds all the elements from the container to the scene
  128767. * @param container the container holding the elements
  128768. */
  128769. addFromContainer(container: AbstractScene): void;
  128770. /**
  128771. * Removes all the elements in the container from the scene
  128772. * @param container contains the elements to remove
  128773. * @param dispose if the removed element should be disposed (default: false)
  128774. */
  128775. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128776. /**
  128777. * Serializes the component data to the specified json object
  128778. * @param serializationObject The object to serialize to
  128779. */
  128780. serialize(serializationObject: any): void;
  128781. /**
  128782. * Disposes the component and the associated ressources.
  128783. */
  128784. dispose(): void;
  128785. private _draw;
  128786. }
  128787. }
  128788. declare module BABYLON {
  128789. /** @hidden */
  128790. export var depthPixelShader: {
  128791. name: string;
  128792. shader: string;
  128793. };
  128794. }
  128795. declare module BABYLON {
  128796. /** @hidden */
  128797. export var depthVertexShader: {
  128798. name: string;
  128799. shader: string;
  128800. };
  128801. }
  128802. declare module BABYLON {
  128803. /**
  128804. * This represents a depth renderer in Babylon.
  128805. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128806. */
  128807. export class DepthRenderer {
  128808. private _scene;
  128809. private _depthMap;
  128810. private _effect;
  128811. private readonly _storeNonLinearDepth;
  128812. private readonly _clearColor;
  128813. /** Get if the depth renderer is using packed depth or not */
  128814. readonly isPacked: boolean;
  128815. private _cachedDefines;
  128816. private _camera;
  128817. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128818. enabled: boolean;
  128819. /**
  128820. * Specifiess that the depth renderer will only be used within
  128821. * the camera it is created for.
  128822. * This can help forcing its rendering during the camera processing.
  128823. */
  128824. useOnlyInActiveCamera: boolean;
  128825. /** @hidden */
  128826. static _SceneComponentInitialization: (scene: Scene) => void;
  128827. /**
  128828. * Instantiates a depth renderer
  128829. * @param scene The scene the renderer belongs to
  128830. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128831. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128832. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128833. */
  128834. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128835. /**
  128836. * Creates the depth rendering effect and checks if the effect is ready.
  128837. * @param subMesh The submesh to be used to render the depth map of
  128838. * @param useInstances If multiple world instances should be used
  128839. * @returns if the depth renderer is ready to render the depth map
  128840. */
  128841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128842. /**
  128843. * Gets the texture which the depth map will be written to.
  128844. * @returns The depth map texture
  128845. */
  128846. getDepthMap(): RenderTargetTexture;
  128847. /**
  128848. * Disposes of the depth renderer.
  128849. */
  128850. dispose(): void;
  128851. }
  128852. }
  128853. declare module BABYLON {
  128854. /** @hidden */
  128855. export var minmaxReduxPixelShader: {
  128856. name: string;
  128857. shader: string;
  128858. };
  128859. }
  128860. declare module BABYLON {
  128861. /**
  128862. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128863. * and maximum values from all values of the texture.
  128864. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128865. * The source values are read from the red channel of the texture.
  128866. */
  128867. export class MinMaxReducer {
  128868. /**
  128869. * Observable triggered when the computation has been performed
  128870. */
  128871. onAfterReductionPerformed: Observable<{
  128872. min: number;
  128873. max: number;
  128874. }>;
  128875. protected _camera: Camera;
  128876. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128877. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128878. protected _postProcessManager: PostProcessManager;
  128879. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128880. protected _forceFullscreenViewport: boolean;
  128881. /**
  128882. * Creates a min/max reducer
  128883. * @param camera The camera to use for the post processes
  128884. */
  128885. constructor(camera: Camera);
  128886. /**
  128887. * Gets the texture used to read the values from.
  128888. */
  128889. get sourceTexture(): Nullable<RenderTargetTexture>;
  128890. /**
  128891. * Sets the source texture to read the values from.
  128892. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128893. * because in such textures '1' value must not be taken into account to compute the maximum
  128894. * as this value is used to clear the texture.
  128895. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128896. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128897. * @param depthRedux Indicates if the texture is a depth texture or not
  128898. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128899. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128900. */
  128901. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128902. /**
  128903. * Defines the refresh rate of the computation.
  128904. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128905. */
  128906. get refreshRate(): number;
  128907. set refreshRate(value: number);
  128908. protected _activated: boolean;
  128909. /**
  128910. * Gets the activation status of the reducer
  128911. */
  128912. get activated(): boolean;
  128913. /**
  128914. * Activates the reduction computation.
  128915. * When activated, the observers registered in onAfterReductionPerformed are
  128916. * called after the compuation is performed
  128917. */
  128918. activate(): void;
  128919. /**
  128920. * Deactivates the reduction computation.
  128921. */
  128922. deactivate(): void;
  128923. /**
  128924. * Disposes the min/max reducer
  128925. * @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.
  128926. */
  128927. dispose(disposeAll?: boolean): void;
  128928. }
  128929. }
  128930. declare module BABYLON {
  128931. /**
  128932. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128933. */
  128934. export class DepthReducer extends MinMaxReducer {
  128935. private _depthRenderer;
  128936. private _depthRendererId;
  128937. /**
  128938. * Gets the depth renderer used for the computation.
  128939. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128940. */
  128941. get depthRenderer(): Nullable<DepthRenderer>;
  128942. /**
  128943. * Creates a depth reducer
  128944. * @param camera The camera used to render the depth texture
  128945. */
  128946. constructor(camera: Camera);
  128947. /**
  128948. * Sets the depth renderer to use to generate the depth map
  128949. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128950. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128951. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128952. */
  128953. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128954. /** @hidden */
  128955. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  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 depth 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. * A CSM implementation allowing casting shadows on large scenes.
  128976. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128977. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  128978. */
  128979. export class CascadedShadowGenerator extends ShadowGenerator {
  128980. private static readonly frustumCornersNDCSpace;
  128981. /**
  128982. * Name of the CSM class
  128983. */
  128984. static CLASSNAME: string;
  128985. /**
  128986. * Defines the default number of cascades used by the CSM.
  128987. */
  128988. static readonly DEFAULT_CASCADES_COUNT: number;
  128989. /**
  128990. * Defines the minimum number of cascades used by the CSM.
  128991. */
  128992. static readonly MIN_CASCADES_COUNT: number;
  128993. /**
  128994. * Defines the maximum number of cascades used by the CSM.
  128995. */
  128996. static readonly MAX_CASCADES_COUNT: number;
  128997. protected _validateFilter(filter: number): number;
  128998. /**
  128999. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129000. */
  129001. penumbraDarkness: number;
  129002. private _numCascades;
  129003. /**
  129004. * Gets or set the number of cascades used by the CSM.
  129005. */
  129006. get numCascades(): number;
  129007. set numCascades(value: number);
  129008. /**
  129009. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129010. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129011. */
  129012. stabilizeCascades: boolean;
  129013. private _freezeShadowCastersBoundingInfo;
  129014. private _freezeShadowCastersBoundingInfoObservable;
  129015. /**
  129016. * Enables or disables the shadow casters bounding info computation.
  129017. * If your shadow casters don't move, you can disable this feature.
  129018. * If it is enabled, the bounding box computation is done every frame.
  129019. */
  129020. get freezeShadowCastersBoundingInfo(): boolean;
  129021. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129022. private _scbiMin;
  129023. private _scbiMax;
  129024. protected _computeShadowCastersBoundingInfo(): void;
  129025. protected _shadowCastersBoundingInfo: BoundingInfo;
  129026. /**
  129027. * Gets or sets the shadow casters bounding info.
  129028. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129029. * so that the system won't overwrite the bounds you provide
  129030. */
  129031. get shadowCastersBoundingInfo(): BoundingInfo;
  129032. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129033. protected _breaksAreDirty: boolean;
  129034. protected _minDistance: number;
  129035. protected _maxDistance: number;
  129036. /**
  129037. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129038. *
  129039. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129040. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129041. * @param min minimal distance for the breaks (default to 0.)
  129042. * @param max maximal distance for the breaks (default to 1.)
  129043. */
  129044. setMinMaxDistance(min: number, max: number): void;
  129045. /** Gets the minimal distance used in the cascade break computation */
  129046. get minDistance(): number;
  129047. /** Gets the maximal distance used in the cascade break computation */
  129048. get maxDistance(): number;
  129049. /**
  129050. * Gets the class name of that object
  129051. * @returns "CascadedShadowGenerator"
  129052. */
  129053. getClassName(): string;
  129054. private _cascadeMinExtents;
  129055. private _cascadeMaxExtents;
  129056. /**
  129057. * Gets a cascade minimum extents
  129058. * @param cascadeIndex index of the cascade
  129059. * @returns the minimum cascade extents
  129060. */
  129061. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129062. /**
  129063. * Gets a cascade maximum extents
  129064. * @param cascadeIndex index of the cascade
  129065. * @returns the maximum cascade extents
  129066. */
  129067. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129068. private _cascades;
  129069. private _currentLayer;
  129070. private _viewSpaceFrustumsZ;
  129071. private _viewMatrices;
  129072. private _projectionMatrices;
  129073. private _transformMatrices;
  129074. private _transformMatricesAsArray;
  129075. private _frustumLengths;
  129076. private _lightSizeUVCorrection;
  129077. private _depthCorrection;
  129078. private _frustumCornersWorldSpace;
  129079. private _frustumCenter;
  129080. private _shadowCameraPos;
  129081. private _shadowMaxZ;
  129082. /**
  129083. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129084. * It defaults to camera.maxZ
  129085. */
  129086. get shadowMaxZ(): number;
  129087. /**
  129088. * Sets the shadow max z distance.
  129089. */
  129090. set shadowMaxZ(value: number);
  129091. protected _debug: boolean;
  129092. /**
  129093. * Gets or sets the debug flag.
  129094. * When enabled, the cascades are materialized by different colors on the screen.
  129095. */
  129096. get debug(): boolean;
  129097. set debug(dbg: boolean);
  129098. private _depthClamp;
  129099. /**
  129100. * Gets or sets the depth clamping value.
  129101. *
  129102. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129103. * to account for the shadow casters far away.
  129104. *
  129105. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129106. */
  129107. get depthClamp(): boolean;
  129108. set depthClamp(value: boolean);
  129109. private _cascadeBlendPercentage;
  129110. /**
  129111. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129112. * It defaults to 0.1 (10% blending).
  129113. */
  129114. get cascadeBlendPercentage(): number;
  129115. set cascadeBlendPercentage(value: number);
  129116. private _lambda;
  129117. /**
  129118. * Gets or set the lambda parameter.
  129119. * This parameter is used to split the camera frustum and create the cascades.
  129120. * 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.
  129121. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129122. */
  129123. get lambda(): number;
  129124. set lambda(value: number);
  129125. /**
  129126. * Gets the view matrix corresponding to a given cascade
  129127. * @param cascadeNum cascade to retrieve the view matrix from
  129128. * @returns the cascade view matrix
  129129. */
  129130. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129131. /**
  129132. * Gets the projection matrix corresponding to a given cascade
  129133. * @param cascadeNum cascade to retrieve the projection matrix from
  129134. * @returns the cascade projection matrix
  129135. */
  129136. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129137. /**
  129138. * Gets the transformation matrix corresponding to a given cascade
  129139. * @param cascadeNum cascade to retrieve the transformation matrix from
  129140. * @returns the cascade transformation matrix
  129141. */
  129142. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129143. private _depthRenderer;
  129144. /**
  129145. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129146. *
  129147. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129148. *
  129149. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129150. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129151. * @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
  129152. */
  129153. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129154. private _depthReducer;
  129155. private _autoCalcDepthBounds;
  129156. /**
  129157. * Gets or sets the autoCalcDepthBounds property.
  129158. *
  129159. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129160. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129161. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129162. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129163. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129164. */
  129165. get autoCalcDepthBounds(): boolean;
  129166. set autoCalcDepthBounds(value: boolean);
  129167. /**
  129168. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129169. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129170. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129171. * for setting the refresh rate on the renderer yourself!
  129172. */
  129173. get autoCalcDepthBoundsRefreshRate(): number;
  129174. set autoCalcDepthBoundsRefreshRate(value: number);
  129175. /**
  129176. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129177. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129178. * you change the camera near/far planes!
  129179. */
  129180. splitFrustum(): void;
  129181. private _splitFrustum;
  129182. private _computeMatrices;
  129183. private _computeFrustumInWorldSpace;
  129184. private _computeCascadeFrustum;
  129185. /**
  129186. * Support test.
  129187. */
  129188. static get IsSupported(): boolean;
  129189. /** @hidden */
  129190. static _SceneComponentInitialization: (scene: Scene) => void;
  129191. /**
  129192. * Creates a Cascaded Shadow Generator object.
  129193. * A ShadowGenerator is the required tool to use the shadows.
  129194. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129195. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129196. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129197. * @param light The directional light object generating the shadows.
  129198. * @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.
  129199. */
  129200. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129201. protected _initializeGenerator(): void;
  129202. protected _createTargetRenderTexture(): void;
  129203. protected _initializeShadowMap(): void;
  129204. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129205. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129206. /**
  129207. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129208. * @param defines Defines of the material we want to update
  129209. * @param lightIndex Index of the light in the enabled light list of the material
  129210. */
  129211. prepareDefines(defines: any, lightIndex: number): void;
  129212. /**
  129213. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129214. * defined in the generator but impacting the effect).
  129215. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129216. * @param effect The effect we are binfing the information for
  129217. */
  129218. bindShadowLight(lightIndex: string, effect: Effect): void;
  129219. /**
  129220. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129221. * (eq to view projection * shadow projection matrices)
  129222. * @returns The transform matrix used to create the shadow map
  129223. */
  129224. getTransformMatrix(): Matrix;
  129225. /**
  129226. * Disposes the ShadowGenerator.
  129227. * Returns nothing.
  129228. */
  129229. dispose(): void;
  129230. /**
  129231. * Serializes the shadow generator setup to a json object.
  129232. * @returns The serialized JSON object
  129233. */
  129234. serialize(): any;
  129235. /**
  129236. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129237. * @param parsedShadowGenerator The JSON object to parse
  129238. * @param scene The scene to create the shadow map for
  129239. * @returns The parsed shadow generator
  129240. */
  129241. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129242. }
  129243. }
  129244. declare module BABYLON {
  129245. /**
  129246. * Defines the shadow generator component responsible to manage any shadow generators
  129247. * in a given scene.
  129248. */
  129249. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129250. /**
  129251. * The component name helpfull to identify the component in the list of scene components.
  129252. */
  129253. readonly name: string;
  129254. /**
  129255. * The scene the component belongs to.
  129256. */
  129257. scene: Scene;
  129258. /**
  129259. * Creates a new instance of the component for the given scene
  129260. * @param scene Defines the scene to register the component in
  129261. */
  129262. constructor(scene: Scene);
  129263. /**
  129264. * Registers the component in a given scene
  129265. */
  129266. register(): void;
  129267. /**
  129268. * Rebuilds the elements related to this component in case of
  129269. * context lost for instance.
  129270. */
  129271. rebuild(): void;
  129272. /**
  129273. * Serializes the component data to the specified json object
  129274. * @param serializationObject The object to serialize to
  129275. */
  129276. serialize(serializationObject: any): void;
  129277. /**
  129278. * Adds all the elements from the container to the scene
  129279. * @param container the container holding the elements
  129280. */
  129281. addFromContainer(container: AbstractScene): void;
  129282. /**
  129283. * Removes all the elements in the container from the scene
  129284. * @param container contains the elements to remove
  129285. * @param dispose if the removed element should be disposed (default: false)
  129286. */
  129287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129288. /**
  129289. * Rebuilds the elements related to this component in case of
  129290. * context lost for instance.
  129291. */
  129292. dispose(): void;
  129293. private _gatherRenderTargets;
  129294. }
  129295. }
  129296. declare module BABYLON {
  129297. /**
  129298. * A point light is a light defined by an unique point in world space.
  129299. * The light is emitted in every direction from this point.
  129300. * A good example of a point light is a standard light bulb.
  129301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129302. */
  129303. export class PointLight extends ShadowLight {
  129304. private _shadowAngle;
  129305. /**
  129306. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129307. * This specifies what angle the shadow will use to be created.
  129308. *
  129309. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129310. */
  129311. get shadowAngle(): number;
  129312. /**
  129313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129314. * This specifies what angle the shadow will use to be created.
  129315. *
  129316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129317. */
  129318. set shadowAngle(value: number);
  129319. /**
  129320. * Gets the direction if it has been set.
  129321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129322. */
  129323. get direction(): Vector3;
  129324. /**
  129325. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129326. */
  129327. set direction(value: Vector3);
  129328. /**
  129329. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129330. * A PointLight emits the light in every direction.
  129331. * It can cast shadows.
  129332. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129333. * ```javascript
  129334. * var pointLight = new PointLight("pl", camera.position, scene);
  129335. * ```
  129336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129337. * @param name The light friendly name
  129338. * @param position The position of the point light in the scene
  129339. * @param scene The scene the lights belongs to
  129340. */
  129341. constructor(name: string, position: Vector3, scene: Scene);
  129342. /**
  129343. * Returns the string "PointLight"
  129344. * @returns the class name
  129345. */
  129346. getClassName(): string;
  129347. /**
  129348. * Returns the integer 0.
  129349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129350. */
  129351. getTypeID(): number;
  129352. /**
  129353. * Specifies wether or not the shadowmap should be a cube texture.
  129354. * @returns true if the shadowmap needs to be a cube texture.
  129355. */
  129356. needCube(): boolean;
  129357. /**
  129358. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129359. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129360. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129361. */
  129362. getShadowDirection(faceIndex?: number): Vector3;
  129363. /**
  129364. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129365. * - fov = PI / 2
  129366. * - aspect ratio : 1.0
  129367. * - z-near and far equal to the active camera minZ and maxZ.
  129368. * Returns the PointLight.
  129369. */
  129370. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129371. protected _buildUniformLayout(): void;
  129372. /**
  129373. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129374. * @param effect The effect to update
  129375. * @param lightIndex The index of the light in the effect to update
  129376. * @returns The point light
  129377. */
  129378. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129379. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129380. /**
  129381. * Prepares the list of defines specific to the light type.
  129382. * @param defines the list of defines
  129383. * @param lightIndex defines the index of the light for the effect
  129384. */
  129385. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129386. }
  129387. }
  129388. declare module BABYLON {
  129389. /**
  129390. * Header information of HDR texture files.
  129391. */
  129392. export interface HDRInfo {
  129393. /**
  129394. * The height of the texture in pixels.
  129395. */
  129396. height: number;
  129397. /**
  129398. * The width of the texture in pixels.
  129399. */
  129400. width: number;
  129401. /**
  129402. * The index of the beginning of the data in the binary file.
  129403. */
  129404. dataPosition: number;
  129405. }
  129406. /**
  129407. * This groups tools to convert HDR texture to native colors array.
  129408. */
  129409. export class HDRTools {
  129410. private static Ldexp;
  129411. private static Rgbe2float;
  129412. private static readStringLine;
  129413. /**
  129414. * Reads header information from an RGBE texture stored in a native array.
  129415. * More information on this format are available here:
  129416. * https://en.wikipedia.org/wiki/RGBE_image_format
  129417. *
  129418. * @param uint8array The binary file stored in native array.
  129419. * @return The header information.
  129420. */
  129421. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129422. /**
  129423. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129424. * This RGBE texture needs to store the information as a panorama.
  129425. *
  129426. * More information on this format are available here:
  129427. * https://en.wikipedia.org/wiki/RGBE_image_format
  129428. *
  129429. * @param buffer The binary file stored in an array buffer.
  129430. * @param size The expected size of the extracted cubemap.
  129431. * @return The Cube Map information.
  129432. */
  129433. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129434. /**
  129435. * Returns the pixels data extracted from an RGBE texture.
  129436. * This pixels will be stored left to right up to down in the R G B order in one array.
  129437. *
  129438. * More information on this format are available here:
  129439. * https://en.wikipedia.org/wiki/RGBE_image_format
  129440. *
  129441. * @param uint8array The binary file stored in an array buffer.
  129442. * @param hdrInfo The header information of the file.
  129443. * @return The pixels data in RGB right to left up to down order.
  129444. */
  129445. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129446. private static RGBE_ReadPixels_RLE;
  129447. }
  129448. }
  129449. declare module BABYLON {
  129450. /**
  129451. * This represents a texture coming from an HDR input.
  129452. *
  129453. * The only supported format is currently panorama picture stored in RGBE format.
  129454. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129455. */
  129456. export class HDRCubeTexture extends BaseTexture {
  129457. private static _facesMapping;
  129458. private _generateHarmonics;
  129459. private _noMipmap;
  129460. private _textureMatrix;
  129461. private _size;
  129462. private _onLoad;
  129463. private _onError;
  129464. /**
  129465. * The texture URL.
  129466. */
  129467. url: string;
  129468. /**
  129469. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129470. */
  129471. coordinatesMode: number;
  129472. protected _isBlocking: boolean;
  129473. /**
  129474. * Sets wether or not the texture is blocking during loading.
  129475. */
  129476. set isBlocking(value: boolean);
  129477. /**
  129478. * Gets wether or not the texture is blocking during loading.
  129479. */
  129480. get isBlocking(): boolean;
  129481. protected _rotationY: number;
  129482. /**
  129483. * Sets texture matrix rotation angle around Y axis in radians.
  129484. */
  129485. set rotationY(value: number);
  129486. /**
  129487. * Gets texture matrix rotation angle around Y axis radians.
  129488. */
  129489. get rotationY(): number;
  129490. /**
  129491. * Gets or sets the center of the bounding box associated with the cube texture
  129492. * It must define where the camera used to render the texture was set
  129493. */
  129494. boundingBoxPosition: Vector3;
  129495. private _boundingBoxSize;
  129496. /**
  129497. * Gets or sets the size of the bounding box associated with the cube texture
  129498. * When defined, the cubemap will switch to local mode
  129499. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129500. * @example https://www.babylonjs-playground.com/#RNASML
  129501. */
  129502. set boundingBoxSize(value: Vector3);
  129503. get boundingBoxSize(): Vector3;
  129504. /**
  129505. * Instantiates an HDRTexture from the following parameters.
  129506. *
  129507. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129508. * @param scene The scene the texture will be used in
  129509. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129510. * @param noMipmap Forces to not generate the mipmap if true
  129511. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129512. * @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)
  129513. * @param reserved Reserved flag for internal use.
  129514. */
  129515. 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>);
  129516. /**
  129517. * Get the current class name of the texture useful for serialization or dynamic coding.
  129518. * @returns "HDRCubeTexture"
  129519. */
  129520. getClassName(): string;
  129521. /**
  129522. * Occurs when the file is raw .hdr file.
  129523. */
  129524. private loadTexture;
  129525. clone(): HDRCubeTexture;
  129526. delayLoad(): void;
  129527. /**
  129528. * Get the texture reflection matrix used to rotate/transform the reflection.
  129529. * @returns the reflection matrix
  129530. */
  129531. getReflectionTextureMatrix(): Matrix;
  129532. /**
  129533. * Set the texture reflection matrix used to rotate/transform the reflection.
  129534. * @param value Define the reflection matrix to set
  129535. */
  129536. setReflectionTextureMatrix(value: Matrix): void;
  129537. /**
  129538. * Parses a JSON representation of an HDR Texture in order to create the texture
  129539. * @param parsedTexture Define the JSON representation
  129540. * @param scene Define the scene the texture should be created in
  129541. * @param rootUrl Define the root url in case we need to load relative dependencies
  129542. * @returns the newly created texture after parsing
  129543. */
  129544. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129545. serialize(): any;
  129546. }
  129547. }
  129548. declare module BABYLON {
  129549. /**
  129550. * Class used to control physics engine
  129551. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129552. */
  129553. export class PhysicsEngine implements IPhysicsEngine {
  129554. private _physicsPlugin;
  129555. /**
  129556. * Global value used to control the smallest number supported by the simulation
  129557. */
  129558. static Epsilon: number;
  129559. private _impostors;
  129560. private _joints;
  129561. private _subTimeStep;
  129562. /**
  129563. * Gets the gravity vector used by the simulation
  129564. */
  129565. gravity: Vector3;
  129566. /**
  129567. * Factory used to create the default physics plugin.
  129568. * @returns The default physics plugin
  129569. */
  129570. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129571. /**
  129572. * Creates a new Physics Engine
  129573. * @param gravity defines the gravity vector used by the simulation
  129574. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129575. */
  129576. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129577. /**
  129578. * Sets the gravity vector used by the simulation
  129579. * @param gravity defines the gravity vector to use
  129580. */
  129581. setGravity(gravity: Vector3): void;
  129582. /**
  129583. * Set the time step of the physics engine.
  129584. * Default is 1/60.
  129585. * To slow it down, enter 1/600 for example.
  129586. * To speed it up, 1/30
  129587. * @param newTimeStep defines the new timestep to apply to this world.
  129588. */
  129589. setTimeStep(newTimeStep?: number): void;
  129590. /**
  129591. * Get the time step of the physics engine.
  129592. * @returns the current time step
  129593. */
  129594. getTimeStep(): number;
  129595. /**
  129596. * Set the sub time step of the physics engine.
  129597. * Default is 0 meaning there is no sub steps
  129598. * To increase physics resolution precision, set a small value (like 1 ms)
  129599. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129600. */
  129601. setSubTimeStep(subTimeStep?: number): void;
  129602. /**
  129603. * Get the sub time step of the physics engine.
  129604. * @returns the current sub time step
  129605. */
  129606. getSubTimeStep(): number;
  129607. /**
  129608. * Release all resources
  129609. */
  129610. dispose(): void;
  129611. /**
  129612. * Gets the name of the current physics plugin
  129613. * @returns the name of the plugin
  129614. */
  129615. getPhysicsPluginName(): string;
  129616. /**
  129617. * Adding a new impostor for the impostor tracking.
  129618. * This will be done by the impostor itself.
  129619. * @param impostor the impostor to add
  129620. */
  129621. addImpostor(impostor: PhysicsImpostor): void;
  129622. /**
  129623. * Remove an impostor from the engine.
  129624. * This impostor and its mesh will not longer be updated by the physics engine.
  129625. * @param impostor the impostor to remove
  129626. */
  129627. removeImpostor(impostor: PhysicsImpostor): void;
  129628. /**
  129629. * Add a joint to the physics engine
  129630. * @param mainImpostor defines the main impostor to which the joint is added.
  129631. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129632. * @param joint defines the joint that will connect both impostors.
  129633. */
  129634. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129635. /**
  129636. * Removes a joint from the simulation
  129637. * @param mainImpostor defines the impostor used with the joint
  129638. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129639. * @param joint defines the joint to remove
  129640. */
  129641. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129642. /**
  129643. * Called by the scene. No need to call it.
  129644. * @param delta defines the timespam between frames
  129645. */
  129646. _step(delta: number): void;
  129647. /**
  129648. * Gets the current plugin used to run the simulation
  129649. * @returns current plugin
  129650. */
  129651. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129652. /**
  129653. * Gets the list of physic impostors
  129654. * @returns an array of PhysicsImpostor
  129655. */
  129656. getImpostors(): Array<PhysicsImpostor>;
  129657. /**
  129658. * Gets the impostor for a physics enabled object
  129659. * @param object defines the object impersonated by the impostor
  129660. * @returns the PhysicsImpostor or null if not found
  129661. */
  129662. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129663. /**
  129664. * Gets the impostor for a physics body object
  129665. * @param body defines physics body used by the impostor
  129666. * @returns the PhysicsImpostor or null if not found
  129667. */
  129668. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129669. /**
  129670. * Does a raycast in the physics world
  129671. * @param from when should the ray start?
  129672. * @param to when should the ray end?
  129673. * @returns PhysicsRaycastResult
  129674. */
  129675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129676. }
  129677. }
  129678. declare module BABYLON {
  129679. /** @hidden */
  129680. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129681. private _useDeltaForWorldStep;
  129682. world: any;
  129683. name: string;
  129684. private _physicsMaterials;
  129685. private _fixedTimeStep;
  129686. private _cannonRaycastResult;
  129687. private _raycastResult;
  129688. private _physicsBodysToRemoveAfterStep;
  129689. BJSCANNON: any;
  129690. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129691. setGravity(gravity: Vector3): void;
  129692. setTimeStep(timeStep: number): void;
  129693. getTimeStep(): number;
  129694. executeStep(delta: number): void;
  129695. private _removeMarkedPhysicsBodiesFromWorld;
  129696. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129697. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129698. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129699. private _processChildMeshes;
  129700. removePhysicsBody(impostor: PhysicsImpostor): void;
  129701. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129702. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129703. private _addMaterial;
  129704. private _checkWithEpsilon;
  129705. private _createShape;
  129706. private _createHeightmap;
  129707. private _minus90X;
  129708. private _plus90X;
  129709. private _tmpPosition;
  129710. private _tmpDeltaPosition;
  129711. private _tmpUnityRotation;
  129712. private _updatePhysicsBodyTransformation;
  129713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129715. isSupported(): boolean;
  129716. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129717. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129718. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129719. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129720. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129721. getBodyMass(impostor: PhysicsImpostor): number;
  129722. getBodyFriction(impostor: PhysicsImpostor): number;
  129723. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129724. getBodyRestitution(impostor: PhysicsImpostor): number;
  129725. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129726. sleepBody(impostor: PhysicsImpostor): void;
  129727. wakeUpBody(impostor: PhysicsImpostor): void;
  129728. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129729. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129730. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129731. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129732. getRadius(impostor: PhysicsImpostor): number;
  129733. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129734. dispose(): void;
  129735. private _extendNamespace;
  129736. /**
  129737. * Does a raycast in the physics world
  129738. * @param from when should the ray start?
  129739. * @param to when should the ray end?
  129740. * @returns PhysicsRaycastResult
  129741. */
  129742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129743. }
  129744. }
  129745. declare module BABYLON {
  129746. /** @hidden */
  129747. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129748. world: any;
  129749. name: string;
  129750. BJSOIMO: any;
  129751. private _raycastResult;
  129752. constructor(iterations?: number, oimoInjection?: any);
  129753. setGravity(gravity: Vector3): void;
  129754. setTimeStep(timeStep: number): void;
  129755. getTimeStep(): number;
  129756. private _tmpImpostorsArray;
  129757. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129758. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129759. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129760. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129761. private _tmpPositionVector;
  129762. removePhysicsBody(impostor: PhysicsImpostor): void;
  129763. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129764. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129765. isSupported(): boolean;
  129766. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129767. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129769. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129770. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129772. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129773. getBodyMass(impostor: PhysicsImpostor): number;
  129774. getBodyFriction(impostor: PhysicsImpostor): number;
  129775. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129776. getBodyRestitution(impostor: PhysicsImpostor): number;
  129777. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129778. sleepBody(impostor: PhysicsImpostor): void;
  129779. wakeUpBody(impostor: PhysicsImpostor): void;
  129780. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129781. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129784. getRadius(impostor: PhysicsImpostor): number;
  129785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129786. dispose(): void;
  129787. /**
  129788. * Does a raycast in the physics world
  129789. * @param from when should the ray start?
  129790. * @param to when should the ray end?
  129791. * @returns PhysicsRaycastResult
  129792. */
  129793. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129794. }
  129795. }
  129796. declare module BABYLON {
  129797. /**
  129798. * Class containing static functions to help procedurally build meshes
  129799. */
  129800. export class RibbonBuilder {
  129801. /**
  129802. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129803. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129804. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129805. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129806. * * 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
  129807. * * 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
  129808. * * 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
  129809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129812. * * 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
  129813. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129814. * * 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
  129815. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129817. * @param name defines the name of the mesh
  129818. * @param options defines the options used to create the mesh
  129819. * @param scene defines the hosting scene
  129820. * @returns the ribbon mesh
  129821. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129822. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129823. */
  129824. static CreateRibbon(name: string, options: {
  129825. pathArray: Vector3[][];
  129826. closeArray?: boolean;
  129827. closePath?: boolean;
  129828. offset?: number;
  129829. updatable?: boolean;
  129830. sideOrientation?: number;
  129831. frontUVs?: Vector4;
  129832. backUVs?: Vector4;
  129833. instance?: Mesh;
  129834. invertUV?: boolean;
  129835. uvs?: Vector2[];
  129836. colors?: Color4[];
  129837. }, scene?: Nullable<Scene>): Mesh;
  129838. }
  129839. }
  129840. declare module BABYLON {
  129841. /**
  129842. * Class containing static functions to help procedurally build meshes
  129843. */
  129844. export class ShapeBuilder {
  129845. /**
  129846. * 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.
  129847. * * 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.
  129848. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129849. * * 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.
  129850. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129851. * * 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
  129852. * * 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
  129853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129858. * @param name defines the name of the mesh
  129859. * @param options defines the options used to create the mesh
  129860. * @param scene defines the hosting scene
  129861. * @returns the extruded shape mesh
  129862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129864. */
  129865. static ExtrudeShape(name: string, options: {
  129866. shape: Vector3[];
  129867. path: Vector3[];
  129868. scale?: number;
  129869. rotation?: number;
  129870. cap?: number;
  129871. updatable?: boolean;
  129872. sideOrientation?: number;
  129873. frontUVs?: Vector4;
  129874. backUVs?: Vector4;
  129875. instance?: Mesh;
  129876. invertUV?: boolean;
  129877. }, scene?: Nullable<Scene>): Mesh;
  129878. /**
  129879. * Creates an custom extruded shape mesh.
  129880. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129881. * * 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.
  129882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129883. * * 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
  129884. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129885. * * 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
  129886. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129887. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129888. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129889. * * 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
  129890. * * 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
  129891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129896. * @param name defines the name of the mesh
  129897. * @param options defines the options used to create the mesh
  129898. * @param scene defines the hosting scene
  129899. * @returns the custom extruded shape mesh
  129900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129903. */
  129904. static ExtrudeShapeCustom(name: string, options: {
  129905. shape: Vector3[];
  129906. path: Vector3[];
  129907. scaleFunction?: any;
  129908. rotationFunction?: any;
  129909. ribbonCloseArray?: boolean;
  129910. ribbonClosePath?: boolean;
  129911. cap?: number;
  129912. updatable?: boolean;
  129913. sideOrientation?: number;
  129914. frontUVs?: Vector4;
  129915. backUVs?: Vector4;
  129916. instance?: Mesh;
  129917. invertUV?: boolean;
  129918. }, scene?: Nullable<Scene>): Mesh;
  129919. private static _ExtrudeShapeGeneric;
  129920. }
  129921. }
  129922. declare module BABYLON {
  129923. /**
  129924. * AmmoJS Physics plugin
  129925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129926. * @see https://github.com/kripken/ammo.js/
  129927. */
  129928. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129929. private _useDeltaForWorldStep;
  129930. /**
  129931. * Reference to the Ammo library
  129932. */
  129933. bjsAMMO: any;
  129934. /**
  129935. * Created ammoJS world which physics bodies are added to
  129936. */
  129937. world: any;
  129938. /**
  129939. * Name of the plugin
  129940. */
  129941. name: string;
  129942. private _timeStep;
  129943. private _fixedTimeStep;
  129944. private _maxSteps;
  129945. private _tmpQuaternion;
  129946. private _tmpAmmoTransform;
  129947. private _tmpAmmoQuaternion;
  129948. private _tmpAmmoConcreteContactResultCallback;
  129949. private _collisionConfiguration;
  129950. private _dispatcher;
  129951. private _overlappingPairCache;
  129952. private _solver;
  129953. private _softBodySolver;
  129954. private _tmpAmmoVectorA;
  129955. private _tmpAmmoVectorB;
  129956. private _tmpAmmoVectorC;
  129957. private _tmpAmmoVectorD;
  129958. private _tmpContactCallbackResult;
  129959. private _tmpAmmoVectorRCA;
  129960. private _tmpAmmoVectorRCB;
  129961. private _raycastResult;
  129962. private static readonly DISABLE_COLLISION_FLAG;
  129963. private static readonly KINEMATIC_FLAG;
  129964. private static readonly DISABLE_DEACTIVATION_FLAG;
  129965. /**
  129966. * Initializes the ammoJS plugin
  129967. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129968. * @param ammoInjection can be used to inject your own ammo reference
  129969. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129970. */
  129971. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  129972. /**
  129973. * Sets the gravity of the physics world (m/(s^2))
  129974. * @param gravity Gravity to set
  129975. */
  129976. setGravity(gravity: Vector3): void;
  129977. /**
  129978. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  129979. * @param timeStep timestep to use in seconds
  129980. */
  129981. setTimeStep(timeStep: number): void;
  129982. /**
  129983. * 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)
  129984. * @param fixedTimeStep fixedTimeStep to use in seconds
  129985. */
  129986. setFixedTimeStep(fixedTimeStep: number): void;
  129987. /**
  129988. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  129989. * @param maxSteps the maximum number of steps by the physics engine per frame
  129990. */
  129991. setMaxSteps(maxSteps: number): void;
  129992. /**
  129993. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  129994. * @returns the current timestep in seconds
  129995. */
  129996. getTimeStep(): number;
  129997. /**
  129998. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  129999. */
  130000. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130001. private _isImpostorInContact;
  130002. private _isImpostorPairInContact;
  130003. private _stepSimulation;
  130004. /**
  130005. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130006. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130007. * After the step the babylon meshes are set to the position of the physics imposters
  130008. * @param delta amount of time to step forward
  130009. * @param impostors array of imposters to update before/after the step
  130010. */
  130011. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130012. /**
  130013. * Update babylon mesh to match physics world object
  130014. * @param impostor imposter to match
  130015. */
  130016. private _afterSoftStep;
  130017. /**
  130018. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130019. * @param impostor imposter to match
  130020. */
  130021. private _ropeStep;
  130022. /**
  130023. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130024. * @param impostor imposter to match
  130025. */
  130026. private _softbodyOrClothStep;
  130027. private _tmpVector;
  130028. private _tmpMatrix;
  130029. /**
  130030. * Applies an impulse on the imposter
  130031. * @param impostor imposter to apply impulse to
  130032. * @param force amount of force to be applied to the imposter
  130033. * @param contactPoint the location to apply the impulse on the imposter
  130034. */
  130035. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130036. /**
  130037. * Applies a force on the imposter
  130038. * @param impostor imposter to apply force
  130039. * @param force amount of force to be applied to the imposter
  130040. * @param contactPoint the location to apply the force on the imposter
  130041. */
  130042. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130043. /**
  130044. * Creates a physics body using the plugin
  130045. * @param impostor the imposter to create the physics body on
  130046. */
  130047. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130048. /**
  130049. * Removes the physics body from the imposter and disposes of the body's memory
  130050. * @param impostor imposter to remove the physics body from
  130051. */
  130052. removePhysicsBody(impostor: PhysicsImpostor): void;
  130053. /**
  130054. * Generates a joint
  130055. * @param impostorJoint the imposter joint to create the joint with
  130056. */
  130057. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130058. /**
  130059. * Removes a joint
  130060. * @param impostorJoint the imposter joint to remove the joint from
  130061. */
  130062. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130063. private _addMeshVerts;
  130064. /**
  130065. * Initialise the soft body vertices to match its object's (mesh) vertices
  130066. * Softbody vertices (nodes) are in world space and to match this
  130067. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130068. * @param impostor to create the softbody for
  130069. */
  130070. private _softVertexData;
  130071. /**
  130072. * Create an impostor's soft body
  130073. * @param impostor to create the softbody for
  130074. */
  130075. private _createSoftbody;
  130076. /**
  130077. * Create cloth for an impostor
  130078. * @param impostor to create the softbody for
  130079. */
  130080. private _createCloth;
  130081. /**
  130082. * Create rope for an impostor
  130083. * @param impostor to create the softbody for
  130084. */
  130085. private _createRope;
  130086. /**
  130087. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130088. * @param impostor to create the custom physics shape for
  130089. */
  130090. private _createCustom;
  130091. private _addHullVerts;
  130092. private _createShape;
  130093. /**
  130094. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130095. * @param impostor imposter containing the physics body and babylon object
  130096. */
  130097. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130098. /**
  130099. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130100. * @param impostor imposter containing the physics body and babylon object
  130101. * @param newPosition new position
  130102. * @param newRotation new rotation
  130103. */
  130104. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130105. /**
  130106. * If this plugin is supported
  130107. * @returns true if its supported
  130108. */
  130109. isSupported(): boolean;
  130110. /**
  130111. * Sets the linear velocity of the physics body
  130112. * @param impostor imposter to set the velocity on
  130113. * @param velocity velocity to set
  130114. */
  130115. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130116. /**
  130117. * Sets the angular velocity of the physics body
  130118. * @param impostor imposter to set the velocity on
  130119. * @param velocity velocity to set
  130120. */
  130121. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130122. /**
  130123. * gets the linear velocity
  130124. * @param impostor imposter to get linear velocity from
  130125. * @returns linear velocity
  130126. */
  130127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130128. /**
  130129. * gets the angular velocity
  130130. * @param impostor imposter to get angular velocity from
  130131. * @returns angular velocity
  130132. */
  130133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130134. /**
  130135. * Sets the mass of physics body
  130136. * @param impostor imposter to set the mass on
  130137. * @param mass mass to set
  130138. */
  130139. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130140. /**
  130141. * Gets the mass of the physics body
  130142. * @param impostor imposter to get the mass from
  130143. * @returns mass
  130144. */
  130145. getBodyMass(impostor: PhysicsImpostor): number;
  130146. /**
  130147. * Gets friction of the impostor
  130148. * @param impostor impostor to get friction from
  130149. * @returns friction value
  130150. */
  130151. getBodyFriction(impostor: PhysicsImpostor): number;
  130152. /**
  130153. * Sets friction of the impostor
  130154. * @param impostor impostor to set friction on
  130155. * @param friction friction value
  130156. */
  130157. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130158. /**
  130159. * Gets restitution of the impostor
  130160. * @param impostor impostor to get restitution from
  130161. * @returns restitution value
  130162. */
  130163. getBodyRestitution(impostor: PhysicsImpostor): number;
  130164. /**
  130165. * Sets resitution of the impostor
  130166. * @param impostor impostor to set resitution on
  130167. * @param restitution resitution value
  130168. */
  130169. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130170. /**
  130171. * Gets pressure inside the impostor
  130172. * @param impostor impostor to get pressure from
  130173. * @returns pressure value
  130174. */
  130175. getBodyPressure(impostor: PhysicsImpostor): number;
  130176. /**
  130177. * Sets pressure inside a soft body impostor
  130178. * Cloth and rope must remain 0 pressure
  130179. * @param impostor impostor to set pressure on
  130180. * @param pressure pressure value
  130181. */
  130182. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130183. /**
  130184. * Gets stiffness of the impostor
  130185. * @param impostor impostor to get stiffness from
  130186. * @returns pressure value
  130187. */
  130188. getBodyStiffness(impostor: PhysicsImpostor): number;
  130189. /**
  130190. * Sets stiffness of the impostor
  130191. * @param impostor impostor to set stiffness on
  130192. * @param stiffness stiffness value from 0 to 1
  130193. */
  130194. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130195. /**
  130196. * Gets velocityIterations of the impostor
  130197. * @param impostor impostor to get velocity iterations from
  130198. * @returns velocityIterations value
  130199. */
  130200. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130201. /**
  130202. * Sets velocityIterations of the impostor
  130203. * @param impostor impostor to set velocity iterations on
  130204. * @param velocityIterations velocityIterations value
  130205. */
  130206. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130207. /**
  130208. * Gets positionIterations of the impostor
  130209. * @param impostor impostor to get position iterations from
  130210. * @returns positionIterations value
  130211. */
  130212. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130213. /**
  130214. * Sets positionIterations of the impostor
  130215. * @param impostor impostor to set position on
  130216. * @param positionIterations positionIterations value
  130217. */
  130218. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130219. /**
  130220. * Append an anchor to a cloth object
  130221. * @param impostor is the cloth impostor to add anchor to
  130222. * @param otherImpostor is the rigid impostor to anchor to
  130223. * @param width ratio across width from 0 to 1
  130224. * @param height ratio up height from 0 to 1
  130225. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130226. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130227. */
  130228. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130229. /**
  130230. * Append an hook to a rope object
  130231. * @param impostor is the rope impostor to add hook to
  130232. * @param otherImpostor is the rigid impostor to hook to
  130233. * @param length ratio along the rope from 0 to 1
  130234. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130235. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130236. */
  130237. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130238. /**
  130239. * Sleeps the physics body and stops it from being active
  130240. * @param impostor impostor to sleep
  130241. */
  130242. sleepBody(impostor: PhysicsImpostor): void;
  130243. /**
  130244. * Activates the physics body
  130245. * @param impostor impostor to activate
  130246. */
  130247. wakeUpBody(impostor: PhysicsImpostor): void;
  130248. /**
  130249. * Updates the distance parameters of the joint
  130250. * @param joint joint to update
  130251. * @param maxDistance maximum distance of the joint
  130252. * @param minDistance minimum distance of the joint
  130253. */
  130254. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130255. /**
  130256. * Sets a motor on the joint
  130257. * @param joint joint to set motor on
  130258. * @param speed speed of the motor
  130259. * @param maxForce maximum force of the motor
  130260. * @param motorIndex index of the motor
  130261. */
  130262. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130263. /**
  130264. * Sets the motors limit
  130265. * @param joint joint to set limit on
  130266. * @param upperLimit upper limit
  130267. * @param lowerLimit lower limit
  130268. */
  130269. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130270. /**
  130271. * Syncs the position and rotation of a mesh with the impostor
  130272. * @param mesh mesh to sync
  130273. * @param impostor impostor to update the mesh with
  130274. */
  130275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130276. /**
  130277. * Gets the radius of the impostor
  130278. * @param impostor impostor to get radius from
  130279. * @returns the radius
  130280. */
  130281. getRadius(impostor: PhysicsImpostor): number;
  130282. /**
  130283. * Gets the box size of the impostor
  130284. * @param impostor impostor to get box size from
  130285. * @param result the resulting box size
  130286. */
  130287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130288. /**
  130289. * Disposes of the impostor
  130290. */
  130291. dispose(): void;
  130292. /**
  130293. * Does a raycast in the physics world
  130294. * @param from when should the ray start?
  130295. * @param to when should the ray end?
  130296. * @returns PhysicsRaycastResult
  130297. */
  130298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130299. }
  130300. }
  130301. declare module BABYLON {
  130302. interface AbstractScene {
  130303. /**
  130304. * The list of reflection probes added to the scene
  130305. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130306. */
  130307. reflectionProbes: Array<ReflectionProbe>;
  130308. /**
  130309. * Removes the given reflection probe from this scene.
  130310. * @param toRemove The reflection probe to remove
  130311. * @returns The index of the removed reflection probe
  130312. */
  130313. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130314. /**
  130315. * Adds the given reflection probe to this scene.
  130316. * @param newReflectionProbe The reflection probe to add
  130317. */
  130318. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130319. }
  130320. /**
  130321. * Class used to generate realtime reflection / refraction cube textures
  130322. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130323. */
  130324. export class ReflectionProbe {
  130325. /** defines the name of the probe */
  130326. name: string;
  130327. private _scene;
  130328. private _renderTargetTexture;
  130329. private _projectionMatrix;
  130330. private _viewMatrix;
  130331. private _target;
  130332. private _add;
  130333. private _attachedMesh;
  130334. private _invertYAxis;
  130335. /** Gets or sets probe position (center of the cube map) */
  130336. position: Vector3;
  130337. /**
  130338. * Creates a new reflection probe
  130339. * @param name defines the name of the probe
  130340. * @param size defines the texture resolution (for each face)
  130341. * @param scene defines the hosting scene
  130342. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130343. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130344. */
  130345. constructor(
  130346. /** defines the name of the probe */
  130347. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130348. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130349. get samples(): number;
  130350. set samples(value: number);
  130351. /** Gets or sets the refresh rate to use (on every frame by default) */
  130352. get refreshRate(): number;
  130353. set refreshRate(value: number);
  130354. /**
  130355. * Gets the hosting scene
  130356. * @returns a Scene
  130357. */
  130358. getScene(): Scene;
  130359. /** Gets the internal CubeTexture used to render to */
  130360. get cubeTexture(): RenderTargetTexture;
  130361. /** Gets the list of meshes to render */
  130362. get renderList(): Nullable<AbstractMesh[]>;
  130363. /**
  130364. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130365. * @param mesh defines the mesh to attach to
  130366. */
  130367. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130368. /**
  130369. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130370. * @param renderingGroupId The rendering group id corresponding to its index
  130371. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130372. */
  130373. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130374. /**
  130375. * Clean all associated resources
  130376. */
  130377. dispose(): void;
  130378. /**
  130379. * Converts the reflection probe information to a readable string for debug purpose.
  130380. * @param fullDetails Supports for multiple levels of logging within scene loading
  130381. * @returns the human readable reflection probe info
  130382. */
  130383. toString(fullDetails?: boolean): string;
  130384. /**
  130385. * Get the class name of the relfection probe.
  130386. * @returns "ReflectionProbe"
  130387. */
  130388. getClassName(): string;
  130389. /**
  130390. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130391. * @returns The JSON representation of the texture
  130392. */
  130393. serialize(): any;
  130394. /**
  130395. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130396. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130397. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130398. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130399. * @returns The parsed reflection probe if successful
  130400. */
  130401. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130402. }
  130403. }
  130404. declare module BABYLON {
  130405. /** @hidden */
  130406. export var _BabylonLoaderRegistered: boolean;
  130407. /**
  130408. * Helps setting up some configuration for the babylon file loader.
  130409. */
  130410. export class BabylonFileLoaderConfiguration {
  130411. /**
  130412. * The loader does not allow injecting custom physix engine into the plugins.
  130413. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130414. * So you could set this variable to your engine import to make it work.
  130415. */
  130416. static LoaderInjectedPhysicsEngine: any;
  130417. }
  130418. }
  130419. declare module BABYLON {
  130420. /**
  130421. * The Physically based simple base material of BJS.
  130422. *
  130423. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130424. * It is used as the base class for both the specGloss and metalRough conventions.
  130425. */
  130426. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130427. /**
  130428. * Number of Simultaneous lights allowed on the material.
  130429. */
  130430. maxSimultaneousLights: number;
  130431. /**
  130432. * If sets to true, disables all the lights affecting the material.
  130433. */
  130434. disableLighting: boolean;
  130435. /**
  130436. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130437. */
  130438. environmentTexture: BaseTexture;
  130439. /**
  130440. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130441. */
  130442. invertNormalMapX: boolean;
  130443. /**
  130444. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130445. */
  130446. invertNormalMapY: boolean;
  130447. /**
  130448. * Normal map used in the model.
  130449. */
  130450. normalTexture: BaseTexture;
  130451. /**
  130452. * Emissivie color used to self-illuminate the model.
  130453. */
  130454. emissiveColor: Color3;
  130455. /**
  130456. * Emissivie texture used to self-illuminate the model.
  130457. */
  130458. emissiveTexture: BaseTexture;
  130459. /**
  130460. * Occlusion Channel Strenght.
  130461. */
  130462. occlusionStrength: number;
  130463. /**
  130464. * Occlusion Texture of the material (adding extra occlusion effects).
  130465. */
  130466. occlusionTexture: BaseTexture;
  130467. /**
  130468. * Defines the alpha limits in alpha test mode.
  130469. */
  130470. alphaCutOff: number;
  130471. /**
  130472. * Gets the current double sided mode.
  130473. */
  130474. get doubleSided(): boolean;
  130475. /**
  130476. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130477. */
  130478. set doubleSided(value: boolean);
  130479. /**
  130480. * Stores the pre-calculated light information of a mesh in a texture.
  130481. */
  130482. lightmapTexture: BaseTexture;
  130483. /**
  130484. * If true, the light map contains occlusion information instead of lighting info.
  130485. */
  130486. useLightmapAsShadowmap: boolean;
  130487. /**
  130488. * Instantiates a new PBRMaterial instance.
  130489. *
  130490. * @param name The material name
  130491. * @param scene The scene the material will be use in.
  130492. */
  130493. constructor(name: string, scene: Scene);
  130494. getClassName(): string;
  130495. }
  130496. }
  130497. declare module BABYLON {
  130498. /**
  130499. * The PBR material of BJS following the metal roughness convention.
  130500. *
  130501. * This fits to the PBR convention in the GLTF definition:
  130502. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130503. */
  130504. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130505. /**
  130506. * The base color has two different interpretations depending on the value of metalness.
  130507. * When the material is a metal, the base color is the specific measured reflectance value
  130508. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130509. * of the material.
  130510. */
  130511. baseColor: Color3;
  130512. /**
  130513. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130514. * well as opacity information in the alpha channel.
  130515. */
  130516. baseTexture: BaseTexture;
  130517. /**
  130518. * Specifies the metallic scalar value of the material.
  130519. * Can also be used to scale the metalness values of the metallic texture.
  130520. */
  130521. metallic: number;
  130522. /**
  130523. * Specifies the roughness scalar value of the material.
  130524. * Can also be used to scale the roughness values of the metallic texture.
  130525. */
  130526. roughness: number;
  130527. /**
  130528. * Texture containing both the metallic value in the B channel and the
  130529. * roughness value in the G channel to keep better precision.
  130530. */
  130531. metallicRoughnessTexture: BaseTexture;
  130532. /**
  130533. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130534. *
  130535. * @param name The material name
  130536. * @param scene The scene the material will be use in.
  130537. */
  130538. constructor(name: string, scene: Scene);
  130539. /**
  130540. * Return the currrent class name of the material.
  130541. */
  130542. getClassName(): string;
  130543. /**
  130544. * Makes a duplicate of the current material.
  130545. * @param name - name to use for the new material.
  130546. */
  130547. clone(name: string): PBRMetallicRoughnessMaterial;
  130548. /**
  130549. * Serialize the material to a parsable JSON object.
  130550. */
  130551. serialize(): any;
  130552. /**
  130553. * Parses a JSON object correponding to the serialize function.
  130554. */
  130555. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * The PBR material of BJS following the specular glossiness convention.
  130561. *
  130562. * This fits to the PBR convention in the GLTF definition:
  130563. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130564. */
  130565. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130566. /**
  130567. * Specifies the diffuse color of the material.
  130568. */
  130569. diffuseColor: Color3;
  130570. /**
  130571. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130572. * channel.
  130573. */
  130574. diffuseTexture: BaseTexture;
  130575. /**
  130576. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130577. */
  130578. specularColor: Color3;
  130579. /**
  130580. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130581. */
  130582. glossiness: number;
  130583. /**
  130584. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130585. */
  130586. specularGlossinessTexture: BaseTexture;
  130587. /**
  130588. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130589. *
  130590. * @param name The material name
  130591. * @param scene The scene the material will be use in.
  130592. */
  130593. constructor(name: string, scene: Scene);
  130594. /**
  130595. * Return the currrent class name of the material.
  130596. */
  130597. getClassName(): string;
  130598. /**
  130599. * Makes a duplicate of the current material.
  130600. * @param name - name to use for the new material.
  130601. */
  130602. clone(name: string): PBRSpecularGlossinessMaterial;
  130603. /**
  130604. * Serialize the material to a parsable JSON object.
  130605. */
  130606. serialize(): any;
  130607. /**
  130608. * Parses a JSON object correponding to the serialize function.
  130609. */
  130610. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130611. }
  130612. }
  130613. declare module BABYLON {
  130614. /**
  130615. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130616. * It can help converting any input color in a desired output one. This can then be used to create effects
  130617. * from sepia, black and white to sixties or futuristic rendering...
  130618. *
  130619. * The only supported format is currently 3dl.
  130620. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130621. */
  130622. export class ColorGradingTexture extends BaseTexture {
  130623. /**
  130624. * The current texture matrix. (will always be identity in color grading texture)
  130625. */
  130626. private _textureMatrix;
  130627. /**
  130628. * The texture URL.
  130629. */
  130630. url: string;
  130631. /**
  130632. * Empty line regex stored for GC.
  130633. */
  130634. private static _noneEmptyLineRegex;
  130635. private _engine;
  130636. /**
  130637. * Instantiates a ColorGradingTexture from the following parameters.
  130638. *
  130639. * @param url The location of the color gradind data (currently only supporting 3dl)
  130640. * @param scene The scene the texture will be used in
  130641. */
  130642. constructor(url: string, scene: Scene);
  130643. /**
  130644. * Returns the texture matrix used in most of the material.
  130645. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130646. */
  130647. getTextureMatrix(): Matrix;
  130648. /**
  130649. * Occurs when the file being loaded is a .3dl LUT file.
  130650. */
  130651. private load3dlTexture;
  130652. /**
  130653. * Starts the loading process of the texture.
  130654. */
  130655. private loadTexture;
  130656. /**
  130657. * Clones the color gradind texture.
  130658. */
  130659. clone(): ColorGradingTexture;
  130660. /**
  130661. * Called during delayed load for textures.
  130662. */
  130663. delayLoad(): void;
  130664. /**
  130665. * Parses a color grading texture serialized by Babylon.
  130666. * @param parsedTexture The texture information being parsedTexture
  130667. * @param scene The scene to load the texture in
  130668. * @param rootUrl The root url of the data assets to load
  130669. * @return A color gradind texture
  130670. */
  130671. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130672. /**
  130673. * Serializes the LUT texture to json format.
  130674. */
  130675. serialize(): any;
  130676. }
  130677. }
  130678. declare module BABYLON {
  130679. /**
  130680. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130681. */
  130682. export class EquiRectangularCubeTexture extends BaseTexture {
  130683. /** The six faces of the cube. */
  130684. private static _FacesMapping;
  130685. private _noMipmap;
  130686. private _onLoad;
  130687. private _onError;
  130688. /** The size of the cubemap. */
  130689. private _size;
  130690. /** The buffer of the image. */
  130691. private _buffer;
  130692. /** The width of the input image. */
  130693. private _width;
  130694. /** The height of the input image. */
  130695. private _height;
  130696. /** The URL to the image. */
  130697. url: string;
  130698. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130699. coordinatesMode: number;
  130700. /**
  130701. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130702. * @param url The location of the image
  130703. * @param scene The scene the texture will be used in
  130704. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130705. * @param noMipmap Forces to not generate the mipmap if true
  130706. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130707. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130708. * @param onLoad — defines a callback called when texture is loaded
  130709. * @param onError — defines a callback called if there is an error
  130710. */
  130711. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130712. /**
  130713. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130714. */
  130715. private loadImage;
  130716. /**
  130717. * Convert the image buffer into a cubemap and create a CubeTexture.
  130718. */
  130719. private loadTexture;
  130720. /**
  130721. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130722. * @param buffer The ArrayBuffer that should be converted.
  130723. * @returns The buffer as Float32Array.
  130724. */
  130725. private getFloat32ArrayFromArrayBuffer;
  130726. /**
  130727. * Get the current class name of the texture useful for serialization or dynamic coding.
  130728. * @returns "EquiRectangularCubeTexture"
  130729. */
  130730. getClassName(): string;
  130731. /**
  130732. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130733. * @returns A clone of the current EquiRectangularCubeTexture.
  130734. */
  130735. clone(): EquiRectangularCubeTexture;
  130736. }
  130737. }
  130738. declare module BABYLON {
  130739. /**
  130740. * Based on jsTGALoader - Javascript loader for TGA file
  130741. * By Vincent Thibault
  130742. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130743. */
  130744. export class TGATools {
  130745. private static _TYPE_INDEXED;
  130746. private static _TYPE_RGB;
  130747. private static _TYPE_GREY;
  130748. private static _TYPE_RLE_INDEXED;
  130749. private static _TYPE_RLE_RGB;
  130750. private static _TYPE_RLE_GREY;
  130751. private static _ORIGIN_MASK;
  130752. private static _ORIGIN_SHIFT;
  130753. private static _ORIGIN_BL;
  130754. private static _ORIGIN_BR;
  130755. private static _ORIGIN_UL;
  130756. private static _ORIGIN_UR;
  130757. /**
  130758. * Gets the header of a TGA file
  130759. * @param data defines the TGA data
  130760. * @returns the header
  130761. */
  130762. static GetTGAHeader(data: Uint8Array): any;
  130763. /**
  130764. * Uploads TGA content to a Babylon Texture
  130765. * @hidden
  130766. */
  130767. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130768. /** @hidden */
  130769. 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;
  130770. /** @hidden */
  130771. 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;
  130772. /** @hidden */
  130773. 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;
  130774. /** @hidden */
  130775. 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;
  130776. /** @hidden */
  130777. 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;
  130778. /** @hidden */
  130779. 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;
  130780. }
  130781. }
  130782. declare module BABYLON {
  130783. /**
  130784. * Implementation of the TGA Texture Loader.
  130785. * @hidden
  130786. */
  130787. export class _TGATextureLoader implements IInternalTextureLoader {
  130788. /**
  130789. * Defines wether the loader supports cascade loading the different faces.
  130790. */
  130791. readonly supportCascades: boolean;
  130792. /**
  130793. * This returns if the loader support the current file information.
  130794. * @param extension defines the file extension of the file being loaded
  130795. * @returns true if the loader can load the specified file
  130796. */
  130797. canLoad(extension: string): boolean;
  130798. /**
  130799. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130800. * @param data contains the texture data
  130801. * @param texture defines the BabylonJS internal texture
  130802. * @param createPolynomials will be true if polynomials have been requested
  130803. * @param onLoad defines the callback to trigger once the texture is ready
  130804. * @param onError defines the callback to trigger in case of error
  130805. */
  130806. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130807. /**
  130808. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130809. * @param data contains the texture data
  130810. * @param texture defines the BabylonJS internal texture
  130811. * @param callback defines the method to call once ready to upload
  130812. */
  130813. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130814. }
  130815. }
  130816. declare module BABYLON {
  130817. /**
  130818. * Info about the .basis files
  130819. */
  130820. class BasisFileInfo {
  130821. /**
  130822. * If the file has alpha
  130823. */
  130824. hasAlpha: boolean;
  130825. /**
  130826. * Info about each image of the basis file
  130827. */
  130828. images: Array<{
  130829. levels: Array<{
  130830. width: number;
  130831. height: number;
  130832. transcodedPixels: ArrayBufferView;
  130833. }>;
  130834. }>;
  130835. }
  130836. /**
  130837. * Result of transcoding a basis file
  130838. */
  130839. class TranscodeResult {
  130840. /**
  130841. * Info about the .basis file
  130842. */
  130843. fileInfo: BasisFileInfo;
  130844. /**
  130845. * Format to use when loading the file
  130846. */
  130847. format: number;
  130848. }
  130849. /**
  130850. * Configuration options for the Basis transcoder
  130851. */
  130852. export class BasisTranscodeConfiguration {
  130853. /**
  130854. * Supported compression formats used to determine the supported output format of the transcoder
  130855. */
  130856. supportedCompressionFormats?: {
  130857. /**
  130858. * etc1 compression format
  130859. */
  130860. etc1?: boolean;
  130861. /**
  130862. * s3tc compression format
  130863. */
  130864. s3tc?: boolean;
  130865. /**
  130866. * pvrtc compression format
  130867. */
  130868. pvrtc?: boolean;
  130869. /**
  130870. * etc2 compression format
  130871. */
  130872. etc2?: boolean;
  130873. };
  130874. /**
  130875. * If mipmap levels should be loaded for transcoded images (Default: true)
  130876. */
  130877. loadMipmapLevels?: boolean;
  130878. /**
  130879. * Index of a single image to load (Default: all images)
  130880. */
  130881. loadSingleImage?: number;
  130882. }
  130883. /**
  130884. * Used to load .Basis files
  130885. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130886. */
  130887. export class BasisTools {
  130888. private static _IgnoreSupportedFormats;
  130889. /**
  130890. * URL to use when loading the basis transcoder
  130891. */
  130892. static JSModuleURL: string;
  130893. /**
  130894. * URL to use when loading the wasm module for the transcoder
  130895. */
  130896. static WasmModuleURL: string;
  130897. /**
  130898. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130899. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130900. * @returns internal format corresponding to the Basis format
  130901. */
  130902. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130903. private static _WorkerPromise;
  130904. private static _Worker;
  130905. private static _actionId;
  130906. private static _CreateWorkerAsync;
  130907. /**
  130908. * Transcodes a loaded image file to compressed pixel data
  130909. * @param data image data to transcode
  130910. * @param config configuration options for the transcoding
  130911. * @returns a promise resulting in the transcoded image
  130912. */
  130913. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130914. /**
  130915. * Loads a texture from the transcode result
  130916. * @param texture texture load to
  130917. * @param transcodeResult the result of transcoding the basis file to load from
  130918. */
  130919. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130920. }
  130921. }
  130922. declare module BABYLON {
  130923. /**
  130924. * Loader for .basis file format
  130925. */
  130926. export class _BasisTextureLoader implements IInternalTextureLoader {
  130927. /**
  130928. * Defines whether the loader supports cascade loading the different faces.
  130929. */
  130930. readonly supportCascades: boolean;
  130931. /**
  130932. * This returns if the loader support the current file information.
  130933. * @param extension defines the file extension of the file being loaded
  130934. * @returns true if the loader can load the specified file
  130935. */
  130936. canLoad(extension: string): boolean;
  130937. /**
  130938. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130939. * @param data contains the texture data
  130940. * @param texture defines the BabylonJS internal texture
  130941. * @param createPolynomials will be true if polynomials have been requested
  130942. * @param onLoad defines the callback to trigger once the texture is ready
  130943. * @param onError defines the callback to trigger in case of error
  130944. */
  130945. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130946. /**
  130947. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130948. * @param data contains the texture data
  130949. * @param texture defines the BabylonJS internal texture
  130950. * @param callback defines the method to call once ready to upload
  130951. */
  130952. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130953. }
  130954. }
  130955. declare module BABYLON {
  130956. /**
  130957. * 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.
  130958. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130960. */
  130961. export class CustomProceduralTexture extends ProceduralTexture {
  130962. private _animate;
  130963. private _time;
  130964. private _config;
  130965. private _texturePath;
  130966. /**
  130967. * Instantiates a new Custom Procedural Texture.
  130968. * 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.
  130969. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130970. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130971. * @param name Define the name of the texture
  130972. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  130973. * @param size Define the size of the texture to create
  130974. * @param scene Define the scene the texture belongs to
  130975. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  130976. * @param generateMipMaps Define if the texture should creates mip maps or not
  130977. */
  130978. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130979. private _loadJson;
  130980. /**
  130981. * Is the texture ready to be used ? (rendered at least once)
  130982. * @returns true if ready, otherwise, false.
  130983. */
  130984. isReady(): boolean;
  130985. /**
  130986. * Render the texture to its associated render target.
  130987. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  130988. */
  130989. render(useCameraPostProcess?: boolean): void;
  130990. /**
  130991. * Update the list of dependant textures samplers in the shader.
  130992. */
  130993. updateTextures(): void;
  130994. /**
  130995. * Update the uniform values of the procedural texture in the shader.
  130996. */
  130997. updateShaderUniforms(): void;
  130998. /**
  130999. * Define if the texture animates or not.
  131000. */
  131001. get animate(): boolean;
  131002. set animate(value: boolean);
  131003. }
  131004. }
  131005. declare module BABYLON {
  131006. /** @hidden */
  131007. export var noisePixelShader: {
  131008. name: string;
  131009. shader: string;
  131010. };
  131011. }
  131012. declare module BABYLON {
  131013. /**
  131014. * Class used to generate noise procedural textures
  131015. */
  131016. export class NoiseProceduralTexture extends ProceduralTexture {
  131017. private _time;
  131018. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131019. brightness: number;
  131020. /** Defines the number of octaves to process */
  131021. octaves: number;
  131022. /** Defines the level of persistence (0.8 by default) */
  131023. persistence: number;
  131024. /** Gets or sets animation speed factor (default is 1) */
  131025. animationSpeedFactor: number;
  131026. /**
  131027. * Creates a new NoiseProceduralTexture
  131028. * @param name defines the name fo the texture
  131029. * @param size defines the size of the texture (default is 256)
  131030. * @param scene defines the hosting scene
  131031. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131032. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131033. */
  131034. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131035. private _updateShaderUniforms;
  131036. protected _getDefines(): string;
  131037. /** Generate the current state of the procedural texture */
  131038. render(useCameraPostProcess?: boolean): void;
  131039. /**
  131040. * Serializes this noise procedural texture
  131041. * @returns a serialized noise procedural texture object
  131042. */
  131043. serialize(): any;
  131044. /**
  131045. * Clone the texture.
  131046. * @returns the cloned texture
  131047. */
  131048. clone(): NoiseProceduralTexture;
  131049. /**
  131050. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131051. * @param parsedTexture defines parsed texture data
  131052. * @param scene defines the current scene
  131053. * @param rootUrl defines the root URL containing noise procedural texture information
  131054. * @returns a parsed NoiseProceduralTexture
  131055. */
  131056. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131057. }
  131058. }
  131059. declare module BABYLON {
  131060. /**
  131061. * Raw cube texture where the raw buffers are passed in
  131062. */
  131063. export class RawCubeTexture extends CubeTexture {
  131064. /**
  131065. * Creates a cube texture where the raw buffers are passed in.
  131066. * @param scene defines the scene the texture is attached to
  131067. * @param data defines the array of data to use to create each face
  131068. * @param size defines the size of the textures
  131069. * @param format defines the format of the data
  131070. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131071. * @param generateMipMaps defines if the engine should generate the mip levels
  131072. * @param invertY defines if data must be stored with Y axis inverted
  131073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131074. * @param compression defines the compression used (null by default)
  131075. */
  131076. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131077. /**
  131078. * Updates the raw cube texture.
  131079. * @param data defines the data to store
  131080. * @param format defines the data format
  131081. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131082. * @param invertY defines if data must be stored with Y axis inverted
  131083. * @param compression defines the compression used (null by default)
  131084. * @param level defines which level of the texture to update
  131085. */
  131086. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131087. /**
  131088. * Updates a raw cube texture with RGBD encoded data.
  131089. * @param data defines the array of data [mipmap][face] to use to create each face
  131090. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131091. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131092. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131093. * @returns a promsie that resolves when the operation is complete
  131094. */
  131095. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131096. /**
  131097. * Clones the raw cube texture.
  131098. * @return a new cube texture
  131099. */
  131100. clone(): CubeTexture;
  131101. /** @hidden */
  131102. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131103. }
  131104. }
  131105. declare module BABYLON {
  131106. /**
  131107. * Class used to store 3D textures containing user data
  131108. */
  131109. export class RawTexture3D extends Texture {
  131110. /** Gets or sets the texture format to use */
  131111. format: number;
  131112. private _engine;
  131113. /**
  131114. * Create a new RawTexture3D
  131115. * @param data defines the data of the texture
  131116. * @param width defines the width of the texture
  131117. * @param height defines the height of the texture
  131118. * @param depth defines the depth of the texture
  131119. * @param format defines the texture format to use
  131120. * @param scene defines the hosting scene
  131121. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131122. * @param invertY defines if texture must be stored with Y axis inverted
  131123. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131124. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131125. */
  131126. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131127. /** Gets or sets the texture format to use */
  131128. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131129. /**
  131130. * Update the texture with new data
  131131. * @param data defines the data to store in the texture
  131132. */
  131133. update(data: ArrayBufferView): void;
  131134. }
  131135. }
  131136. declare module BABYLON {
  131137. /**
  131138. * Class used to store 2D array textures containing user data
  131139. */
  131140. export class RawTexture2DArray extends Texture {
  131141. /** Gets or sets the texture format to use */
  131142. format: number;
  131143. private _engine;
  131144. /**
  131145. * Create a new RawTexture2DArray
  131146. * @param data defines the data of the texture
  131147. * @param width defines the width of the texture
  131148. * @param height defines the height of the texture
  131149. * @param depth defines the number of layers of the texture
  131150. * @param format defines the texture format to use
  131151. * @param scene defines the hosting scene
  131152. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131153. * @param invertY defines if texture must be stored with Y axis inverted
  131154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131155. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131156. */
  131157. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131158. /** Gets or sets the texture format to use */
  131159. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131160. /**
  131161. * Update the texture with new data
  131162. * @param data defines the data to store in the texture
  131163. */
  131164. update(data: ArrayBufferView): void;
  131165. }
  131166. }
  131167. declare module BABYLON {
  131168. /**
  131169. * Creates a refraction texture used by refraction channel of the standard material.
  131170. * It is like a mirror but to see through a material.
  131171. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131172. */
  131173. export class RefractionTexture extends RenderTargetTexture {
  131174. /**
  131175. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131176. * 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.
  131177. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131178. */
  131179. refractionPlane: Plane;
  131180. /**
  131181. * Define how deep under the surface we should see.
  131182. */
  131183. depth: number;
  131184. /**
  131185. * Creates a refraction texture used by refraction channel of the standard material.
  131186. * It is like a mirror but to see through a material.
  131187. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131188. * @param name Define the texture name
  131189. * @param size Define the size of the underlying texture
  131190. * @param scene Define the scene the refraction belongs to
  131191. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131192. */
  131193. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131194. /**
  131195. * Clone the refraction texture.
  131196. * @returns the cloned texture
  131197. */
  131198. clone(): RefractionTexture;
  131199. /**
  131200. * Serialize the texture to a JSON representation you could use in Parse later on
  131201. * @returns the serialized JSON representation
  131202. */
  131203. serialize(): any;
  131204. }
  131205. }
  131206. declare module BABYLON {
  131207. /**
  131208. * Defines the options related to the creation of an HtmlElementTexture
  131209. */
  131210. export interface IHtmlElementTextureOptions {
  131211. /**
  131212. * Defines wether mip maps should be created or not.
  131213. */
  131214. generateMipMaps?: boolean;
  131215. /**
  131216. * Defines the sampling mode of the texture.
  131217. */
  131218. samplingMode?: number;
  131219. /**
  131220. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131221. */
  131222. engine: Nullable<ThinEngine>;
  131223. /**
  131224. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131225. */
  131226. scene: Nullable<Scene>;
  131227. }
  131228. /**
  131229. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131230. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131231. * is automatically managed.
  131232. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131233. * in your application.
  131234. *
  131235. * As the update is not automatic, you need to call them manually.
  131236. */
  131237. export class HtmlElementTexture extends BaseTexture {
  131238. /**
  131239. * The texture URL.
  131240. */
  131241. element: HTMLVideoElement | HTMLCanvasElement;
  131242. private static readonly DefaultOptions;
  131243. private _textureMatrix;
  131244. private _engine;
  131245. private _isVideo;
  131246. private _generateMipMaps;
  131247. private _samplingMode;
  131248. /**
  131249. * Instantiates a HtmlElementTexture from the following parameters.
  131250. *
  131251. * @param name Defines the name of the texture
  131252. * @param element Defines the video or canvas the texture is filled with
  131253. * @param options Defines the other none mandatory texture creation options
  131254. */
  131255. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131256. private _createInternalTexture;
  131257. /**
  131258. * Returns the texture matrix used in most of the material.
  131259. */
  131260. getTextureMatrix(): Matrix;
  131261. /**
  131262. * Updates the content of the texture.
  131263. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131264. */
  131265. update(invertY?: Nullable<boolean>): void;
  131266. }
  131267. }
  131268. declare module BABYLON {
  131269. /**
  131270. * Defines the basic options interface of a TexturePacker Frame
  131271. */
  131272. export interface ITexturePackerFrame {
  131273. /**
  131274. * The frame ID
  131275. */
  131276. id: number;
  131277. /**
  131278. * The frames Scale
  131279. */
  131280. scale: Vector2;
  131281. /**
  131282. * The Frames offset
  131283. */
  131284. offset: Vector2;
  131285. }
  131286. /**
  131287. * This is a support class for frame Data on texture packer sets.
  131288. */
  131289. export class TexturePackerFrame implements ITexturePackerFrame {
  131290. /**
  131291. * The frame ID
  131292. */
  131293. id: number;
  131294. /**
  131295. * The frames Scale
  131296. */
  131297. scale: Vector2;
  131298. /**
  131299. * The Frames offset
  131300. */
  131301. offset: Vector2;
  131302. /**
  131303. * Initializes a texture package frame.
  131304. * @param id The numerical frame identifier
  131305. * @param scale Scalar Vector2 for UV frame
  131306. * @param offset Vector2 for the frame position in UV units.
  131307. * @returns TexturePackerFrame
  131308. */
  131309. constructor(id: number, scale: Vector2, offset: Vector2);
  131310. }
  131311. }
  131312. declare module BABYLON {
  131313. /**
  131314. * Defines the basic options interface of a TexturePacker
  131315. */
  131316. export interface ITexturePackerOptions {
  131317. /**
  131318. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131319. */
  131320. map?: string[];
  131321. /**
  131322. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131323. */
  131324. uvsIn?: string;
  131325. /**
  131326. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131327. */
  131328. uvsOut?: string;
  131329. /**
  131330. * number representing the layout style. Defaults to LAYOUT_STRIP
  131331. */
  131332. layout?: number;
  131333. /**
  131334. * number of columns if using custom column count layout(2). This defaults to 4.
  131335. */
  131336. colnum?: number;
  131337. /**
  131338. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131339. */
  131340. updateInputMeshes?: boolean;
  131341. /**
  131342. * boolean flag to dispose all the source textures. Defaults to true.
  131343. */
  131344. disposeSources?: boolean;
  131345. /**
  131346. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131347. */
  131348. fillBlanks?: boolean;
  131349. /**
  131350. * string value representing the context fill style color. Defaults to 'black'.
  131351. */
  131352. customFillColor?: string;
  131353. /**
  131354. * Width and Height Value of each Frame in the TexturePacker Sets
  131355. */
  131356. frameSize?: number;
  131357. /**
  131358. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131359. */
  131360. paddingRatio?: number;
  131361. /**
  131362. * Number that declares the fill method for the padding gutter.
  131363. */
  131364. paddingMode?: number;
  131365. /**
  131366. * If in SUBUV_COLOR padding mode what color to use.
  131367. */
  131368. paddingColor?: Color3 | Color4;
  131369. }
  131370. /**
  131371. * Defines the basic interface of a TexturePacker JSON File
  131372. */
  131373. export interface ITexturePackerJSON {
  131374. /**
  131375. * The frame ID
  131376. */
  131377. name: string;
  131378. /**
  131379. * The base64 channel data
  131380. */
  131381. sets: any;
  131382. /**
  131383. * The options of the Packer
  131384. */
  131385. options: ITexturePackerOptions;
  131386. /**
  131387. * The frame data of the Packer
  131388. */
  131389. frames: Array<number>;
  131390. }
  131391. /**
  131392. * This is a support class that generates a series of packed texture sets.
  131393. * @see https://doc.babylonjs.com/babylon101/materials
  131394. */
  131395. export class TexturePacker {
  131396. /** Packer Layout Constant 0 */
  131397. static readonly LAYOUT_STRIP: number;
  131398. /** Packer Layout Constant 1 */
  131399. static readonly LAYOUT_POWER2: number;
  131400. /** Packer Layout Constant 2 */
  131401. static readonly LAYOUT_COLNUM: number;
  131402. /** Packer Layout Constant 0 */
  131403. static readonly SUBUV_WRAP: number;
  131404. /** Packer Layout Constant 1 */
  131405. static readonly SUBUV_EXTEND: number;
  131406. /** Packer Layout Constant 2 */
  131407. static readonly SUBUV_COLOR: number;
  131408. /** The Name of the Texture Package */
  131409. name: string;
  131410. /** The scene scope of the TexturePacker */
  131411. scene: Scene;
  131412. /** The Meshes to target */
  131413. meshes: AbstractMesh[];
  131414. /** Arguments passed with the Constructor */
  131415. options: ITexturePackerOptions;
  131416. /** The promise that is started upon initialization */
  131417. promise: Nullable<Promise<TexturePacker | string>>;
  131418. /** The Container object for the channel sets that are generated */
  131419. sets: object;
  131420. /** The Container array for the frames that are generated */
  131421. frames: TexturePackerFrame[];
  131422. /** The expected number of textures the system is parsing. */
  131423. private _expecting;
  131424. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131425. private _paddingValue;
  131426. /**
  131427. * Initializes a texture package series from an array of meshes or a single mesh.
  131428. * @param name The name of the package
  131429. * @param meshes The target meshes to compose the package from
  131430. * @param options The arguments that texture packer should follow while building.
  131431. * @param scene The scene which the textures are scoped to.
  131432. * @returns TexturePacker
  131433. */
  131434. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131435. /**
  131436. * Starts the package process
  131437. * @param resolve The promises resolution function
  131438. * @returns TexturePacker
  131439. */
  131440. private _createFrames;
  131441. /**
  131442. * Calculates the Size of the Channel Sets
  131443. * @returns Vector2
  131444. */
  131445. private _calculateSize;
  131446. /**
  131447. * Calculates the UV data for the frames.
  131448. * @param baseSize the base frameSize
  131449. * @param padding the base frame padding
  131450. * @param dtSize size of the Dynamic Texture for that channel
  131451. * @param dtUnits is 1/dtSize
  131452. * @param update flag to update the input meshes
  131453. */
  131454. private _calculateMeshUVFrames;
  131455. /**
  131456. * Calculates the frames Offset.
  131457. * @param index of the frame
  131458. * @returns Vector2
  131459. */
  131460. private _getFrameOffset;
  131461. /**
  131462. * Updates a Mesh to the frame data
  131463. * @param mesh that is the target
  131464. * @param frameID or the frame index
  131465. */
  131466. private _updateMeshUV;
  131467. /**
  131468. * Updates a Meshes materials to use the texture packer channels
  131469. * @param m is the mesh to target
  131470. * @param force all channels on the packer to be set.
  131471. */
  131472. private _updateTextureReferences;
  131473. /**
  131474. * Public method to set a Mesh to a frame
  131475. * @param m that is the target
  131476. * @param frameID or the frame index
  131477. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131478. */
  131479. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131480. /**
  131481. * Starts the async promise to compile the texture packer.
  131482. * @returns Promise<void>
  131483. */
  131484. processAsync(): Promise<void>;
  131485. /**
  131486. * Disposes all textures associated with this packer
  131487. */
  131488. dispose(): void;
  131489. /**
  131490. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131491. * @param imageType is the image type to use.
  131492. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131493. */
  131494. download(imageType?: string, quality?: number): void;
  131495. /**
  131496. * Public method to load a texturePacker JSON file.
  131497. * @param data of the JSON file in string format.
  131498. */
  131499. updateFromJSON(data: string): void;
  131500. }
  131501. }
  131502. declare module BABYLON {
  131503. /**
  131504. * Enum used to define the target of a block
  131505. */
  131506. export enum NodeMaterialBlockTargets {
  131507. /** Vertex shader */
  131508. Vertex = 1,
  131509. /** Fragment shader */
  131510. Fragment = 2,
  131511. /** Neutral */
  131512. Neutral = 4,
  131513. /** Vertex and Fragment */
  131514. VertexAndFragment = 3
  131515. }
  131516. }
  131517. declare module BABYLON {
  131518. /**
  131519. * Defines the kind of connection point for node based material
  131520. */
  131521. export enum NodeMaterialBlockConnectionPointTypes {
  131522. /** Float */
  131523. Float = 1,
  131524. /** Int */
  131525. Int = 2,
  131526. /** Vector2 */
  131527. Vector2 = 4,
  131528. /** Vector3 */
  131529. Vector3 = 8,
  131530. /** Vector4 */
  131531. Vector4 = 16,
  131532. /** Color3 */
  131533. Color3 = 32,
  131534. /** Color4 */
  131535. Color4 = 64,
  131536. /** Matrix */
  131537. Matrix = 128,
  131538. /** Detect type based on connection */
  131539. AutoDetect = 1024,
  131540. /** Output type that will be defined by input type */
  131541. BasedOnInput = 2048
  131542. }
  131543. }
  131544. declare module BABYLON {
  131545. /**
  131546. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131547. */
  131548. export enum NodeMaterialBlockConnectionPointMode {
  131549. /** Value is an uniform */
  131550. Uniform = 0,
  131551. /** Value is a mesh attribute */
  131552. Attribute = 1,
  131553. /** Value is a varying between vertex and fragment shaders */
  131554. Varying = 2,
  131555. /** Mode is undefined */
  131556. Undefined = 3
  131557. }
  131558. }
  131559. declare module BABYLON {
  131560. /**
  131561. * Enum used to define system values e.g. values automatically provided by the system
  131562. */
  131563. export enum NodeMaterialSystemValues {
  131564. /** World */
  131565. World = 1,
  131566. /** View */
  131567. View = 2,
  131568. /** Projection */
  131569. Projection = 3,
  131570. /** ViewProjection */
  131571. ViewProjection = 4,
  131572. /** WorldView */
  131573. WorldView = 5,
  131574. /** WorldViewProjection */
  131575. WorldViewProjection = 6,
  131576. /** CameraPosition */
  131577. CameraPosition = 7,
  131578. /** Fog Color */
  131579. FogColor = 8,
  131580. /** Delta time */
  131581. DeltaTime = 9
  131582. }
  131583. }
  131584. declare module BABYLON {
  131585. /**
  131586. * Root class for all node material optimizers
  131587. */
  131588. export class NodeMaterialOptimizer {
  131589. /**
  131590. * Function used to optimize a NodeMaterial graph
  131591. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131592. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131593. */
  131594. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131595. }
  131596. }
  131597. declare module BABYLON {
  131598. /**
  131599. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131600. */
  131601. export class TransformBlock extends NodeMaterialBlock {
  131602. /**
  131603. * Defines the value to use to complement W value to transform it to a Vector4
  131604. */
  131605. complementW: number;
  131606. /**
  131607. * Defines the value to use to complement z value to transform it to a Vector4
  131608. */
  131609. complementZ: number;
  131610. /**
  131611. * Creates a new TransformBlock
  131612. * @param name defines the block name
  131613. */
  131614. constructor(name: string);
  131615. /**
  131616. * Gets the current class name
  131617. * @returns the class name
  131618. */
  131619. getClassName(): string;
  131620. /**
  131621. * Gets the vector input
  131622. */
  131623. get vector(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the output component
  131626. */
  131627. get output(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the xyz output component
  131630. */
  131631. get xyz(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the matrix transform input
  131634. */
  131635. get transform(): NodeMaterialConnectionPoint;
  131636. protected _buildBlock(state: NodeMaterialBuildState): this;
  131637. serialize(): any;
  131638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131639. protected _dumpPropertiesCode(): string;
  131640. }
  131641. }
  131642. declare module BABYLON {
  131643. /**
  131644. * Block used to output the vertex position
  131645. */
  131646. export class VertexOutputBlock extends NodeMaterialBlock {
  131647. /**
  131648. * Creates a new VertexOutputBlock
  131649. * @param name defines the block name
  131650. */
  131651. constructor(name: string);
  131652. /**
  131653. * Gets the current class name
  131654. * @returns the class name
  131655. */
  131656. getClassName(): string;
  131657. /**
  131658. * Gets the vector input component
  131659. */
  131660. get vector(): NodeMaterialConnectionPoint;
  131661. protected _buildBlock(state: NodeMaterialBuildState): this;
  131662. }
  131663. }
  131664. declare module BABYLON {
  131665. /**
  131666. * Block used to output the final color
  131667. */
  131668. export class FragmentOutputBlock extends NodeMaterialBlock {
  131669. /**
  131670. * Create a new FragmentOutputBlock
  131671. * @param name defines the block name
  131672. */
  131673. constructor(name: string);
  131674. /**
  131675. * Gets the current class name
  131676. * @returns the class name
  131677. */
  131678. getClassName(): string;
  131679. /**
  131680. * Gets the rgba input component
  131681. */
  131682. get rgba(): NodeMaterialConnectionPoint;
  131683. /**
  131684. * Gets the rgb input component
  131685. */
  131686. get rgb(): NodeMaterialConnectionPoint;
  131687. /**
  131688. * Gets the a input component
  131689. */
  131690. get a(): NodeMaterialConnectionPoint;
  131691. protected _buildBlock(state: NodeMaterialBuildState): this;
  131692. }
  131693. }
  131694. declare module BABYLON {
  131695. /**
  131696. * Block used to read a reflection texture from a sampler
  131697. */
  131698. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131699. private _define3DName;
  131700. private _defineCubicName;
  131701. private _defineExplicitName;
  131702. private _defineProjectionName;
  131703. private _defineLocalCubicName;
  131704. private _defineSphericalName;
  131705. private _definePlanarName;
  131706. private _defineEquirectangularName;
  131707. private _defineMirroredEquirectangularFixedName;
  131708. private _defineEquirectangularFixedName;
  131709. private _defineSkyboxName;
  131710. private _cubeSamplerName;
  131711. private _2DSamplerName;
  131712. private _positionUVWName;
  131713. private _directionWName;
  131714. private _reflectionCoordsName;
  131715. private _reflection2DCoordsName;
  131716. private _reflectionColorName;
  131717. private _reflectionMatrixName;
  131718. /**
  131719. * Gets or sets the texture associated with the node
  131720. */
  131721. texture: Nullable<BaseTexture>;
  131722. /**
  131723. * Create a new TextureBlock
  131724. * @param name defines the block name
  131725. */
  131726. constructor(name: string);
  131727. /**
  131728. * Gets the current class name
  131729. * @returns the class name
  131730. */
  131731. getClassName(): string;
  131732. /**
  131733. * Gets the world position input component
  131734. */
  131735. get position(): NodeMaterialConnectionPoint;
  131736. /**
  131737. * Gets the world position input component
  131738. */
  131739. get worldPosition(): NodeMaterialConnectionPoint;
  131740. /**
  131741. * Gets the world normal input component
  131742. */
  131743. get worldNormal(): NodeMaterialConnectionPoint;
  131744. /**
  131745. * Gets the world input component
  131746. */
  131747. get world(): NodeMaterialConnectionPoint;
  131748. /**
  131749. * Gets the camera (or eye) position component
  131750. */
  131751. get cameraPosition(): NodeMaterialConnectionPoint;
  131752. /**
  131753. * Gets the view input component
  131754. */
  131755. get view(): NodeMaterialConnectionPoint;
  131756. /**
  131757. * Gets the rgb output component
  131758. */
  131759. get rgb(): NodeMaterialConnectionPoint;
  131760. /**
  131761. * Gets the r output component
  131762. */
  131763. get r(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the g output component
  131766. */
  131767. get g(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the b output component
  131770. */
  131771. get b(): NodeMaterialConnectionPoint;
  131772. autoConfigure(material: NodeMaterial): void;
  131773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131774. isReady(): boolean;
  131775. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131776. private _injectVertexCode;
  131777. private _writeOutput;
  131778. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131779. protected _dumpPropertiesCode(): string;
  131780. serialize(): any;
  131781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Interface used to configure the node material editor
  131787. */
  131788. export interface INodeMaterialEditorOptions {
  131789. /** Define the URl to load node editor script */
  131790. editorURL?: string;
  131791. }
  131792. /** @hidden */
  131793. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131794. NORMAL: boolean;
  131795. TANGENT: boolean;
  131796. UV1: boolean;
  131797. /** BONES */
  131798. NUM_BONE_INFLUENCERS: number;
  131799. BonesPerMesh: number;
  131800. BONETEXTURE: boolean;
  131801. /** MORPH TARGETS */
  131802. MORPHTARGETS: boolean;
  131803. MORPHTARGETS_NORMAL: boolean;
  131804. MORPHTARGETS_TANGENT: boolean;
  131805. MORPHTARGETS_UV: boolean;
  131806. NUM_MORPH_INFLUENCERS: number;
  131807. /** IMAGE PROCESSING */
  131808. IMAGEPROCESSING: boolean;
  131809. VIGNETTE: boolean;
  131810. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131811. VIGNETTEBLENDMODEOPAQUE: boolean;
  131812. TONEMAPPING: boolean;
  131813. TONEMAPPING_ACES: boolean;
  131814. CONTRAST: boolean;
  131815. EXPOSURE: boolean;
  131816. COLORCURVES: boolean;
  131817. COLORGRADING: boolean;
  131818. COLORGRADING3D: boolean;
  131819. SAMPLER3DGREENDEPTH: boolean;
  131820. SAMPLER3DBGRMAP: boolean;
  131821. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131822. /** MISC. */
  131823. BUMPDIRECTUV: number;
  131824. constructor();
  131825. setValue(name: string, value: boolean): void;
  131826. }
  131827. /**
  131828. * Class used to configure NodeMaterial
  131829. */
  131830. export interface INodeMaterialOptions {
  131831. /**
  131832. * Defines if blocks should emit comments
  131833. */
  131834. emitComments: boolean;
  131835. }
  131836. /**
  131837. * Class used to create a node based material built by assembling shader blocks
  131838. */
  131839. export class NodeMaterial extends PushMaterial {
  131840. private static _BuildIdGenerator;
  131841. private _options;
  131842. private _vertexCompilationState;
  131843. private _fragmentCompilationState;
  131844. private _sharedData;
  131845. private _buildId;
  131846. private _buildWasSuccessful;
  131847. private _cachedWorldViewMatrix;
  131848. private _cachedWorldViewProjectionMatrix;
  131849. private _optimizers;
  131850. private _animationFrame;
  131851. /** Define the Url to load node editor script */
  131852. static EditorURL: string;
  131853. /** Define the Url to load snippets */
  131854. static SnippetUrl: string;
  131855. private BJSNODEMATERIALEDITOR;
  131856. /** Get the inspector from bundle or global */
  131857. private _getGlobalNodeMaterialEditor;
  131858. /**
  131859. * Snippet ID if the material was created from the snippet server
  131860. */
  131861. snippetId: string;
  131862. /**
  131863. * Gets or sets data used by visual editor
  131864. * @see https://nme.babylonjs.com
  131865. */
  131866. editorData: any;
  131867. /**
  131868. * 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)
  131869. */
  131870. ignoreAlpha: boolean;
  131871. /**
  131872. * Defines the maximum number of lights that can be used in the material
  131873. */
  131874. maxSimultaneousLights: number;
  131875. /**
  131876. * Observable raised when the material is built
  131877. */
  131878. onBuildObservable: Observable<NodeMaterial>;
  131879. /**
  131880. * Gets or sets the root nodes of the material vertex shader
  131881. */
  131882. _vertexOutputNodes: NodeMaterialBlock[];
  131883. /**
  131884. * Gets or sets the root nodes of the material fragment (pixel) shader
  131885. */
  131886. _fragmentOutputNodes: NodeMaterialBlock[];
  131887. /** Gets or sets options to control the node material overall behavior */
  131888. get options(): INodeMaterialOptions;
  131889. set options(options: INodeMaterialOptions);
  131890. /**
  131891. * Default configuration related to image processing available in the standard Material.
  131892. */
  131893. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131894. /**
  131895. * Gets the image processing configuration used either in this material.
  131896. */
  131897. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131898. /**
  131899. * Sets the Default image processing configuration used either in the this material.
  131900. *
  131901. * If sets to null, the scene one is in use.
  131902. */
  131903. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131904. /**
  131905. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131906. */
  131907. attachedBlocks: NodeMaterialBlock[];
  131908. /**
  131909. * Create a new node based material
  131910. * @param name defines the material name
  131911. * @param scene defines the hosting scene
  131912. * @param options defines creation option
  131913. */
  131914. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131915. /**
  131916. * Gets the current class name of the material e.g. "NodeMaterial"
  131917. * @returns the class name
  131918. */
  131919. getClassName(): string;
  131920. /**
  131921. * Keep track of the image processing observer to allow dispose and replace.
  131922. */
  131923. private _imageProcessingObserver;
  131924. /**
  131925. * Attaches a new image processing configuration to the Standard Material.
  131926. * @param configuration
  131927. */
  131928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131929. /**
  131930. * Get a block by its name
  131931. * @param name defines the name of the block to retrieve
  131932. * @returns the required block or null if not found
  131933. */
  131934. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131935. /**
  131936. * Get a block by its name
  131937. * @param predicate defines the predicate used to find the good candidate
  131938. * @returns the required block or null if not found
  131939. */
  131940. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131941. /**
  131942. * Get an input block by its name
  131943. * @param predicate defines the predicate used to find the good candidate
  131944. * @returns the required input block or null if not found
  131945. */
  131946. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131947. /**
  131948. * Gets the list of input blocks attached to this material
  131949. * @returns an array of InputBlocks
  131950. */
  131951. getInputBlocks(): InputBlock[];
  131952. /**
  131953. * Adds a new optimizer to the list of optimizers
  131954. * @param optimizer defines the optimizers to add
  131955. * @returns the current material
  131956. */
  131957. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131958. /**
  131959. * Remove an optimizer from the list of optimizers
  131960. * @param optimizer defines the optimizers to remove
  131961. * @returns the current material
  131962. */
  131963. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131964. /**
  131965. * Add a new block to the list of output nodes
  131966. * @param node defines the node to add
  131967. * @returns the current material
  131968. */
  131969. addOutputNode(node: NodeMaterialBlock): this;
  131970. /**
  131971. * Remove a block from the list of root nodes
  131972. * @param node defines the node to remove
  131973. * @returns the current material
  131974. */
  131975. removeOutputNode(node: NodeMaterialBlock): this;
  131976. private _addVertexOutputNode;
  131977. private _removeVertexOutputNode;
  131978. private _addFragmentOutputNode;
  131979. private _removeFragmentOutputNode;
  131980. /**
  131981. * Specifies if the material will require alpha blending
  131982. * @returns a boolean specifying if alpha blending is needed
  131983. */
  131984. needAlphaBlending(): boolean;
  131985. /**
  131986. * Specifies if this material should be rendered in alpha test mode
  131987. * @returns a boolean specifying if an alpha test is needed.
  131988. */
  131989. needAlphaTesting(): boolean;
  131990. private _initializeBlock;
  131991. private _resetDualBlocks;
  131992. /**
  131993. * Remove a block from the current node material
  131994. * @param block defines the block to remove
  131995. */
  131996. removeBlock(block: NodeMaterialBlock): void;
  131997. /**
  131998. * Build the material and generates the inner effect
  131999. * @param verbose defines if the build should log activity
  132000. */
  132001. build(verbose?: boolean): void;
  132002. /**
  132003. * Runs an otpimization phase to try to improve the shader code
  132004. */
  132005. optimize(): void;
  132006. private _prepareDefinesForAttributes;
  132007. /**
  132008. * Get if the submesh is ready to be used and all its information available.
  132009. * Child classes can use it to update shaders
  132010. * @param mesh defines the mesh to check
  132011. * @param subMesh defines which submesh to check
  132012. * @param useInstances specifies that instances should be used
  132013. * @returns a boolean indicating that the submesh is ready or not
  132014. */
  132015. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132016. /**
  132017. * Get a string representing the shaders built by the current node graph
  132018. */
  132019. get compiledShaders(): string;
  132020. /**
  132021. * Binds the world matrix to the material
  132022. * @param world defines the world transformation matrix
  132023. */
  132024. bindOnlyWorldMatrix(world: Matrix): void;
  132025. /**
  132026. * Binds the submesh to this material by preparing the effect and shader to draw
  132027. * @param world defines the world transformation matrix
  132028. * @param mesh defines the mesh containing the submesh
  132029. * @param subMesh defines the submesh to bind the material to
  132030. */
  132031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132032. /**
  132033. * Gets the active textures from the material
  132034. * @returns an array of textures
  132035. */
  132036. getActiveTextures(): BaseTexture[];
  132037. /**
  132038. * Gets the list of texture blocks
  132039. * @returns an array of texture blocks
  132040. */
  132041. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132042. /**
  132043. * Specifies if the material uses a texture
  132044. * @param texture defines the texture to check against the material
  132045. * @returns a boolean specifying if the material uses the texture
  132046. */
  132047. hasTexture(texture: BaseTexture): boolean;
  132048. /**
  132049. * Disposes the material
  132050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132053. */
  132054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132055. /** Creates the node editor window. */
  132056. private _createNodeEditor;
  132057. /**
  132058. * Launch the node material editor
  132059. * @param config Define the configuration of the editor
  132060. * @return a promise fulfilled when the node editor is visible
  132061. */
  132062. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132063. /**
  132064. * Clear the current material
  132065. */
  132066. clear(): void;
  132067. /**
  132068. * Clear the current material and set it to a default state
  132069. */
  132070. setToDefault(): void;
  132071. /**
  132072. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132073. * @param url defines the url to load from
  132074. * @returns a promise that will fullfil when the material is fully loaded
  132075. */
  132076. loadAsync(url: string): Promise<void>;
  132077. private _gatherBlocks;
  132078. /**
  132079. * Generate a string containing the code declaration required to create an equivalent of this material
  132080. * @returns a string
  132081. */
  132082. generateCode(): string;
  132083. /**
  132084. * Serializes this material in a JSON representation
  132085. * @returns the serialized material object
  132086. */
  132087. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132088. private _restoreConnections;
  132089. /**
  132090. * Clear the current graph and load a new one from a serialization object
  132091. * @param source defines the JSON representation of the material
  132092. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132093. */
  132094. loadFromSerialization(source: any, rootUrl?: string): void;
  132095. /**
  132096. * Makes a duplicate of the current material.
  132097. * @param name - name to use for the new material.
  132098. */
  132099. clone(name: string): NodeMaterial;
  132100. /**
  132101. * Creates a node material from parsed material data
  132102. * @param source defines the JSON representation of the material
  132103. * @param scene defines the hosting scene
  132104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132105. * @returns a new node material
  132106. */
  132107. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132108. /**
  132109. * Creates a node material from a snippet saved in a remote file
  132110. * @param name defines the name of the material to create
  132111. * @param url defines the url to load from
  132112. * @param scene defines the hosting scene
  132113. * @returns a promise that will resolve to the new node material
  132114. */
  132115. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132116. /**
  132117. * Creates a node material from a snippet saved by the node material editor
  132118. * @param snippetId defines the snippet to load
  132119. * @param scene defines the hosting scene
  132120. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132121. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132122. * @returns a promise that will resolve to the new node material
  132123. */
  132124. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132125. /**
  132126. * Creates a new node material set to default basic configuration
  132127. * @param name defines the name of the material
  132128. * @param scene defines the hosting scene
  132129. * @returns a new NodeMaterial
  132130. */
  132131. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132132. }
  132133. }
  132134. declare module BABYLON {
  132135. /**
  132136. * Block used to read a texture from a sampler
  132137. */
  132138. export class TextureBlock extends NodeMaterialBlock {
  132139. private _defineName;
  132140. private _linearDefineName;
  132141. private _tempTextureRead;
  132142. private _samplerName;
  132143. private _transformedUVName;
  132144. private _textureTransformName;
  132145. private _textureInfoName;
  132146. private _mainUVName;
  132147. private _mainUVDefineName;
  132148. /**
  132149. * Gets or sets the texture associated with the node
  132150. */
  132151. texture: Nullable<Texture>;
  132152. /**
  132153. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132154. */
  132155. convertToGammaSpace: boolean;
  132156. /**
  132157. * Create a new TextureBlock
  132158. * @param name defines the block name
  132159. */
  132160. constructor(name: string);
  132161. /**
  132162. * Gets the current class name
  132163. * @returns the class name
  132164. */
  132165. getClassName(): string;
  132166. /**
  132167. * Gets the uv input component
  132168. */
  132169. get uv(): NodeMaterialConnectionPoint;
  132170. /**
  132171. * Gets the rgba output component
  132172. */
  132173. get rgba(): NodeMaterialConnectionPoint;
  132174. /**
  132175. * Gets the rgb output component
  132176. */
  132177. get rgb(): NodeMaterialConnectionPoint;
  132178. /**
  132179. * Gets the r output component
  132180. */
  132181. get r(): NodeMaterialConnectionPoint;
  132182. /**
  132183. * Gets the g output component
  132184. */
  132185. get g(): NodeMaterialConnectionPoint;
  132186. /**
  132187. * Gets the b output component
  132188. */
  132189. get b(): NodeMaterialConnectionPoint;
  132190. /**
  132191. * Gets the a output component
  132192. */
  132193. get a(): NodeMaterialConnectionPoint;
  132194. get target(): NodeMaterialBlockTargets;
  132195. autoConfigure(material: NodeMaterial): void;
  132196. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132198. isReady(): boolean;
  132199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132200. private get _isMixed();
  132201. private _injectVertexCode;
  132202. private _writeTextureRead;
  132203. private _writeOutput;
  132204. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132205. protected _dumpPropertiesCode(): string;
  132206. serialize(): any;
  132207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132208. }
  132209. }
  132210. declare module BABYLON {
  132211. /**
  132212. * Class used to store shared data between 2 NodeMaterialBuildState
  132213. */
  132214. export class NodeMaterialBuildStateSharedData {
  132215. /**
  132216. * Gets the list of emitted varyings
  132217. */
  132218. temps: string[];
  132219. /**
  132220. * Gets the list of emitted varyings
  132221. */
  132222. varyings: string[];
  132223. /**
  132224. * Gets the varying declaration string
  132225. */
  132226. varyingDeclaration: string;
  132227. /**
  132228. * Input blocks
  132229. */
  132230. inputBlocks: InputBlock[];
  132231. /**
  132232. * Input blocks
  132233. */
  132234. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132235. /**
  132236. * Bindable blocks (Blocks that need to set data to the effect)
  132237. */
  132238. bindableBlocks: NodeMaterialBlock[];
  132239. /**
  132240. * List of blocks that can provide a compilation fallback
  132241. */
  132242. blocksWithFallbacks: NodeMaterialBlock[];
  132243. /**
  132244. * List of blocks that can provide a define update
  132245. */
  132246. blocksWithDefines: NodeMaterialBlock[];
  132247. /**
  132248. * List of blocks that can provide a repeatable content
  132249. */
  132250. repeatableContentBlocks: NodeMaterialBlock[];
  132251. /**
  132252. * List of blocks that can provide a dynamic list of uniforms
  132253. */
  132254. dynamicUniformBlocks: NodeMaterialBlock[];
  132255. /**
  132256. * List of blocks that can block the isReady function for the material
  132257. */
  132258. blockingBlocks: NodeMaterialBlock[];
  132259. /**
  132260. * Gets the list of animated inputs
  132261. */
  132262. animatedInputs: InputBlock[];
  132263. /**
  132264. * Build Id used to avoid multiple recompilations
  132265. */
  132266. buildId: number;
  132267. /** List of emitted variables */
  132268. variableNames: {
  132269. [key: string]: number;
  132270. };
  132271. /** List of emitted defines */
  132272. defineNames: {
  132273. [key: string]: number;
  132274. };
  132275. /** Should emit comments? */
  132276. emitComments: boolean;
  132277. /** Emit build activity */
  132278. verbose: boolean;
  132279. /** Gets or sets the hosting scene */
  132280. scene: Scene;
  132281. /**
  132282. * Gets the compilation hints emitted at compilation time
  132283. */
  132284. hints: {
  132285. needWorldViewMatrix: boolean;
  132286. needWorldViewProjectionMatrix: boolean;
  132287. needAlphaBlending: boolean;
  132288. needAlphaTesting: boolean;
  132289. };
  132290. /**
  132291. * List of compilation checks
  132292. */
  132293. checks: {
  132294. emitVertex: boolean;
  132295. emitFragment: boolean;
  132296. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132297. };
  132298. /** Creates a new shared data */
  132299. constructor();
  132300. /**
  132301. * Emits console errors and exceptions if there is a failing check
  132302. */
  132303. emitErrors(): void;
  132304. }
  132305. }
  132306. declare module BABYLON {
  132307. /**
  132308. * Class used to store node based material build state
  132309. */
  132310. export class NodeMaterialBuildState {
  132311. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132312. supportUniformBuffers: boolean;
  132313. /**
  132314. * Gets the list of emitted attributes
  132315. */
  132316. attributes: string[];
  132317. /**
  132318. * Gets the list of emitted uniforms
  132319. */
  132320. uniforms: string[];
  132321. /**
  132322. * Gets the list of emitted constants
  132323. */
  132324. constants: string[];
  132325. /**
  132326. * Gets the list of emitted samplers
  132327. */
  132328. samplers: string[];
  132329. /**
  132330. * Gets the list of emitted functions
  132331. */
  132332. functions: {
  132333. [key: string]: string;
  132334. };
  132335. /**
  132336. * Gets the list of emitted extensions
  132337. */
  132338. extensions: {
  132339. [key: string]: string;
  132340. };
  132341. /**
  132342. * Gets the target of the compilation state
  132343. */
  132344. target: NodeMaterialBlockTargets;
  132345. /**
  132346. * Gets the list of emitted counters
  132347. */
  132348. counters: {
  132349. [key: string]: number;
  132350. };
  132351. /**
  132352. * Shared data between multiple NodeMaterialBuildState instances
  132353. */
  132354. sharedData: NodeMaterialBuildStateSharedData;
  132355. /** @hidden */
  132356. _vertexState: NodeMaterialBuildState;
  132357. /** @hidden */
  132358. _attributeDeclaration: string;
  132359. /** @hidden */
  132360. _uniformDeclaration: string;
  132361. /** @hidden */
  132362. _constantDeclaration: string;
  132363. /** @hidden */
  132364. _samplerDeclaration: string;
  132365. /** @hidden */
  132366. _varyingTransfer: string;
  132367. private _repeatableContentAnchorIndex;
  132368. /** @hidden */
  132369. _builtCompilationString: string;
  132370. /**
  132371. * Gets the emitted compilation strings
  132372. */
  132373. compilationString: string;
  132374. /**
  132375. * Finalize the compilation strings
  132376. * @param state defines the current compilation state
  132377. */
  132378. finalize(state: NodeMaterialBuildState): void;
  132379. /** @hidden */
  132380. get _repeatableContentAnchor(): string;
  132381. /** @hidden */
  132382. _getFreeVariableName(prefix: string): string;
  132383. /** @hidden */
  132384. _getFreeDefineName(prefix: string): string;
  132385. /** @hidden */
  132386. _excludeVariableName(name: string): void;
  132387. /** @hidden */
  132388. _emit2DSampler(name: string): void;
  132389. /** @hidden */
  132390. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132391. /** @hidden */
  132392. _emitExtension(name: string, extension: string): void;
  132393. /** @hidden */
  132394. _emitFunction(name: string, code: string, comments: string): void;
  132395. /** @hidden */
  132396. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132397. replaceStrings?: {
  132398. search: RegExp;
  132399. replace: string;
  132400. }[];
  132401. repeatKey?: string;
  132402. }): string;
  132403. /** @hidden */
  132404. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132405. repeatKey?: string;
  132406. removeAttributes?: boolean;
  132407. removeUniforms?: boolean;
  132408. removeVaryings?: boolean;
  132409. removeIfDef?: boolean;
  132410. replaceStrings?: {
  132411. search: RegExp;
  132412. replace: string;
  132413. }[];
  132414. }, storeKey?: string): void;
  132415. /** @hidden */
  132416. _registerTempVariable(name: string): boolean;
  132417. /** @hidden */
  132418. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132419. /** @hidden */
  132420. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132421. /** @hidden */
  132422. _emitFloat(value: number): string;
  132423. }
  132424. }
  132425. declare module BABYLON {
  132426. /**
  132427. * Defines a block that can be used inside a node based material
  132428. */
  132429. export class NodeMaterialBlock {
  132430. private _buildId;
  132431. private _buildTarget;
  132432. private _target;
  132433. private _isFinalMerger;
  132434. private _isInput;
  132435. protected _isUnique: boolean;
  132436. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132437. inputsAreExclusive: boolean;
  132438. /** @hidden */
  132439. _codeVariableName: string;
  132440. /** @hidden */
  132441. _inputs: NodeMaterialConnectionPoint[];
  132442. /** @hidden */
  132443. _outputs: NodeMaterialConnectionPoint[];
  132444. /** @hidden */
  132445. _preparationId: number;
  132446. /**
  132447. * Gets or sets the name of the block
  132448. */
  132449. name: string;
  132450. /**
  132451. * Gets or sets the unique id of the node
  132452. */
  132453. uniqueId: number;
  132454. /**
  132455. * Gets or sets the comments associated with this block
  132456. */
  132457. comments: string;
  132458. /**
  132459. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132460. */
  132461. get isUnique(): boolean;
  132462. /**
  132463. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132464. */
  132465. get isFinalMerger(): boolean;
  132466. /**
  132467. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132468. */
  132469. get isInput(): boolean;
  132470. /**
  132471. * Gets or sets the build Id
  132472. */
  132473. get buildId(): number;
  132474. set buildId(value: number);
  132475. /**
  132476. * Gets or sets the target of the block
  132477. */
  132478. get target(): NodeMaterialBlockTargets;
  132479. set target(value: NodeMaterialBlockTargets);
  132480. /**
  132481. * Gets the list of input points
  132482. */
  132483. get inputs(): NodeMaterialConnectionPoint[];
  132484. /** Gets the list of output points */
  132485. get outputs(): NodeMaterialConnectionPoint[];
  132486. /**
  132487. * Find an input by its name
  132488. * @param name defines the name of the input to look for
  132489. * @returns the input or null if not found
  132490. */
  132491. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132492. /**
  132493. * Find an output by its name
  132494. * @param name defines the name of the outputto look for
  132495. * @returns the output or null if not found
  132496. */
  132497. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132498. /**
  132499. * Creates a new NodeMaterialBlock
  132500. * @param name defines the block name
  132501. * @param target defines the target of that block (Vertex by default)
  132502. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132503. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132504. */
  132505. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132506. /**
  132507. * Initialize the block and prepare the context for build
  132508. * @param state defines the state that will be used for the build
  132509. */
  132510. initialize(state: NodeMaterialBuildState): void;
  132511. /**
  132512. * Bind data to effect. Will only be called for blocks with isBindable === true
  132513. * @param effect defines the effect to bind data to
  132514. * @param nodeMaterial defines the hosting NodeMaterial
  132515. * @param mesh defines the mesh that will be rendered
  132516. */
  132517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132518. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132519. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132520. protected _writeFloat(value: number): string;
  132521. /**
  132522. * Gets the current class name e.g. "NodeMaterialBlock"
  132523. * @returns the class name
  132524. */
  132525. getClassName(): string;
  132526. /**
  132527. * Register a new input. Must be called inside a block constructor
  132528. * @param name defines the connection point name
  132529. * @param type defines the connection point type
  132530. * @param isOptional defines a boolean indicating that this input can be omitted
  132531. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132532. * @returns the current block
  132533. */
  132534. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132535. /**
  132536. * Register a new output. Must be called inside a block constructor
  132537. * @param name defines the connection point name
  132538. * @param type defines the connection point type
  132539. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132540. * @returns the current block
  132541. */
  132542. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132543. /**
  132544. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132545. * @param forOutput defines an optional connection point to check compatibility with
  132546. * @returns the first available input or null
  132547. */
  132548. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132549. /**
  132550. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132551. * @param forBlock defines an optional block to check compatibility with
  132552. * @returns the first available input or null
  132553. */
  132554. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132555. /**
  132556. * Gets the sibling of the given output
  132557. * @param current defines the current output
  132558. * @returns the next output in the list or null
  132559. */
  132560. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132561. /**
  132562. * Connect current block with another block
  132563. * @param other defines the block to connect with
  132564. * @param options define the various options to help pick the right connections
  132565. * @returns the current block
  132566. */
  132567. connectTo(other: NodeMaterialBlock, options?: {
  132568. input?: string;
  132569. output?: string;
  132570. outputSwizzle?: string;
  132571. }): this | undefined;
  132572. protected _buildBlock(state: NodeMaterialBuildState): void;
  132573. /**
  132574. * Add uniforms, samplers and uniform buffers at compilation time
  132575. * @param state defines the state to update
  132576. * @param nodeMaterial defines the node material requesting the update
  132577. * @param defines defines the material defines to update
  132578. * @param uniformBuffers defines the list of uniform buffer names
  132579. */
  132580. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132581. /**
  132582. * Add potential fallbacks if shader compilation fails
  132583. * @param mesh defines the mesh to be rendered
  132584. * @param fallbacks defines the current prioritized list of fallbacks
  132585. */
  132586. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132587. /**
  132588. * Initialize defines for shader compilation
  132589. * @param mesh defines the mesh to be rendered
  132590. * @param nodeMaterial defines the node material requesting the update
  132591. * @param defines defines the material defines to update
  132592. * @param useInstances specifies that instances should be used
  132593. */
  132594. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132595. /**
  132596. * Update defines for shader compilation
  132597. * @param mesh defines the mesh to be rendered
  132598. * @param nodeMaterial defines the node material requesting the update
  132599. * @param defines defines the material defines to update
  132600. * @param useInstances specifies that instances should be used
  132601. */
  132602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132603. /**
  132604. * Lets the block try to connect some inputs automatically
  132605. * @param material defines the hosting NodeMaterial
  132606. */
  132607. autoConfigure(material: NodeMaterial): void;
  132608. /**
  132609. * Function called when a block is declared as repeatable content generator
  132610. * @param vertexShaderState defines the current compilation state for the vertex shader
  132611. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132612. * @param mesh defines the mesh to be rendered
  132613. * @param defines defines the material defines to update
  132614. */
  132615. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132616. /**
  132617. * Checks if the block is ready
  132618. * @param mesh defines the mesh to be rendered
  132619. * @param nodeMaterial defines the node material requesting the update
  132620. * @param defines defines the material defines to update
  132621. * @param useInstances specifies that instances should be used
  132622. * @returns true if the block is ready
  132623. */
  132624. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132625. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132626. private _processBuild;
  132627. /**
  132628. * Compile the current node and generate the shader code
  132629. * @param state defines the current compilation state (uniforms, samplers, current string)
  132630. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132631. * @returns true if already built
  132632. */
  132633. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132634. protected _inputRename(name: string): string;
  132635. protected _outputRename(name: string): string;
  132636. protected _dumpPropertiesCode(): string;
  132637. /** @hidden */
  132638. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132639. /** @hidden */
  132640. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132641. /**
  132642. * Clone the current block to a new identical block
  132643. * @param scene defines the hosting scene
  132644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132645. * @returns a copy of the current block
  132646. */
  132647. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132648. /**
  132649. * Serializes this block in a JSON representation
  132650. * @returns the serialized block object
  132651. */
  132652. serialize(): any;
  132653. /** @hidden */
  132654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132655. /**
  132656. * Release resources
  132657. */
  132658. dispose(): void;
  132659. }
  132660. }
  132661. declare module BABYLON {
  132662. /**
  132663. * Enum defining the type of animations supported by InputBlock
  132664. */
  132665. export enum AnimatedInputBlockTypes {
  132666. /** No animation */
  132667. None = 0,
  132668. /** Time based animation. Will only work for floats */
  132669. Time = 1
  132670. }
  132671. }
  132672. declare module BABYLON {
  132673. /**
  132674. * Block used to expose an input value
  132675. */
  132676. export class InputBlock extends NodeMaterialBlock {
  132677. private _mode;
  132678. private _associatedVariableName;
  132679. private _storedValue;
  132680. private _valueCallback;
  132681. private _type;
  132682. private _animationType;
  132683. /** Gets or set a value used to limit the range of float values */
  132684. min: number;
  132685. /** Gets or set a value used to limit the range of float values */
  132686. max: number;
  132687. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132688. isBoolean: boolean;
  132689. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132690. matrixMode: number;
  132691. /** @hidden */
  132692. _systemValue: Nullable<NodeMaterialSystemValues>;
  132693. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132694. visibleInInspector: boolean;
  132695. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132696. isConstant: boolean;
  132697. /** Gets or sets the group to use to display this block in the Inspector */
  132698. groupInInspector: string;
  132699. /** Gets an observable raised when the value is changed */
  132700. onValueChangedObservable: Observable<InputBlock>;
  132701. /**
  132702. * Gets or sets the connection point type (default is float)
  132703. */
  132704. get type(): NodeMaterialBlockConnectionPointTypes;
  132705. /**
  132706. * Creates a new InputBlock
  132707. * @param name defines the block name
  132708. * @param target defines the target of that block (Vertex by default)
  132709. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132710. */
  132711. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132712. /**
  132713. * Gets the output component
  132714. */
  132715. get output(): NodeMaterialConnectionPoint;
  132716. /**
  132717. * Set the source of this connection point to a vertex attribute
  132718. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132719. * @returns the current connection point
  132720. */
  132721. setAsAttribute(attributeName?: string): InputBlock;
  132722. /**
  132723. * Set the source of this connection point to a system value
  132724. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132725. * @returns the current connection point
  132726. */
  132727. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132728. /**
  132729. * Gets or sets the value of that point.
  132730. * Please note that this value will be ignored if valueCallback is defined
  132731. */
  132732. get value(): any;
  132733. set value(value: any);
  132734. /**
  132735. * Gets or sets a callback used to get the value of that point.
  132736. * Please note that setting this value will force the connection point to ignore the value property
  132737. */
  132738. get valueCallback(): () => any;
  132739. set valueCallback(value: () => any);
  132740. /**
  132741. * Gets or sets the associated variable name in the shader
  132742. */
  132743. get associatedVariableName(): string;
  132744. set associatedVariableName(value: string);
  132745. /** Gets or sets the type of animation applied to the input */
  132746. get animationType(): AnimatedInputBlockTypes;
  132747. set animationType(value: AnimatedInputBlockTypes);
  132748. /**
  132749. * Gets a boolean indicating that this connection point not defined yet
  132750. */
  132751. get isUndefined(): boolean;
  132752. /**
  132753. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132754. * In this case the connection point name must be the name of the uniform to use.
  132755. * Can only be set on inputs
  132756. */
  132757. get isUniform(): boolean;
  132758. set isUniform(value: boolean);
  132759. /**
  132760. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132761. * In this case the connection point name must be the name of the attribute to use
  132762. * Can only be set on inputs
  132763. */
  132764. get isAttribute(): boolean;
  132765. set isAttribute(value: boolean);
  132766. /**
  132767. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132768. * Can only be set on exit points
  132769. */
  132770. get isVarying(): boolean;
  132771. set isVarying(value: boolean);
  132772. /**
  132773. * Gets a boolean indicating that the current connection point is a system value
  132774. */
  132775. get isSystemValue(): boolean;
  132776. /**
  132777. * Gets or sets the current well known value or null if not defined as a system value
  132778. */
  132779. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132780. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132781. /**
  132782. * Gets the current class name
  132783. * @returns the class name
  132784. */
  132785. getClassName(): string;
  132786. /**
  132787. * Animate the input if animationType !== None
  132788. * @param scene defines the rendering scene
  132789. */
  132790. animate(scene: Scene): void;
  132791. private _emitDefine;
  132792. initialize(state: NodeMaterialBuildState): void;
  132793. /**
  132794. * Set the input block to its default value (based on its type)
  132795. */
  132796. setDefaultValue(): void;
  132797. private _emitConstant;
  132798. private _emit;
  132799. /** @hidden */
  132800. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132801. /** @hidden */
  132802. _transmit(effect: Effect, scene: Scene): void;
  132803. protected _buildBlock(state: NodeMaterialBuildState): void;
  132804. protected _dumpPropertiesCode(): string;
  132805. dispose(): void;
  132806. serialize(): any;
  132807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132808. }
  132809. }
  132810. declare module BABYLON {
  132811. /**
  132812. * Enum used to define the compatibility state between two connection points
  132813. */
  132814. export enum NodeMaterialConnectionPointCompatibilityStates {
  132815. /** Points are compatibles */
  132816. Compatible = 0,
  132817. /** Points are incompatible because of their types */
  132818. TypeIncompatible = 1,
  132819. /** Points are incompatible because of their targets (vertex vs fragment) */
  132820. TargetIncompatible = 2
  132821. }
  132822. /**
  132823. * Defines the direction of a connection point
  132824. */
  132825. export enum NodeMaterialConnectionPointDirection {
  132826. /** Input */
  132827. Input = 0,
  132828. /** Output */
  132829. Output = 1
  132830. }
  132831. /**
  132832. * Defines a connection point for a block
  132833. */
  132834. export class NodeMaterialConnectionPoint {
  132835. /** @hidden */
  132836. _ownerBlock: NodeMaterialBlock;
  132837. /** @hidden */
  132838. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132839. private _endpoints;
  132840. private _associatedVariableName;
  132841. private _direction;
  132842. /** @hidden */
  132843. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132844. /** @hidden */
  132845. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132846. private _type;
  132847. /** @hidden */
  132848. _enforceAssociatedVariableName: boolean;
  132849. /** Gets the direction of the point */
  132850. get direction(): NodeMaterialConnectionPointDirection;
  132851. /**
  132852. * Gets or sets the additional types supported by this connection point
  132853. */
  132854. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132855. /**
  132856. * Gets or sets the additional types excluded by this connection point
  132857. */
  132858. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132859. /**
  132860. * Observable triggered when this point is connected
  132861. */
  132862. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132863. /**
  132864. * Gets or sets the associated variable name in the shader
  132865. */
  132866. get associatedVariableName(): string;
  132867. set associatedVariableName(value: string);
  132868. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132869. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132870. /**
  132871. * Gets or sets the connection point type (default is float)
  132872. */
  132873. get type(): NodeMaterialBlockConnectionPointTypes;
  132874. set type(value: NodeMaterialBlockConnectionPointTypes);
  132875. /**
  132876. * Gets or sets the connection point name
  132877. */
  132878. name: string;
  132879. /**
  132880. * Gets or sets a boolean indicating that this connection point can be omitted
  132881. */
  132882. isOptional: boolean;
  132883. /**
  132884. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132885. */
  132886. define: string;
  132887. /** @hidden */
  132888. _prioritizeVertex: boolean;
  132889. private _target;
  132890. /** Gets or sets the target of that connection point */
  132891. get target(): NodeMaterialBlockTargets;
  132892. set target(value: NodeMaterialBlockTargets);
  132893. /**
  132894. * Gets a boolean indicating that the current point is connected
  132895. */
  132896. get isConnected(): boolean;
  132897. /**
  132898. * Gets a boolean indicating that the current point is connected to an input block
  132899. */
  132900. get isConnectedToInputBlock(): boolean;
  132901. /**
  132902. * Gets a the connected input block (if any)
  132903. */
  132904. get connectInputBlock(): Nullable<InputBlock>;
  132905. /** Get the other side of the connection (if any) */
  132906. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132907. /** Get the block that owns this connection point */
  132908. get ownerBlock(): NodeMaterialBlock;
  132909. /** Get the block connected on the other side of this connection (if any) */
  132910. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132911. /** Get the block connected on the endpoints of this connection (if any) */
  132912. get connectedBlocks(): Array<NodeMaterialBlock>;
  132913. /** Gets the list of connected endpoints */
  132914. get endpoints(): NodeMaterialConnectionPoint[];
  132915. /** Gets a boolean indicating if that output point is connected to at least one input */
  132916. get hasEndpoints(): boolean;
  132917. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132918. get isConnectedInVertexShader(): boolean;
  132919. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132920. get isConnectedInFragmentShader(): boolean;
  132921. /**
  132922. * Creates a new connection point
  132923. * @param name defines the connection point name
  132924. * @param ownerBlock defines the block hosting this connection point
  132925. * @param direction defines the direction of the connection point
  132926. */
  132927. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132928. /**
  132929. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132930. * @returns the class name
  132931. */
  132932. getClassName(): string;
  132933. /**
  132934. * Gets a boolean indicating if the current point can be connected to another point
  132935. * @param connectionPoint defines the other connection point
  132936. * @returns a boolean
  132937. */
  132938. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132939. /**
  132940. * Gets a number indicating if the current point can be connected to another point
  132941. * @param connectionPoint defines the other connection point
  132942. * @returns a number defining the compatibility state
  132943. */
  132944. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132945. /**
  132946. * Connect this point to another connection point
  132947. * @param connectionPoint defines the other connection point
  132948. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132949. * @returns the current connection point
  132950. */
  132951. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132952. /**
  132953. * Disconnect this point from one of his endpoint
  132954. * @param endpoint defines the other connection point
  132955. * @returns the current connection point
  132956. */
  132957. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132958. /**
  132959. * Serializes this point in a JSON representation
  132960. * @returns the serialized point object
  132961. */
  132962. serialize(): any;
  132963. /**
  132964. * Release resources
  132965. */
  132966. dispose(): void;
  132967. }
  132968. }
  132969. declare module BABYLON {
  132970. /**
  132971. * Block used to add support for vertex skinning (bones)
  132972. */
  132973. export class BonesBlock extends NodeMaterialBlock {
  132974. /**
  132975. * Creates a new BonesBlock
  132976. * @param name defines the block name
  132977. */
  132978. constructor(name: string);
  132979. /**
  132980. * Initialize the block and prepare the context for build
  132981. * @param state defines the state that will be used for the build
  132982. */
  132983. initialize(state: NodeMaterialBuildState): void;
  132984. /**
  132985. * Gets the current class name
  132986. * @returns the class name
  132987. */
  132988. getClassName(): string;
  132989. /**
  132990. * Gets the matrix indices input component
  132991. */
  132992. get matricesIndices(): NodeMaterialConnectionPoint;
  132993. /**
  132994. * Gets the matrix weights input component
  132995. */
  132996. get matricesWeights(): NodeMaterialConnectionPoint;
  132997. /**
  132998. * Gets the extra matrix indices input component
  132999. */
  133000. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133001. /**
  133002. * Gets the extra matrix weights input component
  133003. */
  133004. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133005. /**
  133006. * Gets the world input component
  133007. */
  133008. get world(): NodeMaterialConnectionPoint;
  133009. /**
  133010. * Gets the output component
  133011. */
  133012. get output(): NodeMaterialConnectionPoint;
  133013. autoConfigure(material: NodeMaterial): void;
  133014. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133017. protected _buildBlock(state: NodeMaterialBuildState): this;
  133018. }
  133019. }
  133020. declare module BABYLON {
  133021. /**
  133022. * Block used to add support for instances
  133023. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133024. */
  133025. export class InstancesBlock extends NodeMaterialBlock {
  133026. /**
  133027. * Creates a new InstancesBlock
  133028. * @param name defines the block name
  133029. */
  133030. constructor(name: string);
  133031. /**
  133032. * Gets the current class name
  133033. * @returns the class name
  133034. */
  133035. getClassName(): string;
  133036. /**
  133037. * Gets the first world row input component
  133038. */
  133039. get world0(): NodeMaterialConnectionPoint;
  133040. /**
  133041. * Gets the second world row input component
  133042. */
  133043. get world1(): NodeMaterialConnectionPoint;
  133044. /**
  133045. * Gets the third world row input component
  133046. */
  133047. get world2(): NodeMaterialConnectionPoint;
  133048. /**
  133049. * Gets the forth world row input component
  133050. */
  133051. get world3(): NodeMaterialConnectionPoint;
  133052. /**
  133053. * Gets the world input component
  133054. */
  133055. get world(): NodeMaterialConnectionPoint;
  133056. /**
  133057. * Gets the output component
  133058. */
  133059. get output(): NodeMaterialConnectionPoint;
  133060. /**
  133061. * Gets the isntanceID component
  133062. */
  133063. get instanceID(): NodeMaterialConnectionPoint;
  133064. autoConfigure(material: NodeMaterial): void;
  133065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133066. protected _buildBlock(state: NodeMaterialBuildState): this;
  133067. }
  133068. }
  133069. declare module BABYLON {
  133070. /**
  133071. * Block used to add morph targets support to vertex shader
  133072. */
  133073. export class MorphTargetsBlock extends NodeMaterialBlock {
  133074. private _repeatableContentAnchor;
  133075. /**
  133076. * Create a new MorphTargetsBlock
  133077. * @param name defines the block name
  133078. */
  133079. constructor(name: string);
  133080. /**
  133081. * Gets the current class name
  133082. * @returns the class name
  133083. */
  133084. getClassName(): string;
  133085. /**
  133086. * Gets the position input component
  133087. */
  133088. get position(): NodeMaterialConnectionPoint;
  133089. /**
  133090. * Gets the normal input component
  133091. */
  133092. get normal(): NodeMaterialConnectionPoint;
  133093. /**
  133094. * Gets the tangent input component
  133095. */
  133096. get tangent(): NodeMaterialConnectionPoint;
  133097. /**
  133098. * Gets the tangent input component
  133099. */
  133100. get uv(): NodeMaterialConnectionPoint;
  133101. /**
  133102. * Gets the position output component
  133103. */
  133104. get positionOutput(): NodeMaterialConnectionPoint;
  133105. /**
  133106. * Gets the normal output component
  133107. */
  133108. get normalOutput(): NodeMaterialConnectionPoint;
  133109. /**
  133110. * Gets the tangent output component
  133111. */
  133112. get tangentOutput(): NodeMaterialConnectionPoint;
  133113. /**
  133114. * Gets the tangent output component
  133115. */
  133116. get uvOutput(): NodeMaterialConnectionPoint;
  133117. initialize(state: NodeMaterialBuildState): void;
  133118. autoConfigure(material: NodeMaterial): void;
  133119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133121. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133122. protected _buildBlock(state: NodeMaterialBuildState): this;
  133123. }
  133124. }
  133125. declare module BABYLON {
  133126. /**
  133127. * Block used to get data information from a light
  133128. */
  133129. export class LightInformationBlock extends NodeMaterialBlock {
  133130. private _lightDataUniformName;
  133131. private _lightColorUniformName;
  133132. private _lightTypeDefineName;
  133133. /**
  133134. * Gets or sets the light associated with this block
  133135. */
  133136. light: Nullable<Light>;
  133137. /**
  133138. * Creates a new LightInformationBlock
  133139. * @param name defines the block name
  133140. */
  133141. constructor(name: string);
  133142. /**
  133143. * Gets the current class name
  133144. * @returns the class name
  133145. */
  133146. getClassName(): string;
  133147. /**
  133148. * Gets the world position input component
  133149. */
  133150. get worldPosition(): NodeMaterialConnectionPoint;
  133151. /**
  133152. * Gets the direction output component
  133153. */
  133154. get direction(): NodeMaterialConnectionPoint;
  133155. /**
  133156. * Gets the direction output component
  133157. */
  133158. get color(): NodeMaterialConnectionPoint;
  133159. /**
  133160. * Gets the direction output component
  133161. */
  133162. get intensity(): NodeMaterialConnectionPoint;
  133163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133165. protected _buildBlock(state: NodeMaterialBuildState): this;
  133166. serialize(): any;
  133167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133168. }
  133169. }
  133170. declare module BABYLON {
  133171. /**
  133172. * Block used to add image processing support to fragment shader
  133173. */
  133174. export class ImageProcessingBlock extends NodeMaterialBlock {
  133175. /**
  133176. * Create a new ImageProcessingBlock
  133177. * @param name defines the block name
  133178. */
  133179. constructor(name: string);
  133180. /**
  133181. * Gets the current class name
  133182. * @returns the class name
  133183. */
  133184. getClassName(): string;
  133185. /**
  133186. * Gets the color input component
  133187. */
  133188. get color(): NodeMaterialConnectionPoint;
  133189. /**
  133190. * Gets the output component
  133191. */
  133192. get output(): NodeMaterialConnectionPoint;
  133193. /**
  133194. * Initialize the block and prepare the context for build
  133195. * @param state defines the state that will be used for the build
  133196. */
  133197. initialize(state: NodeMaterialBuildState): void;
  133198. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133201. protected _buildBlock(state: NodeMaterialBuildState): this;
  133202. }
  133203. }
  133204. declare module BABYLON {
  133205. /**
  133206. * Block used to pertub normals based on a normal map
  133207. */
  133208. export class PerturbNormalBlock extends NodeMaterialBlock {
  133209. private _tangentSpaceParameterName;
  133210. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133211. invertX: boolean;
  133212. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133213. invertY: boolean;
  133214. /**
  133215. * Create a new PerturbNormalBlock
  133216. * @param name defines the block name
  133217. */
  133218. constructor(name: string);
  133219. /**
  133220. * Gets the current class name
  133221. * @returns the class name
  133222. */
  133223. getClassName(): string;
  133224. /**
  133225. * Gets the world position input component
  133226. */
  133227. get worldPosition(): NodeMaterialConnectionPoint;
  133228. /**
  133229. * Gets the world normal input component
  133230. */
  133231. get worldNormal(): NodeMaterialConnectionPoint;
  133232. /**
  133233. * Gets the world tangent input component
  133234. */
  133235. get worldTangent(): NodeMaterialConnectionPoint;
  133236. /**
  133237. * Gets the uv input component
  133238. */
  133239. get uv(): NodeMaterialConnectionPoint;
  133240. /**
  133241. * Gets the normal map color input component
  133242. */
  133243. get normalMapColor(): NodeMaterialConnectionPoint;
  133244. /**
  133245. * Gets the strength input component
  133246. */
  133247. get strength(): NodeMaterialConnectionPoint;
  133248. /**
  133249. * Gets the output component
  133250. */
  133251. get output(): NodeMaterialConnectionPoint;
  133252. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133253. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133254. autoConfigure(material: NodeMaterial): void;
  133255. protected _buildBlock(state: NodeMaterialBuildState): this;
  133256. protected _dumpPropertiesCode(): string;
  133257. serialize(): any;
  133258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133259. }
  133260. }
  133261. declare module BABYLON {
  133262. /**
  133263. * Block used to discard a pixel if a value is smaller than a cutoff
  133264. */
  133265. export class DiscardBlock extends NodeMaterialBlock {
  133266. /**
  133267. * Create a new DiscardBlock
  133268. * @param name defines the block name
  133269. */
  133270. constructor(name: string);
  133271. /**
  133272. * Gets the current class name
  133273. * @returns the class name
  133274. */
  133275. getClassName(): string;
  133276. /**
  133277. * Gets the color input component
  133278. */
  133279. get value(): NodeMaterialConnectionPoint;
  133280. /**
  133281. * Gets the cutoff input component
  133282. */
  133283. get cutoff(): NodeMaterialConnectionPoint;
  133284. protected _buildBlock(state: NodeMaterialBuildState): this;
  133285. }
  133286. }
  133287. declare module BABYLON {
  133288. /**
  133289. * Block used to test if the fragment shader is front facing
  133290. */
  133291. export class FrontFacingBlock extends NodeMaterialBlock {
  133292. /**
  133293. * Creates a new FrontFacingBlock
  133294. * @param name defines the block name
  133295. */
  133296. constructor(name: string);
  133297. /**
  133298. * Gets the current class name
  133299. * @returns the class name
  133300. */
  133301. getClassName(): string;
  133302. /**
  133303. * Gets the output component
  133304. */
  133305. get output(): NodeMaterialConnectionPoint;
  133306. protected _buildBlock(state: NodeMaterialBuildState): this;
  133307. }
  133308. }
  133309. declare module BABYLON {
  133310. /**
  133311. * Block used to get the derivative value on x and y of a given input
  133312. */
  133313. export class DerivativeBlock extends NodeMaterialBlock {
  133314. /**
  133315. * Create a new DerivativeBlock
  133316. * @param name defines the block name
  133317. */
  133318. constructor(name: string);
  133319. /**
  133320. * Gets the current class name
  133321. * @returns the class name
  133322. */
  133323. getClassName(): string;
  133324. /**
  133325. * Gets the input component
  133326. */
  133327. get input(): NodeMaterialConnectionPoint;
  133328. /**
  133329. * Gets the derivative output on x
  133330. */
  133331. get dx(): NodeMaterialConnectionPoint;
  133332. /**
  133333. * Gets the derivative output on y
  133334. */
  133335. get dy(): NodeMaterialConnectionPoint;
  133336. protected _buildBlock(state: NodeMaterialBuildState): this;
  133337. }
  133338. }
  133339. declare module BABYLON {
  133340. /**
  133341. * Block used to add support for scene fog
  133342. */
  133343. export class FogBlock extends NodeMaterialBlock {
  133344. private _fogDistanceName;
  133345. private _fogParameters;
  133346. /**
  133347. * Create a new FogBlock
  133348. * @param name defines the block name
  133349. */
  133350. constructor(name: string);
  133351. /**
  133352. * Gets the current class name
  133353. * @returns the class name
  133354. */
  133355. getClassName(): string;
  133356. /**
  133357. * Gets the world position input component
  133358. */
  133359. get worldPosition(): NodeMaterialConnectionPoint;
  133360. /**
  133361. * Gets the view input component
  133362. */
  133363. get view(): NodeMaterialConnectionPoint;
  133364. /**
  133365. * Gets the color input component
  133366. */
  133367. get input(): NodeMaterialConnectionPoint;
  133368. /**
  133369. * Gets the fog color input component
  133370. */
  133371. get fogColor(): NodeMaterialConnectionPoint;
  133372. /**
  133373. * Gets the output component
  133374. */
  133375. get output(): NodeMaterialConnectionPoint;
  133376. autoConfigure(material: NodeMaterial): void;
  133377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133379. protected _buildBlock(state: NodeMaterialBuildState): this;
  133380. }
  133381. }
  133382. declare module BABYLON {
  133383. /**
  133384. * Block used to add light in the fragment shader
  133385. */
  133386. export class LightBlock extends NodeMaterialBlock {
  133387. private _lightId;
  133388. /**
  133389. * Gets or sets the light associated with this block
  133390. */
  133391. light: Nullable<Light>;
  133392. /**
  133393. * Create a new LightBlock
  133394. * @param name defines the block name
  133395. */
  133396. constructor(name: string);
  133397. /**
  133398. * Gets the current class name
  133399. * @returns the class name
  133400. */
  133401. getClassName(): string;
  133402. /**
  133403. * Gets the world position input component
  133404. */
  133405. get worldPosition(): NodeMaterialConnectionPoint;
  133406. /**
  133407. * Gets the world normal input component
  133408. */
  133409. get worldNormal(): NodeMaterialConnectionPoint;
  133410. /**
  133411. * Gets the camera (or eye) position component
  133412. */
  133413. get cameraPosition(): NodeMaterialConnectionPoint;
  133414. /**
  133415. * Gets the glossiness component
  133416. */
  133417. get glossiness(): NodeMaterialConnectionPoint;
  133418. /**
  133419. * Gets the glossinness power component
  133420. */
  133421. get glossPower(): NodeMaterialConnectionPoint;
  133422. /**
  133423. * Gets the diffuse color component
  133424. */
  133425. get diffuseColor(): NodeMaterialConnectionPoint;
  133426. /**
  133427. * Gets the specular color component
  133428. */
  133429. get specularColor(): NodeMaterialConnectionPoint;
  133430. /**
  133431. * Gets the diffuse output component
  133432. */
  133433. get diffuseOutput(): NodeMaterialConnectionPoint;
  133434. /**
  133435. * Gets the specular output component
  133436. */
  133437. get specularOutput(): NodeMaterialConnectionPoint;
  133438. /**
  133439. * Gets the shadow output component
  133440. */
  133441. get shadow(): NodeMaterialConnectionPoint;
  133442. autoConfigure(material: NodeMaterial): void;
  133443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133444. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133445. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133446. private _injectVertexCode;
  133447. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133448. serialize(): any;
  133449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133450. }
  133451. }
  133452. declare module BABYLON {
  133453. /**
  133454. * Block used to multiply 2 values
  133455. */
  133456. export class MultiplyBlock extends NodeMaterialBlock {
  133457. /**
  133458. * Creates a new MultiplyBlock
  133459. * @param name defines the block name
  133460. */
  133461. constructor(name: string);
  133462. /**
  133463. * Gets the current class name
  133464. * @returns the class name
  133465. */
  133466. getClassName(): string;
  133467. /**
  133468. * Gets the left operand input component
  133469. */
  133470. get left(): NodeMaterialConnectionPoint;
  133471. /**
  133472. * Gets the right operand input component
  133473. */
  133474. get right(): NodeMaterialConnectionPoint;
  133475. /**
  133476. * Gets the output component
  133477. */
  133478. get output(): NodeMaterialConnectionPoint;
  133479. protected _buildBlock(state: NodeMaterialBuildState): this;
  133480. }
  133481. }
  133482. declare module BABYLON {
  133483. /**
  133484. * Block used to add 2 vectors
  133485. */
  133486. export class AddBlock extends NodeMaterialBlock {
  133487. /**
  133488. * Creates a new AddBlock
  133489. * @param name defines the block name
  133490. */
  133491. constructor(name: string);
  133492. /**
  133493. * Gets the current class name
  133494. * @returns the class name
  133495. */
  133496. getClassName(): string;
  133497. /**
  133498. * Gets the left operand input component
  133499. */
  133500. get left(): NodeMaterialConnectionPoint;
  133501. /**
  133502. * Gets the right operand input component
  133503. */
  133504. get right(): NodeMaterialConnectionPoint;
  133505. /**
  133506. * Gets the output component
  133507. */
  133508. get output(): NodeMaterialConnectionPoint;
  133509. protected _buildBlock(state: NodeMaterialBuildState): this;
  133510. }
  133511. }
  133512. declare module BABYLON {
  133513. /**
  133514. * Block used to scale a vector by a float
  133515. */
  133516. export class ScaleBlock extends NodeMaterialBlock {
  133517. /**
  133518. * Creates a new ScaleBlock
  133519. * @param name defines the block name
  133520. */
  133521. constructor(name: string);
  133522. /**
  133523. * Gets the current class name
  133524. * @returns the class name
  133525. */
  133526. getClassName(): string;
  133527. /**
  133528. * Gets the input component
  133529. */
  133530. get input(): NodeMaterialConnectionPoint;
  133531. /**
  133532. * Gets the factor input component
  133533. */
  133534. get factor(): NodeMaterialConnectionPoint;
  133535. /**
  133536. * Gets the output component
  133537. */
  133538. get output(): NodeMaterialConnectionPoint;
  133539. protected _buildBlock(state: NodeMaterialBuildState): this;
  133540. }
  133541. }
  133542. declare module BABYLON {
  133543. /**
  133544. * Block used to clamp a float
  133545. */
  133546. export class ClampBlock extends NodeMaterialBlock {
  133547. /** Gets or sets the minimum range */
  133548. minimum: number;
  133549. /** Gets or sets the maximum range */
  133550. maximum: number;
  133551. /**
  133552. * Creates a new ClampBlock
  133553. * @param name defines the block name
  133554. */
  133555. constructor(name: string);
  133556. /**
  133557. * Gets the current class name
  133558. * @returns the class name
  133559. */
  133560. getClassName(): string;
  133561. /**
  133562. * Gets the value input component
  133563. */
  133564. get value(): NodeMaterialConnectionPoint;
  133565. /**
  133566. * Gets the output component
  133567. */
  133568. get output(): NodeMaterialConnectionPoint;
  133569. protected _buildBlock(state: NodeMaterialBuildState): this;
  133570. protected _dumpPropertiesCode(): string;
  133571. serialize(): any;
  133572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133573. }
  133574. }
  133575. declare module BABYLON {
  133576. /**
  133577. * Block used to apply a cross product between 2 vectors
  133578. */
  133579. export class CrossBlock extends NodeMaterialBlock {
  133580. /**
  133581. * Creates a new CrossBlock
  133582. * @param name defines the block name
  133583. */
  133584. constructor(name: string);
  133585. /**
  133586. * Gets the current class name
  133587. * @returns the class name
  133588. */
  133589. getClassName(): string;
  133590. /**
  133591. * Gets the left operand input component
  133592. */
  133593. get left(): NodeMaterialConnectionPoint;
  133594. /**
  133595. * Gets the right operand input component
  133596. */
  133597. get right(): NodeMaterialConnectionPoint;
  133598. /**
  133599. * Gets the output component
  133600. */
  133601. get output(): NodeMaterialConnectionPoint;
  133602. protected _buildBlock(state: NodeMaterialBuildState): this;
  133603. }
  133604. }
  133605. declare module BABYLON {
  133606. /**
  133607. * Block used to apply a dot product between 2 vectors
  133608. */
  133609. export class DotBlock extends NodeMaterialBlock {
  133610. /**
  133611. * Creates a new DotBlock
  133612. * @param name defines the block name
  133613. */
  133614. constructor(name: string);
  133615. /**
  133616. * Gets the current class name
  133617. * @returns the class name
  133618. */
  133619. getClassName(): string;
  133620. /**
  133621. * Gets the left operand input component
  133622. */
  133623. get left(): NodeMaterialConnectionPoint;
  133624. /**
  133625. * Gets the right operand input component
  133626. */
  133627. get right(): NodeMaterialConnectionPoint;
  133628. /**
  133629. * Gets the output component
  133630. */
  133631. get output(): NodeMaterialConnectionPoint;
  133632. protected _buildBlock(state: NodeMaterialBuildState): this;
  133633. }
  133634. }
  133635. declare module BABYLON {
  133636. /**
  133637. * Block used to remap a float from a range to a new one
  133638. */
  133639. export class RemapBlock extends NodeMaterialBlock {
  133640. /**
  133641. * Gets or sets the source range
  133642. */
  133643. sourceRange: Vector2;
  133644. /**
  133645. * Gets or sets the target range
  133646. */
  133647. targetRange: Vector2;
  133648. /**
  133649. * Creates a new RemapBlock
  133650. * @param name defines the block name
  133651. */
  133652. constructor(name: string);
  133653. /**
  133654. * Gets the current class name
  133655. * @returns the class name
  133656. */
  133657. getClassName(): string;
  133658. /**
  133659. * Gets the input component
  133660. */
  133661. get input(): NodeMaterialConnectionPoint;
  133662. /**
  133663. * Gets the source min input component
  133664. */
  133665. get sourceMin(): NodeMaterialConnectionPoint;
  133666. /**
  133667. * Gets the source max input component
  133668. */
  133669. get sourceMax(): NodeMaterialConnectionPoint;
  133670. /**
  133671. * Gets the target min input component
  133672. */
  133673. get targetMin(): NodeMaterialConnectionPoint;
  133674. /**
  133675. * Gets the target max input component
  133676. */
  133677. get targetMax(): NodeMaterialConnectionPoint;
  133678. /**
  133679. * Gets the output component
  133680. */
  133681. get output(): NodeMaterialConnectionPoint;
  133682. protected _buildBlock(state: NodeMaterialBuildState): this;
  133683. protected _dumpPropertiesCode(): string;
  133684. serialize(): any;
  133685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133686. }
  133687. }
  133688. declare module BABYLON {
  133689. /**
  133690. * Block used to normalize a vector
  133691. */
  133692. export class NormalizeBlock extends NodeMaterialBlock {
  133693. /**
  133694. * Creates a new NormalizeBlock
  133695. * @param name defines the block name
  133696. */
  133697. constructor(name: string);
  133698. /**
  133699. * Gets the current class name
  133700. * @returns the class name
  133701. */
  133702. getClassName(): string;
  133703. /**
  133704. * Gets the input component
  133705. */
  133706. get input(): NodeMaterialConnectionPoint;
  133707. /**
  133708. * Gets the output component
  133709. */
  133710. get output(): NodeMaterialConnectionPoint;
  133711. protected _buildBlock(state: NodeMaterialBuildState): this;
  133712. }
  133713. }
  133714. declare module BABYLON {
  133715. /**
  133716. * Operations supported by the Trigonometry block
  133717. */
  133718. export enum TrigonometryBlockOperations {
  133719. /** Cos */
  133720. Cos = 0,
  133721. /** Sin */
  133722. Sin = 1,
  133723. /** Abs */
  133724. Abs = 2,
  133725. /** Exp */
  133726. Exp = 3,
  133727. /** Exp2 */
  133728. Exp2 = 4,
  133729. /** Round */
  133730. Round = 5,
  133731. /** Floor */
  133732. Floor = 6,
  133733. /** Ceiling */
  133734. Ceiling = 7,
  133735. /** Square root */
  133736. Sqrt = 8,
  133737. /** Log */
  133738. Log = 9,
  133739. /** Tangent */
  133740. Tan = 10,
  133741. /** Arc tangent */
  133742. ArcTan = 11,
  133743. /** Arc cosinus */
  133744. ArcCos = 12,
  133745. /** Arc sinus */
  133746. ArcSin = 13,
  133747. /** Fraction */
  133748. Fract = 14,
  133749. /** Sign */
  133750. Sign = 15,
  133751. /** To radians (from degrees) */
  133752. Radians = 16,
  133753. /** To degrees (from radians) */
  133754. Degrees = 17
  133755. }
  133756. /**
  133757. * Block used to apply trigonometry operation to floats
  133758. */
  133759. export class TrigonometryBlock extends NodeMaterialBlock {
  133760. /**
  133761. * Gets or sets the operation applied by the block
  133762. */
  133763. operation: TrigonometryBlockOperations;
  133764. /**
  133765. * Creates a new TrigonometryBlock
  133766. * @param name defines the block name
  133767. */
  133768. constructor(name: string);
  133769. /**
  133770. * Gets the current class name
  133771. * @returns the class name
  133772. */
  133773. getClassName(): string;
  133774. /**
  133775. * Gets the input component
  133776. */
  133777. get input(): NodeMaterialConnectionPoint;
  133778. /**
  133779. * Gets the output component
  133780. */
  133781. get output(): NodeMaterialConnectionPoint;
  133782. protected _buildBlock(state: NodeMaterialBuildState): this;
  133783. serialize(): any;
  133784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133785. protected _dumpPropertiesCode(): string;
  133786. }
  133787. }
  133788. declare module BABYLON {
  133789. /**
  133790. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133791. */
  133792. export class ColorMergerBlock extends NodeMaterialBlock {
  133793. /**
  133794. * Create a new ColorMergerBlock
  133795. * @param name defines the block name
  133796. */
  133797. constructor(name: string);
  133798. /**
  133799. * Gets the current class name
  133800. * @returns the class name
  133801. */
  133802. getClassName(): string;
  133803. /**
  133804. * Gets the rgb component (input)
  133805. */
  133806. get rgbIn(): NodeMaterialConnectionPoint;
  133807. /**
  133808. * Gets the r component (input)
  133809. */
  133810. get r(): NodeMaterialConnectionPoint;
  133811. /**
  133812. * Gets the g component (input)
  133813. */
  133814. get g(): NodeMaterialConnectionPoint;
  133815. /**
  133816. * Gets the b component (input)
  133817. */
  133818. get b(): NodeMaterialConnectionPoint;
  133819. /**
  133820. * Gets the a component (input)
  133821. */
  133822. get a(): NodeMaterialConnectionPoint;
  133823. /**
  133824. * Gets the rgba component (output)
  133825. */
  133826. get rgba(): NodeMaterialConnectionPoint;
  133827. /**
  133828. * Gets the rgb component (output)
  133829. */
  133830. get rgbOut(): NodeMaterialConnectionPoint;
  133831. /**
  133832. * Gets the rgb component (output)
  133833. * @deprecated Please use rgbOut instead.
  133834. */
  133835. get rgb(): NodeMaterialConnectionPoint;
  133836. protected _buildBlock(state: NodeMaterialBuildState): this;
  133837. }
  133838. }
  133839. declare module BABYLON {
  133840. /**
  133841. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133842. */
  133843. export class VectorMergerBlock extends NodeMaterialBlock {
  133844. /**
  133845. * Create a new VectorMergerBlock
  133846. * @param name defines the block name
  133847. */
  133848. constructor(name: string);
  133849. /**
  133850. * Gets the current class name
  133851. * @returns the class name
  133852. */
  133853. getClassName(): string;
  133854. /**
  133855. * Gets the xyz component (input)
  133856. */
  133857. get xyzIn(): NodeMaterialConnectionPoint;
  133858. /**
  133859. * Gets the xy component (input)
  133860. */
  133861. get xyIn(): NodeMaterialConnectionPoint;
  133862. /**
  133863. * Gets the x component (input)
  133864. */
  133865. get x(): NodeMaterialConnectionPoint;
  133866. /**
  133867. * Gets the y component (input)
  133868. */
  133869. get y(): NodeMaterialConnectionPoint;
  133870. /**
  133871. * Gets the z component (input)
  133872. */
  133873. get z(): NodeMaterialConnectionPoint;
  133874. /**
  133875. * Gets the w component (input)
  133876. */
  133877. get w(): NodeMaterialConnectionPoint;
  133878. /**
  133879. * Gets the xyzw component (output)
  133880. */
  133881. get xyzw(): NodeMaterialConnectionPoint;
  133882. /**
  133883. * Gets the xyz component (output)
  133884. */
  133885. get xyzOut(): NodeMaterialConnectionPoint;
  133886. /**
  133887. * Gets the xy component (output)
  133888. */
  133889. get xyOut(): NodeMaterialConnectionPoint;
  133890. /**
  133891. * Gets the xy component (output)
  133892. * @deprecated Please use xyOut instead.
  133893. */
  133894. get xy(): NodeMaterialConnectionPoint;
  133895. /**
  133896. * Gets the xyz component (output)
  133897. * @deprecated Please use xyzOut instead.
  133898. */
  133899. get xyz(): NodeMaterialConnectionPoint;
  133900. protected _buildBlock(state: NodeMaterialBuildState): this;
  133901. }
  133902. }
  133903. declare module BABYLON {
  133904. /**
  133905. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133906. */
  133907. export class ColorSplitterBlock extends NodeMaterialBlock {
  133908. /**
  133909. * Create a new ColorSplitterBlock
  133910. * @param name defines the block name
  133911. */
  133912. constructor(name: string);
  133913. /**
  133914. * Gets the current class name
  133915. * @returns the class name
  133916. */
  133917. getClassName(): string;
  133918. /**
  133919. * Gets the rgba component (input)
  133920. */
  133921. get rgba(): NodeMaterialConnectionPoint;
  133922. /**
  133923. * Gets the rgb component (input)
  133924. */
  133925. get rgbIn(): NodeMaterialConnectionPoint;
  133926. /**
  133927. * Gets the rgb component (output)
  133928. */
  133929. get rgbOut(): NodeMaterialConnectionPoint;
  133930. /**
  133931. * Gets the r component (output)
  133932. */
  133933. get r(): NodeMaterialConnectionPoint;
  133934. /**
  133935. * Gets the g component (output)
  133936. */
  133937. get g(): NodeMaterialConnectionPoint;
  133938. /**
  133939. * Gets the b component (output)
  133940. */
  133941. get b(): NodeMaterialConnectionPoint;
  133942. /**
  133943. * Gets the a component (output)
  133944. */
  133945. get a(): NodeMaterialConnectionPoint;
  133946. protected _inputRename(name: string): string;
  133947. protected _outputRename(name: string): string;
  133948. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133949. }
  133950. }
  133951. declare module BABYLON {
  133952. /**
  133953. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133954. */
  133955. export class VectorSplitterBlock extends NodeMaterialBlock {
  133956. /**
  133957. * Create a new VectorSplitterBlock
  133958. * @param name defines the block name
  133959. */
  133960. constructor(name: string);
  133961. /**
  133962. * Gets the current class name
  133963. * @returns the class name
  133964. */
  133965. getClassName(): string;
  133966. /**
  133967. * Gets the xyzw component (input)
  133968. */
  133969. get xyzw(): NodeMaterialConnectionPoint;
  133970. /**
  133971. * Gets the xyz component (input)
  133972. */
  133973. get xyzIn(): NodeMaterialConnectionPoint;
  133974. /**
  133975. * Gets the xy component (input)
  133976. */
  133977. get xyIn(): NodeMaterialConnectionPoint;
  133978. /**
  133979. * Gets the xyz component (output)
  133980. */
  133981. get xyzOut(): NodeMaterialConnectionPoint;
  133982. /**
  133983. * Gets the xy component (output)
  133984. */
  133985. get xyOut(): NodeMaterialConnectionPoint;
  133986. /**
  133987. * Gets the x component (output)
  133988. */
  133989. get x(): NodeMaterialConnectionPoint;
  133990. /**
  133991. * Gets the y component (output)
  133992. */
  133993. get y(): NodeMaterialConnectionPoint;
  133994. /**
  133995. * Gets the z component (output)
  133996. */
  133997. get z(): NodeMaterialConnectionPoint;
  133998. /**
  133999. * Gets the w component (output)
  134000. */
  134001. get w(): NodeMaterialConnectionPoint;
  134002. protected _inputRename(name: string): string;
  134003. protected _outputRename(name: string): string;
  134004. protected _buildBlock(state: NodeMaterialBuildState): this;
  134005. }
  134006. }
  134007. declare module BABYLON {
  134008. /**
  134009. * Block used to lerp between 2 values
  134010. */
  134011. export class LerpBlock extends NodeMaterialBlock {
  134012. /**
  134013. * Creates a new LerpBlock
  134014. * @param name defines the block name
  134015. */
  134016. constructor(name: string);
  134017. /**
  134018. * Gets the current class name
  134019. * @returns the class name
  134020. */
  134021. getClassName(): string;
  134022. /**
  134023. * Gets the left operand input component
  134024. */
  134025. get left(): NodeMaterialConnectionPoint;
  134026. /**
  134027. * Gets the right operand input component
  134028. */
  134029. get right(): NodeMaterialConnectionPoint;
  134030. /**
  134031. * Gets the gradient operand input component
  134032. */
  134033. get gradient(): NodeMaterialConnectionPoint;
  134034. /**
  134035. * Gets the output component
  134036. */
  134037. get output(): NodeMaterialConnectionPoint;
  134038. protected _buildBlock(state: NodeMaterialBuildState): this;
  134039. }
  134040. }
  134041. declare module BABYLON {
  134042. /**
  134043. * Block used to divide 2 vectors
  134044. */
  134045. export class DivideBlock extends NodeMaterialBlock {
  134046. /**
  134047. * Creates a new DivideBlock
  134048. * @param name defines the block name
  134049. */
  134050. constructor(name: string);
  134051. /**
  134052. * Gets the current class name
  134053. * @returns the class name
  134054. */
  134055. getClassName(): string;
  134056. /**
  134057. * Gets the left operand input component
  134058. */
  134059. get left(): NodeMaterialConnectionPoint;
  134060. /**
  134061. * Gets the right operand input component
  134062. */
  134063. get right(): NodeMaterialConnectionPoint;
  134064. /**
  134065. * Gets the output component
  134066. */
  134067. get output(): NodeMaterialConnectionPoint;
  134068. protected _buildBlock(state: NodeMaterialBuildState): this;
  134069. }
  134070. }
  134071. declare module BABYLON {
  134072. /**
  134073. * Block used to subtract 2 vectors
  134074. */
  134075. export class SubtractBlock extends NodeMaterialBlock {
  134076. /**
  134077. * Creates a new SubtractBlock
  134078. * @param name defines the block name
  134079. */
  134080. constructor(name: string);
  134081. /**
  134082. * Gets the current class name
  134083. * @returns the class name
  134084. */
  134085. getClassName(): string;
  134086. /**
  134087. * Gets the left operand input component
  134088. */
  134089. get left(): NodeMaterialConnectionPoint;
  134090. /**
  134091. * Gets the right operand input component
  134092. */
  134093. get right(): NodeMaterialConnectionPoint;
  134094. /**
  134095. * Gets the output component
  134096. */
  134097. get output(): NodeMaterialConnectionPoint;
  134098. protected _buildBlock(state: NodeMaterialBuildState): this;
  134099. }
  134100. }
  134101. declare module BABYLON {
  134102. /**
  134103. * Block used to step a value
  134104. */
  134105. export class StepBlock extends NodeMaterialBlock {
  134106. /**
  134107. * Creates a new StepBlock
  134108. * @param name defines the block name
  134109. */
  134110. constructor(name: string);
  134111. /**
  134112. * Gets the current class name
  134113. * @returns the class name
  134114. */
  134115. getClassName(): string;
  134116. /**
  134117. * Gets the value operand input component
  134118. */
  134119. get value(): NodeMaterialConnectionPoint;
  134120. /**
  134121. * Gets the edge operand input component
  134122. */
  134123. get edge(): NodeMaterialConnectionPoint;
  134124. /**
  134125. * Gets the output component
  134126. */
  134127. get output(): NodeMaterialConnectionPoint;
  134128. protected _buildBlock(state: NodeMaterialBuildState): this;
  134129. }
  134130. }
  134131. declare module BABYLON {
  134132. /**
  134133. * Block used to get the opposite (1 - x) of a value
  134134. */
  134135. export class OneMinusBlock extends NodeMaterialBlock {
  134136. /**
  134137. * Creates a new OneMinusBlock
  134138. * @param name defines the block name
  134139. */
  134140. constructor(name: string);
  134141. /**
  134142. * Gets the current class name
  134143. * @returns the class name
  134144. */
  134145. getClassName(): string;
  134146. /**
  134147. * Gets the input component
  134148. */
  134149. get input(): NodeMaterialConnectionPoint;
  134150. /**
  134151. * Gets the output component
  134152. */
  134153. get output(): NodeMaterialConnectionPoint;
  134154. protected _buildBlock(state: NodeMaterialBuildState): this;
  134155. }
  134156. }
  134157. declare module BABYLON {
  134158. /**
  134159. * Block used to get the view direction
  134160. */
  134161. export class ViewDirectionBlock extends NodeMaterialBlock {
  134162. /**
  134163. * Creates a new ViewDirectionBlock
  134164. * @param name defines the block name
  134165. */
  134166. constructor(name: string);
  134167. /**
  134168. * Gets the current class name
  134169. * @returns the class name
  134170. */
  134171. getClassName(): string;
  134172. /**
  134173. * Gets the world position component
  134174. */
  134175. get worldPosition(): NodeMaterialConnectionPoint;
  134176. /**
  134177. * Gets the camera position component
  134178. */
  134179. get cameraPosition(): NodeMaterialConnectionPoint;
  134180. /**
  134181. * Gets the output component
  134182. */
  134183. get output(): NodeMaterialConnectionPoint;
  134184. autoConfigure(material: NodeMaterial): void;
  134185. protected _buildBlock(state: NodeMaterialBuildState): this;
  134186. }
  134187. }
  134188. declare module BABYLON {
  134189. /**
  134190. * Block used to compute fresnel value
  134191. */
  134192. export class FresnelBlock extends NodeMaterialBlock {
  134193. /**
  134194. * Create a new FresnelBlock
  134195. * @param name defines the block name
  134196. */
  134197. constructor(name: string);
  134198. /**
  134199. * Gets the current class name
  134200. * @returns the class name
  134201. */
  134202. getClassName(): string;
  134203. /**
  134204. * Gets the world normal input component
  134205. */
  134206. get worldNormal(): NodeMaterialConnectionPoint;
  134207. /**
  134208. * Gets the view direction input component
  134209. */
  134210. get viewDirection(): NodeMaterialConnectionPoint;
  134211. /**
  134212. * Gets the bias input component
  134213. */
  134214. get bias(): NodeMaterialConnectionPoint;
  134215. /**
  134216. * Gets the camera (or eye) position component
  134217. */
  134218. get power(): NodeMaterialConnectionPoint;
  134219. /**
  134220. * Gets the fresnel output component
  134221. */
  134222. get fresnel(): NodeMaterialConnectionPoint;
  134223. autoConfigure(material: NodeMaterial): void;
  134224. protected _buildBlock(state: NodeMaterialBuildState): this;
  134225. }
  134226. }
  134227. declare module BABYLON {
  134228. /**
  134229. * Block used to get the max of 2 values
  134230. */
  134231. export class MaxBlock extends NodeMaterialBlock {
  134232. /**
  134233. * Creates a new MaxBlock
  134234. * @param name defines the block name
  134235. */
  134236. constructor(name: string);
  134237. /**
  134238. * Gets the current class name
  134239. * @returns the class name
  134240. */
  134241. getClassName(): string;
  134242. /**
  134243. * Gets the left operand input component
  134244. */
  134245. get left(): NodeMaterialConnectionPoint;
  134246. /**
  134247. * Gets the right operand input component
  134248. */
  134249. get right(): NodeMaterialConnectionPoint;
  134250. /**
  134251. * Gets the output component
  134252. */
  134253. get output(): NodeMaterialConnectionPoint;
  134254. protected _buildBlock(state: NodeMaterialBuildState): this;
  134255. }
  134256. }
  134257. declare module BABYLON {
  134258. /**
  134259. * Block used to get the min of 2 values
  134260. */
  134261. export class MinBlock extends NodeMaterialBlock {
  134262. /**
  134263. * Creates a new MinBlock
  134264. * @param name defines the block name
  134265. */
  134266. constructor(name: string);
  134267. /**
  134268. * Gets the current class name
  134269. * @returns the class name
  134270. */
  134271. getClassName(): string;
  134272. /**
  134273. * Gets the left operand input component
  134274. */
  134275. get left(): NodeMaterialConnectionPoint;
  134276. /**
  134277. * Gets the right operand input component
  134278. */
  134279. get right(): NodeMaterialConnectionPoint;
  134280. /**
  134281. * Gets the output component
  134282. */
  134283. get output(): NodeMaterialConnectionPoint;
  134284. protected _buildBlock(state: NodeMaterialBuildState): this;
  134285. }
  134286. }
  134287. declare module BABYLON {
  134288. /**
  134289. * Block used to get the distance between 2 values
  134290. */
  134291. export class DistanceBlock extends NodeMaterialBlock {
  134292. /**
  134293. * Creates a new DistanceBlock
  134294. * @param name defines the block name
  134295. */
  134296. constructor(name: string);
  134297. /**
  134298. * Gets the current class name
  134299. * @returns the class name
  134300. */
  134301. getClassName(): string;
  134302. /**
  134303. * Gets the left operand input component
  134304. */
  134305. get left(): NodeMaterialConnectionPoint;
  134306. /**
  134307. * Gets the right operand input component
  134308. */
  134309. get right(): NodeMaterialConnectionPoint;
  134310. /**
  134311. * Gets the output component
  134312. */
  134313. get output(): NodeMaterialConnectionPoint;
  134314. protected _buildBlock(state: NodeMaterialBuildState): this;
  134315. }
  134316. }
  134317. declare module BABYLON {
  134318. /**
  134319. * Block used to get the length of a vector
  134320. */
  134321. export class LengthBlock extends NodeMaterialBlock {
  134322. /**
  134323. * Creates a new LengthBlock
  134324. * @param name defines the block name
  134325. */
  134326. constructor(name: string);
  134327. /**
  134328. * Gets the current class name
  134329. * @returns the class name
  134330. */
  134331. getClassName(): string;
  134332. /**
  134333. * Gets the value input component
  134334. */
  134335. get value(): NodeMaterialConnectionPoint;
  134336. /**
  134337. * Gets the output component
  134338. */
  134339. get output(): NodeMaterialConnectionPoint;
  134340. protected _buildBlock(state: NodeMaterialBuildState): this;
  134341. }
  134342. }
  134343. declare module BABYLON {
  134344. /**
  134345. * Block used to get negative version of a value (i.e. x * -1)
  134346. */
  134347. export class NegateBlock extends NodeMaterialBlock {
  134348. /**
  134349. * Creates a new NegateBlock
  134350. * @param name defines the block name
  134351. */
  134352. constructor(name: string);
  134353. /**
  134354. * Gets the current class name
  134355. * @returns the class name
  134356. */
  134357. getClassName(): string;
  134358. /**
  134359. * Gets the value input component
  134360. */
  134361. get value(): NodeMaterialConnectionPoint;
  134362. /**
  134363. * Gets the output component
  134364. */
  134365. get output(): NodeMaterialConnectionPoint;
  134366. protected _buildBlock(state: NodeMaterialBuildState): this;
  134367. }
  134368. }
  134369. declare module BABYLON {
  134370. /**
  134371. * Block used to get the value of the first parameter raised to the power of the second
  134372. */
  134373. export class PowBlock extends NodeMaterialBlock {
  134374. /**
  134375. * Creates a new PowBlock
  134376. * @param name defines the block name
  134377. */
  134378. constructor(name: string);
  134379. /**
  134380. * Gets the current class name
  134381. * @returns the class name
  134382. */
  134383. getClassName(): string;
  134384. /**
  134385. * Gets the value operand input component
  134386. */
  134387. get value(): NodeMaterialConnectionPoint;
  134388. /**
  134389. * Gets the power operand input component
  134390. */
  134391. get power(): NodeMaterialConnectionPoint;
  134392. /**
  134393. * Gets the output component
  134394. */
  134395. get output(): NodeMaterialConnectionPoint;
  134396. protected _buildBlock(state: NodeMaterialBuildState): this;
  134397. }
  134398. }
  134399. declare module BABYLON {
  134400. /**
  134401. * Block used to get a random number
  134402. */
  134403. export class RandomNumberBlock extends NodeMaterialBlock {
  134404. /**
  134405. * Creates a new RandomNumberBlock
  134406. * @param name defines the block name
  134407. */
  134408. constructor(name: string);
  134409. /**
  134410. * Gets the current class name
  134411. * @returns the class name
  134412. */
  134413. getClassName(): string;
  134414. /**
  134415. * Gets the seed input component
  134416. */
  134417. get seed(): NodeMaterialConnectionPoint;
  134418. /**
  134419. * Gets the output component
  134420. */
  134421. get output(): NodeMaterialConnectionPoint;
  134422. protected _buildBlock(state: NodeMaterialBuildState): this;
  134423. }
  134424. }
  134425. declare module BABYLON {
  134426. /**
  134427. * Block used to compute arc tangent of 2 values
  134428. */
  134429. export class ArcTan2Block extends NodeMaterialBlock {
  134430. /**
  134431. * Creates a new ArcTan2Block
  134432. * @param name defines the block name
  134433. */
  134434. constructor(name: string);
  134435. /**
  134436. * Gets the current class name
  134437. * @returns the class name
  134438. */
  134439. getClassName(): string;
  134440. /**
  134441. * Gets the x operand input component
  134442. */
  134443. get x(): NodeMaterialConnectionPoint;
  134444. /**
  134445. * Gets the y operand input component
  134446. */
  134447. get y(): NodeMaterialConnectionPoint;
  134448. /**
  134449. * Gets the output component
  134450. */
  134451. get output(): NodeMaterialConnectionPoint;
  134452. protected _buildBlock(state: NodeMaterialBuildState): this;
  134453. }
  134454. }
  134455. declare module BABYLON {
  134456. /**
  134457. * Block used to smooth step a value
  134458. */
  134459. export class SmoothStepBlock extends NodeMaterialBlock {
  134460. /**
  134461. * Creates a new SmoothStepBlock
  134462. * @param name defines the block name
  134463. */
  134464. constructor(name: string);
  134465. /**
  134466. * Gets the current class name
  134467. * @returns the class name
  134468. */
  134469. getClassName(): string;
  134470. /**
  134471. * Gets the value operand input component
  134472. */
  134473. get value(): NodeMaterialConnectionPoint;
  134474. /**
  134475. * Gets the first edge operand input component
  134476. */
  134477. get edge0(): NodeMaterialConnectionPoint;
  134478. /**
  134479. * Gets the second edge operand input component
  134480. */
  134481. get edge1(): NodeMaterialConnectionPoint;
  134482. /**
  134483. * Gets the output component
  134484. */
  134485. get output(): NodeMaterialConnectionPoint;
  134486. protected _buildBlock(state: NodeMaterialBuildState): this;
  134487. }
  134488. }
  134489. declare module BABYLON {
  134490. /**
  134491. * Block used to get the reciprocal (1 / x) of a value
  134492. */
  134493. export class ReciprocalBlock extends NodeMaterialBlock {
  134494. /**
  134495. * Creates a new ReciprocalBlock
  134496. * @param name defines the block name
  134497. */
  134498. constructor(name: string);
  134499. /**
  134500. * Gets the current class name
  134501. * @returns the class name
  134502. */
  134503. getClassName(): string;
  134504. /**
  134505. * Gets the input component
  134506. */
  134507. get input(): NodeMaterialConnectionPoint;
  134508. /**
  134509. * Gets the output component
  134510. */
  134511. get output(): NodeMaterialConnectionPoint;
  134512. protected _buildBlock(state: NodeMaterialBuildState): this;
  134513. }
  134514. }
  134515. declare module BABYLON {
  134516. /**
  134517. * Block used to replace a color by another one
  134518. */
  134519. export class ReplaceColorBlock extends NodeMaterialBlock {
  134520. /**
  134521. * Creates a new ReplaceColorBlock
  134522. * @param name defines the block name
  134523. */
  134524. constructor(name: string);
  134525. /**
  134526. * Gets the current class name
  134527. * @returns the class name
  134528. */
  134529. getClassName(): string;
  134530. /**
  134531. * Gets the value input component
  134532. */
  134533. get value(): NodeMaterialConnectionPoint;
  134534. /**
  134535. * Gets the reference input component
  134536. */
  134537. get reference(): NodeMaterialConnectionPoint;
  134538. /**
  134539. * Gets the distance input component
  134540. */
  134541. get distance(): NodeMaterialConnectionPoint;
  134542. /**
  134543. * Gets the replacement input component
  134544. */
  134545. get replacement(): NodeMaterialConnectionPoint;
  134546. /**
  134547. * Gets the output component
  134548. */
  134549. get output(): NodeMaterialConnectionPoint;
  134550. protected _buildBlock(state: NodeMaterialBuildState): this;
  134551. }
  134552. }
  134553. declare module BABYLON {
  134554. /**
  134555. * Block used to posterize a value
  134556. * @see https://en.wikipedia.org/wiki/Posterization
  134557. */
  134558. export class PosterizeBlock extends NodeMaterialBlock {
  134559. /**
  134560. * Creates a new PosterizeBlock
  134561. * @param name defines the block name
  134562. */
  134563. constructor(name: string);
  134564. /**
  134565. * Gets the current class name
  134566. * @returns the class name
  134567. */
  134568. getClassName(): string;
  134569. /**
  134570. * Gets the value input component
  134571. */
  134572. get value(): NodeMaterialConnectionPoint;
  134573. /**
  134574. * Gets the steps input component
  134575. */
  134576. get steps(): NodeMaterialConnectionPoint;
  134577. /**
  134578. * Gets the output component
  134579. */
  134580. get output(): NodeMaterialConnectionPoint;
  134581. protected _buildBlock(state: NodeMaterialBuildState): this;
  134582. }
  134583. }
  134584. declare module BABYLON {
  134585. /**
  134586. * Operations supported by the Wave block
  134587. */
  134588. export enum WaveBlockKind {
  134589. /** SawTooth */
  134590. SawTooth = 0,
  134591. /** Square */
  134592. Square = 1,
  134593. /** Triangle */
  134594. Triangle = 2
  134595. }
  134596. /**
  134597. * Block used to apply wave operation to floats
  134598. */
  134599. export class WaveBlock extends NodeMaterialBlock {
  134600. /**
  134601. * Gets or sets the kibnd of wave to be applied by the block
  134602. */
  134603. kind: WaveBlockKind;
  134604. /**
  134605. * Creates a new WaveBlock
  134606. * @param name defines the block name
  134607. */
  134608. constructor(name: string);
  134609. /**
  134610. * Gets the current class name
  134611. * @returns the class name
  134612. */
  134613. getClassName(): string;
  134614. /**
  134615. * Gets the input component
  134616. */
  134617. get input(): NodeMaterialConnectionPoint;
  134618. /**
  134619. * Gets the output component
  134620. */
  134621. get output(): NodeMaterialConnectionPoint;
  134622. protected _buildBlock(state: NodeMaterialBuildState): this;
  134623. serialize(): any;
  134624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134625. }
  134626. }
  134627. declare module BABYLON {
  134628. /**
  134629. * Class used to store a color step for the GradientBlock
  134630. */
  134631. export class GradientBlockColorStep {
  134632. /**
  134633. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134634. */
  134635. step: number;
  134636. /**
  134637. * Gets or sets the color associated with this step
  134638. */
  134639. color: Color3;
  134640. /**
  134641. * Creates a new GradientBlockColorStep
  134642. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134643. * @param color defines the color associated with this step
  134644. */
  134645. constructor(
  134646. /**
  134647. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134648. */
  134649. step: number,
  134650. /**
  134651. * Gets or sets the color associated with this step
  134652. */
  134653. color: Color3);
  134654. }
  134655. /**
  134656. * Block used to return a color from a gradient based on an input value between 0 and 1
  134657. */
  134658. export class GradientBlock extends NodeMaterialBlock {
  134659. /**
  134660. * Gets or sets the list of color steps
  134661. */
  134662. colorSteps: GradientBlockColorStep[];
  134663. /**
  134664. * Creates a new GradientBlock
  134665. * @param name defines the block name
  134666. */
  134667. constructor(name: string);
  134668. /**
  134669. * Gets the current class name
  134670. * @returns the class name
  134671. */
  134672. getClassName(): string;
  134673. /**
  134674. * Gets the gradient input component
  134675. */
  134676. get gradient(): NodeMaterialConnectionPoint;
  134677. /**
  134678. * Gets the output component
  134679. */
  134680. get output(): NodeMaterialConnectionPoint;
  134681. private _writeColorConstant;
  134682. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134683. serialize(): any;
  134684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134685. protected _dumpPropertiesCode(): string;
  134686. }
  134687. }
  134688. declare module BABYLON {
  134689. /**
  134690. * Block used to normalize lerp between 2 values
  134691. */
  134692. export class NLerpBlock extends NodeMaterialBlock {
  134693. /**
  134694. * Creates a new NLerpBlock
  134695. * @param name defines the block name
  134696. */
  134697. constructor(name: string);
  134698. /**
  134699. * Gets the current class name
  134700. * @returns the class name
  134701. */
  134702. getClassName(): string;
  134703. /**
  134704. * Gets the left operand input component
  134705. */
  134706. get left(): NodeMaterialConnectionPoint;
  134707. /**
  134708. * Gets the right operand input component
  134709. */
  134710. get right(): NodeMaterialConnectionPoint;
  134711. /**
  134712. * Gets the gradient operand input component
  134713. */
  134714. get gradient(): NodeMaterialConnectionPoint;
  134715. /**
  134716. * Gets the output component
  134717. */
  134718. get output(): NodeMaterialConnectionPoint;
  134719. protected _buildBlock(state: NodeMaterialBuildState): this;
  134720. }
  134721. }
  134722. declare module BABYLON {
  134723. /**
  134724. * block used to Generate a Worley Noise 3D Noise Pattern
  134725. */
  134726. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134727. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134728. manhattanDistance: boolean;
  134729. /**
  134730. * Creates a new WorleyNoise3DBlock
  134731. * @param name defines the block name
  134732. */
  134733. constructor(name: string);
  134734. /**
  134735. * Gets the current class name
  134736. * @returns the class name
  134737. */
  134738. getClassName(): string;
  134739. /**
  134740. * Gets the seed input component
  134741. */
  134742. get seed(): NodeMaterialConnectionPoint;
  134743. /**
  134744. * Gets the jitter input component
  134745. */
  134746. get jitter(): NodeMaterialConnectionPoint;
  134747. /**
  134748. * Gets the output component
  134749. */
  134750. get output(): NodeMaterialConnectionPoint;
  134751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134752. /**
  134753. * Exposes the properties to the UI?
  134754. */
  134755. protected _dumpPropertiesCode(): string;
  134756. /**
  134757. * Exposes the properties to the Seralize?
  134758. */
  134759. serialize(): any;
  134760. /**
  134761. * Exposes the properties to the deseralize?
  134762. */
  134763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134764. }
  134765. }
  134766. declare module BABYLON {
  134767. /**
  134768. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134769. */
  134770. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134771. /**
  134772. * Creates a new SimplexPerlin3DBlock
  134773. * @param name defines the block name
  134774. */
  134775. constructor(name: string);
  134776. /**
  134777. * Gets the current class name
  134778. * @returns the class name
  134779. */
  134780. getClassName(): string;
  134781. /**
  134782. * Gets the seed operand input component
  134783. */
  134784. get seed(): NodeMaterialConnectionPoint;
  134785. /**
  134786. * Gets the output component
  134787. */
  134788. get output(): NodeMaterialConnectionPoint;
  134789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134790. }
  134791. }
  134792. declare module BABYLON {
  134793. /**
  134794. * Block used to blend normals
  134795. */
  134796. export class NormalBlendBlock extends NodeMaterialBlock {
  134797. /**
  134798. * Creates a new NormalBlendBlock
  134799. * @param name defines the block name
  134800. */
  134801. constructor(name: string);
  134802. /**
  134803. * Gets the current class name
  134804. * @returns the class name
  134805. */
  134806. getClassName(): string;
  134807. /**
  134808. * Gets the first input component
  134809. */
  134810. get normalMap0(): NodeMaterialConnectionPoint;
  134811. /**
  134812. * Gets the second input component
  134813. */
  134814. get normalMap1(): NodeMaterialConnectionPoint;
  134815. /**
  134816. * Gets the output component
  134817. */
  134818. get output(): NodeMaterialConnectionPoint;
  134819. protected _buildBlock(state: NodeMaterialBuildState): this;
  134820. }
  134821. }
  134822. declare module BABYLON {
  134823. /**
  134824. * Block used to rotate a 2d vector by a given angle
  134825. */
  134826. export class Rotate2dBlock extends NodeMaterialBlock {
  134827. /**
  134828. * Creates a new Rotate2dBlock
  134829. * @param name defines the block name
  134830. */
  134831. constructor(name: string);
  134832. /**
  134833. * Gets the current class name
  134834. * @returns the class name
  134835. */
  134836. getClassName(): string;
  134837. /**
  134838. * Gets the input vector
  134839. */
  134840. get input(): NodeMaterialConnectionPoint;
  134841. /**
  134842. * Gets the input angle
  134843. */
  134844. get angle(): NodeMaterialConnectionPoint;
  134845. /**
  134846. * Gets the output component
  134847. */
  134848. get output(): NodeMaterialConnectionPoint;
  134849. autoConfigure(material: NodeMaterial): void;
  134850. protected _buildBlock(state: NodeMaterialBuildState): this;
  134851. }
  134852. }
  134853. declare module BABYLON {
  134854. /**
  134855. * Block used to get the reflected vector from a direction and a normal
  134856. */
  134857. export class ReflectBlock extends NodeMaterialBlock {
  134858. /**
  134859. * Creates a new ReflectBlock
  134860. * @param name defines the block name
  134861. */
  134862. constructor(name: string);
  134863. /**
  134864. * Gets the current class name
  134865. * @returns the class name
  134866. */
  134867. getClassName(): string;
  134868. /**
  134869. * Gets the incident component
  134870. */
  134871. get incident(): NodeMaterialConnectionPoint;
  134872. /**
  134873. * Gets the normal component
  134874. */
  134875. get normal(): NodeMaterialConnectionPoint;
  134876. /**
  134877. * Gets the output component
  134878. */
  134879. get output(): NodeMaterialConnectionPoint;
  134880. protected _buildBlock(state: NodeMaterialBuildState): this;
  134881. }
  134882. }
  134883. declare module BABYLON {
  134884. /**
  134885. * Block used to get the refracted vector from a direction and a normal
  134886. */
  134887. export class RefractBlock extends NodeMaterialBlock {
  134888. /**
  134889. * Creates a new RefractBlock
  134890. * @param name defines the block name
  134891. */
  134892. constructor(name: string);
  134893. /**
  134894. * Gets the current class name
  134895. * @returns the class name
  134896. */
  134897. getClassName(): string;
  134898. /**
  134899. * Gets the incident component
  134900. */
  134901. get incident(): NodeMaterialConnectionPoint;
  134902. /**
  134903. * Gets the normal component
  134904. */
  134905. get normal(): NodeMaterialConnectionPoint;
  134906. /**
  134907. * Gets the index of refraction component
  134908. */
  134909. get ior(): NodeMaterialConnectionPoint;
  134910. /**
  134911. * Gets the output component
  134912. */
  134913. get output(): NodeMaterialConnectionPoint;
  134914. protected _buildBlock(state: NodeMaterialBuildState): this;
  134915. }
  134916. }
  134917. declare module BABYLON {
  134918. /**
  134919. * Block used to desaturate a color
  134920. */
  134921. export class DesaturateBlock extends NodeMaterialBlock {
  134922. /**
  134923. * Creates a new DesaturateBlock
  134924. * @param name defines the block name
  134925. */
  134926. constructor(name: string);
  134927. /**
  134928. * Gets the current class name
  134929. * @returns the class name
  134930. */
  134931. getClassName(): string;
  134932. /**
  134933. * Gets the color operand input component
  134934. */
  134935. get color(): NodeMaterialConnectionPoint;
  134936. /**
  134937. * Gets the level operand input component
  134938. */
  134939. get level(): NodeMaterialConnectionPoint;
  134940. /**
  134941. * Gets the output component
  134942. */
  134943. get output(): NodeMaterialConnectionPoint;
  134944. protected _buildBlock(state: NodeMaterialBuildState): this;
  134945. }
  134946. }
  134947. declare module BABYLON {
  134948. /**
  134949. * Effect Render Options
  134950. */
  134951. export interface IEffectRendererOptions {
  134952. /**
  134953. * Defines the vertices positions.
  134954. */
  134955. positions?: number[];
  134956. /**
  134957. * Defines the indices.
  134958. */
  134959. indices?: number[];
  134960. }
  134961. /**
  134962. * Helper class to render one or more effects
  134963. */
  134964. export class EffectRenderer {
  134965. private engine;
  134966. private static _DefaultOptions;
  134967. private _vertexBuffers;
  134968. private _indexBuffer;
  134969. private _ringBufferIndex;
  134970. private _ringScreenBuffer;
  134971. private _fullscreenViewport;
  134972. private _getNextFrameBuffer;
  134973. /**
  134974. * Creates an effect renderer
  134975. * @param engine the engine to use for rendering
  134976. * @param options defines the options of the effect renderer
  134977. */
  134978. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  134979. /**
  134980. * Sets the current viewport in normalized coordinates 0-1
  134981. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  134982. */
  134983. setViewport(viewport?: Viewport): void;
  134984. /**
  134985. * Binds the embedded attributes buffer to the effect.
  134986. * @param effect Defines the effect to bind the attributes for
  134987. */
  134988. bindBuffers(effect: Effect): void;
  134989. /**
  134990. * Sets the current effect wrapper to use during draw.
  134991. * The effect needs to be ready before calling this api.
  134992. * This also sets the default full screen position attribute.
  134993. * @param effectWrapper Defines the effect to draw with
  134994. */
  134995. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  134996. /**
  134997. * Draws a full screen quad.
  134998. */
  134999. draw(): void;
  135000. /**
  135001. * renders one or more effects to a specified texture
  135002. * @param effectWrappers list of effects to renderer
  135003. * @param outputTexture texture to draw to, if null it will render to the screen
  135004. */
  135005. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  135006. /**
  135007. * Disposes of the effect renderer
  135008. */
  135009. dispose(): void;
  135010. }
  135011. /**
  135012. * Options to create an EffectWrapper
  135013. */
  135014. interface EffectWrapperCreationOptions {
  135015. /**
  135016. * Engine to use to create the effect
  135017. */
  135018. engine: ThinEngine;
  135019. /**
  135020. * Fragment shader for the effect
  135021. */
  135022. fragmentShader: string;
  135023. /**
  135024. * Vertex shader for the effect
  135025. */
  135026. vertexShader?: string;
  135027. /**
  135028. * Attributes to use in the shader
  135029. */
  135030. attributeNames?: Array<string>;
  135031. /**
  135032. * Uniforms to use in the shader
  135033. */
  135034. uniformNames?: Array<string>;
  135035. /**
  135036. * Texture sampler names to use in the shader
  135037. */
  135038. samplerNames?: Array<string>;
  135039. /**
  135040. * The friendly name of the effect displayed in Spector.
  135041. */
  135042. name?: string;
  135043. }
  135044. /**
  135045. * Wraps an effect to be used for rendering
  135046. */
  135047. export class EffectWrapper {
  135048. /**
  135049. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135050. */
  135051. onApplyObservable: Observable<{}>;
  135052. /**
  135053. * The underlying effect
  135054. */
  135055. effect: Effect;
  135056. /**
  135057. * Creates an effect to be renderer
  135058. * @param creationOptions options to create the effect
  135059. */
  135060. constructor(creationOptions: EffectWrapperCreationOptions);
  135061. /**
  135062. * Disposes of the effect wrapper
  135063. */
  135064. dispose(): void;
  135065. }
  135066. }
  135067. declare module BABYLON {
  135068. /**
  135069. * Helper class to push actions to a pool of workers.
  135070. */
  135071. export class WorkerPool implements IDisposable {
  135072. private _workerInfos;
  135073. private _pendingActions;
  135074. /**
  135075. * Constructor
  135076. * @param workers Array of workers to use for actions
  135077. */
  135078. constructor(workers: Array<Worker>);
  135079. /**
  135080. * Terminates all workers and clears any pending actions.
  135081. */
  135082. dispose(): void;
  135083. /**
  135084. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135085. * pended until a worker has completed its action.
  135086. * @param action The action to perform. Call onComplete when the action is complete.
  135087. */
  135088. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135089. private _execute;
  135090. }
  135091. }
  135092. declare module BABYLON {
  135093. /**
  135094. * Configuration for Draco compression
  135095. */
  135096. export interface IDracoCompressionConfiguration {
  135097. /**
  135098. * Configuration for the decoder.
  135099. */
  135100. decoder: {
  135101. /**
  135102. * The url to the WebAssembly module.
  135103. */
  135104. wasmUrl?: string;
  135105. /**
  135106. * The url to the WebAssembly binary.
  135107. */
  135108. wasmBinaryUrl?: string;
  135109. /**
  135110. * The url to the fallback JavaScript module.
  135111. */
  135112. fallbackUrl?: string;
  135113. };
  135114. }
  135115. /**
  135116. * Draco compression (https://google.github.io/draco/)
  135117. *
  135118. * This class wraps the Draco module.
  135119. *
  135120. * **Encoder**
  135121. *
  135122. * The encoder is not currently implemented.
  135123. *
  135124. * **Decoder**
  135125. *
  135126. * 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.
  135127. *
  135128. * To update the configuration, use the following code:
  135129. * ```javascript
  135130. * DracoCompression.Configuration = {
  135131. * decoder: {
  135132. * wasmUrl: "<url to the WebAssembly library>",
  135133. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135134. * fallbackUrl: "<url to the fallback JavaScript library>",
  135135. * }
  135136. * };
  135137. * ```
  135138. *
  135139. * 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.
  135140. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135141. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135142. *
  135143. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135144. * ```javascript
  135145. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135146. * ```
  135147. *
  135148. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135149. */
  135150. export class DracoCompression implements IDisposable {
  135151. private _workerPoolPromise?;
  135152. private _decoderModulePromise?;
  135153. /**
  135154. * The configuration. Defaults to the following urls:
  135155. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135156. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135157. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135158. */
  135159. static Configuration: IDracoCompressionConfiguration;
  135160. /**
  135161. * Returns true if the decoder configuration is available.
  135162. */
  135163. static get DecoderAvailable(): boolean;
  135164. /**
  135165. * Default number of workers to create when creating the draco compression object.
  135166. */
  135167. static DefaultNumWorkers: number;
  135168. private static GetDefaultNumWorkers;
  135169. private static _Default;
  135170. /**
  135171. * Default instance for the draco compression object.
  135172. */
  135173. static get Default(): DracoCompression;
  135174. /**
  135175. * Constructor
  135176. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135177. */
  135178. constructor(numWorkers?: number);
  135179. /**
  135180. * Stop all async operations and release resources.
  135181. */
  135182. dispose(): void;
  135183. /**
  135184. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135185. * @returns a promise that resolves when ready
  135186. */
  135187. whenReadyAsync(): Promise<void>;
  135188. /**
  135189. * Decode Draco compressed mesh data to vertex data.
  135190. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135191. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135192. * @returns A promise that resolves with the decoded vertex data
  135193. */
  135194. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135195. [kind: string]: number;
  135196. }): Promise<VertexData>;
  135197. }
  135198. }
  135199. declare module BABYLON {
  135200. /**
  135201. * Class for building Constructive Solid Geometry
  135202. */
  135203. export class CSG {
  135204. private polygons;
  135205. /**
  135206. * The world matrix
  135207. */
  135208. matrix: Matrix;
  135209. /**
  135210. * Stores the position
  135211. */
  135212. position: Vector3;
  135213. /**
  135214. * Stores the rotation
  135215. */
  135216. rotation: Vector3;
  135217. /**
  135218. * Stores the rotation quaternion
  135219. */
  135220. rotationQuaternion: Nullable<Quaternion>;
  135221. /**
  135222. * Stores the scaling vector
  135223. */
  135224. scaling: Vector3;
  135225. /**
  135226. * Convert the Mesh to CSG
  135227. * @param mesh The Mesh to convert to CSG
  135228. * @returns A new CSG from the Mesh
  135229. */
  135230. static FromMesh(mesh: Mesh): CSG;
  135231. /**
  135232. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135233. * @param polygons Polygons used to construct a CSG solid
  135234. */
  135235. private static FromPolygons;
  135236. /**
  135237. * Clones, or makes a deep copy, of the CSG
  135238. * @returns A new CSG
  135239. */
  135240. clone(): CSG;
  135241. /**
  135242. * Unions this CSG with another CSG
  135243. * @param csg The CSG to union against this CSG
  135244. * @returns The unioned CSG
  135245. */
  135246. union(csg: CSG): CSG;
  135247. /**
  135248. * Unions this CSG with another CSG in place
  135249. * @param csg The CSG to union against this CSG
  135250. */
  135251. unionInPlace(csg: CSG): void;
  135252. /**
  135253. * Subtracts this CSG with another CSG
  135254. * @param csg The CSG to subtract against this CSG
  135255. * @returns A new CSG
  135256. */
  135257. subtract(csg: CSG): CSG;
  135258. /**
  135259. * Subtracts this CSG with another CSG in place
  135260. * @param csg The CSG to subtact against this CSG
  135261. */
  135262. subtractInPlace(csg: CSG): void;
  135263. /**
  135264. * Intersect this CSG with another CSG
  135265. * @param csg The CSG to intersect against this CSG
  135266. * @returns A new CSG
  135267. */
  135268. intersect(csg: CSG): CSG;
  135269. /**
  135270. * Intersects this CSG with another CSG in place
  135271. * @param csg The CSG to intersect against this CSG
  135272. */
  135273. intersectInPlace(csg: CSG): void;
  135274. /**
  135275. * Return a new CSG solid with solid and empty space switched. This solid is
  135276. * not modified.
  135277. * @returns A new CSG solid with solid and empty space switched
  135278. */
  135279. inverse(): CSG;
  135280. /**
  135281. * Inverses the CSG in place
  135282. */
  135283. inverseInPlace(): void;
  135284. /**
  135285. * This is used to keep meshes transformations so they can be restored
  135286. * when we build back a Babylon Mesh
  135287. * NB : All CSG operations are performed in world coordinates
  135288. * @param csg The CSG to copy the transform attributes from
  135289. * @returns This CSG
  135290. */
  135291. copyTransformAttributes(csg: CSG): CSG;
  135292. /**
  135293. * Build Raw mesh from CSG
  135294. * Coordinates here are in world space
  135295. * @param name The name of the mesh geometry
  135296. * @param scene The Scene
  135297. * @param keepSubMeshes Specifies if the submeshes should be kept
  135298. * @returns A new Mesh
  135299. */
  135300. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135301. /**
  135302. * Build Mesh from CSG taking material and transforms into account
  135303. * @param name The name of the Mesh
  135304. * @param material The material of the Mesh
  135305. * @param scene The Scene
  135306. * @param keepSubMeshes Specifies if submeshes should be kept
  135307. * @returns The new Mesh
  135308. */
  135309. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135310. }
  135311. }
  135312. declare module BABYLON {
  135313. /**
  135314. * Class used to create a trail following a mesh
  135315. */
  135316. export class TrailMesh extends Mesh {
  135317. private _generator;
  135318. private _autoStart;
  135319. private _running;
  135320. private _diameter;
  135321. private _length;
  135322. private _sectionPolygonPointsCount;
  135323. private _sectionVectors;
  135324. private _sectionNormalVectors;
  135325. private _beforeRenderObserver;
  135326. /**
  135327. * @constructor
  135328. * @param name The value used by scene.getMeshByName() to do a lookup.
  135329. * @param generator The mesh or transform node to generate a trail.
  135330. * @param scene The scene to add this mesh to.
  135331. * @param diameter Diameter of trailing mesh. Default is 1.
  135332. * @param length Length of trailing mesh. Default is 60.
  135333. * @param autoStart Automatically start trailing mesh. Default true.
  135334. */
  135335. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135336. /**
  135337. * "TrailMesh"
  135338. * @returns "TrailMesh"
  135339. */
  135340. getClassName(): string;
  135341. private _createMesh;
  135342. /**
  135343. * Start trailing mesh.
  135344. */
  135345. start(): void;
  135346. /**
  135347. * Stop trailing mesh.
  135348. */
  135349. stop(): void;
  135350. /**
  135351. * Update trailing mesh geometry.
  135352. */
  135353. update(): void;
  135354. /**
  135355. * Returns a new TrailMesh object.
  135356. * @param name is a string, the name given to the new mesh
  135357. * @param newGenerator use new generator object for cloned trail mesh
  135358. * @returns a new mesh
  135359. */
  135360. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135361. /**
  135362. * Serializes this trail mesh
  135363. * @param serializationObject object to write serialization to
  135364. */
  135365. serialize(serializationObject: any): void;
  135366. /**
  135367. * Parses a serialized trail mesh
  135368. * @param parsedMesh the serialized mesh
  135369. * @param scene the scene to create the trail mesh in
  135370. * @returns the created trail mesh
  135371. */
  135372. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135373. }
  135374. }
  135375. declare module BABYLON {
  135376. /**
  135377. * Class containing static functions to help procedurally build meshes
  135378. */
  135379. export class TiledBoxBuilder {
  135380. /**
  135381. * Creates a box mesh
  135382. * 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)
  135383. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135387. * @param name defines the name of the mesh
  135388. * @param options defines the options used to create the mesh
  135389. * @param scene defines the hosting scene
  135390. * @returns the box mesh
  135391. */
  135392. static CreateTiledBox(name: string, options: {
  135393. pattern?: number;
  135394. width?: number;
  135395. height?: number;
  135396. depth?: number;
  135397. tileSize?: number;
  135398. tileWidth?: number;
  135399. tileHeight?: number;
  135400. alignHorizontal?: number;
  135401. alignVertical?: number;
  135402. faceUV?: Vector4[];
  135403. faceColors?: Color4[];
  135404. sideOrientation?: number;
  135405. updatable?: boolean;
  135406. }, scene?: Nullable<Scene>): Mesh;
  135407. }
  135408. }
  135409. declare module BABYLON {
  135410. /**
  135411. * Class containing static functions to help procedurally build meshes
  135412. */
  135413. export class TorusKnotBuilder {
  135414. /**
  135415. * Creates a torus knot mesh
  135416. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135417. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135418. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135419. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135423. * @param name defines the name of the mesh
  135424. * @param options defines the options used to create the mesh
  135425. * @param scene defines the hosting scene
  135426. * @returns the torus knot mesh
  135427. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135428. */
  135429. static CreateTorusKnot(name: string, options: {
  135430. radius?: number;
  135431. tube?: number;
  135432. radialSegments?: number;
  135433. tubularSegments?: number;
  135434. p?: number;
  135435. q?: number;
  135436. updatable?: boolean;
  135437. sideOrientation?: number;
  135438. frontUVs?: Vector4;
  135439. backUVs?: Vector4;
  135440. }, scene: any): Mesh;
  135441. }
  135442. }
  135443. declare module BABYLON {
  135444. /**
  135445. * Polygon
  135446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135447. */
  135448. export class Polygon {
  135449. /**
  135450. * Creates a rectangle
  135451. * @param xmin bottom X coord
  135452. * @param ymin bottom Y coord
  135453. * @param xmax top X coord
  135454. * @param ymax top Y coord
  135455. * @returns points that make the resulting rectation
  135456. */
  135457. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135458. /**
  135459. * Creates a circle
  135460. * @param radius radius of circle
  135461. * @param cx scale in x
  135462. * @param cy scale in y
  135463. * @param numberOfSides number of sides that make up the circle
  135464. * @returns points that make the resulting circle
  135465. */
  135466. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135467. /**
  135468. * Creates a polygon from input string
  135469. * @param input Input polygon data
  135470. * @returns the parsed points
  135471. */
  135472. static Parse(input: string): Vector2[];
  135473. /**
  135474. * Starts building a polygon from x and y coordinates
  135475. * @param x x coordinate
  135476. * @param y y coordinate
  135477. * @returns the started path2
  135478. */
  135479. static StartingAt(x: number, y: number): Path2;
  135480. }
  135481. /**
  135482. * Builds a polygon
  135483. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135484. */
  135485. export class PolygonMeshBuilder {
  135486. private _points;
  135487. private _outlinepoints;
  135488. private _holes;
  135489. private _name;
  135490. private _scene;
  135491. private _epoints;
  135492. private _eholes;
  135493. private _addToepoint;
  135494. /**
  135495. * Babylon reference to the earcut plugin.
  135496. */
  135497. bjsEarcut: any;
  135498. /**
  135499. * Creates a PolygonMeshBuilder
  135500. * @param name name of the builder
  135501. * @param contours Path of the polygon
  135502. * @param scene scene to add to when creating the mesh
  135503. * @param earcutInjection can be used to inject your own earcut reference
  135504. */
  135505. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135506. /**
  135507. * Adds a whole within the polygon
  135508. * @param hole Array of points defining the hole
  135509. * @returns this
  135510. */
  135511. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135512. /**
  135513. * Creates the polygon
  135514. * @param updatable If the mesh should be updatable
  135515. * @param depth The depth of the mesh created
  135516. * @returns the created mesh
  135517. */
  135518. build(updatable?: boolean, depth?: number): Mesh;
  135519. /**
  135520. * Creates the polygon
  135521. * @param depth The depth of the mesh created
  135522. * @returns the created VertexData
  135523. */
  135524. buildVertexData(depth?: number): VertexData;
  135525. /**
  135526. * Adds a side to the polygon
  135527. * @param positions points that make the polygon
  135528. * @param normals normals of the polygon
  135529. * @param uvs uvs of the polygon
  135530. * @param indices indices of the polygon
  135531. * @param bounds bounds of the polygon
  135532. * @param points points of the polygon
  135533. * @param depth depth of the polygon
  135534. * @param flip flip of the polygon
  135535. */
  135536. private addSide;
  135537. }
  135538. }
  135539. declare module BABYLON {
  135540. /**
  135541. * Class containing static functions to help procedurally build meshes
  135542. */
  135543. export class PolygonBuilder {
  135544. /**
  135545. * Creates a polygon mesh
  135546. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135547. * * 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
  135548. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135551. * * Remember you can only change the shape positions, not their number when updating a polygon
  135552. * @param name defines the name of the mesh
  135553. * @param options defines the options used to create the mesh
  135554. * @param scene defines the hosting scene
  135555. * @param earcutInjection can be used to inject your own earcut reference
  135556. * @returns the polygon mesh
  135557. */
  135558. static CreatePolygon(name: string, options: {
  135559. shape: Vector3[];
  135560. holes?: Vector3[][];
  135561. depth?: number;
  135562. faceUV?: Vector4[];
  135563. faceColors?: Color4[];
  135564. updatable?: boolean;
  135565. sideOrientation?: number;
  135566. frontUVs?: Vector4;
  135567. backUVs?: Vector4;
  135568. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135569. /**
  135570. * Creates an extruded polygon mesh, with depth in the Y direction.
  135571. * * 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)
  135572. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135573. * @param name defines the name of the mesh
  135574. * @param options defines the options used to create the mesh
  135575. * @param scene defines the hosting scene
  135576. * @param earcutInjection can be used to inject your own earcut reference
  135577. * @returns the polygon mesh
  135578. */
  135579. static ExtrudePolygon(name: string, options: {
  135580. shape: Vector3[];
  135581. holes?: Vector3[][];
  135582. depth?: number;
  135583. faceUV?: Vector4[];
  135584. faceColors?: Color4[];
  135585. updatable?: boolean;
  135586. sideOrientation?: number;
  135587. frontUVs?: Vector4;
  135588. backUVs?: Vector4;
  135589. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135590. }
  135591. }
  135592. declare module BABYLON {
  135593. /**
  135594. * Class containing static functions to help procedurally build meshes
  135595. */
  135596. export class LatheBuilder {
  135597. /**
  135598. * Creates lathe mesh.
  135599. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135600. * * 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
  135601. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135602. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135603. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135604. * * 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
  135605. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135606. * * 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
  135607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135611. * @param name defines the name of the mesh
  135612. * @param options defines the options used to create the mesh
  135613. * @param scene defines the hosting scene
  135614. * @returns the lathe mesh
  135615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135616. */
  135617. static CreateLathe(name: string, options: {
  135618. shape: Vector3[];
  135619. radius?: number;
  135620. tessellation?: number;
  135621. clip?: number;
  135622. arc?: number;
  135623. closed?: boolean;
  135624. updatable?: boolean;
  135625. sideOrientation?: number;
  135626. frontUVs?: Vector4;
  135627. backUVs?: Vector4;
  135628. cap?: number;
  135629. invertUV?: boolean;
  135630. }, scene?: Nullable<Scene>): Mesh;
  135631. }
  135632. }
  135633. declare module BABYLON {
  135634. /**
  135635. * Class containing static functions to help procedurally build meshes
  135636. */
  135637. export class TiledPlaneBuilder {
  135638. /**
  135639. * Creates a tiled plane mesh
  135640. * * The parameter `pattern` will, depending on value, do nothing or
  135641. * * * flip (reflect about central vertical) alternate tiles across and up
  135642. * * * flip every tile on alternate rows
  135643. * * * rotate (180 degs) alternate tiles across and up
  135644. * * * rotate every tile on alternate rows
  135645. * * * flip and rotate alternate tiles across and up
  135646. * * * flip and rotate every tile on alternate rows
  135647. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135648. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135650. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135651. * * 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)
  135652. * * 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)
  135653. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  135658. */
  135659. static CreateTiledPlane(name: string, options: {
  135660. pattern?: number;
  135661. tileSize?: number;
  135662. tileWidth?: number;
  135663. tileHeight?: number;
  135664. size?: number;
  135665. width?: number;
  135666. height?: number;
  135667. alignHorizontal?: number;
  135668. alignVertical?: number;
  135669. sideOrientation?: number;
  135670. frontUVs?: Vector4;
  135671. backUVs?: Vector4;
  135672. updatable?: 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 TubeBuilder {
  135681. /**
  135682. * Creates a tube mesh.
  135683. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135684. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135685. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135686. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135687. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135688. * * 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)
  135689. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135690. * * 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
  135691. * * 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
  135692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135696. * @param name defines the name of the mesh
  135697. * @param options defines the options used to create the mesh
  135698. * @param scene defines the hosting scene
  135699. * @returns the tube mesh
  135700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135701. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135702. */
  135703. static CreateTube(name: string, options: {
  135704. path: Vector3[];
  135705. radius?: number;
  135706. tessellation?: number;
  135707. radiusFunction?: {
  135708. (i: number, distance: number): number;
  135709. };
  135710. cap?: number;
  135711. arc?: number;
  135712. updatable?: boolean;
  135713. sideOrientation?: number;
  135714. frontUVs?: Vector4;
  135715. backUVs?: Vector4;
  135716. instance?: Mesh;
  135717. invertUV?: boolean;
  135718. }, scene?: Nullable<Scene>): Mesh;
  135719. }
  135720. }
  135721. declare module BABYLON {
  135722. /**
  135723. * Class containing static functions to help procedurally build meshes
  135724. */
  135725. export class IcoSphereBuilder {
  135726. /**
  135727. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135728. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135729. * * 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`)
  135730. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135731. * * 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
  135732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135735. * @param name defines the name of the mesh
  135736. * @param options defines the options used to create the mesh
  135737. * @param scene defines the hosting scene
  135738. * @returns the icosahedron mesh
  135739. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135740. */
  135741. static CreateIcoSphere(name: string, options: {
  135742. radius?: number;
  135743. radiusX?: number;
  135744. radiusY?: number;
  135745. radiusZ?: number;
  135746. flat?: boolean;
  135747. subdivisions?: number;
  135748. sideOrientation?: number;
  135749. frontUVs?: Vector4;
  135750. backUVs?: Vector4;
  135751. updatable?: boolean;
  135752. }, scene?: Nullable<Scene>): Mesh;
  135753. }
  135754. }
  135755. declare module BABYLON {
  135756. /**
  135757. * Class containing static functions to help procedurally build meshes
  135758. */
  135759. export class DecalBuilder {
  135760. /**
  135761. * Creates a decal mesh.
  135762. * 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
  135763. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135764. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135765. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135766. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135767. * @param name defines the name of the mesh
  135768. * @param sourceMesh defines the mesh where the decal must be applied
  135769. * @param options defines the options used to create the mesh
  135770. * @param scene defines the hosting scene
  135771. * @returns the decal mesh
  135772. * @see https://doc.babylonjs.com/how_to/decals
  135773. */
  135774. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135775. position?: Vector3;
  135776. normal?: Vector3;
  135777. size?: Vector3;
  135778. angle?: number;
  135779. }): Mesh;
  135780. }
  135781. }
  135782. declare module BABYLON {
  135783. /**
  135784. * Class containing static functions to help procedurally build meshes
  135785. */
  135786. export class MeshBuilder {
  135787. /**
  135788. * Creates a box mesh
  135789. * * The parameter `size` sets the size (float) of each box side (default 1)
  135790. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135791. * * 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)
  135792. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135796. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135797. * @param name defines the name of the mesh
  135798. * @param options defines the options used to create the mesh
  135799. * @param scene defines the hosting scene
  135800. * @returns the box mesh
  135801. */
  135802. static CreateBox(name: string, options: {
  135803. size?: number;
  135804. width?: number;
  135805. height?: number;
  135806. depth?: number;
  135807. faceUV?: Vector4[];
  135808. faceColors?: Color4[];
  135809. sideOrientation?: number;
  135810. frontUVs?: Vector4;
  135811. backUVs?: Vector4;
  135812. wrap?: boolean;
  135813. topBaseAt?: number;
  135814. bottomBaseAt?: number;
  135815. updatable?: boolean;
  135816. }, scene?: Nullable<Scene>): Mesh;
  135817. /**
  135818. * Creates a tiled box mesh
  135819. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135821. * @param name defines the name of the mesh
  135822. * @param options defines the options used to create the mesh
  135823. * @param scene defines the hosting scene
  135824. * @returns the tiled box mesh
  135825. */
  135826. static CreateTiledBox(name: string, options: {
  135827. pattern?: number;
  135828. size?: number;
  135829. width?: number;
  135830. height?: number;
  135831. depth: number;
  135832. tileSize?: number;
  135833. tileWidth?: number;
  135834. tileHeight?: number;
  135835. faceUV?: Vector4[];
  135836. faceColors?: Color4[];
  135837. alignHorizontal?: number;
  135838. alignVertical?: number;
  135839. sideOrientation?: number;
  135840. updatable?: boolean;
  135841. }, scene?: Nullable<Scene>): Mesh;
  135842. /**
  135843. * Creates a sphere mesh
  135844. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135845. * * 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`)
  135846. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135847. * * 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
  135848. * * 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)
  135849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135852. * @param name defines the name of the mesh
  135853. * @param options defines the options used to create the mesh
  135854. * @param scene defines the hosting scene
  135855. * @returns the sphere mesh
  135856. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135857. */
  135858. static CreateSphere(name: string, options: {
  135859. segments?: number;
  135860. diameter?: number;
  135861. diameterX?: number;
  135862. diameterY?: number;
  135863. diameterZ?: number;
  135864. arc?: number;
  135865. slice?: number;
  135866. sideOrientation?: number;
  135867. frontUVs?: Vector4;
  135868. backUVs?: Vector4;
  135869. updatable?: boolean;
  135870. }, scene?: Nullable<Scene>): Mesh;
  135871. /**
  135872. * Creates a plane polygonal mesh. By default, this is a disc
  135873. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135874. * * 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
  135875. * * 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
  135876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135879. * @param name defines the name of the mesh
  135880. * @param options defines the options used to create the mesh
  135881. * @param scene defines the hosting scene
  135882. * @returns the plane polygonal mesh
  135883. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135884. */
  135885. static CreateDisc(name: string, options: {
  135886. radius?: number;
  135887. tessellation?: number;
  135888. arc?: number;
  135889. updatable?: boolean;
  135890. sideOrientation?: number;
  135891. frontUVs?: Vector4;
  135892. backUVs?: Vector4;
  135893. }, scene?: Nullable<Scene>): Mesh;
  135894. /**
  135895. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135896. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135897. * * 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`)
  135898. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135899. * * 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
  135900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135903. * @param name defines the name of the mesh
  135904. * @param options defines the options used to create the mesh
  135905. * @param scene defines the hosting scene
  135906. * @returns the icosahedron mesh
  135907. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135908. */
  135909. static CreateIcoSphere(name: string, options: {
  135910. radius?: number;
  135911. radiusX?: number;
  135912. radiusY?: number;
  135913. radiusZ?: number;
  135914. flat?: boolean;
  135915. subdivisions?: number;
  135916. sideOrientation?: number;
  135917. frontUVs?: Vector4;
  135918. backUVs?: Vector4;
  135919. updatable?: boolean;
  135920. }, scene?: Nullable<Scene>): Mesh;
  135921. /**
  135922. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135923. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135924. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135925. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135926. * * 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
  135927. * * 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
  135928. * * 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
  135929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135932. * * 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
  135933. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135934. * * 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
  135935. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135937. * @param name defines the name of the mesh
  135938. * @param options defines the options used to create the mesh
  135939. * @param scene defines the hosting scene
  135940. * @returns the ribbon mesh
  135941. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135943. */
  135944. static CreateRibbon(name: string, options: {
  135945. pathArray: Vector3[][];
  135946. closeArray?: boolean;
  135947. closePath?: boolean;
  135948. offset?: number;
  135949. updatable?: boolean;
  135950. sideOrientation?: number;
  135951. frontUVs?: Vector4;
  135952. backUVs?: Vector4;
  135953. instance?: Mesh;
  135954. invertUV?: boolean;
  135955. uvs?: Vector2[];
  135956. colors?: Color4[];
  135957. }, scene?: Nullable<Scene>): Mesh;
  135958. /**
  135959. * Creates a cylinder or a cone mesh
  135960. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135961. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135962. * * 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.
  135963. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135964. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135965. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135966. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135967. * * 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).
  135968. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135969. * * 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).
  135970. * * 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
  135971. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  135972. * * 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
  135973. * * 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.
  135974. * * If `enclose` is false, a ring surface is one element.
  135975. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  135976. * * 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
  135977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 cylinder mesh
  135984. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  135985. */
  135986. static CreateCylinder(name: string, options: {
  135987. height?: number;
  135988. diameterTop?: number;
  135989. diameterBottom?: number;
  135990. diameter?: number;
  135991. tessellation?: number;
  135992. subdivisions?: number;
  135993. arc?: number;
  135994. faceColors?: Color4[];
  135995. faceUV?: Vector4[];
  135996. updatable?: boolean;
  135997. hasRings?: boolean;
  135998. enclose?: boolean;
  135999. cap?: number;
  136000. sideOrientation?: number;
  136001. frontUVs?: Vector4;
  136002. backUVs?: Vector4;
  136003. }, scene?: Nullable<Scene>): Mesh;
  136004. /**
  136005. * Creates a torus mesh
  136006. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136007. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136008. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136012. * @param name defines the name of the mesh
  136013. * @param options defines the options used to create the mesh
  136014. * @param scene defines the hosting scene
  136015. * @returns the torus mesh
  136016. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136017. */
  136018. static CreateTorus(name: string, options: {
  136019. diameter?: number;
  136020. thickness?: number;
  136021. tessellation?: number;
  136022. updatable?: boolean;
  136023. sideOrientation?: number;
  136024. frontUVs?: Vector4;
  136025. backUVs?: Vector4;
  136026. }, scene?: Nullable<Scene>): Mesh;
  136027. /**
  136028. * Creates a torus knot mesh
  136029. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136030. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136031. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136032. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136036. * @param name defines the name of the mesh
  136037. * @param options defines the options used to create the mesh
  136038. * @param scene defines the hosting scene
  136039. * @returns the torus knot mesh
  136040. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136041. */
  136042. static CreateTorusKnot(name: string, options: {
  136043. radius?: number;
  136044. tube?: number;
  136045. radialSegments?: number;
  136046. tubularSegments?: number;
  136047. p?: number;
  136048. q?: number;
  136049. updatable?: boolean;
  136050. sideOrientation?: number;
  136051. frontUVs?: Vector4;
  136052. backUVs?: Vector4;
  136053. }, scene?: Nullable<Scene>): Mesh;
  136054. /**
  136055. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136056. * * 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
  136057. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136058. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136059. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136060. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136061. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136062. * * 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
  136063. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136066. * @param name defines the name of the new line system
  136067. * @param options defines the options used to create the line system
  136068. * @param scene defines the hosting scene
  136069. * @returns a new line system mesh
  136070. */
  136071. static CreateLineSystem(name: string, options: {
  136072. lines: Vector3[][];
  136073. updatable?: boolean;
  136074. instance?: Nullable<LinesMesh>;
  136075. colors?: Nullable<Color4[][]>;
  136076. useVertexAlpha?: boolean;
  136077. }, scene: Nullable<Scene>): LinesMesh;
  136078. /**
  136079. * Creates a line mesh
  136080. * 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
  136081. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136082. * * The parameter `points` is an array successive Vector3
  136083. * * 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
  136084. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136085. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136086. * * When updating an instance, remember that only point positions can change, not the number of points
  136087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136089. * @param name defines the name of the new line system
  136090. * @param options defines the options used to create the line system
  136091. * @param scene defines the hosting scene
  136092. * @returns a new line mesh
  136093. */
  136094. static CreateLines(name: string, options: {
  136095. points: Vector3[];
  136096. updatable?: boolean;
  136097. instance?: Nullable<LinesMesh>;
  136098. colors?: Color4[];
  136099. useVertexAlpha?: boolean;
  136100. }, scene?: Nullable<Scene>): LinesMesh;
  136101. /**
  136102. * Creates a dashed line mesh
  136103. * * 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
  136104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136105. * * The parameter `points` is an array successive Vector3
  136106. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136107. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136108. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136109. * * 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
  136110. * * When updating an instance, remember that only point positions can change, not the number of points
  136111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136112. * @param name defines the name of the mesh
  136113. * @param options defines the options used to create the mesh
  136114. * @param scene defines the hosting scene
  136115. * @returns the dashed line mesh
  136116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136117. */
  136118. static CreateDashedLines(name: string, options: {
  136119. points: Vector3[];
  136120. dashSize?: number;
  136121. gapSize?: number;
  136122. dashNb?: number;
  136123. updatable?: boolean;
  136124. instance?: LinesMesh;
  136125. }, scene?: Nullable<Scene>): LinesMesh;
  136126. /**
  136127. * 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.
  136128. * * 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.
  136129. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136130. * * 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.
  136131. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136132. * * 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
  136133. * * 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
  136134. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136137. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136139. * @param name defines the name of the mesh
  136140. * @param options defines the options used to create the mesh
  136141. * @param scene defines the hosting scene
  136142. * @returns the extruded shape mesh
  136143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136145. */
  136146. static ExtrudeShape(name: string, options: {
  136147. shape: Vector3[];
  136148. path: Vector3[];
  136149. scale?: number;
  136150. rotation?: number;
  136151. cap?: number;
  136152. updatable?: boolean;
  136153. sideOrientation?: number;
  136154. frontUVs?: Vector4;
  136155. backUVs?: Vector4;
  136156. instance?: Mesh;
  136157. invertUV?: boolean;
  136158. }, scene?: Nullable<Scene>): Mesh;
  136159. /**
  136160. * Creates an custom extruded shape mesh.
  136161. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136162. * * 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.
  136163. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136164. * * 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
  136165. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136166. * * 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
  136167. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136168. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136169. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136170. * * 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
  136171. * * 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
  136172. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136175. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136177. * @param name defines the name of the mesh
  136178. * @param options defines the options used to create the mesh
  136179. * @param scene defines the hosting scene
  136180. * @returns the custom extruded shape mesh
  136181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136184. */
  136185. static ExtrudeShapeCustom(name: string, options: {
  136186. shape: Vector3[];
  136187. path: Vector3[];
  136188. scaleFunction?: any;
  136189. rotationFunction?: any;
  136190. ribbonCloseArray?: boolean;
  136191. ribbonClosePath?: boolean;
  136192. cap?: number;
  136193. updatable?: boolean;
  136194. sideOrientation?: number;
  136195. frontUVs?: Vector4;
  136196. backUVs?: Vector4;
  136197. instance?: Mesh;
  136198. invertUV?: boolean;
  136199. }, scene?: Nullable<Scene>): Mesh;
  136200. /**
  136201. * Creates lathe mesh.
  136202. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136203. * * 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
  136204. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136205. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136206. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136207. * * 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
  136208. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136209. * * 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
  136210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136212. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136214. * @param name defines the name of the mesh
  136215. * @param options defines the options used to create the mesh
  136216. * @param scene defines the hosting scene
  136217. * @returns the lathe mesh
  136218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136219. */
  136220. static CreateLathe(name: string, options: {
  136221. shape: Vector3[];
  136222. radius?: number;
  136223. tessellation?: number;
  136224. clip?: number;
  136225. arc?: number;
  136226. closed?: boolean;
  136227. updatable?: boolean;
  136228. sideOrientation?: number;
  136229. frontUVs?: Vector4;
  136230. backUVs?: Vector4;
  136231. cap?: number;
  136232. invertUV?: boolean;
  136233. }, scene?: Nullable<Scene>): Mesh;
  136234. /**
  136235. * Creates a tiled plane mesh
  136236. * * You can set a limited pattern arrangement with the tiles
  136237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136240. * @param name defines the name of the mesh
  136241. * @param options defines the options used to create the mesh
  136242. * @param scene defines the hosting scene
  136243. * @returns the plane mesh
  136244. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136245. */
  136246. static CreateTiledPlane(name: string, options: {
  136247. pattern?: number;
  136248. tileSize?: number;
  136249. tileWidth?: number;
  136250. tileHeight?: number;
  136251. size?: number;
  136252. width?: number;
  136253. height?: number;
  136254. alignHorizontal?: number;
  136255. alignVertical?: number;
  136256. sideOrientation?: number;
  136257. frontUVs?: Vector4;
  136258. backUVs?: Vector4;
  136259. updatable?: boolean;
  136260. }, scene?: Nullable<Scene>): Mesh;
  136261. /**
  136262. * Creates a plane mesh
  136263. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136264. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136265. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136269. * @param name defines the name of the mesh
  136270. * @param options defines the options used to create the mesh
  136271. * @param scene defines the hosting scene
  136272. * @returns the plane mesh
  136273. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136274. */
  136275. static CreatePlane(name: string, options: {
  136276. size?: number;
  136277. width?: number;
  136278. height?: number;
  136279. sideOrientation?: number;
  136280. frontUVs?: Vector4;
  136281. backUVs?: Vector4;
  136282. updatable?: boolean;
  136283. sourcePlane?: Plane;
  136284. }, scene?: Nullable<Scene>): Mesh;
  136285. /**
  136286. * Creates a ground mesh
  136287. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136288. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136290. * @param name defines the name of the mesh
  136291. * @param options defines the options used to create the mesh
  136292. * @param scene defines the hosting scene
  136293. * @returns the ground mesh
  136294. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136295. */
  136296. static CreateGround(name: string, options: {
  136297. width?: number;
  136298. height?: number;
  136299. subdivisions?: number;
  136300. subdivisionsX?: number;
  136301. subdivisionsY?: number;
  136302. updatable?: boolean;
  136303. }, scene?: Nullable<Scene>): Mesh;
  136304. /**
  136305. * Creates a tiled ground mesh
  136306. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136307. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136308. * * 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
  136309. * * 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
  136310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136311. * @param name defines the name of the mesh
  136312. * @param options defines the options used to create the mesh
  136313. * @param scene defines the hosting scene
  136314. * @returns the tiled ground mesh
  136315. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136316. */
  136317. static CreateTiledGround(name: string, options: {
  136318. xmin: number;
  136319. zmin: number;
  136320. xmax: number;
  136321. zmax: number;
  136322. subdivisions?: {
  136323. w: number;
  136324. h: number;
  136325. };
  136326. precision?: {
  136327. w: number;
  136328. h: number;
  136329. };
  136330. updatable?: boolean;
  136331. }, scene?: Nullable<Scene>): Mesh;
  136332. /**
  136333. * Creates a ground mesh from a height map
  136334. * * The parameter `url` sets the URL of the height map image resource.
  136335. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136336. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136337. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136338. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136339. * * 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.
  136340. * * 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).
  136341. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136343. * @param name defines the name of the mesh
  136344. * @param url defines the url to the height map
  136345. * @param options defines the options used to create the mesh
  136346. * @param scene defines the hosting scene
  136347. * @returns the ground mesh
  136348. * @see https://doc.babylonjs.com/babylon101/height_map
  136349. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136350. */
  136351. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136352. width?: number;
  136353. height?: number;
  136354. subdivisions?: number;
  136355. minHeight?: number;
  136356. maxHeight?: number;
  136357. colorFilter?: Color3;
  136358. alphaFilter?: number;
  136359. updatable?: boolean;
  136360. onReady?: (mesh: GroundMesh) => void;
  136361. }, scene?: Nullable<Scene>): GroundMesh;
  136362. /**
  136363. * Creates a polygon mesh
  136364. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136365. * * 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
  136366. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136369. * * Remember you can only change the shape positions, not their number when updating a polygon
  136370. * @param name defines the name of the mesh
  136371. * @param options defines the options used to create the mesh
  136372. * @param scene defines the hosting scene
  136373. * @param earcutInjection can be used to inject your own earcut reference
  136374. * @returns the polygon mesh
  136375. */
  136376. static CreatePolygon(name: string, options: {
  136377. shape: Vector3[];
  136378. holes?: Vector3[][];
  136379. depth?: number;
  136380. faceUV?: Vector4[];
  136381. faceColors?: Color4[];
  136382. updatable?: boolean;
  136383. sideOrientation?: number;
  136384. frontUVs?: Vector4;
  136385. backUVs?: Vector4;
  136386. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136387. /**
  136388. * Creates an extruded polygon mesh, with depth in the Y direction.
  136389. * * 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)
  136390. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136391. * @param name defines the name of the mesh
  136392. * @param options defines the options used to create the mesh
  136393. * @param scene defines the hosting scene
  136394. * @param earcutInjection can be used to inject your own earcut reference
  136395. * @returns the polygon mesh
  136396. */
  136397. static ExtrudePolygon(name: string, options: {
  136398. shape: Vector3[];
  136399. holes?: Vector3[][];
  136400. depth?: number;
  136401. faceUV?: Vector4[];
  136402. faceColors?: Color4[];
  136403. updatable?: boolean;
  136404. sideOrientation?: number;
  136405. frontUVs?: Vector4;
  136406. backUVs?: Vector4;
  136407. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136408. /**
  136409. * Creates a tube mesh.
  136410. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136411. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136412. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136413. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136414. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136415. * * 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)
  136416. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136417. * * 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
  136418. * * 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
  136419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136423. * @param name defines the name of the mesh
  136424. * @param options defines the options used to create the mesh
  136425. * @param scene defines the hosting scene
  136426. * @returns the tube mesh
  136427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136428. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136429. */
  136430. static CreateTube(name: string, options: {
  136431. path: Vector3[];
  136432. radius?: number;
  136433. tessellation?: number;
  136434. radiusFunction?: {
  136435. (i: number, distance: number): number;
  136436. };
  136437. cap?: number;
  136438. arc?: number;
  136439. updatable?: boolean;
  136440. sideOrientation?: number;
  136441. frontUVs?: Vector4;
  136442. backUVs?: Vector4;
  136443. instance?: Mesh;
  136444. invertUV?: boolean;
  136445. }, scene?: Nullable<Scene>): Mesh;
  136446. /**
  136447. * Creates a polyhedron mesh
  136448. * * 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
  136449. * * The parameter `size` (positive float, default 1) sets the polygon size
  136450. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136451. * * 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`
  136452. * * 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
  136453. * * 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)`)
  136454. * * 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
  136455. * * 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
  136456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136459. * @param name defines the name of the mesh
  136460. * @param options defines the options used to create the mesh
  136461. * @param scene defines the hosting scene
  136462. * @returns the polyhedron mesh
  136463. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136464. */
  136465. static CreatePolyhedron(name: string, options: {
  136466. type?: number;
  136467. size?: number;
  136468. sizeX?: number;
  136469. sizeY?: number;
  136470. sizeZ?: number;
  136471. custom?: any;
  136472. faceUV?: Vector4[];
  136473. faceColors?: Color4[];
  136474. flat?: boolean;
  136475. updatable?: boolean;
  136476. sideOrientation?: number;
  136477. frontUVs?: Vector4;
  136478. backUVs?: Vector4;
  136479. }, scene?: Nullable<Scene>): Mesh;
  136480. /**
  136481. * Creates a decal mesh.
  136482. * 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
  136483. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136484. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136485. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136486. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136487. * @param name defines the name of the mesh
  136488. * @param sourceMesh defines the mesh where the decal must be applied
  136489. * @param options defines the options used to create the mesh
  136490. * @param scene defines the hosting scene
  136491. * @returns the decal mesh
  136492. * @see https://doc.babylonjs.com/how_to/decals
  136493. */
  136494. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136495. position?: Vector3;
  136496. normal?: Vector3;
  136497. size?: Vector3;
  136498. angle?: number;
  136499. }): Mesh;
  136500. }
  136501. }
  136502. declare module BABYLON {
  136503. /**
  136504. * A simplifier interface for future simplification implementations
  136505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136506. */
  136507. export interface ISimplifier {
  136508. /**
  136509. * Simplification of a given mesh according to the given settings.
  136510. * Since this requires computation, it is assumed that the function runs async.
  136511. * @param settings The settings of the simplification, including quality and distance
  136512. * @param successCallback A callback that will be called after the mesh was simplified.
  136513. * @param errorCallback in case of an error, this callback will be called. optional.
  136514. */
  136515. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136516. }
  136517. /**
  136518. * Expected simplification settings.
  136519. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136521. */
  136522. export interface ISimplificationSettings {
  136523. /**
  136524. * Gets or sets the expected quality
  136525. */
  136526. quality: number;
  136527. /**
  136528. * Gets or sets the distance when this optimized version should be used
  136529. */
  136530. distance: number;
  136531. /**
  136532. * Gets an already optimized mesh
  136533. */
  136534. optimizeMesh?: boolean;
  136535. }
  136536. /**
  136537. * Class used to specify simplification options
  136538. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136539. */
  136540. export class SimplificationSettings implements ISimplificationSettings {
  136541. /** expected quality */
  136542. quality: number;
  136543. /** distance when this optimized version should be used */
  136544. distance: number;
  136545. /** already optimized mesh */
  136546. optimizeMesh?: boolean | undefined;
  136547. /**
  136548. * Creates a SimplificationSettings
  136549. * @param quality expected quality
  136550. * @param distance distance when this optimized version should be used
  136551. * @param optimizeMesh already optimized mesh
  136552. */
  136553. constructor(
  136554. /** expected quality */
  136555. quality: number,
  136556. /** distance when this optimized version should be used */
  136557. distance: number,
  136558. /** already optimized mesh */
  136559. optimizeMesh?: boolean | undefined);
  136560. }
  136561. /**
  136562. * Interface used to define a simplification task
  136563. */
  136564. export interface ISimplificationTask {
  136565. /**
  136566. * Array of settings
  136567. */
  136568. settings: Array<ISimplificationSettings>;
  136569. /**
  136570. * Simplification type
  136571. */
  136572. simplificationType: SimplificationType;
  136573. /**
  136574. * Mesh to simplify
  136575. */
  136576. mesh: Mesh;
  136577. /**
  136578. * Callback called on success
  136579. */
  136580. successCallback?: () => void;
  136581. /**
  136582. * Defines if parallel processing can be used
  136583. */
  136584. parallelProcessing: boolean;
  136585. }
  136586. /**
  136587. * Queue used to order the simplification tasks
  136588. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136589. */
  136590. export class SimplificationQueue {
  136591. private _simplificationArray;
  136592. /**
  136593. * Gets a boolean indicating that the process is still running
  136594. */
  136595. running: boolean;
  136596. /**
  136597. * Creates a new queue
  136598. */
  136599. constructor();
  136600. /**
  136601. * Adds a new simplification task
  136602. * @param task defines a task to add
  136603. */
  136604. addTask(task: ISimplificationTask): void;
  136605. /**
  136606. * Execute next task
  136607. */
  136608. executeNext(): void;
  136609. /**
  136610. * Execute a simplification task
  136611. * @param task defines the task to run
  136612. */
  136613. runSimplification(task: ISimplificationTask): void;
  136614. private getSimplifier;
  136615. }
  136616. /**
  136617. * The implemented types of simplification
  136618. * At the moment only Quadratic Error Decimation is implemented
  136619. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136620. */
  136621. export enum SimplificationType {
  136622. /** Quadratic error decimation */
  136623. QUADRATIC = 0
  136624. }
  136625. /**
  136626. * An implementation of the Quadratic Error simplification algorithm.
  136627. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136628. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136629. * @author RaananW
  136630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136631. */
  136632. export class QuadraticErrorSimplification implements ISimplifier {
  136633. private _mesh;
  136634. private triangles;
  136635. private vertices;
  136636. private references;
  136637. private _reconstructedMesh;
  136638. /** Gets or sets the number pf sync interations */
  136639. syncIterations: number;
  136640. /** Gets or sets the aggressiveness of the simplifier */
  136641. aggressiveness: number;
  136642. /** Gets or sets the number of allowed iterations for decimation */
  136643. decimationIterations: number;
  136644. /** Gets or sets the espilon to use for bounding box computation */
  136645. boundingBoxEpsilon: number;
  136646. /**
  136647. * Creates a new QuadraticErrorSimplification
  136648. * @param _mesh defines the target mesh
  136649. */
  136650. constructor(_mesh: Mesh);
  136651. /**
  136652. * Simplification of a given mesh according to the given settings.
  136653. * Since this requires computation, it is assumed that the function runs async.
  136654. * @param settings The settings of the simplification, including quality and distance
  136655. * @param successCallback A callback that will be called after the mesh was simplified.
  136656. */
  136657. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136658. private runDecimation;
  136659. private initWithMesh;
  136660. private init;
  136661. private reconstructMesh;
  136662. private initDecimatedMesh;
  136663. private isFlipped;
  136664. private updateTriangles;
  136665. private identifyBorder;
  136666. private updateMesh;
  136667. private vertexError;
  136668. private calculateError;
  136669. }
  136670. }
  136671. declare module BABYLON {
  136672. interface Scene {
  136673. /** @hidden (Backing field) */
  136674. _simplificationQueue: SimplificationQueue;
  136675. /**
  136676. * Gets or sets the simplification queue attached to the scene
  136677. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136678. */
  136679. simplificationQueue: SimplificationQueue;
  136680. }
  136681. interface Mesh {
  136682. /**
  136683. * Simplify the mesh according to the given array of settings.
  136684. * Function will return immediately and will simplify async
  136685. * @param settings a collection of simplification settings
  136686. * @param parallelProcessing should all levels calculate parallel or one after the other
  136687. * @param simplificationType the type of simplification to run
  136688. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136689. * @returns the current mesh
  136690. */
  136691. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136692. }
  136693. /**
  136694. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136695. * created in a scene
  136696. */
  136697. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136698. /**
  136699. * The component name helpfull to identify the component in the list of scene components.
  136700. */
  136701. readonly name: string;
  136702. /**
  136703. * The scene the component belongs to.
  136704. */
  136705. scene: Scene;
  136706. /**
  136707. * Creates a new instance of the component for the given scene
  136708. * @param scene Defines the scene to register the component in
  136709. */
  136710. constructor(scene: Scene);
  136711. /**
  136712. * Registers the component in a given scene
  136713. */
  136714. register(): void;
  136715. /**
  136716. * Rebuilds the elements related to this component in case of
  136717. * context lost for instance.
  136718. */
  136719. rebuild(): void;
  136720. /**
  136721. * Disposes the component and the associated ressources
  136722. */
  136723. dispose(): void;
  136724. private _beforeCameraUpdate;
  136725. }
  136726. }
  136727. declare module BABYLON {
  136728. /**
  136729. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136730. */
  136731. export interface INavigationEnginePlugin {
  136732. /**
  136733. * plugin name
  136734. */
  136735. name: string;
  136736. /**
  136737. * Creates a navigation mesh
  136738. * @param meshes array of all the geometry used to compute the navigatio mesh
  136739. * @param parameters bunch of parameters used to filter geometry
  136740. */
  136741. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136742. /**
  136743. * Create a navigation mesh debug mesh
  136744. * @param scene is where the mesh will be added
  136745. * @returns debug display mesh
  136746. */
  136747. createDebugNavMesh(scene: Scene): Mesh;
  136748. /**
  136749. * Get a navigation mesh constrained position, closest to the parameter position
  136750. * @param position world position
  136751. * @returns the closest point to position constrained by the navigation mesh
  136752. */
  136753. getClosestPoint(position: Vector3): Vector3;
  136754. /**
  136755. * Get a navigation mesh constrained position, closest to the parameter position
  136756. * @param position world position
  136757. * @param result output the closest point to position constrained by the navigation mesh
  136758. */
  136759. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136760. /**
  136761. * Get a navigation mesh constrained position, within a particular radius
  136762. * @param position world position
  136763. * @param maxRadius the maximum distance to the constrained world position
  136764. * @returns the closest point to position constrained by the navigation mesh
  136765. */
  136766. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136767. /**
  136768. * Get a navigation mesh constrained position, within a particular radius
  136769. * @param position world position
  136770. * @param maxRadius the maximum distance to the constrained world position
  136771. * @param result output the closest point to position constrained by the navigation mesh
  136772. */
  136773. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136774. /**
  136775. * Compute the final position from a segment made of destination-position
  136776. * @param position world position
  136777. * @param destination world position
  136778. * @returns the resulting point along the navmesh
  136779. */
  136780. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136781. /**
  136782. * Compute the final position from a segment made of destination-position
  136783. * @param position world position
  136784. * @param destination world position
  136785. * @param result output the resulting point along the navmesh
  136786. */
  136787. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136788. /**
  136789. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136790. * @param start world position
  136791. * @param end world position
  136792. * @returns array containing world position composing the path
  136793. */
  136794. computePath(start: Vector3, end: Vector3): Vector3[];
  136795. /**
  136796. * If this plugin is supported
  136797. * @returns true if plugin is supported
  136798. */
  136799. isSupported(): boolean;
  136800. /**
  136801. * Create a new Crowd so you can add agents
  136802. * @param maxAgents the maximum agent count in the crowd
  136803. * @param maxAgentRadius the maximum radius an agent can have
  136804. * @param scene to attach the crowd to
  136805. * @returns the crowd you can add agents to
  136806. */
  136807. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136808. /**
  136809. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136810. * The queries will try to find a solution within those bounds
  136811. * default is (1,1,1)
  136812. * @param extent x,y,z value that define the extent around the queries point of reference
  136813. */
  136814. setDefaultQueryExtent(extent: Vector3): void;
  136815. /**
  136816. * Get the Bounding box extent specified by setDefaultQueryExtent
  136817. * @returns the box extent values
  136818. */
  136819. getDefaultQueryExtent(): Vector3;
  136820. /**
  136821. * build the navmesh from a previously saved state using getNavmeshData
  136822. * @param data the Uint8Array returned by getNavmeshData
  136823. */
  136824. buildFromNavmeshData(data: Uint8Array): void;
  136825. /**
  136826. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136827. * @returns data the Uint8Array that can be saved and reused
  136828. */
  136829. getNavmeshData(): Uint8Array;
  136830. /**
  136831. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136832. * @param result output the box extent values
  136833. */
  136834. getDefaultQueryExtentToRef(result: Vector3): void;
  136835. /**
  136836. * Release all resources
  136837. */
  136838. dispose(): void;
  136839. }
  136840. /**
  136841. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136842. */
  136843. export interface ICrowd {
  136844. /**
  136845. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136846. * You can attach anything to that node. The node position is updated in the scene update tick.
  136847. * @param pos world position that will be constrained by the navigation mesh
  136848. * @param parameters agent parameters
  136849. * @param transform hooked to the agent that will be update by the scene
  136850. * @returns agent index
  136851. */
  136852. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136853. /**
  136854. * Returns the agent position in world space
  136855. * @param index agent index returned by addAgent
  136856. * @returns world space position
  136857. */
  136858. getAgentPosition(index: number): Vector3;
  136859. /**
  136860. * Gets the agent position result in world space
  136861. * @param index agent index returned by addAgent
  136862. * @param result output world space position
  136863. */
  136864. getAgentPositionToRef(index: number, result: Vector3): void;
  136865. /**
  136866. * Gets the agent velocity in world space
  136867. * @param index agent index returned by addAgent
  136868. * @returns world space velocity
  136869. */
  136870. getAgentVelocity(index: number): Vector3;
  136871. /**
  136872. * Gets the agent velocity result in world space
  136873. * @param index agent index returned by addAgent
  136874. * @param result output world space velocity
  136875. */
  136876. getAgentVelocityToRef(index: number, result: Vector3): void;
  136877. /**
  136878. * remove a particular agent previously created
  136879. * @param index agent index returned by addAgent
  136880. */
  136881. removeAgent(index: number): void;
  136882. /**
  136883. * get the list of all agents attached to this crowd
  136884. * @returns list of agent indices
  136885. */
  136886. getAgents(): number[];
  136887. /**
  136888. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136889. * @param deltaTime in seconds
  136890. */
  136891. update(deltaTime: number): void;
  136892. /**
  136893. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136894. * @param index agent index returned by addAgent
  136895. * @param destination targeted world position
  136896. */
  136897. agentGoto(index: number, destination: Vector3): void;
  136898. /**
  136899. * Teleport the agent to a new position
  136900. * @param index agent index returned by addAgent
  136901. * @param destination targeted world position
  136902. */
  136903. agentTeleport(index: number, destination: Vector3): void;
  136904. /**
  136905. * Update agent parameters
  136906. * @param index agent index returned by addAgent
  136907. * @param parameters agent parameters
  136908. */
  136909. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136910. /**
  136911. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136912. * The queries will try to find a solution within those bounds
  136913. * default is (1,1,1)
  136914. * @param extent x,y,z value that define the extent around the queries point of reference
  136915. */
  136916. setDefaultQueryExtent(extent: Vector3): void;
  136917. /**
  136918. * Get the Bounding box extent specified by setDefaultQueryExtent
  136919. * @returns the box extent values
  136920. */
  136921. getDefaultQueryExtent(): Vector3;
  136922. /**
  136923. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136924. * @param result output the box extent values
  136925. */
  136926. getDefaultQueryExtentToRef(result: Vector3): void;
  136927. /**
  136928. * Release all resources
  136929. */
  136930. dispose(): void;
  136931. }
  136932. /**
  136933. * Configures an agent
  136934. */
  136935. export interface IAgentParameters {
  136936. /**
  136937. * Agent radius. [Limit: >= 0]
  136938. */
  136939. radius: number;
  136940. /**
  136941. * Agent height. [Limit: > 0]
  136942. */
  136943. height: number;
  136944. /**
  136945. * Maximum allowed acceleration. [Limit: >= 0]
  136946. */
  136947. maxAcceleration: number;
  136948. /**
  136949. * Maximum allowed speed. [Limit: >= 0]
  136950. */
  136951. maxSpeed: number;
  136952. /**
  136953. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136954. */
  136955. collisionQueryRange: number;
  136956. /**
  136957. * The path visibility optimization range. [Limit: > 0]
  136958. */
  136959. pathOptimizationRange: number;
  136960. /**
  136961. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136962. */
  136963. separationWeight: number;
  136964. }
  136965. /**
  136966. * Configures the navigation mesh creation
  136967. */
  136968. export interface INavMeshParameters {
  136969. /**
  136970. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136971. */
  136972. cs: number;
  136973. /**
  136974. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  136975. */
  136976. ch: number;
  136977. /**
  136978. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  136979. */
  136980. walkableSlopeAngle: number;
  136981. /**
  136982. * Minimum floor to 'ceiling' height that will still allow the floor area to
  136983. * be considered walkable. [Limit: >= 3] [Units: vx]
  136984. */
  136985. walkableHeight: number;
  136986. /**
  136987. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  136988. */
  136989. walkableClimb: number;
  136990. /**
  136991. * The distance to erode/shrink the walkable area of the heightfield away from
  136992. * obstructions. [Limit: >=0] [Units: vx]
  136993. */
  136994. walkableRadius: number;
  136995. /**
  136996. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  136997. */
  136998. maxEdgeLen: number;
  136999. /**
  137000. * The maximum distance a simplfied contour's border edges should deviate
  137001. * the original raw contour. [Limit: >=0] [Units: vx]
  137002. */
  137003. maxSimplificationError: number;
  137004. /**
  137005. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137006. */
  137007. minRegionArea: number;
  137008. /**
  137009. * Any regions with a span count smaller than this value will, if possible,
  137010. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137011. */
  137012. mergeRegionArea: number;
  137013. /**
  137014. * The maximum number of vertices allowed for polygons generated during the
  137015. * contour to polygon conversion process. [Limit: >= 3]
  137016. */
  137017. maxVertsPerPoly: number;
  137018. /**
  137019. * Sets the sampling distance to use when generating the detail mesh.
  137020. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137021. */
  137022. detailSampleDist: number;
  137023. /**
  137024. * The maximum distance the detail mesh surface should deviate from heightfield
  137025. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137026. */
  137027. detailSampleMaxError: number;
  137028. }
  137029. }
  137030. declare module BABYLON {
  137031. /**
  137032. * RecastJS navigation plugin
  137033. */
  137034. export class RecastJSPlugin implements INavigationEnginePlugin {
  137035. /**
  137036. * Reference to the Recast library
  137037. */
  137038. bjsRECAST: any;
  137039. /**
  137040. * plugin name
  137041. */
  137042. name: string;
  137043. /**
  137044. * the first navmesh created. We might extend this to support multiple navmeshes
  137045. */
  137046. navMesh: any;
  137047. /**
  137048. * Initializes the recastJS plugin
  137049. * @param recastInjection can be used to inject your own recast reference
  137050. */
  137051. constructor(recastInjection?: any);
  137052. /**
  137053. * Creates a navigation mesh
  137054. * @param meshes array of all the geometry used to compute the navigatio mesh
  137055. * @param parameters bunch of parameters used to filter geometry
  137056. */
  137057. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137058. /**
  137059. * Create a navigation mesh debug mesh
  137060. * @param scene is where the mesh will be added
  137061. * @returns debug display mesh
  137062. */
  137063. createDebugNavMesh(scene: Scene): Mesh;
  137064. /**
  137065. * Get a navigation mesh constrained position, closest to the parameter position
  137066. * @param position world position
  137067. * @returns the closest point to position constrained by the navigation mesh
  137068. */
  137069. getClosestPoint(position: Vector3): Vector3;
  137070. /**
  137071. * Get a navigation mesh constrained position, closest to the parameter position
  137072. * @param position world position
  137073. * @param result output the closest point to position constrained by the navigation mesh
  137074. */
  137075. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137076. /**
  137077. * Get a navigation mesh constrained position, within a particular radius
  137078. * @param position world position
  137079. * @param maxRadius the maximum distance to the constrained world position
  137080. * @returns the closest point to position constrained by the navigation mesh
  137081. */
  137082. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137083. /**
  137084. * Get a navigation mesh constrained position, within a particular radius
  137085. * @param position world position
  137086. * @param maxRadius the maximum distance to the constrained world position
  137087. * @param result output the closest point to position constrained by the navigation mesh
  137088. */
  137089. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137090. /**
  137091. * Compute the final position from a segment made of destination-position
  137092. * @param position world position
  137093. * @param destination world position
  137094. * @returns the resulting point along the navmesh
  137095. */
  137096. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137097. /**
  137098. * Compute the final position from a segment made of destination-position
  137099. * @param position world position
  137100. * @param destination world position
  137101. * @param result output the resulting point along the navmesh
  137102. */
  137103. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137104. /**
  137105. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137106. * @param start world position
  137107. * @param end world position
  137108. * @returns array containing world position composing the path
  137109. */
  137110. computePath(start: Vector3, end: Vector3): Vector3[];
  137111. /**
  137112. * Create a new Crowd so you can add agents
  137113. * @param maxAgents the maximum agent count in the crowd
  137114. * @param maxAgentRadius the maximum radius an agent can have
  137115. * @param scene to attach the crowd to
  137116. * @returns the crowd you can add agents to
  137117. */
  137118. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137119. /**
  137120. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137121. * The queries will try to find a solution within those bounds
  137122. * default is (1,1,1)
  137123. * @param extent x,y,z value that define the extent around the queries point of reference
  137124. */
  137125. setDefaultQueryExtent(extent: Vector3): void;
  137126. /**
  137127. * Get the Bounding box extent specified by setDefaultQueryExtent
  137128. * @returns the box extent values
  137129. */
  137130. getDefaultQueryExtent(): Vector3;
  137131. /**
  137132. * build the navmesh from a previously saved state using getNavmeshData
  137133. * @param data the Uint8Array returned by getNavmeshData
  137134. */
  137135. buildFromNavmeshData(data: Uint8Array): void;
  137136. /**
  137137. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137138. * @returns data the Uint8Array that can be saved and reused
  137139. */
  137140. getNavmeshData(): Uint8Array;
  137141. /**
  137142. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137143. * @param result output the box extent values
  137144. */
  137145. getDefaultQueryExtentToRef(result: Vector3): void;
  137146. /**
  137147. * Disposes
  137148. */
  137149. dispose(): void;
  137150. /**
  137151. * If this plugin is supported
  137152. * @returns true if plugin is supported
  137153. */
  137154. isSupported(): boolean;
  137155. }
  137156. /**
  137157. * Recast detour crowd implementation
  137158. */
  137159. export class RecastJSCrowd implements ICrowd {
  137160. /**
  137161. * Recast/detour plugin
  137162. */
  137163. bjsRECASTPlugin: RecastJSPlugin;
  137164. /**
  137165. * Link to the detour crowd
  137166. */
  137167. recastCrowd: any;
  137168. /**
  137169. * One transform per agent
  137170. */
  137171. transforms: TransformNode[];
  137172. /**
  137173. * All agents created
  137174. */
  137175. agents: number[];
  137176. /**
  137177. * Link to the scene is kept to unregister the crowd from the scene
  137178. */
  137179. private _scene;
  137180. /**
  137181. * Observer for crowd updates
  137182. */
  137183. private _onBeforeAnimationsObserver;
  137184. /**
  137185. * Constructor
  137186. * @param plugin recastJS plugin
  137187. * @param maxAgents the maximum agent count in the crowd
  137188. * @param maxAgentRadius the maximum radius an agent can have
  137189. * @param scene to attach the crowd to
  137190. * @returns the crowd you can add agents to
  137191. */
  137192. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137193. /**
  137194. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137195. * You can attach anything to that node. The node position is updated in the scene update tick.
  137196. * @param pos world position that will be constrained by the navigation mesh
  137197. * @param parameters agent parameters
  137198. * @param transform hooked to the agent that will be update by the scene
  137199. * @returns agent index
  137200. */
  137201. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137202. /**
  137203. * Returns the agent position in world space
  137204. * @param index agent index returned by addAgent
  137205. * @returns world space position
  137206. */
  137207. getAgentPosition(index: number): Vector3;
  137208. /**
  137209. * Returns the agent position result in world space
  137210. * @param index agent index returned by addAgent
  137211. * @param result output world space position
  137212. */
  137213. getAgentPositionToRef(index: number, result: Vector3): void;
  137214. /**
  137215. * Returns the agent velocity in world space
  137216. * @param index agent index returned by addAgent
  137217. * @returns world space velocity
  137218. */
  137219. getAgentVelocity(index: number): Vector3;
  137220. /**
  137221. * Returns the agent velocity result in world space
  137222. * @param index agent index returned by addAgent
  137223. * @param result output world space velocity
  137224. */
  137225. getAgentVelocityToRef(index: number, result: Vector3): void;
  137226. /**
  137227. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137228. * @param index agent index returned by addAgent
  137229. * @param destination targeted world position
  137230. */
  137231. agentGoto(index: number, destination: Vector3): void;
  137232. /**
  137233. * Teleport the agent to a new position
  137234. * @param index agent index returned by addAgent
  137235. * @param destination targeted world position
  137236. */
  137237. agentTeleport(index: number, destination: Vector3): void;
  137238. /**
  137239. * Update agent parameters
  137240. * @param index agent index returned by addAgent
  137241. * @param parameters agent parameters
  137242. */
  137243. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137244. /**
  137245. * remove a particular agent previously created
  137246. * @param index agent index returned by addAgent
  137247. */
  137248. removeAgent(index: number): void;
  137249. /**
  137250. * get the list of all agents attached to this crowd
  137251. * @returns list of agent indices
  137252. */
  137253. getAgents(): number[];
  137254. /**
  137255. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137256. * @param deltaTime in seconds
  137257. */
  137258. update(deltaTime: number): void;
  137259. /**
  137260. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137261. * The queries will try to find a solution within those bounds
  137262. * default is (1,1,1)
  137263. * @param extent x,y,z value that define the extent around the queries point of reference
  137264. */
  137265. setDefaultQueryExtent(extent: Vector3): void;
  137266. /**
  137267. * Get the Bounding box extent specified by setDefaultQueryExtent
  137268. * @returns the box extent values
  137269. */
  137270. getDefaultQueryExtent(): Vector3;
  137271. /**
  137272. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137273. * @param result output the box extent values
  137274. */
  137275. getDefaultQueryExtentToRef(result: Vector3): void;
  137276. /**
  137277. * Release all resources
  137278. */
  137279. dispose(): void;
  137280. }
  137281. }
  137282. declare module BABYLON {
  137283. /**
  137284. * Class used to enable access to IndexedDB
  137285. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137286. */
  137287. export class Database implements IOfflineProvider {
  137288. private _callbackManifestChecked;
  137289. private _currentSceneUrl;
  137290. private _db;
  137291. private _enableSceneOffline;
  137292. private _enableTexturesOffline;
  137293. private _manifestVersionFound;
  137294. private _mustUpdateRessources;
  137295. private _hasReachedQuota;
  137296. private _isSupported;
  137297. private _idbFactory;
  137298. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137299. private static IsUASupportingBlobStorage;
  137300. /**
  137301. * Gets a boolean indicating if Database storate is enabled (off by default)
  137302. */
  137303. static IDBStorageEnabled: boolean;
  137304. /**
  137305. * Gets a boolean indicating if scene must be saved in the database
  137306. */
  137307. get enableSceneOffline(): boolean;
  137308. /**
  137309. * Gets a boolean indicating if textures must be saved in the database
  137310. */
  137311. get enableTexturesOffline(): boolean;
  137312. /**
  137313. * Creates a new Database
  137314. * @param urlToScene defines the url to load the scene
  137315. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137316. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137317. */
  137318. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137319. private static _ParseURL;
  137320. private static _ReturnFullUrlLocation;
  137321. private _checkManifestFile;
  137322. /**
  137323. * Open the database and make it available
  137324. * @param successCallback defines the callback to call on success
  137325. * @param errorCallback defines the callback to call on error
  137326. */
  137327. open(successCallback: () => void, errorCallback: () => void): void;
  137328. /**
  137329. * Loads an image from the database
  137330. * @param url defines the url to load from
  137331. * @param image defines the target DOM image
  137332. */
  137333. loadImage(url: string, image: HTMLImageElement): void;
  137334. private _loadImageFromDBAsync;
  137335. private _saveImageIntoDBAsync;
  137336. private _checkVersionFromDB;
  137337. private _loadVersionFromDBAsync;
  137338. private _saveVersionIntoDBAsync;
  137339. /**
  137340. * Loads a file from database
  137341. * @param url defines the URL to load from
  137342. * @param sceneLoaded defines a callback to call on success
  137343. * @param progressCallBack defines a callback to call when progress changed
  137344. * @param errorCallback defines a callback to call on error
  137345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137346. */
  137347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137348. private _loadFileAsync;
  137349. private _saveFileAsync;
  137350. /**
  137351. * Validates if xhr data is correct
  137352. * @param xhr defines the request to validate
  137353. * @param dataType defines the expected data type
  137354. * @returns true if data is correct
  137355. */
  137356. private static _ValidateXHRData;
  137357. }
  137358. }
  137359. declare module BABYLON {
  137360. /** @hidden */
  137361. export var gpuUpdateParticlesPixelShader: {
  137362. name: string;
  137363. shader: string;
  137364. };
  137365. }
  137366. declare module BABYLON {
  137367. /** @hidden */
  137368. export var gpuUpdateParticlesVertexShader: {
  137369. name: string;
  137370. shader: string;
  137371. };
  137372. }
  137373. declare module BABYLON {
  137374. /** @hidden */
  137375. export var clipPlaneFragmentDeclaration2: {
  137376. name: string;
  137377. shader: string;
  137378. };
  137379. }
  137380. declare module BABYLON {
  137381. /** @hidden */
  137382. export var gpuRenderParticlesPixelShader: {
  137383. name: string;
  137384. shader: string;
  137385. };
  137386. }
  137387. declare module BABYLON {
  137388. /** @hidden */
  137389. export var clipPlaneVertexDeclaration2: {
  137390. name: string;
  137391. shader: string;
  137392. };
  137393. }
  137394. declare module BABYLON {
  137395. /** @hidden */
  137396. export var gpuRenderParticlesVertexShader: {
  137397. name: string;
  137398. shader: string;
  137399. };
  137400. }
  137401. declare module BABYLON {
  137402. /**
  137403. * This represents a GPU particle system in Babylon
  137404. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137405. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137406. */
  137407. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137408. /**
  137409. * The layer mask we are rendering the particles through.
  137410. */
  137411. layerMask: number;
  137412. private _capacity;
  137413. private _activeCount;
  137414. private _currentActiveCount;
  137415. private _accumulatedCount;
  137416. private _renderEffect;
  137417. private _updateEffect;
  137418. private _buffer0;
  137419. private _buffer1;
  137420. private _spriteBuffer;
  137421. private _updateVAO;
  137422. private _renderVAO;
  137423. private _targetIndex;
  137424. private _sourceBuffer;
  137425. private _targetBuffer;
  137426. private _engine;
  137427. private _currentRenderId;
  137428. private _started;
  137429. private _stopped;
  137430. private _timeDelta;
  137431. private _randomTexture;
  137432. private _randomTexture2;
  137433. private _attributesStrideSize;
  137434. private _updateEffectOptions;
  137435. private _randomTextureSize;
  137436. private _actualFrame;
  137437. private readonly _rawTextureWidth;
  137438. /**
  137439. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137440. */
  137441. static get IsSupported(): boolean;
  137442. /**
  137443. * An event triggered when the system is disposed.
  137444. */
  137445. onDisposeObservable: Observable<GPUParticleSystem>;
  137446. /**
  137447. * Gets the maximum number of particles active at the same time.
  137448. * @returns The max number of active particles.
  137449. */
  137450. getCapacity(): number;
  137451. /**
  137452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137453. * to override the particles.
  137454. */
  137455. forceDepthWrite: boolean;
  137456. /**
  137457. * Gets or set the number of active particles
  137458. */
  137459. get activeParticleCount(): number;
  137460. set activeParticleCount(value: number);
  137461. private _preWarmDone;
  137462. /**
  137463. * Specifies if the particles are updated in emitter local space or world space.
  137464. * This is always false for GPU particles
  137465. */
  137466. get isLocal(): boolean;
  137467. set isLocal(value: boolean);
  137468. /**
  137469. * Is this system ready to be used/rendered
  137470. * @return true if the system is ready
  137471. */
  137472. isReady(): boolean;
  137473. /**
  137474. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137475. * @returns True if it has been started, otherwise false.
  137476. */
  137477. isStarted(): boolean;
  137478. /**
  137479. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137480. * @returns True if it has been stopped, otherwise false.
  137481. */
  137482. isStopped(): boolean;
  137483. /**
  137484. * Gets a boolean indicating that the system is stopping
  137485. * @returns true if the system is currently stopping
  137486. */
  137487. isStopping(): boolean;
  137488. /**
  137489. * Gets the number of particles active at the same time.
  137490. * @returns The number of active particles.
  137491. */
  137492. getActiveCount(): number;
  137493. /**
  137494. * Starts the particle system and begins to emit
  137495. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137496. */
  137497. start(delay?: number): void;
  137498. /**
  137499. * Stops the particle system.
  137500. */
  137501. stop(): void;
  137502. /**
  137503. * Remove all active particles
  137504. */
  137505. reset(): void;
  137506. /**
  137507. * Returns the string "GPUParticleSystem"
  137508. * @returns a string containing the class name
  137509. */
  137510. getClassName(): string;
  137511. private _colorGradientsTexture;
  137512. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137513. /**
  137514. * Adds a new color gradient
  137515. * @param gradient defines the gradient to use (between 0 and 1)
  137516. * @param color1 defines the color to affect to the specified gradient
  137517. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137518. * @returns the current particle system
  137519. */
  137520. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137521. private _refreshColorGradient;
  137522. /** Force the system to rebuild all gradients */
  137523. forceRefreshGradients(): void;
  137524. /**
  137525. * Remove a specific color gradient
  137526. * @param gradient defines the gradient to remove
  137527. * @returns the current particle system
  137528. */
  137529. removeColorGradient(gradient: number): GPUParticleSystem;
  137530. private _angularSpeedGradientsTexture;
  137531. private _sizeGradientsTexture;
  137532. private _velocityGradientsTexture;
  137533. private _limitVelocityGradientsTexture;
  137534. private _dragGradientsTexture;
  137535. private _addFactorGradient;
  137536. /**
  137537. * Adds a new size gradient
  137538. * @param gradient defines the gradient to use (between 0 and 1)
  137539. * @param factor defines the size factor to affect to the specified gradient
  137540. * @returns the current particle system
  137541. */
  137542. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137543. /**
  137544. * Remove a specific size gradient
  137545. * @param gradient defines the gradient to remove
  137546. * @returns the current particle system
  137547. */
  137548. removeSizeGradient(gradient: number): GPUParticleSystem;
  137549. private _refreshFactorGradient;
  137550. /**
  137551. * Adds a new angular speed gradient
  137552. * @param gradient defines the gradient to use (between 0 and 1)
  137553. * @param factor defines the angular speed to affect to the specified gradient
  137554. * @returns the current particle system
  137555. */
  137556. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137557. /**
  137558. * Remove a specific angular speed gradient
  137559. * @param gradient defines the gradient to remove
  137560. * @returns the current particle system
  137561. */
  137562. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137563. /**
  137564. * Adds a new velocity gradient
  137565. * @param gradient defines the gradient to use (between 0 and 1)
  137566. * @param factor defines the velocity to affect to the specified gradient
  137567. * @returns the current particle system
  137568. */
  137569. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137570. /**
  137571. * Remove a specific velocity gradient
  137572. * @param gradient defines the gradient to remove
  137573. * @returns the current particle system
  137574. */
  137575. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137576. /**
  137577. * Adds a new limit velocity gradient
  137578. * @param gradient defines the gradient to use (between 0 and 1)
  137579. * @param factor defines the limit velocity value to affect to the specified gradient
  137580. * @returns the current particle system
  137581. */
  137582. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137583. /**
  137584. * Remove a specific limit velocity gradient
  137585. * @param gradient defines the gradient to remove
  137586. * @returns the current particle system
  137587. */
  137588. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137589. /**
  137590. * Adds a new drag gradient
  137591. * @param gradient defines the gradient to use (between 0 and 1)
  137592. * @param factor defines the drag value to affect to the specified gradient
  137593. * @returns the current particle system
  137594. */
  137595. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137596. /**
  137597. * Remove a specific drag gradient
  137598. * @param gradient defines the gradient to remove
  137599. * @returns the current particle system
  137600. */
  137601. removeDragGradient(gradient: number): GPUParticleSystem;
  137602. /**
  137603. * Not supported by GPUParticleSystem
  137604. * @param gradient defines the gradient to use (between 0 and 1)
  137605. * @param factor defines the emit rate value to affect to the specified gradient
  137606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137607. * @returns the current particle system
  137608. */
  137609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137610. /**
  137611. * Not supported by GPUParticleSystem
  137612. * @param gradient defines the gradient to remove
  137613. * @returns the current particle system
  137614. */
  137615. removeEmitRateGradient(gradient: number): IParticleSystem;
  137616. /**
  137617. * Not supported by GPUParticleSystem
  137618. * @param gradient defines the gradient to use (between 0 and 1)
  137619. * @param factor defines the start size value to affect to the specified gradient
  137620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137621. * @returns the current particle system
  137622. */
  137623. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137624. /**
  137625. * Not supported by GPUParticleSystem
  137626. * @param gradient defines the gradient to remove
  137627. * @returns the current particle system
  137628. */
  137629. removeStartSizeGradient(gradient: number): IParticleSystem;
  137630. /**
  137631. * Not supported by GPUParticleSystem
  137632. * @param gradient defines the gradient to use (between 0 and 1)
  137633. * @param min defines the color remap minimal range
  137634. * @param max defines the color remap maximal range
  137635. * @returns the current particle system
  137636. */
  137637. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137638. /**
  137639. * Not supported by GPUParticleSystem
  137640. * @param gradient defines the gradient to remove
  137641. * @returns the current particle system
  137642. */
  137643. removeColorRemapGradient(): IParticleSystem;
  137644. /**
  137645. * Not supported by GPUParticleSystem
  137646. * @param gradient defines the gradient to use (between 0 and 1)
  137647. * @param min defines the alpha remap minimal range
  137648. * @param max defines the alpha remap maximal range
  137649. * @returns the current particle system
  137650. */
  137651. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137652. /**
  137653. * Not supported by GPUParticleSystem
  137654. * @param gradient defines the gradient to remove
  137655. * @returns the current particle system
  137656. */
  137657. removeAlphaRemapGradient(): IParticleSystem;
  137658. /**
  137659. * Not supported by GPUParticleSystem
  137660. * @param gradient defines the gradient to use (between 0 and 1)
  137661. * @param color defines the color to affect to the specified gradient
  137662. * @returns the current particle system
  137663. */
  137664. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137665. /**
  137666. * Not supported by GPUParticleSystem
  137667. * @param gradient defines the gradient to remove
  137668. * @returns the current particle system
  137669. */
  137670. removeRampGradient(): IParticleSystem;
  137671. /**
  137672. * Not supported by GPUParticleSystem
  137673. * @returns the list of ramp gradients
  137674. */
  137675. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137676. /**
  137677. * Not supported by GPUParticleSystem
  137678. * Gets or sets a boolean indicating that ramp gradients must be used
  137679. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137680. */
  137681. get useRampGradients(): boolean;
  137682. set useRampGradients(value: boolean);
  137683. /**
  137684. * Not supported by GPUParticleSystem
  137685. * @param gradient defines the gradient to use (between 0 and 1)
  137686. * @param factor defines the life time factor to affect to the specified gradient
  137687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137688. * @returns the current particle system
  137689. */
  137690. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137691. /**
  137692. * Not supported by GPUParticleSystem
  137693. * @param gradient defines the gradient to remove
  137694. * @returns the current particle system
  137695. */
  137696. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137697. /**
  137698. * Instantiates a GPU particle system.
  137699. * 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.
  137700. * @param name The name of the particle system
  137701. * @param options The options used to create the system
  137702. * @param scene The scene the particle system belongs to
  137703. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137704. */
  137705. constructor(name: string, options: Partial<{
  137706. capacity: number;
  137707. randomTextureSize: number;
  137708. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137709. protected _reset(): void;
  137710. private _createUpdateVAO;
  137711. private _createRenderVAO;
  137712. private _initialize;
  137713. /** @hidden */
  137714. _recreateUpdateEffect(): void;
  137715. /** @hidden */
  137716. _recreateRenderEffect(): void;
  137717. /**
  137718. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137719. * @param preWarm defines if we are in the pre-warmimg phase
  137720. */
  137721. animate(preWarm?: boolean): void;
  137722. private _createFactorGradientTexture;
  137723. private _createSizeGradientTexture;
  137724. private _createAngularSpeedGradientTexture;
  137725. private _createVelocityGradientTexture;
  137726. private _createLimitVelocityGradientTexture;
  137727. private _createDragGradientTexture;
  137728. private _createColorGradientTexture;
  137729. /**
  137730. * Renders the particle system in its current state
  137731. * @param preWarm defines if the system should only update the particles but not render them
  137732. * @returns the current number of particles
  137733. */
  137734. render(preWarm?: boolean): number;
  137735. /**
  137736. * Rebuilds the particle system
  137737. */
  137738. rebuild(): void;
  137739. private _releaseBuffers;
  137740. private _releaseVAOs;
  137741. /**
  137742. * Disposes the particle system and free the associated resources
  137743. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137744. */
  137745. dispose(disposeTexture?: boolean): void;
  137746. /**
  137747. * Clones the particle system.
  137748. * @param name The name of the cloned object
  137749. * @param newEmitter The new emitter to use
  137750. * @returns the cloned particle system
  137751. */
  137752. clone(name: string, newEmitter: any): GPUParticleSystem;
  137753. /**
  137754. * Serializes the particle system to a JSON object.
  137755. * @returns the JSON object
  137756. */
  137757. serialize(): any;
  137758. /**
  137759. * Parses a JSON object to create a GPU particle system.
  137760. * @param parsedParticleSystem The JSON object to parse
  137761. * @param scene The scene to create the particle system in
  137762. * @param rootUrl The root url to use to load external dependencies like texture
  137763. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137764. * @returns the parsed GPU particle system
  137765. */
  137766. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137767. }
  137768. }
  137769. declare module BABYLON {
  137770. /**
  137771. * Represents a set of particle systems working together to create a specific effect
  137772. */
  137773. export class ParticleSystemSet implements IDisposable {
  137774. /**
  137775. * Gets or sets base Assets URL
  137776. */
  137777. static BaseAssetsUrl: string;
  137778. private _emitterCreationOptions;
  137779. private _emitterNode;
  137780. /**
  137781. * Gets the particle system list
  137782. */
  137783. systems: IParticleSystem[];
  137784. /**
  137785. * Gets the emitter node used with this set
  137786. */
  137787. get emitterNode(): Nullable<TransformNode>;
  137788. /**
  137789. * Creates a new emitter mesh as a sphere
  137790. * @param options defines the options used to create the sphere
  137791. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137792. * @param scene defines the hosting scene
  137793. */
  137794. setEmitterAsSphere(options: {
  137795. diameter: number;
  137796. segments: number;
  137797. color: Color3;
  137798. }, renderingGroupId: number, scene: Scene): void;
  137799. /**
  137800. * Starts all particle systems of the set
  137801. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137802. */
  137803. start(emitter?: AbstractMesh): void;
  137804. /**
  137805. * Release all associated resources
  137806. */
  137807. dispose(): void;
  137808. /**
  137809. * Serialize the set into a JSON compatible object
  137810. * @returns a JSON compatible representation of the set
  137811. */
  137812. serialize(): any;
  137813. /**
  137814. * Parse a new ParticleSystemSet from a serialized source
  137815. * @param data defines a JSON compatible representation of the set
  137816. * @param scene defines the hosting scene
  137817. * @param gpu defines if we want GPU particles or CPU particles
  137818. * @returns a new ParticleSystemSet
  137819. */
  137820. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137821. }
  137822. }
  137823. declare module BABYLON {
  137824. /**
  137825. * This class is made for on one-liner static method to help creating particle system set.
  137826. */
  137827. export class ParticleHelper {
  137828. /**
  137829. * Gets or sets base Assets URL
  137830. */
  137831. static BaseAssetsUrl: string;
  137832. /** Define the Url to load snippets */
  137833. static SnippetUrl: string;
  137834. /**
  137835. * Create a default particle system that you can tweak
  137836. * @param emitter defines the emitter to use
  137837. * @param capacity defines the system capacity (default is 500 particles)
  137838. * @param scene defines the hosting scene
  137839. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137840. * @returns the new Particle system
  137841. */
  137842. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137843. /**
  137844. * This is the main static method (one-liner) of this helper to create different particle systems
  137845. * @param type This string represents the type to the particle system to create
  137846. * @param scene The scene where the particle system should live
  137847. * @param gpu If the system will use gpu
  137848. * @returns the ParticleSystemSet created
  137849. */
  137850. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137851. /**
  137852. * Static function used to export a particle system to a ParticleSystemSet variable.
  137853. * Please note that the emitter shape is not exported
  137854. * @param systems defines the particle systems to export
  137855. * @returns the created particle system set
  137856. */
  137857. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137858. /**
  137859. * Creates a node material from a snippet saved by the node material editor
  137860. * @param snippetId defines the snippet to load
  137861. * @param scene defines the hosting scene
  137862. * @param gpu If the system will use gpu
  137863. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137864. * @returns a promise that will resolve to the new node material
  137865. */
  137866. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137867. }
  137868. }
  137869. declare module BABYLON {
  137870. interface Engine {
  137871. /**
  137872. * Create an effect to use with particle systems.
  137873. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137874. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137875. * @param uniformsNames defines a list of attribute names
  137876. * @param samplers defines an array of string used to represent textures
  137877. * @param defines defines the string containing the defines to use to compile the shaders
  137878. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137879. * @param onCompiled defines a function to call when the effect creation is successful
  137880. * @param onError defines a function to call when the effect creation has failed
  137881. * @returns the new Effect
  137882. */
  137883. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137884. }
  137885. interface Mesh {
  137886. /**
  137887. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137888. * @returns an array of IParticleSystem
  137889. */
  137890. getEmittedParticleSystems(): IParticleSystem[];
  137891. /**
  137892. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137893. * @returns an array of IParticleSystem
  137894. */
  137895. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137896. }
  137897. /**
  137898. * @hidden
  137899. */
  137900. export var _IDoNeedToBeInTheBuild: number;
  137901. }
  137902. declare module BABYLON {
  137903. /** Defines the 4 color options */
  137904. export enum PointColor {
  137905. /** color value */
  137906. Color = 2,
  137907. /** uv value */
  137908. UV = 1,
  137909. /** random value */
  137910. Random = 0,
  137911. /** stated value */
  137912. Stated = 3
  137913. }
  137914. /**
  137915. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137916. * 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.
  137917. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137918. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137919. *
  137920. * Full documentation here : TO BE ENTERED
  137921. */
  137922. export class PointsCloudSystem implements IDisposable {
  137923. /**
  137924. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137925. * Example : var p = SPS.particles[i];
  137926. */
  137927. particles: CloudPoint[];
  137928. /**
  137929. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137930. */
  137931. nbParticles: number;
  137932. /**
  137933. * This a counter for your own usage. It's not set by any SPS functions.
  137934. */
  137935. counter: number;
  137936. /**
  137937. * The PCS name. This name is also given to the underlying mesh.
  137938. */
  137939. name: string;
  137940. /**
  137941. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137942. */
  137943. mesh: Mesh;
  137944. /**
  137945. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137946. * Please read :
  137947. */
  137948. vars: any;
  137949. /**
  137950. * @hidden
  137951. */
  137952. _size: number;
  137953. private _scene;
  137954. private _promises;
  137955. private _positions;
  137956. private _indices;
  137957. private _normals;
  137958. private _colors;
  137959. private _uvs;
  137960. private _indices32;
  137961. private _positions32;
  137962. private _colors32;
  137963. private _uvs32;
  137964. private _updatable;
  137965. private _isVisibilityBoxLocked;
  137966. private _alwaysVisible;
  137967. private _groups;
  137968. private _groupCounter;
  137969. private _computeParticleColor;
  137970. private _computeParticleTexture;
  137971. private _computeParticleRotation;
  137972. private _computeBoundingBox;
  137973. private _isReady;
  137974. /**
  137975. * Creates a PCS (Points Cloud System) object
  137976. * @param name (String) is the PCS name, this will be the underlying mesh name
  137977. * @param pointSize (number) is the size for each point
  137978. * @param scene (Scene) is the scene in which the PCS is added
  137979. * @param options defines the options of the PCS e.g.
  137980. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  137981. */
  137982. constructor(name: string, pointSize: number, scene: Scene, options?: {
  137983. updatable?: boolean;
  137984. });
  137985. /**
  137986. * Builds the PCS underlying mesh. Returns a standard Mesh.
  137987. * If no points were added to the PCS, the returned mesh is just a single point.
  137988. * @returns a promise for the created mesh
  137989. */
  137990. buildMeshAsync(): Promise<Mesh>;
  137991. /**
  137992. * @hidden
  137993. */
  137994. private _buildMesh;
  137995. private _addParticle;
  137996. private _randomUnitVector;
  137997. private _getColorIndicesForCoord;
  137998. private _setPointsColorOrUV;
  137999. private _colorFromTexture;
  138000. private _calculateDensity;
  138001. /**
  138002. * Adds points to the PCS in random positions within a unit sphere
  138003. * @param nb (positive integer) the number of particles to be created from this model
  138004. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138005. * @returns the number of groups in the system
  138006. */
  138007. addPoints(nb: number, pointFunction?: any): number;
  138008. /**
  138009. * Adds points to the PCS from the surface of the model shape
  138010. * @param mesh is any Mesh object that will be used as a surface model for the points
  138011. * @param nb (positive integer) the number of particles to be created from this model
  138012. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138013. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138014. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138015. * @returns the number of groups in the system
  138016. */
  138017. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138018. /**
  138019. * Adds points to the PCS inside the model shape
  138020. * @param mesh is any Mesh object that will be used as a surface model for the points
  138021. * @param nb (positive integer) the number of particles to be created from this model
  138022. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138023. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138024. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138025. * @returns the number of groups in the system
  138026. */
  138027. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138028. /**
  138029. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138030. * This method calls `updateParticle()` for each particle of the SPS.
  138031. * For an animated SPS, it is usually called within the render loop.
  138032. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138033. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138034. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138035. * @returns the PCS.
  138036. */
  138037. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138038. /**
  138039. * Disposes the PCS.
  138040. */
  138041. dispose(): void;
  138042. /**
  138043. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138044. * doc :
  138045. * @returns the PCS.
  138046. */
  138047. refreshVisibleSize(): PointsCloudSystem;
  138048. /**
  138049. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138050. * @param size the size (float) of the visibility box
  138051. * note : this doesn't lock the PCS mesh bounding box.
  138052. * doc :
  138053. */
  138054. setVisibilityBox(size: number): void;
  138055. /**
  138056. * Gets whether the PCS is always visible or not
  138057. * doc :
  138058. */
  138059. get isAlwaysVisible(): boolean;
  138060. /**
  138061. * Sets the PCS as always visible or not
  138062. * doc :
  138063. */
  138064. set isAlwaysVisible(val: boolean);
  138065. /**
  138066. * Tells to `setParticles()` to compute the particle rotations or not
  138067. * Default value : false. The PCS is faster when it's set to false
  138068. * Note : particle rotations are only applied to parent particles
  138069. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138070. */
  138071. set computeParticleRotation(val: boolean);
  138072. /**
  138073. * Tells to `setParticles()` to compute the particle colors or not.
  138074. * Default value : true. The PCS is faster when it's set to false.
  138075. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138076. */
  138077. set computeParticleColor(val: boolean);
  138078. set computeParticleTexture(val: boolean);
  138079. /**
  138080. * Gets if `setParticles()` computes the particle colors or not.
  138081. * Default value : false. The PCS is faster when it's set to false.
  138082. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138083. */
  138084. get computeParticleColor(): boolean;
  138085. /**
  138086. * Gets if `setParticles()` computes the particle textures or not.
  138087. * Default value : false. The PCS is faster when it's set to false.
  138088. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138089. */
  138090. get computeParticleTexture(): boolean;
  138091. /**
  138092. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138093. */
  138094. set computeBoundingBox(val: boolean);
  138095. /**
  138096. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138097. */
  138098. get computeBoundingBox(): boolean;
  138099. /**
  138100. * This function does nothing. It may be overwritten to set all the particle first values.
  138101. * The PCS doesn't call this function, you may have to call it by your own.
  138102. * doc :
  138103. */
  138104. initParticles(): void;
  138105. /**
  138106. * This function does nothing. It may be overwritten to recycle a particle
  138107. * The PCS doesn't call this function, you can to call it
  138108. * doc :
  138109. * @param particle The particle to recycle
  138110. * @returns the recycled particle
  138111. */
  138112. recycleParticle(particle: CloudPoint): CloudPoint;
  138113. /**
  138114. * Updates a particle : this function should be overwritten by the user.
  138115. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138116. * doc :
  138117. * @example : just set a particle position or velocity and recycle conditions
  138118. * @param particle The particle to update
  138119. * @returns the updated particle
  138120. */
  138121. updateParticle(particle: CloudPoint): CloudPoint;
  138122. /**
  138123. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138124. * This does nothing and may be overwritten by the user.
  138125. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138126. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138127. * @param update the boolean update value actually passed to setParticles()
  138128. */
  138129. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138130. /**
  138131. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138132. * This will be passed three parameters.
  138133. * This does nothing and may be overwritten by the user.
  138134. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138135. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138136. * @param update the boolean update value actually passed to setParticles()
  138137. */
  138138. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138139. }
  138140. }
  138141. declare module BABYLON {
  138142. /**
  138143. * Represents one particle of a points cloud system.
  138144. */
  138145. export class CloudPoint {
  138146. /**
  138147. * particle global index
  138148. */
  138149. idx: number;
  138150. /**
  138151. * The color of the particle
  138152. */
  138153. color: Nullable<Color4>;
  138154. /**
  138155. * The world space position of the particle.
  138156. */
  138157. position: Vector3;
  138158. /**
  138159. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138160. */
  138161. rotation: Vector3;
  138162. /**
  138163. * The world space rotation quaternion of the particle.
  138164. */
  138165. rotationQuaternion: Nullable<Quaternion>;
  138166. /**
  138167. * The uv of the particle.
  138168. */
  138169. uv: Nullable<Vector2>;
  138170. /**
  138171. * The current speed of the particle.
  138172. */
  138173. velocity: Vector3;
  138174. /**
  138175. * The pivot point in the particle local space.
  138176. */
  138177. pivot: Vector3;
  138178. /**
  138179. * Must the particle be translated from its pivot point in its local space ?
  138180. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138181. * Default : false
  138182. */
  138183. translateFromPivot: boolean;
  138184. /**
  138185. * Index of this particle in the global "positions" array (Internal use)
  138186. * @hidden
  138187. */
  138188. _pos: number;
  138189. /**
  138190. * @hidden Index of this particle in the global "indices" array (Internal use)
  138191. */
  138192. _ind: number;
  138193. /**
  138194. * Group this particle belongs to
  138195. */
  138196. _group: PointsGroup;
  138197. /**
  138198. * Group id of this particle
  138199. */
  138200. groupId: number;
  138201. /**
  138202. * Index of the particle in its group id (Internal use)
  138203. */
  138204. idxInGroup: number;
  138205. /**
  138206. * @hidden Particle BoundingInfo object (Internal use)
  138207. */
  138208. _boundingInfo: BoundingInfo;
  138209. /**
  138210. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138211. */
  138212. _pcs: PointsCloudSystem;
  138213. /**
  138214. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138215. */
  138216. _stillInvisible: boolean;
  138217. /**
  138218. * @hidden Last computed particle rotation matrix
  138219. */
  138220. _rotationMatrix: number[];
  138221. /**
  138222. * Parent particle Id, if any.
  138223. * Default null.
  138224. */
  138225. parentId: Nullable<number>;
  138226. /**
  138227. * @hidden Internal global position in the PCS.
  138228. */
  138229. _globalPosition: Vector3;
  138230. /**
  138231. * Creates a Point Cloud object.
  138232. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138233. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138234. * @param group (PointsGroup) is the group the particle belongs to
  138235. * @param groupId (integer) is the group identifier in the PCS.
  138236. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138237. * @param pcs defines the PCS it is associated to
  138238. */
  138239. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138240. /**
  138241. * get point size
  138242. */
  138243. get size(): Vector3;
  138244. /**
  138245. * Set point size
  138246. */
  138247. set size(scale: Vector3);
  138248. /**
  138249. * Legacy support, changed quaternion to rotationQuaternion
  138250. */
  138251. get quaternion(): Nullable<Quaternion>;
  138252. /**
  138253. * Legacy support, changed quaternion to rotationQuaternion
  138254. */
  138255. set quaternion(q: Nullable<Quaternion>);
  138256. /**
  138257. * Returns a boolean. True if the particle intersects a mesh, else false
  138258. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138259. * @param target is the object (point or mesh) what the intersection is computed against
  138260. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138261. * @returns true if it intersects
  138262. */
  138263. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138264. /**
  138265. * get the rotation matrix of the particle
  138266. * @hidden
  138267. */
  138268. getRotationMatrix(m: Matrix): void;
  138269. }
  138270. /**
  138271. * Represents a group of points in a points cloud system
  138272. * * PCS internal tool, don't use it manually.
  138273. */
  138274. export class PointsGroup {
  138275. /**
  138276. * The group id
  138277. * @hidden
  138278. */
  138279. groupID: number;
  138280. /**
  138281. * image data for group (internal use)
  138282. * @hidden
  138283. */
  138284. _groupImageData: Nullable<ArrayBufferView>;
  138285. /**
  138286. * Image Width (internal use)
  138287. * @hidden
  138288. */
  138289. _groupImgWidth: number;
  138290. /**
  138291. * Image Height (internal use)
  138292. * @hidden
  138293. */
  138294. _groupImgHeight: number;
  138295. /**
  138296. * Custom position function (internal use)
  138297. * @hidden
  138298. */
  138299. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138300. /**
  138301. * density per facet for surface points
  138302. * @hidden
  138303. */
  138304. _groupDensity: number[];
  138305. /**
  138306. * Only when points are colored by texture carries pointer to texture list array
  138307. * @hidden
  138308. */
  138309. _textureNb: number;
  138310. /**
  138311. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138312. * PCS internal tool, don't use it manually.
  138313. * @hidden
  138314. */
  138315. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138316. }
  138317. }
  138318. declare module BABYLON {
  138319. /**
  138320. * Represents a set of particle systems working together to create a specific effect
  138321. */
  138322. export class ParticleSystemDebugger implements IDisposable {
  138323. /**
  138324. * Defines the particle system to debug
  138325. */
  138326. system: IParticleSystem;
  138327. /**
  138328. * Creates a new particle system debugger
  138329. * @param system defines the particle system to debug
  138330. */
  138331. constructor(
  138332. /**
  138333. * Defines the particle system to debug
  138334. */
  138335. system: IParticleSystem);
  138336. /** Clear all the resources */
  138337. dispose(): void;
  138338. }
  138339. }
  138340. declare module BABYLON {
  138341. interface Scene {
  138342. /** @hidden (Backing field) */
  138343. _physicsEngine: Nullable<IPhysicsEngine>;
  138344. /** @hidden */
  138345. _physicsTimeAccumulator: number;
  138346. /**
  138347. * Gets the current physics engine
  138348. * @returns a IPhysicsEngine or null if none attached
  138349. */
  138350. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138351. /**
  138352. * Enables physics to the current scene
  138353. * @param gravity defines the scene's gravity for the physics engine
  138354. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138355. * @return a boolean indicating if the physics engine was initialized
  138356. */
  138357. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138358. /**
  138359. * Disables and disposes the physics engine associated with the scene
  138360. */
  138361. disablePhysicsEngine(): void;
  138362. /**
  138363. * Gets a boolean indicating if there is an active physics engine
  138364. * @returns a boolean indicating if there is an active physics engine
  138365. */
  138366. isPhysicsEnabled(): boolean;
  138367. /**
  138368. * Deletes a physics compound impostor
  138369. * @param compound defines the compound to delete
  138370. */
  138371. deleteCompoundImpostor(compound: any): void;
  138372. /**
  138373. * An event triggered when physic simulation is about to be run
  138374. */
  138375. onBeforePhysicsObservable: Observable<Scene>;
  138376. /**
  138377. * An event triggered when physic simulation has been done
  138378. */
  138379. onAfterPhysicsObservable: Observable<Scene>;
  138380. }
  138381. interface AbstractMesh {
  138382. /** @hidden */
  138383. _physicsImpostor: Nullable<PhysicsImpostor>;
  138384. /**
  138385. * Gets or sets impostor used for physic simulation
  138386. * @see http://doc.babylonjs.com/features/physics_engine
  138387. */
  138388. physicsImpostor: Nullable<PhysicsImpostor>;
  138389. /**
  138390. * Gets the current physics impostor
  138391. * @see http://doc.babylonjs.com/features/physics_engine
  138392. * @returns a physics impostor or null
  138393. */
  138394. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138395. /** Apply a physic impulse to the mesh
  138396. * @param force defines the force to apply
  138397. * @param contactPoint defines where to apply the force
  138398. * @returns the current mesh
  138399. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138400. */
  138401. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138402. /**
  138403. * Creates a physic joint between two meshes
  138404. * @param otherMesh defines the other mesh to use
  138405. * @param pivot1 defines the pivot to use on this mesh
  138406. * @param pivot2 defines the pivot to use on the other mesh
  138407. * @param options defines additional options (can be plugin dependent)
  138408. * @returns the current mesh
  138409. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138410. */
  138411. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138412. /** @hidden */
  138413. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138414. }
  138415. /**
  138416. * Defines the physics engine scene component responsible to manage a physics engine
  138417. */
  138418. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138419. /**
  138420. * The component name helpful to identify the component in the list of scene components.
  138421. */
  138422. readonly name: string;
  138423. /**
  138424. * The scene the component belongs to.
  138425. */
  138426. scene: Scene;
  138427. /**
  138428. * Creates a new instance of the component for the given scene
  138429. * @param scene Defines the scene to register the component in
  138430. */
  138431. constructor(scene: Scene);
  138432. /**
  138433. * Registers the component in a given scene
  138434. */
  138435. register(): void;
  138436. /**
  138437. * Rebuilds the elements related to this component in case of
  138438. * context lost for instance.
  138439. */
  138440. rebuild(): void;
  138441. /**
  138442. * Disposes the component and the associated ressources
  138443. */
  138444. dispose(): void;
  138445. }
  138446. }
  138447. declare module BABYLON {
  138448. /**
  138449. * A helper for physics simulations
  138450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138451. */
  138452. export class PhysicsHelper {
  138453. private _scene;
  138454. private _physicsEngine;
  138455. /**
  138456. * Initializes the Physics helper
  138457. * @param scene Babylon.js scene
  138458. */
  138459. constructor(scene: Scene);
  138460. /**
  138461. * Applies a radial explosion impulse
  138462. * @param origin the origin of the explosion
  138463. * @param radiusOrEventOptions the radius or the options of radial explosion
  138464. * @param strength the explosion strength
  138465. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138466. * @returns A physics radial explosion event, or null
  138467. */
  138468. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138469. /**
  138470. * Applies a radial explosion force
  138471. * @param origin the origin of the explosion
  138472. * @param radiusOrEventOptions the radius or the options of radial explosion
  138473. * @param strength the explosion strength
  138474. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138475. * @returns A physics radial explosion event, or null
  138476. */
  138477. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138478. /**
  138479. * Creates a gravitational field
  138480. * @param origin the origin of the explosion
  138481. * @param radiusOrEventOptions the radius or the options of radial explosion
  138482. * @param strength the explosion strength
  138483. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138484. * @returns A physics gravitational field event, or null
  138485. */
  138486. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138487. /**
  138488. * Creates a physics updraft event
  138489. * @param origin the origin of the updraft
  138490. * @param radiusOrEventOptions the radius or the options of the updraft
  138491. * @param strength the strength of the updraft
  138492. * @param height the height of the updraft
  138493. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138494. * @returns A physics updraft event, or null
  138495. */
  138496. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138497. /**
  138498. * Creates a physics vortex event
  138499. * @param origin the of the vortex
  138500. * @param radiusOrEventOptions the radius or the options of the vortex
  138501. * @param strength the strength of the vortex
  138502. * @param height the height of the vortex
  138503. * @returns a Physics vortex event, or null
  138504. * A physics vortex event or null
  138505. */
  138506. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138507. }
  138508. /**
  138509. * Represents a physics radial explosion event
  138510. */
  138511. class PhysicsRadialExplosionEvent {
  138512. private _scene;
  138513. private _options;
  138514. private _sphere;
  138515. private _dataFetched;
  138516. /**
  138517. * Initializes a radial explosioin event
  138518. * @param _scene BabylonJS scene
  138519. * @param _options The options for the vortex event
  138520. */
  138521. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138522. /**
  138523. * Returns the data related to the radial explosion event (sphere).
  138524. * @returns The radial explosion event data
  138525. */
  138526. getData(): PhysicsRadialExplosionEventData;
  138527. /**
  138528. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138529. * @param impostor A physics imposter
  138530. * @param origin the origin of the explosion
  138531. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138532. */
  138533. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138534. /**
  138535. * Triggers affecterd impostors callbacks
  138536. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138537. */
  138538. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138539. /**
  138540. * Disposes the sphere.
  138541. * @param force Specifies if the sphere should be disposed by force
  138542. */
  138543. dispose(force?: boolean): void;
  138544. /*** Helpers ***/
  138545. private _prepareSphere;
  138546. private _intersectsWithSphere;
  138547. }
  138548. /**
  138549. * Represents a gravitational field event
  138550. */
  138551. class PhysicsGravitationalFieldEvent {
  138552. private _physicsHelper;
  138553. private _scene;
  138554. private _origin;
  138555. private _options;
  138556. private _tickCallback;
  138557. private _sphere;
  138558. private _dataFetched;
  138559. /**
  138560. * Initializes the physics gravitational field event
  138561. * @param _physicsHelper A physics helper
  138562. * @param _scene BabylonJS scene
  138563. * @param _origin The origin position of the gravitational field event
  138564. * @param _options The options for the vortex event
  138565. */
  138566. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138567. /**
  138568. * Returns the data related to the gravitational field event (sphere).
  138569. * @returns A gravitational field event
  138570. */
  138571. getData(): PhysicsGravitationalFieldEventData;
  138572. /**
  138573. * Enables the gravitational field.
  138574. */
  138575. enable(): void;
  138576. /**
  138577. * Disables the gravitational field.
  138578. */
  138579. disable(): void;
  138580. /**
  138581. * Disposes the sphere.
  138582. * @param force The force to dispose from the gravitational field event
  138583. */
  138584. dispose(force?: boolean): void;
  138585. private _tick;
  138586. }
  138587. /**
  138588. * Represents a physics updraft event
  138589. */
  138590. class PhysicsUpdraftEvent {
  138591. private _scene;
  138592. private _origin;
  138593. private _options;
  138594. private _physicsEngine;
  138595. private _originTop;
  138596. private _originDirection;
  138597. private _tickCallback;
  138598. private _cylinder;
  138599. private _cylinderPosition;
  138600. private _dataFetched;
  138601. /**
  138602. * Initializes the physics updraft event
  138603. * @param _scene BabylonJS scene
  138604. * @param _origin The origin position of the updraft
  138605. * @param _options The options for the updraft event
  138606. */
  138607. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138608. /**
  138609. * Returns the data related to the updraft event (cylinder).
  138610. * @returns A physics updraft event
  138611. */
  138612. getData(): PhysicsUpdraftEventData;
  138613. /**
  138614. * Enables the updraft.
  138615. */
  138616. enable(): void;
  138617. /**
  138618. * Disables the updraft.
  138619. */
  138620. disable(): void;
  138621. /**
  138622. * Disposes the cylinder.
  138623. * @param force Specifies if the updraft should be disposed by force
  138624. */
  138625. dispose(force?: boolean): void;
  138626. private getImpostorHitData;
  138627. private _tick;
  138628. /*** Helpers ***/
  138629. private _prepareCylinder;
  138630. private _intersectsWithCylinder;
  138631. }
  138632. /**
  138633. * Represents a physics vortex event
  138634. */
  138635. class PhysicsVortexEvent {
  138636. private _scene;
  138637. private _origin;
  138638. private _options;
  138639. private _physicsEngine;
  138640. private _originTop;
  138641. private _tickCallback;
  138642. private _cylinder;
  138643. private _cylinderPosition;
  138644. private _dataFetched;
  138645. /**
  138646. * Initializes the physics vortex event
  138647. * @param _scene The BabylonJS scene
  138648. * @param _origin The origin position of the vortex
  138649. * @param _options The options for the vortex event
  138650. */
  138651. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138652. /**
  138653. * Returns the data related to the vortex event (cylinder).
  138654. * @returns The physics vortex event data
  138655. */
  138656. getData(): PhysicsVortexEventData;
  138657. /**
  138658. * Enables the vortex.
  138659. */
  138660. enable(): void;
  138661. /**
  138662. * Disables the cortex.
  138663. */
  138664. disable(): void;
  138665. /**
  138666. * Disposes the sphere.
  138667. * @param force
  138668. */
  138669. dispose(force?: boolean): void;
  138670. private getImpostorHitData;
  138671. private _tick;
  138672. /*** Helpers ***/
  138673. private _prepareCylinder;
  138674. private _intersectsWithCylinder;
  138675. }
  138676. /**
  138677. * Options fot the radial explosion event
  138678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138679. */
  138680. export class PhysicsRadialExplosionEventOptions {
  138681. /**
  138682. * The radius of the sphere for the radial explosion.
  138683. */
  138684. radius: number;
  138685. /**
  138686. * The strenth of the explosion.
  138687. */
  138688. strength: number;
  138689. /**
  138690. * The strenght of the force in correspondence to the distance of the affected object
  138691. */
  138692. falloff: PhysicsRadialImpulseFalloff;
  138693. /**
  138694. * Sphere options for the radial explosion.
  138695. */
  138696. sphere: {
  138697. segments: number;
  138698. diameter: number;
  138699. };
  138700. /**
  138701. * Sphere options for the radial explosion.
  138702. */
  138703. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138704. }
  138705. /**
  138706. * Options fot the updraft event
  138707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138708. */
  138709. export class PhysicsUpdraftEventOptions {
  138710. /**
  138711. * The radius of the cylinder for the vortex
  138712. */
  138713. radius: number;
  138714. /**
  138715. * The strenth of the updraft.
  138716. */
  138717. strength: number;
  138718. /**
  138719. * The height of the cylinder for the updraft.
  138720. */
  138721. height: number;
  138722. /**
  138723. * The mode for the the updraft.
  138724. */
  138725. updraftMode: PhysicsUpdraftMode;
  138726. }
  138727. /**
  138728. * Options fot the vortex event
  138729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138730. */
  138731. export class PhysicsVortexEventOptions {
  138732. /**
  138733. * The radius of the cylinder for the vortex
  138734. */
  138735. radius: number;
  138736. /**
  138737. * The strenth of the vortex.
  138738. */
  138739. strength: number;
  138740. /**
  138741. * The height of the cylinder for the vortex.
  138742. */
  138743. height: number;
  138744. /**
  138745. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138746. */
  138747. centripetalForceThreshold: number;
  138748. /**
  138749. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138750. */
  138751. centripetalForceMultiplier: number;
  138752. /**
  138753. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138754. */
  138755. centrifugalForceMultiplier: number;
  138756. /**
  138757. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138758. */
  138759. updraftForceMultiplier: number;
  138760. }
  138761. /**
  138762. * The strenght of the force in correspondence to the distance of the affected object
  138763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138764. */
  138765. export enum PhysicsRadialImpulseFalloff {
  138766. /** Defines that impulse is constant in strength across it's whole radius */
  138767. Constant = 0,
  138768. /** Defines that impulse gets weaker if it's further from the origin */
  138769. Linear = 1
  138770. }
  138771. /**
  138772. * The strength of the force in correspondence to the distance of the affected object
  138773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138774. */
  138775. export enum PhysicsUpdraftMode {
  138776. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138777. Center = 0,
  138778. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138779. Perpendicular = 1
  138780. }
  138781. /**
  138782. * Interface for a physics hit data
  138783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138784. */
  138785. export interface PhysicsHitData {
  138786. /**
  138787. * The force applied at the contact point
  138788. */
  138789. force: Vector3;
  138790. /**
  138791. * The contact point
  138792. */
  138793. contactPoint: Vector3;
  138794. /**
  138795. * The distance from the origin to the contact point
  138796. */
  138797. distanceFromOrigin: number;
  138798. }
  138799. /**
  138800. * Interface for radial explosion event data
  138801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138802. */
  138803. export interface PhysicsRadialExplosionEventData {
  138804. /**
  138805. * A sphere used for the radial explosion event
  138806. */
  138807. sphere: Mesh;
  138808. }
  138809. /**
  138810. * Interface for gravitational field event data
  138811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138812. */
  138813. export interface PhysicsGravitationalFieldEventData {
  138814. /**
  138815. * A sphere mesh used for the gravitational field event
  138816. */
  138817. sphere: Mesh;
  138818. }
  138819. /**
  138820. * Interface for updraft event data
  138821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138822. */
  138823. export interface PhysicsUpdraftEventData {
  138824. /**
  138825. * A cylinder used for the updraft event
  138826. */
  138827. cylinder: Mesh;
  138828. }
  138829. /**
  138830. * Interface for vortex event data
  138831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138832. */
  138833. export interface PhysicsVortexEventData {
  138834. /**
  138835. * A cylinder used for the vortex event
  138836. */
  138837. cylinder: Mesh;
  138838. }
  138839. /**
  138840. * Interface for an affected physics impostor
  138841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138842. */
  138843. export interface PhysicsAffectedImpostorWithData {
  138844. /**
  138845. * The impostor affected by the effect
  138846. */
  138847. impostor: PhysicsImpostor;
  138848. /**
  138849. * The data about the hit/horce from the explosion
  138850. */
  138851. hitData: PhysicsHitData;
  138852. }
  138853. }
  138854. declare module BABYLON {
  138855. /** @hidden */
  138856. export var blackAndWhitePixelShader: {
  138857. name: string;
  138858. shader: string;
  138859. };
  138860. }
  138861. declare module BABYLON {
  138862. /**
  138863. * Post process used to render in black and white
  138864. */
  138865. export class BlackAndWhitePostProcess extends PostProcess {
  138866. /**
  138867. * Linear about to convert he result to black and white (default: 1)
  138868. */
  138869. degree: number;
  138870. /**
  138871. * Creates a black and white post process
  138872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138873. * @param name The name of the effect.
  138874. * @param options The required width/height ratio to downsize to before computing the render pass.
  138875. * @param camera The camera to apply the render pass to.
  138876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138877. * @param engine The engine which the post process will be applied. (default: current engine)
  138878. * @param reusable If the post process can be reused on the same frame. (default: false)
  138879. */
  138880. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138881. }
  138882. }
  138883. declare module BABYLON {
  138884. /**
  138885. * This represents a set of one or more post processes in Babylon.
  138886. * A post process can be used to apply a shader to a texture after it is rendered.
  138887. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138888. */
  138889. export class PostProcessRenderEffect {
  138890. private _postProcesses;
  138891. private _getPostProcesses;
  138892. private _singleInstance;
  138893. private _cameras;
  138894. private _indicesForCamera;
  138895. /**
  138896. * Name of the effect
  138897. * @hidden
  138898. */
  138899. _name: string;
  138900. /**
  138901. * Instantiates a post process render effect.
  138902. * A post process can be used to apply a shader to a texture after it is rendered.
  138903. * @param engine The engine the effect is tied to
  138904. * @param name The name of the effect
  138905. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138906. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138907. */
  138908. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138909. /**
  138910. * Checks if all the post processes in the effect are supported.
  138911. */
  138912. get isSupported(): boolean;
  138913. /**
  138914. * Updates the current state of the effect
  138915. * @hidden
  138916. */
  138917. _update(): void;
  138918. /**
  138919. * Attaches the effect on cameras
  138920. * @param cameras The camera to attach to.
  138921. * @hidden
  138922. */
  138923. _attachCameras(cameras: Camera): void;
  138924. /**
  138925. * Attaches the effect on cameras
  138926. * @param cameras The camera to attach to.
  138927. * @hidden
  138928. */
  138929. _attachCameras(cameras: Camera[]): void;
  138930. /**
  138931. * Detaches the effect on cameras
  138932. * @param cameras The camera to detatch from.
  138933. * @hidden
  138934. */
  138935. _detachCameras(cameras: Camera): void;
  138936. /**
  138937. * Detatches the effect on cameras
  138938. * @param cameras The camera to detatch from.
  138939. * @hidden
  138940. */
  138941. _detachCameras(cameras: Camera[]): void;
  138942. /**
  138943. * Enables the effect on given cameras
  138944. * @param cameras The camera to enable.
  138945. * @hidden
  138946. */
  138947. _enable(cameras: Camera): void;
  138948. /**
  138949. * Enables the effect on given cameras
  138950. * @param cameras The camera to enable.
  138951. * @hidden
  138952. */
  138953. _enable(cameras: Nullable<Camera[]>): void;
  138954. /**
  138955. * Disables the effect on the given cameras
  138956. * @param cameras The camera to disable.
  138957. * @hidden
  138958. */
  138959. _disable(cameras: Camera): void;
  138960. /**
  138961. * Disables the effect on the given cameras
  138962. * @param cameras The camera to disable.
  138963. * @hidden
  138964. */
  138965. _disable(cameras: Nullable<Camera[]>): void;
  138966. /**
  138967. * Gets a list of the post processes contained in the effect.
  138968. * @param camera The camera to get the post processes on.
  138969. * @returns The list of the post processes in the effect.
  138970. */
  138971. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  138972. }
  138973. }
  138974. declare module BABYLON {
  138975. /** @hidden */
  138976. export var extractHighlightsPixelShader: {
  138977. name: string;
  138978. shader: string;
  138979. };
  138980. }
  138981. declare module BABYLON {
  138982. /**
  138983. * 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.
  138984. */
  138985. export class ExtractHighlightsPostProcess extends PostProcess {
  138986. /**
  138987. * The luminance threshold, pixels below this value will be set to black.
  138988. */
  138989. threshold: number;
  138990. /** @hidden */
  138991. _exposure: number;
  138992. /**
  138993. * Post process which has the input texture to be used when performing highlight extraction
  138994. * @hidden
  138995. */
  138996. _inputPostProcess: Nullable<PostProcess>;
  138997. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138998. }
  138999. }
  139000. declare module BABYLON {
  139001. /** @hidden */
  139002. export var bloomMergePixelShader: {
  139003. name: string;
  139004. shader: string;
  139005. };
  139006. }
  139007. declare module BABYLON {
  139008. /**
  139009. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139010. */
  139011. export class BloomMergePostProcess extends PostProcess {
  139012. /** Weight of the bloom to be added to the original input. */
  139013. weight: number;
  139014. /**
  139015. * Creates a new instance of @see BloomMergePostProcess
  139016. * @param name The name of the effect.
  139017. * @param originalFromInput Post process which's input will be used for the merge.
  139018. * @param blurred Blurred highlights post process which's output will be used.
  139019. * @param weight Weight of the bloom to be added to the original input.
  139020. * @param options The required width/height ratio to downsize to before computing the render pass.
  139021. * @param camera The camera to apply the render pass to.
  139022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139023. * @param engine The engine which the post process will be applied. (default: current engine)
  139024. * @param reusable If the post process can be reused on the same frame. (default: false)
  139025. * @param textureType Type of textures used when performing the post process. (default: 0)
  139026. * @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)
  139027. */
  139028. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139029. /** Weight of the bloom to be added to the original input. */
  139030. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139031. }
  139032. }
  139033. declare module BABYLON {
  139034. /**
  139035. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139036. */
  139037. export class BloomEffect extends PostProcessRenderEffect {
  139038. private bloomScale;
  139039. /**
  139040. * @hidden Internal
  139041. */
  139042. _effects: Array<PostProcess>;
  139043. /**
  139044. * @hidden Internal
  139045. */
  139046. _downscale: ExtractHighlightsPostProcess;
  139047. private _blurX;
  139048. private _blurY;
  139049. private _merge;
  139050. /**
  139051. * The luminance threshold to find bright areas of the image to bloom.
  139052. */
  139053. get threshold(): number;
  139054. set threshold(value: number);
  139055. /**
  139056. * The strength of the bloom.
  139057. */
  139058. get weight(): number;
  139059. set weight(value: number);
  139060. /**
  139061. * Specifies the size of the bloom blur kernel, relative to the final output size
  139062. */
  139063. get kernel(): number;
  139064. set kernel(value: number);
  139065. /**
  139066. * Creates a new instance of @see BloomEffect
  139067. * @param scene The scene the effect belongs to.
  139068. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139069. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139070. * @param bloomWeight The the strength of bloom.
  139071. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139072. * @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)
  139073. */
  139074. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139075. /**
  139076. * Disposes each of the internal effects for a given camera.
  139077. * @param camera The camera to dispose the effect on.
  139078. */
  139079. disposeEffects(camera: Camera): void;
  139080. /**
  139081. * @hidden Internal
  139082. */
  139083. _updateEffects(): void;
  139084. /**
  139085. * Internal
  139086. * @returns if all the contained post processes are ready.
  139087. * @hidden
  139088. */
  139089. _isReady(): boolean;
  139090. }
  139091. }
  139092. declare module BABYLON {
  139093. /** @hidden */
  139094. export var chromaticAberrationPixelShader: {
  139095. name: string;
  139096. shader: string;
  139097. };
  139098. }
  139099. declare module BABYLON {
  139100. /**
  139101. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139102. */
  139103. export class ChromaticAberrationPostProcess extends PostProcess {
  139104. /**
  139105. * The amount of seperation of rgb channels (default: 30)
  139106. */
  139107. aberrationAmount: number;
  139108. /**
  139109. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139110. */
  139111. radialIntensity: number;
  139112. /**
  139113. * 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))
  139114. */
  139115. direction: Vector2;
  139116. /**
  139117. * 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))
  139118. */
  139119. centerPosition: Vector2;
  139120. /**
  139121. * Creates a new instance ChromaticAberrationPostProcess
  139122. * @param name The name of the effect.
  139123. * @param screenWidth The width of the screen to apply the effect on.
  139124. * @param screenHeight The height of the screen to apply the effect on.
  139125. * @param options The required width/height ratio to downsize to before computing the render pass.
  139126. * @param camera The camera to apply the render pass to.
  139127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139128. * @param engine The engine which the post process will be applied. (default: current engine)
  139129. * @param reusable If the post process can be reused on the same frame. (default: false)
  139130. * @param textureType Type of textures used when performing the post process. (default: 0)
  139131. * @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)
  139132. */
  139133. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139134. }
  139135. }
  139136. declare module BABYLON {
  139137. /** @hidden */
  139138. export var circleOfConfusionPixelShader: {
  139139. name: string;
  139140. shader: string;
  139141. };
  139142. }
  139143. declare module BABYLON {
  139144. /**
  139145. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139146. */
  139147. export class CircleOfConfusionPostProcess extends PostProcess {
  139148. /**
  139149. * 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.
  139150. */
  139151. lensSize: number;
  139152. /**
  139153. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139154. */
  139155. fStop: number;
  139156. /**
  139157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139158. */
  139159. focusDistance: number;
  139160. /**
  139161. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139162. */
  139163. focalLength: number;
  139164. private _depthTexture;
  139165. /**
  139166. * Creates a new instance CircleOfConfusionPostProcess
  139167. * @param name The name of the effect.
  139168. * @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.
  139169. * @param options The required width/height ratio to downsize to before computing the render pass.
  139170. * @param camera The camera to apply the render pass to.
  139171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139172. * @param engine The engine which the post process will be applied. (default: current engine)
  139173. * @param reusable If the post process can be reused on the same frame. (default: false)
  139174. * @param textureType Type of textures used when performing the post process. (default: 0)
  139175. * @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)
  139176. */
  139177. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139178. /**
  139179. * 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.
  139180. */
  139181. set depthTexture(value: RenderTargetTexture);
  139182. }
  139183. }
  139184. declare module BABYLON {
  139185. /** @hidden */
  139186. export var colorCorrectionPixelShader: {
  139187. name: string;
  139188. shader: string;
  139189. };
  139190. }
  139191. declare module BABYLON {
  139192. /**
  139193. *
  139194. * This post-process allows the modification of rendered colors by using
  139195. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139196. *
  139197. * The object needs to be provided an url to a texture containing the color
  139198. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139199. * Use an image editing software to tweak the LUT to match your needs.
  139200. *
  139201. * For an example of a color LUT, see here:
  139202. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139203. * For explanations on color grading, see here:
  139204. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139205. *
  139206. */
  139207. export class ColorCorrectionPostProcess extends PostProcess {
  139208. private _colorTableTexture;
  139209. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139210. }
  139211. }
  139212. declare module BABYLON {
  139213. /** @hidden */
  139214. export var convolutionPixelShader: {
  139215. name: string;
  139216. shader: string;
  139217. };
  139218. }
  139219. declare module BABYLON {
  139220. /**
  139221. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139222. * input texture to perform effects such as edge detection or sharpening
  139223. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139224. */
  139225. export class ConvolutionPostProcess extends PostProcess {
  139226. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139227. kernel: number[];
  139228. /**
  139229. * Creates a new instance ConvolutionPostProcess
  139230. * @param name The name of the effect.
  139231. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139232. * @param options The required width/height ratio to downsize to before computing the render pass.
  139233. * @param camera The camera to apply the render pass to.
  139234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139235. * @param engine The engine which the post process will be applied. (default: current engine)
  139236. * @param reusable If the post process can be reused on the same frame. (default: false)
  139237. * @param textureType Type of textures used when performing the post process. (default: 0)
  139238. */
  139239. constructor(name: string,
  139240. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139241. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139242. /**
  139243. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139244. */
  139245. static EdgeDetect0Kernel: number[];
  139246. /**
  139247. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139248. */
  139249. static EdgeDetect1Kernel: number[];
  139250. /**
  139251. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139252. */
  139253. static EdgeDetect2Kernel: number[];
  139254. /**
  139255. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139256. */
  139257. static SharpenKernel: number[];
  139258. /**
  139259. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139260. */
  139261. static EmbossKernel: number[];
  139262. /**
  139263. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139264. */
  139265. static GaussianKernel: number[];
  139266. }
  139267. }
  139268. declare module BABYLON {
  139269. /**
  139270. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139271. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139272. * based on samples that have a large difference in distance than the center pixel.
  139273. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139274. */
  139275. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139276. direction: Vector2;
  139277. /**
  139278. * Creates a new instance CircleOfConfusionPostProcess
  139279. * @param name The name of the effect.
  139280. * @param scene The scene the effect belongs to.
  139281. * @param direction The direction the blur should be applied.
  139282. * @param kernel The size of the kernel used to blur.
  139283. * @param options The required width/height ratio to downsize to before computing the render pass.
  139284. * @param camera The camera to apply the render pass to.
  139285. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139286. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139288. * @param engine The engine which the post process will be applied. (default: current engine)
  139289. * @param reusable If the post process can be reused on the same frame. (default: false)
  139290. * @param textureType Type of textures used when performing the post process. (default: 0)
  139291. * @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)
  139292. */
  139293. 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);
  139294. }
  139295. }
  139296. declare module BABYLON {
  139297. /** @hidden */
  139298. export var depthOfFieldMergePixelShader: {
  139299. name: string;
  139300. shader: string;
  139301. };
  139302. }
  139303. declare module BABYLON {
  139304. /**
  139305. * Options to be set when merging outputs from the default pipeline.
  139306. */
  139307. export class DepthOfFieldMergePostProcessOptions {
  139308. /**
  139309. * The original image to merge on top of
  139310. */
  139311. originalFromInput: PostProcess;
  139312. /**
  139313. * Parameters to perform the merge of the depth of field effect
  139314. */
  139315. depthOfField?: {
  139316. circleOfConfusion: PostProcess;
  139317. blurSteps: Array<PostProcess>;
  139318. };
  139319. /**
  139320. * Parameters to perform the merge of bloom effect
  139321. */
  139322. bloom?: {
  139323. blurred: PostProcess;
  139324. weight: number;
  139325. };
  139326. }
  139327. /**
  139328. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139329. */
  139330. export class DepthOfFieldMergePostProcess extends PostProcess {
  139331. private blurSteps;
  139332. /**
  139333. * Creates a new instance of DepthOfFieldMergePostProcess
  139334. * @param name The name of the effect.
  139335. * @param originalFromInput Post process which's input will be used for the merge.
  139336. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139337. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139338. * @param options The required width/height ratio to downsize to before computing the render pass.
  139339. * @param camera The camera to apply the render pass to.
  139340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139341. * @param engine The engine which the post process will be applied. (default: current engine)
  139342. * @param reusable If the post process can be reused on the same frame. (default: false)
  139343. * @param textureType Type of textures used when performing the post process. (default: 0)
  139344. * @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)
  139345. */
  139346. 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);
  139347. /**
  139348. * Updates the effect with the current post process compile time values and recompiles the shader.
  139349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139352. * @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
  139353. * @param onCompiled Called when the shader has been compiled.
  139354. * @param onError Called if there is an error when compiling a shader.
  139355. */
  139356. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139357. }
  139358. }
  139359. declare module BABYLON {
  139360. /**
  139361. * Specifies the level of max blur that should be applied when using the depth of field effect
  139362. */
  139363. export enum DepthOfFieldEffectBlurLevel {
  139364. /**
  139365. * Subtle blur
  139366. */
  139367. Low = 0,
  139368. /**
  139369. * Medium blur
  139370. */
  139371. Medium = 1,
  139372. /**
  139373. * Large blur
  139374. */
  139375. High = 2
  139376. }
  139377. /**
  139378. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139379. */
  139380. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139381. private _circleOfConfusion;
  139382. /**
  139383. * @hidden Internal, blurs from high to low
  139384. */
  139385. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139386. private _depthOfFieldBlurY;
  139387. private _dofMerge;
  139388. /**
  139389. * @hidden Internal post processes in depth of field effect
  139390. */
  139391. _effects: Array<PostProcess>;
  139392. /**
  139393. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139394. */
  139395. set focalLength(value: number);
  139396. get focalLength(): number;
  139397. /**
  139398. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139399. */
  139400. set fStop(value: number);
  139401. get fStop(): number;
  139402. /**
  139403. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139404. */
  139405. set focusDistance(value: number);
  139406. get focusDistance(): number;
  139407. /**
  139408. * 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.
  139409. */
  139410. set lensSize(value: number);
  139411. get lensSize(): number;
  139412. /**
  139413. * Creates a new instance DepthOfFieldEffect
  139414. * @param scene The scene the effect belongs to.
  139415. * @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.
  139416. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139417. * @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)
  139418. */
  139419. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139420. /**
  139421. * Get the current class name of the current effet
  139422. * @returns "DepthOfFieldEffect"
  139423. */
  139424. getClassName(): string;
  139425. /**
  139426. * 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.
  139427. */
  139428. set depthTexture(value: RenderTargetTexture);
  139429. /**
  139430. * Disposes each of the internal effects for a given camera.
  139431. * @param camera The camera to dispose the effect on.
  139432. */
  139433. disposeEffects(camera: Camera): void;
  139434. /**
  139435. * @hidden Internal
  139436. */
  139437. _updateEffects(): void;
  139438. /**
  139439. * Internal
  139440. * @returns if all the contained post processes are ready.
  139441. * @hidden
  139442. */
  139443. _isReady(): boolean;
  139444. }
  139445. }
  139446. declare module BABYLON {
  139447. /** @hidden */
  139448. export var displayPassPixelShader: {
  139449. name: string;
  139450. shader: string;
  139451. };
  139452. }
  139453. declare module BABYLON {
  139454. /**
  139455. * DisplayPassPostProcess which produces an output the same as it's input
  139456. */
  139457. export class DisplayPassPostProcess extends PostProcess {
  139458. /**
  139459. * Creates the DisplayPassPostProcess
  139460. * @param name The name of the effect.
  139461. * @param options The required width/height ratio to downsize to before computing the render pass.
  139462. * @param camera The camera to apply the render pass to.
  139463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139464. * @param engine The engine which the post process will be applied. (default: current engine)
  139465. * @param reusable If the post process can be reused on the same frame. (default: false)
  139466. */
  139467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139468. }
  139469. }
  139470. declare module BABYLON {
  139471. /** @hidden */
  139472. export var filterPixelShader: {
  139473. name: string;
  139474. shader: string;
  139475. };
  139476. }
  139477. declare module BABYLON {
  139478. /**
  139479. * Applies a kernel filter to the image
  139480. */
  139481. export class FilterPostProcess extends PostProcess {
  139482. /** The matrix to be applied to the image */
  139483. kernelMatrix: Matrix;
  139484. /**
  139485. *
  139486. * @param name The name of the effect.
  139487. * @param kernelMatrix The matrix to be applied to the image
  139488. * @param options The required width/height ratio to downsize to before computing the render pass.
  139489. * @param camera The camera to apply the render pass to.
  139490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139491. * @param engine The engine which the post process will be applied. (default: current engine)
  139492. * @param reusable If the post process can be reused on the same frame. (default: false)
  139493. */
  139494. constructor(name: string,
  139495. /** The matrix to be applied to the image */
  139496. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139497. }
  139498. }
  139499. declare module BABYLON {
  139500. /** @hidden */
  139501. export var fxaaPixelShader: {
  139502. name: string;
  139503. shader: string;
  139504. };
  139505. }
  139506. declare module BABYLON {
  139507. /** @hidden */
  139508. export var fxaaVertexShader: {
  139509. name: string;
  139510. shader: string;
  139511. };
  139512. }
  139513. declare module BABYLON {
  139514. /**
  139515. * Fxaa post process
  139516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139517. */
  139518. export class FxaaPostProcess extends PostProcess {
  139519. /** @hidden */
  139520. texelWidth: number;
  139521. /** @hidden */
  139522. texelHeight: number;
  139523. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139524. private _getDefines;
  139525. }
  139526. }
  139527. declare module BABYLON {
  139528. /** @hidden */
  139529. export var grainPixelShader: {
  139530. name: string;
  139531. shader: string;
  139532. };
  139533. }
  139534. declare module BABYLON {
  139535. /**
  139536. * The GrainPostProcess adds noise to the image at mid luminance levels
  139537. */
  139538. export class GrainPostProcess extends PostProcess {
  139539. /**
  139540. * The intensity of the grain added (default: 30)
  139541. */
  139542. intensity: number;
  139543. /**
  139544. * If the grain should be randomized on every frame
  139545. */
  139546. animated: boolean;
  139547. /**
  139548. * Creates a new instance of @see GrainPostProcess
  139549. * @param name The name of the effect.
  139550. * @param options The required width/height ratio to downsize to before computing the render pass.
  139551. * @param camera The camera to apply the render pass to.
  139552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139553. * @param engine The engine which the post process will be applied. (default: current engine)
  139554. * @param reusable If the post process can be reused on the same frame. (default: false)
  139555. * @param textureType Type of textures used when performing the post process. (default: 0)
  139556. * @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)
  139557. */
  139558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139559. }
  139560. }
  139561. declare module BABYLON {
  139562. /** @hidden */
  139563. export var highlightsPixelShader: {
  139564. name: string;
  139565. shader: string;
  139566. };
  139567. }
  139568. declare module BABYLON {
  139569. /**
  139570. * Extracts highlights from the image
  139571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139572. */
  139573. export class HighlightsPostProcess extends PostProcess {
  139574. /**
  139575. * Extracts highlights from the image
  139576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139577. * @param name The name of the effect.
  139578. * @param options The required width/height ratio to downsize to before computing the render pass.
  139579. * @param camera The camera to apply the render pass to.
  139580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139581. * @param engine The engine which the post process will be applied. (default: current engine)
  139582. * @param reusable If the post process can be reused on the same frame. (default: false)
  139583. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139584. */
  139585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139586. }
  139587. }
  139588. declare module BABYLON {
  139589. /** @hidden */
  139590. export var mrtFragmentDeclaration: {
  139591. name: string;
  139592. shader: string;
  139593. };
  139594. }
  139595. declare module BABYLON {
  139596. /** @hidden */
  139597. export var geometryPixelShader: {
  139598. name: string;
  139599. shader: string;
  139600. };
  139601. }
  139602. declare module BABYLON {
  139603. /** @hidden */
  139604. export var geometryVertexShader: {
  139605. name: string;
  139606. shader: string;
  139607. };
  139608. }
  139609. declare module BABYLON {
  139610. /** @hidden */
  139611. interface ISavedTransformationMatrix {
  139612. world: Matrix;
  139613. viewProjection: Matrix;
  139614. }
  139615. /**
  139616. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139617. */
  139618. export class GeometryBufferRenderer {
  139619. /**
  139620. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139621. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139622. */
  139623. static readonly POSITION_TEXTURE_TYPE: number;
  139624. /**
  139625. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139626. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139627. */
  139628. static readonly VELOCITY_TEXTURE_TYPE: number;
  139629. /**
  139630. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139631. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139632. */
  139633. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139634. /**
  139635. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139636. * in order to compute objects velocities when enableVelocity is set to "true"
  139637. * @hidden
  139638. */
  139639. _previousTransformationMatrices: {
  139640. [index: number]: ISavedTransformationMatrix;
  139641. };
  139642. /**
  139643. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139644. * in order to compute objects velocities when enableVelocity is set to "true"
  139645. * @hidden
  139646. */
  139647. _previousBonesTransformationMatrices: {
  139648. [index: number]: Float32Array;
  139649. };
  139650. /**
  139651. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139652. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139653. */
  139654. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139655. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139656. renderTransparentMeshes: boolean;
  139657. private _scene;
  139658. private _multiRenderTarget;
  139659. private _ratio;
  139660. private _enablePosition;
  139661. private _enableVelocity;
  139662. private _enableReflectivity;
  139663. private _positionIndex;
  139664. private _velocityIndex;
  139665. private _reflectivityIndex;
  139666. protected _effect: Effect;
  139667. protected _cachedDefines: string;
  139668. /**
  139669. * Set the render list (meshes to be rendered) used in the G buffer.
  139670. */
  139671. set renderList(meshes: Mesh[]);
  139672. /**
  139673. * Gets wether or not G buffer are supported by the running hardware.
  139674. * This requires draw buffer supports
  139675. */
  139676. get isSupported(): boolean;
  139677. /**
  139678. * Returns the index of the given texture type in the G-Buffer textures array
  139679. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139680. * @returns the index of the given texture type in the G-Buffer textures array
  139681. */
  139682. getTextureIndex(textureType: number): number;
  139683. /**
  139684. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139685. */
  139686. get enablePosition(): boolean;
  139687. /**
  139688. * Sets whether or not objects positions are enabled for the G buffer.
  139689. */
  139690. set enablePosition(enable: boolean);
  139691. /**
  139692. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139693. */
  139694. get enableVelocity(): boolean;
  139695. /**
  139696. * Sets wether or not objects velocities are enabled for the G buffer.
  139697. */
  139698. set enableVelocity(enable: boolean);
  139699. /**
  139700. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139701. */
  139702. get enableReflectivity(): boolean;
  139703. /**
  139704. * Sets wether or not objects roughness are enabled for the G buffer.
  139705. */
  139706. set enableReflectivity(enable: boolean);
  139707. /**
  139708. * Gets the scene associated with the buffer.
  139709. */
  139710. get scene(): Scene;
  139711. /**
  139712. * Gets the ratio used by the buffer during its creation.
  139713. * How big is the buffer related to the main canvas.
  139714. */
  139715. get ratio(): number;
  139716. /** @hidden */
  139717. static _SceneComponentInitialization: (scene: Scene) => void;
  139718. /**
  139719. * Creates a new G Buffer for the scene
  139720. * @param scene The scene the buffer belongs to
  139721. * @param ratio How big is the buffer related to the main canvas.
  139722. */
  139723. constructor(scene: Scene, ratio?: number);
  139724. /**
  139725. * Checks wether everything is ready to render a submesh to the G buffer.
  139726. * @param subMesh the submesh to check readiness for
  139727. * @param useInstances is the mesh drawn using instance or not
  139728. * @returns true if ready otherwise false
  139729. */
  139730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139731. /**
  139732. * Gets the current underlying G Buffer.
  139733. * @returns the buffer
  139734. */
  139735. getGBuffer(): MultiRenderTarget;
  139736. /**
  139737. * Gets the number of samples used to render the buffer (anti aliasing).
  139738. */
  139739. get samples(): number;
  139740. /**
  139741. * Sets the number of samples used to render the buffer (anti aliasing).
  139742. */
  139743. set samples(value: number);
  139744. /**
  139745. * Disposes the renderer and frees up associated resources.
  139746. */
  139747. dispose(): void;
  139748. protected _createRenderTargets(): void;
  139749. private _copyBonesTransformationMatrices;
  139750. }
  139751. }
  139752. declare module BABYLON {
  139753. interface Scene {
  139754. /** @hidden (Backing field) */
  139755. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139756. /**
  139757. * Gets or Sets the current geometry buffer associated to the scene.
  139758. */
  139759. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139760. /**
  139761. * Enables a GeometryBufferRender and associates it with the scene
  139762. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139763. * @returns the GeometryBufferRenderer
  139764. */
  139765. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139766. /**
  139767. * Disables the GeometryBufferRender associated with the scene
  139768. */
  139769. disableGeometryBufferRenderer(): void;
  139770. }
  139771. /**
  139772. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139773. * in several rendering techniques.
  139774. */
  139775. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139776. /**
  139777. * The component name helpful to identify the component in the list of scene components.
  139778. */
  139779. readonly name: string;
  139780. /**
  139781. * The scene the component belongs to.
  139782. */
  139783. scene: Scene;
  139784. /**
  139785. * Creates a new instance of the component for the given scene
  139786. * @param scene Defines the scene to register the component in
  139787. */
  139788. constructor(scene: Scene);
  139789. /**
  139790. * Registers the component in a given scene
  139791. */
  139792. register(): void;
  139793. /**
  139794. * Rebuilds the elements related to this component in case of
  139795. * context lost for instance.
  139796. */
  139797. rebuild(): void;
  139798. /**
  139799. * Disposes the component and the associated ressources
  139800. */
  139801. dispose(): void;
  139802. private _gatherRenderTargets;
  139803. }
  139804. }
  139805. declare module BABYLON {
  139806. /** @hidden */
  139807. export var motionBlurPixelShader: {
  139808. name: string;
  139809. shader: string;
  139810. };
  139811. }
  139812. declare module BABYLON {
  139813. /**
  139814. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139815. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139816. * As an example, all you have to do is to create the post-process:
  139817. * var mb = new BABYLON.MotionBlurPostProcess(
  139818. * 'mb', // The name of the effect.
  139819. * scene, // The scene containing the objects to blur according to their velocity.
  139820. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139821. * camera // The camera to apply the render pass to.
  139822. * );
  139823. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139824. */
  139825. export class MotionBlurPostProcess extends PostProcess {
  139826. /**
  139827. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139828. */
  139829. motionStrength: number;
  139830. /**
  139831. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139832. */
  139833. get motionBlurSamples(): number;
  139834. /**
  139835. * Sets the number of iterations to be used for motion blur quality
  139836. */
  139837. set motionBlurSamples(samples: number);
  139838. private _motionBlurSamples;
  139839. private _geometryBufferRenderer;
  139840. /**
  139841. * Creates a new instance MotionBlurPostProcess
  139842. * @param name The name of the effect.
  139843. * @param scene The scene containing the objects to blur according to their velocity.
  139844. * @param options The required width/height ratio to downsize to before computing the render pass.
  139845. * @param camera The camera to apply the render pass to.
  139846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139847. * @param engine The engine which the post process will be applied. (default: current engine)
  139848. * @param reusable If the post process can be reused on the same frame. (default: false)
  139849. * @param textureType Type of textures used when performing the post process. (default: 0)
  139850. * @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)
  139851. */
  139852. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139853. /**
  139854. * Excludes the given skinned mesh from computing bones velocities.
  139855. * 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.
  139856. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139857. */
  139858. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139859. /**
  139860. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139861. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139862. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139863. */
  139864. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139865. /**
  139866. * Disposes the post process.
  139867. * @param camera The camera to dispose the post process on.
  139868. */
  139869. dispose(camera?: Camera): void;
  139870. }
  139871. }
  139872. declare module BABYLON {
  139873. /** @hidden */
  139874. export var refractionPixelShader: {
  139875. name: string;
  139876. shader: string;
  139877. };
  139878. }
  139879. declare module BABYLON {
  139880. /**
  139881. * Post process which applies a refractin texture
  139882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139883. */
  139884. export class RefractionPostProcess extends PostProcess {
  139885. /** the base color of the refraction (used to taint the rendering) */
  139886. color: Color3;
  139887. /** simulated refraction depth */
  139888. depth: number;
  139889. /** the coefficient of the base color (0 to remove base color tainting) */
  139890. colorLevel: number;
  139891. private _refTexture;
  139892. private _ownRefractionTexture;
  139893. /**
  139894. * Gets or sets the refraction texture
  139895. * Please note that you are responsible for disposing the texture if you set it manually
  139896. */
  139897. get refractionTexture(): Texture;
  139898. set refractionTexture(value: Texture);
  139899. /**
  139900. * Initializes the RefractionPostProcess
  139901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139902. * @param name The name of the effect.
  139903. * @param refractionTextureUrl Url of the refraction texture to use
  139904. * @param color the base color of the refraction (used to taint the rendering)
  139905. * @param depth simulated refraction depth
  139906. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139907. * @param camera The camera to apply the render pass to.
  139908. * @param options The required width/height ratio to downsize to before computing the render pass.
  139909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139910. * @param engine The engine which the post process will be applied. (default: current engine)
  139911. * @param reusable If the post process can be reused on the same frame. (default: false)
  139912. */
  139913. constructor(name: string, refractionTextureUrl: string,
  139914. /** the base color of the refraction (used to taint the rendering) */
  139915. color: Color3,
  139916. /** simulated refraction depth */
  139917. depth: number,
  139918. /** the coefficient of the base color (0 to remove base color tainting) */
  139919. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139920. /**
  139921. * Disposes of the post process
  139922. * @param camera Camera to dispose post process on
  139923. */
  139924. dispose(camera: Camera): void;
  139925. }
  139926. }
  139927. declare module BABYLON {
  139928. /** @hidden */
  139929. export var sharpenPixelShader: {
  139930. name: string;
  139931. shader: string;
  139932. };
  139933. }
  139934. declare module BABYLON {
  139935. /**
  139936. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139937. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139938. */
  139939. export class SharpenPostProcess extends PostProcess {
  139940. /**
  139941. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139942. */
  139943. colorAmount: number;
  139944. /**
  139945. * How much sharpness should be applied (default: 0.3)
  139946. */
  139947. edgeAmount: number;
  139948. /**
  139949. * Creates a new instance ConvolutionPostProcess
  139950. * @param name The name of the effect.
  139951. * @param options The required width/height ratio to downsize to before computing the render pass.
  139952. * @param camera The camera to apply the render pass to.
  139953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139954. * @param engine The engine which the post process will be applied. (default: current engine)
  139955. * @param reusable If the post process can be reused on the same frame. (default: false)
  139956. * @param textureType Type of textures used when performing the post process. (default: 0)
  139957. * @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)
  139958. */
  139959. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139960. }
  139961. }
  139962. declare module BABYLON {
  139963. /**
  139964. * PostProcessRenderPipeline
  139965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139966. */
  139967. export class PostProcessRenderPipeline {
  139968. private engine;
  139969. private _renderEffects;
  139970. private _renderEffectsForIsolatedPass;
  139971. /**
  139972. * List of inspectable custom properties (used by the Inspector)
  139973. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  139974. */
  139975. inspectableCustomProperties: IInspectable[];
  139976. /**
  139977. * @hidden
  139978. */
  139979. protected _cameras: Camera[];
  139980. /** @hidden */
  139981. _name: string;
  139982. /**
  139983. * Gets pipeline name
  139984. */
  139985. get name(): string;
  139986. /** Gets the list of attached cameras */
  139987. get cameras(): Camera[];
  139988. /**
  139989. * Initializes a PostProcessRenderPipeline
  139990. * @param engine engine to add the pipeline to
  139991. * @param name name of the pipeline
  139992. */
  139993. constructor(engine: Engine, name: string);
  139994. /**
  139995. * Gets the class name
  139996. * @returns "PostProcessRenderPipeline"
  139997. */
  139998. getClassName(): string;
  139999. /**
  140000. * If all the render effects in the pipeline are supported
  140001. */
  140002. get isSupported(): boolean;
  140003. /**
  140004. * Adds an effect to the pipeline
  140005. * @param renderEffect the effect to add
  140006. */
  140007. addEffect(renderEffect: PostProcessRenderEffect): void;
  140008. /** @hidden */
  140009. _rebuild(): void;
  140010. /** @hidden */
  140011. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140012. /** @hidden */
  140013. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140014. /** @hidden */
  140015. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140016. /** @hidden */
  140017. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140018. /** @hidden */
  140019. _attachCameras(cameras: Camera, unique: boolean): void;
  140020. /** @hidden */
  140021. _attachCameras(cameras: Camera[], unique: boolean): void;
  140022. /** @hidden */
  140023. _detachCameras(cameras: Camera): void;
  140024. /** @hidden */
  140025. _detachCameras(cameras: Nullable<Camera[]>): void;
  140026. /** @hidden */
  140027. _update(): void;
  140028. /** @hidden */
  140029. _reset(): void;
  140030. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140031. /**
  140032. * Disposes of the pipeline
  140033. */
  140034. dispose(): void;
  140035. }
  140036. }
  140037. declare module BABYLON {
  140038. /**
  140039. * PostProcessRenderPipelineManager class
  140040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140041. */
  140042. export class PostProcessRenderPipelineManager {
  140043. private _renderPipelines;
  140044. /**
  140045. * Initializes a PostProcessRenderPipelineManager
  140046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140047. */
  140048. constructor();
  140049. /**
  140050. * Gets the list of supported render pipelines
  140051. */
  140052. get supportedPipelines(): PostProcessRenderPipeline[];
  140053. /**
  140054. * Adds a pipeline to the manager
  140055. * @param renderPipeline The pipeline to add
  140056. */
  140057. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140058. /**
  140059. * Attaches a camera to the pipeline
  140060. * @param renderPipelineName The name of the pipeline to attach to
  140061. * @param cameras the camera to attach
  140062. * @param unique if the camera can be attached multiple times to the pipeline
  140063. */
  140064. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140065. /**
  140066. * Detaches a camera from the pipeline
  140067. * @param renderPipelineName The name of the pipeline to detach from
  140068. * @param cameras the camera to detach
  140069. */
  140070. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140071. /**
  140072. * Enables an effect by name on a pipeline
  140073. * @param renderPipelineName the name of the pipeline to enable the effect in
  140074. * @param renderEffectName the name of the effect to enable
  140075. * @param cameras the cameras that the effect should be enabled on
  140076. */
  140077. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140078. /**
  140079. * Disables an effect by name on a pipeline
  140080. * @param renderPipelineName the name of the pipeline to disable the effect in
  140081. * @param renderEffectName the name of the effect to disable
  140082. * @param cameras the cameras that the effect should be disabled on
  140083. */
  140084. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140085. /**
  140086. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140087. */
  140088. update(): void;
  140089. /** @hidden */
  140090. _rebuild(): void;
  140091. /**
  140092. * Disposes of the manager and pipelines
  140093. */
  140094. dispose(): void;
  140095. }
  140096. }
  140097. declare module BABYLON {
  140098. interface Scene {
  140099. /** @hidden (Backing field) */
  140100. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140101. /**
  140102. * Gets the postprocess render pipeline manager
  140103. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140104. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140105. */
  140106. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140107. }
  140108. /**
  140109. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140110. */
  140111. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140112. /**
  140113. * The component name helpfull to identify the component in the list of scene components.
  140114. */
  140115. readonly name: string;
  140116. /**
  140117. * The scene the component belongs to.
  140118. */
  140119. scene: Scene;
  140120. /**
  140121. * Creates a new instance of the component for the given scene
  140122. * @param scene Defines the scene to register the component in
  140123. */
  140124. constructor(scene: Scene);
  140125. /**
  140126. * Registers the component in a given scene
  140127. */
  140128. register(): void;
  140129. /**
  140130. * Rebuilds the elements related to this component in case of
  140131. * context lost for instance.
  140132. */
  140133. rebuild(): void;
  140134. /**
  140135. * Disposes the component and the associated ressources
  140136. */
  140137. dispose(): void;
  140138. private _gatherRenderTargets;
  140139. }
  140140. }
  140141. declare module BABYLON {
  140142. /**
  140143. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140144. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140145. */
  140146. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140147. private _scene;
  140148. private _camerasToBeAttached;
  140149. /**
  140150. * ID of the sharpen post process,
  140151. */
  140152. private readonly SharpenPostProcessId;
  140153. /**
  140154. * @ignore
  140155. * ID of the image processing post process;
  140156. */
  140157. readonly ImageProcessingPostProcessId: string;
  140158. /**
  140159. * @ignore
  140160. * ID of the Fast Approximate Anti-Aliasing post process;
  140161. */
  140162. readonly FxaaPostProcessId: string;
  140163. /**
  140164. * ID of the chromatic aberration post process,
  140165. */
  140166. private readonly ChromaticAberrationPostProcessId;
  140167. /**
  140168. * ID of the grain post process
  140169. */
  140170. private readonly GrainPostProcessId;
  140171. /**
  140172. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140173. */
  140174. sharpen: SharpenPostProcess;
  140175. private _sharpenEffect;
  140176. private bloom;
  140177. /**
  140178. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140179. */
  140180. depthOfField: DepthOfFieldEffect;
  140181. /**
  140182. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140183. */
  140184. fxaa: FxaaPostProcess;
  140185. /**
  140186. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140187. */
  140188. imageProcessing: ImageProcessingPostProcess;
  140189. /**
  140190. * Chromatic aberration post process which will shift rgb colors in the image
  140191. */
  140192. chromaticAberration: ChromaticAberrationPostProcess;
  140193. private _chromaticAberrationEffect;
  140194. /**
  140195. * Grain post process which add noise to the image
  140196. */
  140197. grain: GrainPostProcess;
  140198. private _grainEffect;
  140199. /**
  140200. * Glow post process which adds a glow to emissive areas of the image
  140201. */
  140202. private _glowLayer;
  140203. /**
  140204. * Animations which can be used to tweak settings over a period of time
  140205. */
  140206. animations: Animation[];
  140207. private _imageProcessingConfigurationObserver;
  140208. private _sharpenEnabled;
  140209. private _bloomEnabled;
  140210. private _depthOfFieldEnabled;
  140211. private _depthOfFieldBlurLevel;
  140212. private _fxaaEnabled;
  140213. private _imageProcessingEnabled;
  140214. private _defaultPipelineTextureType;
  140215. private _bloomScale;
  140216. private _chromaticAberrationEnabled;
  140217. private _grainEnabled;
  140218. private _buildAllowed;
  140219. /**
  140220. * Gets active scene
  140221. */
  140222. get scene(): Scene;
  140223. /**
  140224. * Enable or disable the sharpen process from the pipeline
  140225. */
  140226. set sharpenEnabled(enabled: boolean);
  140227. get sharpenEnabled(): boolean;
  140228. private _resizeObserver;
  140229. private _hardwareScaleLevel;
  140230. private _bloomKernel;
  140231. /**
  140232. * Specifies the size of the bloom blur kernel, relative to the final output size
  140233. */
  140234. get bloomKernel(): number;
  140235. set bloomKernel(value: number);
  140236. /**
  140237. * Specifies the weight of the bloom in the final rendering
  140238. */
  140239. private _bloomWeight;
  140240. /**
  140241. * Specifies the luma threshold for the area that will be blurred by the bloom
  140242. */
  140243. private _bloomThreshold;
  140244. private _hdr;
  140245. /**
  140246. * The strength of the bloom.
  140247. */
  140248. set bloomWeight(value: number);
  140249. get bloomWeight(): number;
  140250. /**
  140251. * The strength of the bloom.
  140252. */
  140253. set bloomThreshold(value: number);
  140254. get bloomThreshold(): number;
  140255. /**
  140256. * The scale of the bloom, lower value will provide better performance.
  140257. */
  140258. set bloomScale(value: number);
  140259. get bloomScale(): number;
  140260. /**
  140261. * Enable or disable the bloom from the pipeline
  140262. */
  140263. set bloomEnabled(enabled: boolean);
  140264. get bloomEnabled(): boolean;
  140265. private _rebuildBloom;
  140266. /**
  140267. * If the depth of field is enabled.
  140268. */
  140269. get depthOfFieldEnabled(): boolean;
  140270. set depthOfFieldEnabled(enabled: boolean);
  140271. /**
  140272. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140273. */
  140274. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140275. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140276. /**
  140277. * If the anti aliasing is enabled.
  140278. */
  140279. set fxaaEnabled(enabled: boolean);
  140280. get fxaaEnabled(): boolean;
  140281. private _samples;
  140282. /**
  140283. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140284. */
  140285. set samples(sampleCount: number);
  140286. get samples(): number;
  140287. /**
  140288. * If image processing is enabled.
  140289. */
  140290. set imageProcessingEnabled(enabled: boolean);
  140291. get imageProcessingEnabled(): boolean;
  140292. /**
  140293. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140294. */
  140295. set glowLayerEnabled(enabled: boolean);
  140296. get glowLayerEnabled(): boolean;
  140297. /**
  140298. * Gets the glow layer (or null if not defined)
  140299. */
  140300. get glowLayer(): Nullable<GlowLayer>;
  140301. /**
  140302. * Enable or disable the chromaticAberration process from the pipeline
  140303. */
  140304. set chromaticAberrationEnabled(enabled: boolean);
  140305. get chromaticAberrationEnabled(): boolean;
  140306. /**
  140307. * Enable or disable the grain process from the pipeline
  140308. */
  140309. set grainEnabled(enabled: boolean);
  140310. get grainEnabled(): boolean;
  140311. /**
  140312. * @constructor
  140313. * @param name - The rendering pipeline name (default: "")
  140314. * @param hdr - If high dynamic range textures should be used (default: true)
  140315. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140316. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140317. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140318. */
  140319. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140320. /**
  140321. * Get the class name
  140322. * @returns "DefaultRenderingPipeline"
  140323. */
  140324. getClassName(): string;
  140325. /**
  140326. * Force the compilation of the entire pipeline.
  140327. */
  140328. prepare(): void;
  140329. private _hasCleared;
  140330. private _prevPostProcess;
  140331. private _prevPrevPostProcess;
  140332. private _setAutoClearAndTextureSharing;
  140333. private _depthOfFieldSceneObserver;
  140334. private _buildPipeline;
  140335. private _disposePostProcesses;
  140336. /**
  140337. * Adds a camera to the pipeline
  140338. * @param camera the camera to be added
  140339. */
  140340. addCamera(camera: Camera): void;
  140341. /**
  140342. * Removes a camera from the pipeline
  140343. * @param camera the camera to remove
  140344. */
  140345. removeCamera(camera: Camera): void;
  140346. /**
  140347. * Dispose of the pipeline and stop all post processes
  140348. */
  140349. dispose(): void;
  140350. /**
  140351. * Serialize the rendering pipeline (Used when exporting)
  140352. * @returns the serialized object
  140353. */
  140354. serialize(): any;
  140355. /**
  140356. * Parse the serialized pipeline
  140357. * @param source Source pipeline.
  140358. * @param scene The scene to load the pipeline to.
  140359. * @param rootUrl The URL of the serialized pipeline.
  140360. * @returns An instantiated pipeline from the serialized object.
  140361. */
  140362. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140363. }
  140364. }
  140365. declare module BABYLON {
  140366. /** @hidden */
  140367. export var lensHighlightsPixelShader: {
  140368. name: string;
  140369. shader: string;
  140370. };
  140371. }
  140372. declare module BABYLON {
  140373. /** @hidden */
  140374. export var depthOfFieldPixelShader: {
  140375. name: string;
  140376. shader: string;
  140377. };
  140378. }
  140379. declare module BABYLON {
  140380. /**
  140381. * BABYLON.JS Chromatic Aberration GLSL Shader
  140382. * Author: Olivier Guyot
  140383. * Separates very slightly R, G and B colors on the edges of the screen
  140384. * Inspired by Francois Tarlier & Martins Upitis
  140385. */
  140386. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140387. /**
  140388. * @ignore
  140389. * The chromatic aberration PostProcess id in the pipeline
  140390. */
  140391. LensChromaticAberrationEffect: string;
  140392. /**
  140393. * @ignore
  140394. * The highlights enhancing PostProcess id in the pipeline
  140395. */
  140396. HighlightsEnhancingEffect: string;
  140397. /**
  140398. * @ignore
  140399. * The depth-of-field PostProcess id in the pipeline
  140400. */
  140401. LensDepthOfFieldEffect: string;
  140402. private _scene;
  140403. private _depthTexture;
  140404. private _grainTexture;
  140405. private _chromaticAberrationPostProcess;
  140406. private _highlightsPostProcess;
  140407. private _depthOfFieldPostProcess;
  140408. private _edgeBlur;
  140409. private _grainAmount;
  140410. private _chromaticAberration;
  140411. private _distortion;
  140412. private _highlightsGain;
  140413. private _highlightsThreshold;
  140414. private _dofDistance;
  140415. private _dofAperture;
  140416. private _dofDarken;
  140417. private _dofPentagon;
  140418. private _blurNoise;
  140419. /**
  140420. * @constructor
  140421. *
  140422. * Effect parameters are as follow:
  140423. * {
  140424. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140425. * edge_blur: number; // from 0 to x (1 for realism)
  140426. * distortion: number; // from 0 to x (1 for realism)
  140427. * grain_amount: number; // from 0 to 1
  140428. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140429. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140430. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140431. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140432. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140433. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140434. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140435. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140436. * }
  140437. * Note: if an effect parameter is unset, effect is disabled
  140438. *
  140439. * @param name The rendering pipeline name
  140440. * @param parameters - An object containing all parameters (see above)
  140441. * @param scene The scene linked to this pipeline
  140442. * @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)
  140443. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140444. */
  140445. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140446. /**
  140447. * Get the class name
  140448. * @returns "LensRenderingPipeline"
  140449. */
  140450. getClassName(): string;
  140451. /**
  140452. * Gets associated scene
  140453. */
  140454. get scene(): Scene;
  140455. /**
  140456. * Gets or sets the edge blur
  140457. */
  140458. get edgeBlur(): number;
  140459. set edgeBlur(value: number);
  140460. /**
  140461. * Gets or sets the grain amount
  140462. */
  140463. get grainAmount(): number;
  140464. set grainAmount(value: number);
  140465. /**
  140466. * Gets or sets the chromatic aberration amount
  140467. */
  140468. get chromaticAberration(): number;
  140469. set chromaticAberration(value: number);
  140470. /**
  140471. * Gets or sets the depth of field aperture
  140472. */
  140473. get dofAperture(): number;
  140474. set dofAperture(value: number);
  140475. /**
  140476. * Gets or sets the edge distortion
  140477. */
  140478. get edgeDistortion(): number;
  140479. set edgeDistortion(value: number);
  140480. /**
  140481. * Gets or sets the depth of field distortion
  140482. */
  140483. get dofDistortion(): number;
  140484. set dofDistortion(value: number);
  140485. /**
  140486. * Gets or sets the darken out of focus amount
  140487. */
  140488. get darkenOutOfFocus(): number;
  140489. set darkenOutOfFocus(value: number);
  140490. /**
  140491. * Gets or sets a boolean indicating if blur noise is enabled
  140492. */
  140493. get blurNoise(): boolean;
  140494. set blurNoise(value: boolean);
  140495. /**
  140496. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140497. */
  140498. get pentagonBokeh(): boolean;
  140499. set pentagonBokeh(value: boolean);
  140500. /**
  140501. * Gets or sets the highlight grain amount
  140502. */
  140503. get highlightsGain(): number;
  140504. set highlightsGain(value: number);
  140505. /**
  140506. * Gets or sets the highlight threshold
  140507. */
  140508. get highlightsThreshold(): number;
  140509. set highlightsThreshold(value: number);
  140510. /**
  140511. * Sets the amount of blur at the edges
  140512. * @param amount blur amount
  140513. */
  140514. setEdgeBlur(amount: number): void;
  140515. /**
  140516. * Sets edge blur to 0
  140517. */
  140518. disableEdgeBlur(): void;
  140519. /**
  140520. * Sets the amout of grain
  140521. * @param amount Amount of grain
  140522. */
  140523. setGrainAmount(amount: number): void;
  140524. /**
  140525. * Set grain amount to 0
  140526. */
  140527. disableGrain(): void;
  140528. /**
  140529. * Sets the chromatic aberration amount
  140530. * @param amount amount of chromatic aberration
  140531. */
  140532. setChromaticAberration(amount: number): void;
  140533. /**
  140534. * Sets chromatic aberration amount to 0
  140535. */
  140536. disableChromaticAberration(): void;
  140537. /**
  140538. * Sets the EdgeDistortion amount
  140539. * @param amount amount of EdgeDistortion
  140540. */
  140541. setEdgeDistortion(amount: number): void;
  140542. /**
  140543. * Sets edge distortion to 0
  140544. */
  140545. disableEdgeDistortion(): void;
  140546. /**
  140547. * Sets the FocusDistance amount
  140548. * @param amount amount of FocusDistance
  140549. */
  140550. setFocusDistance(amount: number): void;
  140551. /**
  140552. * Disables depth of field
  140553. */
  140554. disableDepthOfField(): void;
  140555. /**
  140556. * Sets the Aperture amount
  140557. * @param amount amount of Aperture
  140558. */
  140559. setAperture(amount: number): void;
  140560. /**
  140561. * Sets the DarkenOutOfFocus amount
  140562. * @param amount amount of DarkenOutOfFocus
  140563. */
  140564. setDarkenOutOfFocus(amount: number): void;
  140565. private _pentagonBokehIsEnabled;
  140566. /**
  140567. * Creates a pentagon bokeh effect
  140568. */
  140569. enablePentagonBokeh(): void;
  140570. /**
  140571. * Disables the pentagon bokeh effect
  140572. */
  140573. disablePentagonBokeh(): void;
  140574. /**
  140575. * Enables noise blur
  140576. */
  140577. enableNoiseBlur(): void;
  140578. /**
  140579. * Disables noise blur
  140580. */
  140581. disableNoiseBlur(): void;
  140582. /**
  140583. * Sets the HighlightsGain amount
  140584. * @param amount amount of HighlightsGain
  140585. */
  140586. setHighlightsGain(amount: number): void;
  140587. /**
  140588. * Sets the HighlightsThreshold amount
  140589. * @param amount amount of HighlightsThreshold
  140590. */
  140591. setHighlightsThreshold(amount: number): void;
  140592. /**
  140593. * Disables highlights
  140594. */
  140595. disableHighlights(): void;
  140596. /**
  140597. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140598. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140599. */
  140600. dispose(disableDepthRender?: boolean): void;
  140601. private _createChromaticAberrationPostProcess;
  140602. private _createHighlightsPostProcess;
  140603. private _createDepthOfFieldPostProcess;
  140604. private _createGrainTexture;
  140605. }
  140606. }
  140607. declare module BABYLON {
  140608. /** @hidden */
  140609. export var ssao2PixelShader: {
  140610. name: string;
  140611. shader: string;
  140612. };
  140613. }
  140614. declare module BABYLON {
  140615. /** @hidden */
  140616. export var ssaoCombinePixelShader: {
  140617. name: string;
  140618. shader: string;
  140619. };
  140620. }
  140621. declare module BABYLON {
  140622. /**
  140623. * Render pipeline to produce ssao effect
  140624. */
  140625. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140626. /**
  140627. * @ignore
  140628. * The PassPostProcess id in the pipeline that contains the original scene color
  140629. */
  140630. SSAOOriginalSceneColorEffect: string;
  140631. /**
  140632. * @ignore
  140633. * The SSAO PostProcess id in the pipeline
  140634. */
  140635. SSAORenderEffect: string;
  140636. /**
  140637. * @ignore
  140638. * The horizontal blur PostProcess id in the pipeline
  140639. */
  140640. SSAOBlurHRenderEffect: string;
  140641. /**
  140642. * @ignore
  140643. * The vertical blur PostProcess id in the pipeline
  140644. */
  140645. SSAOBlurVRenderEffect: string;
  140646. /**
  140647. * @ignore
  140648. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140649. */
  140650. SSAOCombineRenderEffect: string;
  140651. /**
  140652. * The output strength of the SSAO post-process. Default value is 1.0.
  140653. */
  140654. totalStrength: number;
  140655. /**
  140656. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140657. */
  140658. maxZ: number;
  140659. /**
  140660. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140661. */
  140662. minZAspect: number;
  140663. private _samples;
  140664. /**
  140665. * Number of samples used for the SSAO calculations. Default value is 8
  140666. */
  140667. set samples(n: number);
  140668. get samples(): number;
  140669. private _textureSamples;
  140670. /**
  140671. * Number of samples to use for antialiasing
  140672. */
  140673. set textureSamples(n: number);
  140674. get textureSamples(): number;
  140675. /**
  140676. * Ratio object used for SSAO ratio and blur ratio
  140677. */
  140678. private _ratio;
  140679. /**
  140680. * Dynamically generated sphere sampler.
  140681. */
  140682. private _sampleSphere;
  140683. /**
  140684. * Blur filter offsets
  140685. */
  140686. private _samplerOffsets;
  140687. private _expensiveBlur;
  140688. /**
  140689. * If bilateral blur should be used
  140690. */
  140691. set expensiveBlur(b: boolean);
  140692. get expensiveBlur(): boolean;
  140693. /**
  140694. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140695. */
  140696. radius: number;
  140697. /**
  140698. * The base color of the SSAO post-process
  140699. * The final result is "base + ssao" between [0, 1]
  140700. */
  140701. base: number;
  140702. /**
  140703. * Support test.
  140704. */
  140705. static get IsSupported(): boolean;
  140706. private _scene;
  140707. private _depthTexture;
  140708. private _normalTexture;
  140709. private _randomTexture;
  140710. private _originalColorPostProcess;
  140711. private _ssaoPostProcess;
  140712. private _blurHPostProcess;
  140713. private _blurVPostProcess;
  140714. private _ssaoCombinePostProcess;
  140715. /**
  140716. * Gets active scene
  140717. */
  140718. get scene(): Scene;
  140719. /**
  140720. * @constructor
  140721. * @param name The rendering pipeline name
  140722. * @param scene The scene linked to this pipeline
  140723. * @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 }
  140724. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140725. */
  140726. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140727. /**
  140728. * Get the class name
  140729. * @returns "SSAO2RenderingPipeline"
  140730. */
  140731. getClassName(): string;
  140732. /**
  140733. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140734. */
  140735. dispose(disableGeometryBufferRenderer?: boolean): void;
  140736. private _createBlurPostProcess;
  140737. /** @hidden */
  140738. _rebuild(): void;
  140739. private _bits;
  140740. private _radicalInverse_VdC;
  140741. private _hammersley;
  140742. private _hemisphereSample_uniform;
  140743. private _generateHemisphere;
  140744. private _createSSAOPostProcess;
  140745. private _createSSAOCombinePostProcess;
  140746. private _createRandomTexture;
  140747. /**
  140748. * Serialize the rendering pipeline (Used when exporting)
  140749. * @returns the serialized object
  140750. */
  140751. serialize(): any;
  140752. /**
  140753. * Parse the serialized pipeline
  140754. * @param source Source pipeline.
  140755. * @param scene The scene to load the pipeline to.
  140756. * @param rootUrl The URL of the serialized pipeline.
  140757. * @returns An instantiated pipeline from the serialized object.
  140758. */
  140759. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140760. }
  140761. }
  140762. declare module BABYLON {
  140763. /** @hidden */
  140764. export var ssaoPixelShader: {
  140765. name: string;
  140766. shader: string;
  140767. };
  140768. }
  140769. declare module BABYLON {
  140770. /**
  140771. * Render pipeline to produce ssao effect
  140772. */
  140773. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140774. /**
  140775. * @ignore
  140776. * The PassPostProcess id in the pipeline that contains the original scene color
  140777. */
  140778. SSAOOriginalSceneColorEffect: string;
  140779. /**
  140780. * @ignore
  140781. * The SSAO PostProcess id in the pipeline
  140782. */
  140783. SSAORenderEffect: string;
  140784. /**
  140785. * @ignore
  140786. * The horizontal blur PostProcess id in the pipeline
  140787. */
  140788. SSAOBlurHRenderEffect: string;
  140789. /**
  140790. * @ignore
  140791. * The vertical blur PostProcess id in the pipeline
  140792. */
  140793. SSAOBlurVRenderEffect: string;
  140794. /**
  140795. * @ignore
  140796. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140797. */
  140798. SSAOCombineRenderEffect: string;
  140799. /**
  140800. * The output strength of the SSAO post-process. Default value is 1.0.
  140801. */
  140802. totalStrength: number;
  140803. /**
  140804. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140805. */
  140806. radius: number;
  140807. /**
  140808. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140809. * Must not be equal to fallOff and superior to fallOff.
  140810. * Default value is 0.0075
  140811. */
  140812. area: number;
  140813. /**
  140814. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140815. * Must not be equal to area and inferior to area.
  140816. * Default value is 0.000001
  140817. */
  140818. fallOff: number;
  140819. /**
  140820. * The base color of the SSAO post-process
  140821. * The final result is "base + ssao" between [0, 1]
  140822. */
  140823. base: number;
  140824. private _scene;
  140825. private _depthTexture;
  140826. private _randomTexture;
  140827. private _originalColorPostProcess;
  140828. private _ssaoPostProcess;
  140829. private _blurHPostProcess;
  140830. private _blurVPostProcess;
  140831. private _ssaoCombinePostProcess;
  140832. private _firstUpdate;
  140833. /**
  140834. * Gets active scene
  140835. */
  140836. get scene(): Scene;
  140837. /**
  140838. * @constructor
  140839. * @param name - The rendering pipeline name
  140840. * @param scene - The scene linked to this pipeline
  140841. * @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 }
  140842. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140843. */
  140844. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140845. /**
  140846. * Get the class name
  140847. * @returns "SSAORenderingPipeline"
  140848. */
  140849. getClassName(): string;
  140850. /**
  140851. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140852. */
  140853. dispose(disableDepthRender?: boolean): void;
  140854. private _createBlurPostProcess;
  140855. /** @hidden */
  140856. _rebuild(): void;
  140857. private _createSSAOPostProcess;
  140858. private _createSSAOCombinePostProcess;
  140859. private _createRandomTexture;
  140860. }
  140861. }
  140862. declare module BABYLON {
  140863. /** @hidden */
  140864. export var screenSpaceReflectionPixelShader: {
  140865. name: string;
  140866. shader: string;
  140867. };
  140868. }
  140869. declare module BABYLON {
  140870. /**
  140871. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140872. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140873. */
  140874. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140875. /**
  140876. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140877. */
  140878. threshold: number;
  140879. /**
  140880. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140881. */
  140882. strength: number;
  140883. /**
  140884. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140885. */
  140886. reflectionSpecularFalloffExponent: number;
  140887. /**
  140888. * 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]
  140889. */
  140890. step: number;
  140891. /**
  140892. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140893. */
  140894. roughnessFactor: number;
  140895. private _geometryBufferRenderer;
  140896. private _enableSmoothReflections;
  140897. private _reflectionSamples;
  140898. private _smoothSteps;
  140899. /**
  140900. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140901. * @param name The name of the effect.
  140902. * @param scene The scene containing the objects to calculate reflections.
  140903. * @param options The required width/height ratio to downsize to before computing the render pass.
  140904. * @param camera The camera to apply the render pass to.
  140905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140906. * @param engine The engine which the post process will be applied. (default: current engine)
  140907. * @param reusable If the post process can be reused on the same frame. (default: false)
  140908. * @param textureType Type of textures used when performing the post process. (default: 0)
  140909. * @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)
  140910. */
  140911. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140912. /**
  140913. * Gets wether or not smoothing reflections is enabled.
  140914. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140915. */
  140916. get enableSmoothReflections(): boolean;
  140917. /**
  140918. * Sets wether or not smoothing reflections is enabled.
  140919. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140920. */
  140921. set enableSmoothReflections(enabled: boolean);
  140922. /**
  140923. * Gets the number of samples taken while computing reflections. More samples count is high,
  140924. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140925. */
  140926. get reflectionSamples(): number;
  140927. /**
  140928. * Sets the number of samples taken while computing reflections. More samples count is high,
  140929. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140930. */
  140931. set reflectionSamples(samples: number);
  140932. /**
  140933. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140934. * more the post-process will require GPU power and can generate a drop in FPS.
  140935. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140936. */
  140937. get smoothSteps(): number;
  140938. set smoothSteps(steps: number);
  140939. private _updateEffectDefines;
  140940. }
  140941. }
  140942. declare module BABYLON {
  140943. /** @hidden */
  140944. export var standardPixelShader: {
  140945. name: string;
  140946. shader: string;
  140947. };
  140948. }
  140949. declare module BABYLON {
  140950. /**
  140951. * Standard rendering pipeline
  140952. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140953. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140954. */
  140955. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140956. /**
  140957. * Public members
  140958. */
  140959. /**
  140960. * Post-process which contains the original scene color before the pipeline applies all the effects
  140961. */
  140962. originalPostProcess: Nullable<PostProcess>;
  140963. /**
  140964. * Post-process used to down scale an image x4
  140965. */
  140966. downSampleX4PostProcess: Nullable<PostProcess>;
  140967. /**
  140968. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  140969. */
  140970. brightPassPostProcess: Nullable<PostProcess>;
  140971. /**
  140972. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  140973. */
  140974. blurHPostProcesses: PostProcess[];
  140975. /**
  140976. * Post-process array storing all the vertical blur post-processes used by the pipeline
  140977. */
  140978. blurVPostProcesses: PostProcess[];
  140979. /**
  140980. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  140981. */
  140982. textureAdderPostProcess: Nullable<PostProcess>;
  140983. /**
  140984. * Post-process used to create volumetric lighting effect
  140985. */
  140986. volumetricLightPostProcess: Nullable<PostProcess>;
  140987. /**
  140988. * Post-process used to smooth the previous volumetric light post-process on the X axis
  140989. */
  140990. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  140991. /**
  140992. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  140993. */
  140994. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  140995. /**
  140996. * Post-process used to merge the volumetric light effect and the real scene color
  140997. */
  140998. volumetricLightMergePostProces: Nullable<PostProcess>;
  140999. /**
  141000. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141001. */
  141002. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141003. /**
  141004. * Base post-process used to calculate the average luminance of the final image for HDR
  141005. */
  141006. luminancePostProcess: Nullable<PostProcess>;
  141007. /**
  141008. * Post-processes used to create down sample post-processes in order to get
  141009. * the average luminance of the final image for HDR
  141010. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141011. */
  141012. luminanceDownSamplePostProcesses: PostProcess[];
  141013. /**
  141014. * Post-process used to create a HDR effect (light adaptation)
  141015. */
  141016. hdrPostProcess: Nullable<PostProcess>;
  141017. /**
  141018. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141019. */
  141020. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141021. /**
  141022. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141023. */
  141024. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141025. /**
  141026. * Post-process used to merge the final HDR post-process and the real scene color
  141027. */
  141028. hdrFinalPostProcess: Nullable<PostProcess>;
  141029. /**
  141030. * Post-process used to create a lens flare effect
  141031. */
  141032. lensFlarePostProcess: Nullable<PostProcess>;
  141033. /**
  141034. * Post-process that merges the result of the lens flare post-process and the real scene color
  141035. */
  141036. lensFlareComposePostProcess: Nullable<PostProcess>;
  141037. /**
  141038. * Post-process used to create a motion blur effect
  141039. */
  141040. motionBlurPostProcess: Nullable<PostProcess>;
  141041. /**
  141042. * Post-process used to create a depth of field effect
  141043. */
  141044. depthOfFieldPostProcess: Nullable<PostProcess>;
  141045. /**
  141046. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141047. */
  141048. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141049. /**
  141050. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141051. */
  141052. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141053. /**
  141054. * Represents the brightness threshold in order to configure the illuminated surfaces
  141055. */
  141056. brightThreshold: number;
  141057. /**
  141058. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141059. */
  141060. blurWidth: number;
  141061. /**
  141062. * Sets if the blur for highlighted surfaces must be only horizontal
  141063. */
  141064. horizontalBlur: boolean;
  141065. /**
  141066. * Gets the overall exposure used by the pipeline
  141067. */
  141068. get exposure(): number;
  141069. /**
  141070. * Sets the overall exposure used by the pipeline
  141071. */
  141072. set exposure(value: number);
  141073. /**
  141074. * Texture used typically to simulate "dirty" on camera lens
  141075. */
  141076. lensTexture: Nullable<Texture>;
  141077. /**
  141078. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141079. */
  141080. volumetricLightCoefficient: number;
  141081. /**
  141082. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141083. */
  141084. volumetricLightPower: number;
  141085. /**
  141086. * Used the set the blur intensity to smooth the volumetric lights
  141087. */
  141088. volumetricLightBlurScale: number;
  141089. /**
  141090. * Light (spot or directional) used to generate the volumetric lights rays
  141091. * The source light must have a shadow generate so the pipeline can get its
  141092. * depth map
  141093. */
  141094. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141095. /**
  141096. * For eye adaptation, represents the minimum luminance the eye can see
  141097. */
  141098. hdrMinimumLuminance: number;
  141099. /**
  141100. * For eye adaptation, represents the decrease luminance speed
  141101. */
  141102. hdrDecreaseRate: number;
  141103. /**
  141104. * For eye adaptation, represents the increase luminance speed
  141105. */
  141106. hdrIncreaseRate: number;
  141107. /**
  141108. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141109. */
  141110. get hdrAutoExposure(): boolean;
  141111. /**
  141112. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141113. */
  141114. set hdrAutoExposure(value: boolean);
  141115. /**
  141116. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141117. */
  141118. lensColorTexture: Nullable<Texture>;
  141119. /**
  141120. * The overall strengh for the lens flare effect
  141121. */
  141122. lensFlareStrength: number;
  141123. /**
  141124. * Dispersion coefficient for lens flare ghosts
  141125. */
  141126. lensFlareGhostDispersal: number;
  141127. /**
  141128. * Main lens flare halo width
  141129. */
  141130. lensFlareHaloWidth: number;
  141131. /**
  141132. * Based on the lens distortion effect, defines how much the lens flare result
  141133. * is distorted
  141134. */
  141135. lensFlareDistortionStrength: number;
  141136. /**
  141137. * Configures the blur intensity used for for lens flare (halo)
  141138. */
  141139. lensFlareBlurWidth: number;
  141140. /**
  141141. * Lens star texture must be used to simulate rays on the flares and is available
  141142. * in the documentation
  141143. */
  141144. lensStarTexture: Nullable<Texture>;
  141145. /**
  141146. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141147. * flare effect by taking account of the dirt texture
  141148. */
  141149. lensFlareDirtTexture: Nullable<Texture>;
  141150. /**
  141151. * Represents the focal length for the depth of field effect
  141152. */
  141153. depthOfFieldDistance: number;
  141154. /**
  141155. * Represents the blur intensity for the blurred part of the depth of field effect
  141156. */
  141157. depthOfFieldBlurWidth: number;
  141158. /**
  141159. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141160. */
  141161. get motionStrength(): number;
  141162. /**
  141163. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141164. */
  141165. set motionStrength(strength: number);
  141166. /**
  141167. * Gets wether or not the motion blur post-process is object based or screen based.
  141168. */
  141169. get objectBasedMotionBlur(): boolean;
  141170. /**
  141171. * Sets wether or not the motion blur post-process should be object based or screen based
  141172. */
  141173. set objectBasedMotionBlur(value: boolean);
  141174. /**
  141175. * List of animations for the pipeline (IAnimatable implementation)
  141176. */
  141177. animations: Animation[];
  141178. /**
  141179. * Private members
  141180. */
  141181. private _scene;
  141182. private _currentDepthOfFieldSource;
  141183. private _basePostProcess;
  141184. private _fixedExposure;
  141185. private _currentExposure;
  141186. private _hdrAutoExposure;
  141187. private _hdrCurrentLuminance;
  141188. private _motionStrength;
  141189. private _isObjectBasedMotionBlur;
  141190. private _floatTextureType;
  141191. private _camerasToBeAttached;
  141192. private _ratio;
  141193. private _bloomEnabled;
  141194. private _depthOfFieldEnabled;
  141195. private _vlsEnabled;
  141196. private _lensFlareEnabled;
  141197. private _hdrEnabled;
  141198. private _motionBlurEnabled;
  141199. private _fxaaEnabled;
  141200. private _screenSpaceReflectionsEnabled;
  141201. private _motionBlurSamples;
  141202. private _volumetricLightStepsCount;
  141203. private _samples;
  141204. /**
  141205. * @ignore
  141206. * Specifies if the bloom pipeline is enabled
  141207. */
  141208. get BloomEnabled(): boolean;
  141209. set BloomEnabled(enabled: boolean);
  141210. /**
  141211. * @ignore
  141212. * Specifies if the depth of field pipeline is enabed
  141213. */
  141214. get DepthOfFieldEnabled(): boolean;
  141215. set DepthOfFieldEnabled(enabled: boolean);
  141216. /**
  141217. * @ignore
  141218. * Specifies if the lens flare pipeline is enabed
  141219. */
  141220. get LensFlareEnabled(): boolean;
  141221. set LensFlareEnabled(enabled: boolean);
  141222. /**
  141223. * @ignore
  141224. * Specifies if the HDR pipeline is enabled
  141225. */
  141226. get HDREnabled(): boolean;
  141227. set HDREnabled(enabled: boolean);
  141228. /**
  141229. * @ignore
  141230. * Specifies if the volumetric lights scattering effect is enabled
  141231. */
  141232. get VLSEnabled(): boolean;
  141233. set VLSEnabled(enabled: boolean);
  141234. /**
  141235. * @ignore
  141236. * Specifies if the motion blur effect is enabled
  141237. */
  141238. get MotionBlurEnabled(): boolean;
  141239. set MotionBlurEnabled(enabled: boolean);
  141240. /**
  141241. * Specifies if anti-aliasing is enabled
  141242. */
  141243. get fxaaEnabled(): boolean;
  141244. set fxaaEnabled(enabled: boolean);
  141245. /**
  141246. * Specifies if screen space reflections are enabled.
  141247. */
  141248. get screenSpaceReflectionsEnabled(): boolean;
  141249. set screenSpaceReflectionsEnabled(enabled: boolean);
  141250. /**
  141251. * Specifies the number of steps used to calculate the volumetric lights
  141252. * Typically in interval [50, 200]
  141253. */
  141254. get volumetricLightStepsCount(): number;
  141255. set volumetricLightStepsCount(count: number);
  141256. /**
  141257. * Specifies the number of samples used for the motion blur effect
  141258. * Typically in interval [16, 64]
  141259. */
  141260. get motionBlurSamples(): number;
  141261. set motionBlurSamples(samples: number);
  141262. /**
  141263. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141264. */
  141265. get samples(): number;
  141266. set samples(sampleCount: number);
  141267. /**
  141268. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141269. * @constructor
  141270. * @param name The rendering pipeline name
  141271. * @param scene The scene linked to this pipeline
  141272. * @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)
  141273. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141274. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141275. */
  141276. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141277. private _buildPipeline;
  141278. private _createDownSampleX4PostProcess;
  141279. private _createBrightPassPostProcess;
  141280. private _createBlurPostProcesses;
  141281. private _createTextureAdderPostProcess;
  141282. private _createVolumetricLightPostProcess;
  141283. private _createLuminancePostProcesses;
  141284. private _createHdrPostProcess;
  141285. private _createLensFlarePostProcess;
  141286. private _createDepthOfFieldPostProcess;
  141287. private _createMotionBlurPostProcess;
  141288. private _getDepthTexture;
  141289. private _disposePostProcesses;
  141290. /**
  141291. * Dispose of the pipeline and stop all post processes
  141292. */
  141293. dispose(): void;
  141294. /**
  141295. * Serialize the rendering pipeline (Used when exporting)
  141296. * @returns the serialized object
  141297. */
  141298. serialize(): any;
  141299. /**
  141300. * Parse the serialized pipeline
  141301. * @param source Source pipeline.
  141302. * @param scene The scene to load the pipeline to.
  141303. * @param rootUrl The URL of the serialized pipeline.
  141304. * @returns An instantiated pipeline from the serialized object.
  141305. */
  141306. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141307. /**
  141308. * Luminance steps
  141309. */
  141310. static LuminanceSteps: number;
  141311. }
  141312. }
  141313. declare module BABYLON {
  141314. /** @hidden */
  141315. export var tonemapPixelShader: {
  141316. name: string;
  141317. shader: string;
  141318. };
  141319. }
  141320. declare module BABYLON {
  141321. /** Defines operator used for tonemapping */
  141322. export enum TonemappingOperator {
  141323. /** Hable */
  141324. Hable = 0,
  141325. /** Reinhard */
  141326. Reinhard = 1,
  141327. /** HejiDawson */
  141328. HejiDawson = 2,
  141329. /** Photographic */
  141330. Photographic = 3
  141331. }
  141332. /**
  141333. * Defines a post process to apply tone mapping
  141334. */
  141335. export class TonemapPostProcess extends PostProcess {
  141336. private _operator;
  141337. /** Defines the required exposure adjustement */
  141338. exposureAdjustment: number;
  141339. /**
  141340. * Creates a new TonemapPostProcess
  141341. * @param name defines the name of the postprocess
  141342. * @param _operator defines the operator to use
  141343. * @param exposureAdjustment defines the required exposure adjustement
  141344. * @param camera defines the camera to use (can be null)
  141345. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141346. * @param engine defines the hosting engine (can be ignore if camera is set)
  141347. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141348. */
  141349. constructor(name: string, _operator: TonemappingOperator,
  141350. /** Defines the required exposure adjustement */
  141351. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141352. }
  141353. }
  141354. declare module BABYLON {
  141355. /** @hidden */
  141356. export var volumetricLightScatteringPixelShader: {
  141357. name: string;
  141358. shader: string;
  141359. };
  141360. }
  141361. declare module BABYLON {
  141362. /** @hidden */
  141363. export var volumetricLightScatteringPassVertexShader: {
  141364. name: string;
  141365. shader: string;
  141366. };
  141367. }
  141368. declare module BABYLON {
  141369. /** @hidden */
  141370. export var volumetricLightScatteringPassPixelShader: {
  141371. name: string;
  141372. shader: string;
  141373. };
  141374. }
  141375. declare module BABYLON {
  141376. /**
  141377. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141378. */
  141379. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141380. private _volumetricLightScatteringPass;
  141381. private _volumetricLightScatteringRTT;
  141382. private _viewPort;
  141383. private _screenCoordinates;
  141384. private _cachedDefines;
  141385. /**
  141386. * If not undefined, the mesh position is computed from the attached node position
  141387. */
  141388. attachedNode: {
  141389. position: Vector3;
  141390. };
  141391. /**
  141392. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141393. */
  141394. customMeshPosition: Vector3;
  141395. /**
  141396. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141397. */
  141398. useCustomMeshPosition: boolean;
  141399. /**
  141400. * If the post-process should inverse the light scattering direction
  141401. */
  141402. invert: boolean;
  141403. /**
  141404. * The internal mesh used by the post-process
  141405. */
  141406. mesh: Mesh;
  141407. /**
  141408. * @hidden
  141409. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141410. */
  141411. get useDiffuseColor(): boolean;
  141412. set useDiffuseColor(useDiffuseColor: boolean);
  141413. /**
  141414. * Array containing the excluded meshes not rendered in the internal pass
  141415. */
  141416. excludedMeshes: AbstractMesh[];
  141417. /**
  141418. * Controls the overall intensity of the post-process
  141419. */
  141420. exposure: number;
  141421. /**
  141422. * Dissipates each sample's contribution in range [0, 1]
  141423. */
  141424. decay: number;
  141425. /**
  141426. * Controls the overall intensity of each sample
  141427. */
  141428. weight: number;
  141429. /**
  141430. * Controls the density of each sample
  141431. */
  141432. density: number;
  141433. /**
  141434. * @constructor
  141435. * @param name The post-process name
  141436. * @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)
  141437. * @param camera The camera that the post-process will be attached to
  141438. * @param mesh The mesh used to create the light scattering
  141439. * @param samples The post-process quality, default 100
  141440. * @param samplingModeThe post-process filtering mode
  141441. * @param engine The babylon engine
  141442. * @param reusable If the post-process is reusable
  141443. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141444. */
  141445. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141446. /**
  141447. * Returns the string "VolumetricLightScatteringPostProcess"
  141448. * @returns "VolumetricLightScatteringPostProcess"
  141449. */
  141450. getClassName(): string;
  141451. private _isReady;
  141452. /**
  141453. * Sets the new light position for light scattering effect
  141454. * @param position The new custom light position
  141455. */
  141456. setCustomMeshPosition(position: Vector3): void;
  141457. /**
  141458. * Returns the light position for light scattering effect
  141459. * @return Vector3 The custom light position
  141460. */
  141461. getCustomMeshPosition(): Vector3;
  141462. /**
  141463. * Disposes the internal assets and detaches the post-process from the camera
  141464. */
  141465. dispose(camera: Camera): void;
  141466. /**
  141467. * Returns the render target texture used by the post-process
  141468. * @return the render target texture used by the post-process
  141469. */
  141470. getPass(): RenderTargetTexture;
  141471. private _meshExcluded;
  141472. private _createPass;
  141473. private _updateMeshScreenCoordinates;
  141474. /**
  141475. * Creates a default mesh for the Volumeric Light Scattering post-process
  141476. * @param name The mesh name
  141477. * @param scene The scene where to create the mesh
  141478. * @return the default mesh
  141479. */
  141480. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141481. }
  141482. }
  141483. declare module BABYLON {
  141484. interface Scene {
  141485. /** @hidden (Backing field) */
  141486. _boundingBoxRenderer: BoundingBoxRenderer;
  141487. /** @hidden (Backing field) */
  141488. _forceShowBoundingBoxes: boolean;
  141489. /**
  141490. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141491. */
  141492. forceShowBoundingBoxes: boolean;
  141493. /**
  141494. * Gets the bounding box renderer associated with the scene
  141495. * @returns a BoundingBoxRenderer
  141496. */
  141497. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141498. }
  141499. interface AbstractMesh {
  141500. /** @hidden (Backing field) */
  141501. _showBoundingBox: boolean;
  141502. /**
  141503. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141504. */
  141505. showBoundingBox: boolean;
  141506. }
  141507. /**
  141508. * Component responsible of rendering the bounding box of the meshes in a scene.
  141509. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141510. */
  141511. export class BoundingBoxRenderer implements ISceneComponent {
  141512. /**
  141513. * The component name helpfull to identify the component in the list of scene components.
  141514. */
  141515. readonly name: string;
  141516. /**
  141517. * The scene the component belongs to.
  141518. */
  141519. scene: Scene;
  141520. /**
  141521. * Color of the bounding box lines placed in front of an object
  141522. */
  141523. frontColor: Color3;
  141524. /**
  141525. * Color of the bounding box lines placed behind an object
  141526. */
  141527. backColor: Color3;
  141528. /**
  141529. * Defines if the renderer should show the back lines or not
  141530. */
  141531. showBackLines: boolean;
  141532. /**
  141533. * @hidden
  141534. */
  141535. renderList: SmartArray<BoundingBox>;
  141536. private _colorShader;
  141537. private _vertexBuffers;
  141538. private _indexBuffer;
  141539. private _fillIndexBuffer;
  141540. private _fillIndexData;
  141541. /**
  141542. * Instantiates a new bounding box renderer in a scene.
  141543. * @param scene the scene the renderer renders in
  141544. */
  141545. constructor(scene: Scene);
  141546. /**
  141547. * Registers the component in a given scene
  141548. */
  141549. register(): void;
  141550. private _evaluateSubMesh;
  141551. private _activeMesh;
  141552. private _prepareRessources;
  141553. private _createIndexBuffer;
  141554. /**
  141555. * Rebuilds the elements related to this component in case of
  141556. * context lost for instance.
  141557. */
  141558. rebuild(): void;
  141559. /**
  141560. * @hidden
  141561. */
  141562. reset(): void;
  141563. /**
  141564. * Render the bounding boxes of a specific rendering group
  141565. * @param renderingGroupId defines the rendering group to render
  141566. */
  141567. render(renderingGroupId: number): void;
  141568. /**
  141569. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141570. * @param mesh Define the mesh to render the occlusion bounding box for
  141571. */
  141572. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141573. /**
  141574. * Dispose and release the resources attached to this renderer.
  141575. */
  141576. dispose(): void;
  141577. }
  141578. }
  141579. declare module BABYLON {
  141580. interface Scene {
  141581. /** @hidden (Backing field) */
  141582. _depthRenderer: {
  141583. [id: string]: DepthRenderer;
  141584. };
  141585. /**
  141586. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141587. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141588. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141589. * @returns the created depth renderer
  141590. */
  141591. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141592. /**
  141593. * Disables a depth renderer for a given camera
  141594. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141595. */
  141596. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141597. }
  141598. /**
  141599. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141600. * in several rendering techniques.
  141601. */
  141602. export class DepthRendererSceneComponent implements ISceneComponent {
  141603. /**
  141604. * The component name helpfull to identify the component in the list of scene components.
  141605. */
  141606. readonly name: string;
  141607. /**
  141608. * The scene the component belongs to.
  141609. */
  141610. scene: Scene;
  141611. /**
  141612. * Creates a new instance of the component for the given scene
  141613. * @param scene Defines the scene to register the component in
  141614. */
  141615. constructor(scene: Scene);
  141616. /**
  141617. * Registers the component in a given scene
  141618. */
  141619. register(): void;
  141620. /**
  141621. * Rebuilds the elements related to this component in case of
  141622. * context lost for instance.
  141623. */
  141624. rebuild(): void;
  141625. /**
  141626. * Disposes the component and the associated ressources
  141627. */
  141628. dispose(): void;
  141629. private _gatherRenderTargets;
  141630. private _gatherActiveCameraRenderTargets;
  141631. }
  141632. }
  141633. declare module BABYLON {
  141634. /** @hidden */
  141635. export var outlinePixelShader: {
  141636. name: string;
  141637. shader: string;
  141638. };
  141639. }
  141640. declare module BABYLON {
  141641. /** @hidden */
  141642. export var outlineVertexShader: {
  141643. name: string;
  141644. shader: string;
  141645. };
  141646. }
  141647. declare module BABYLON {
  141648. interface Scene {
  141649. /** @hidden */
  141650. _outlineRenderer: OutlineRenderer;
  141651. /**
  141652. * Gets the outline renderer associated with the scene
  141653. * @returns a OutlineRenderer
  141654. */
  141655. getOutlineRenderer(): OutlineRenderer;
  141656. }
  141657. interface AbstractMesh {
  141658. /** @hidden (Backing field) */
  141659. _renderOutline: boolean;
  141660. /**
  141661. * Gets or sets a boolean indicating if the outline must be rendered as well
  141662. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141663. */
  141664. renderOutline: boolean;
  141665. /** @hidden (Backing field) */
  141666. _renderOverlay: boolean;
  141667. /**
  141668. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141669. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141670. */
  141671. renderOverlay: boolean;
  141672. }
  141673. /**
  141674. * This class is responsible to draw bothe outline/overlay of meshes.
  141675. * It should not be used directly but through the available method on mesh.
  141676. */
  141677. export class OutlineRenderer implements ISceneComponent {
  141678. /**
  141679. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141680. */
  141681. private static _StencilReference;
  141682. /**
  141683. * The name of the component. Each component must have a unique name.
  141684. */
  141685. name: string;
  141686. /**
  141687. * The scene the component belongs to.
  141688. */
  141689. scene: Scene;
  141690. /**
  141691. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141692. */
  141693. zOffset: number;
  141694. private _engine;
  141695. private _effect;
  141696. private _cachedDefines;
  141697. private _savedDepthWrite;
  141698. /**
  141699. * Instantiates a new outline renderer. (There could be only one per scene).
  141700. * @param scene Defines the scene it belongs to
  141701. */
  141702. constructor(scene: Scene);
  141703. /**
  141704. * Register the component to one instance of a scene.
  141705. */
  141706. register(): void;
  141707. /**
  141708. * Rebuilds the elements related to this component in case of
  141709. * context lost for instance.
  141710. */
  141711. rebuild(): void;
  141712. /**
  141713. * Disposes the component and the associated ressources.
  141714. */
  141715. dispose(): void;
  141716. /**
  141717. * Renders the outline in the canvas.
  141718. * @param subMesh Defines the sumesh to render
  141719. * @param batch Defines the batch of meshes in case of instances
  141720. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141721. */
  141722. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141723. /**
  141724. * Returns whether or not the outline renderer is ready for a given submesh.
  141725. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141726. * @param subMesh Defines the submesh to check readyness for
  141727. * @param useInstances Defines wheter wee are trying to render instances or not
  141728. * @returns true if ready otherwise false
  141729. */
  141730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141731. private _beforeRenderingMesh;
  141732. private _afterRenderingMesh;
  141733. }
  141734. }
  141735. declare module BABYLON {
  141736. /**
  141737. * Defines the basic options interface of a Sprite Frame Source Size.
  141738. */
  141739. export interface ISpriteJSONSpriteSourceSize {
  141740. /**
  141741. * number of the original width of the Frame
  141742. */
  141743. w: number;
  141744. /**
  141745. * number of the original height of the Frame
  141746. */
  141747. h: number;
  141748. }
  141749. /**
  141750. * Defines the basic options interface of a Sprite Frame Data.
  141751. */
  141752. export interface ISpriteJSONSpriteFrameData {
  141753. /**
  141754. * number of the x offset of the Frame
  141755. */
  141756. x: number;
  141757. /**
  141758. * number of the y offset of the Frame
  141759. */
  141760. y: number;
  141761. /**
  141762. * number of the width of the Frame
  141763. */
  141764. w: number;
  141765. /**
  141766. * number of the height of the Frame
  141767. */
  141768. h: number;
  141769. }
  141770. /**
  141771. * Defines the basic options interface of a JSON Sprite.
  141772. */
  141773. export interface ISpriteJSONSprite {
  141774. /**
  141775. * string name of the Frame
  141776. */
  141777. filename: string;
  141778. /**
  141779. * ISpriteJSONSpriteFrame basic object of the frame data
  141780. */
  141781. frame: ISpriteJSONSpriteFrameData;
  141782. /**
  141783. * boolean to flag is the frame was rotated.
  141784. */
  141785. rotated: boolean;
  141786. /**
  141787. * boolean to flag is the frame was trimmed.
  141788. */
  141789. trimmed: boolean;
  141790. /**
  141791. * ISpriteJSONSpriteFrame basic object of the source data
  141792. */
  141793. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141794. /**
  141795. * ISpriteJSONSpriteFrame basic object of the source data
  141796. */
  141797. sourceSize: ISpriteJSONSpriteSourceSize;
  141798. }
  141799. /**
  141800. * Defines the basic options interface of a JSON atlas.
  141801. */
  141802. export interface ISpriteJSONAtlas {
  141803. /**
  141804. * Array of objects that contain the frame data.
  141805. */
  141806. frames: Array<ISpriteJSONSprite>;
  141807. /**
  141808. * object basic object containing the sprite meta data.
  141809. */
  141810. meta?: object;
  141811. }
  141812. }
  141813. declare module BABYLON {
  141814. /** @hidden */
  141815. export var spriteMapPixelShader: {
  141816. name: string;
  141817. shader: string;
  141818. };
  141819. }
  141820. declare module BABYLON {
  141821. /** @hidden */
  141822. export var spriteMapVertexShader: {
  141823. name: string;
  141824. shader: string;
  141825. };
  141826. }
  141827. declare module BABYLON {
  141828. /**
  141829. * Defines the basic options interface of a SpriteMap
  141830. */
  141831. export interface ISpriteMapOptions {
  141832. /**
  141833. * Vector2 of the number of cells in the grid.
  141834. */
  141835. stageSize?: Vector2;
  141836. /**
  141837. * Vector2 of the size of the output plane in World Units.
  141838. */
  141839. outputSize?: Vector2;
  141840. /**
  141841. * Vector3 of the position of the output plane in World Units.
  141842. */
  141843. outputPosition?: Vector3;
  141844. /**
  141845. * Vector3 of the rotation of the output plane.
  141846. */
  141847. outputRotation?: Vector3;
  141848. /**
  141849. * number of layers that the system will reserve in resources.
  141850. */
  141851. layerCount?: number;
  141852. /**
  141853. * number of max animation frames a single cell will reserve in resources.
  141854. */
  141855. maxAnimationFrames?: number;
  141856. /**
  141857. * number cell index of the base tile when the system compiles.
  141858. */
  141859. baseTile?: number;
  141860. /**
  141861. * boolean flip the sprite after its been repositioned by the framing data.
  141862. */
  141863. flipU?: boolean;
  141864. /**
  141865. * Vector3 scalar of the global RGB values of the SpriteMap.
  141866. */
  141867. colorMultiply?: Vector3;
  141868. }
  141869. /**
  141870. * Defines the IDisposable interface in order to be cleanable from resources.
  141871. */
  141872. export interface ISpriteMap extends IDisposable {
  141873. /**
  141874. * String name of the SpriteMap.
  141875. */
  141876. name: string;
  141877. /**
  141878. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141879. */
  141880. atlasJSON: ISpriteJSONAtlas;
  141881. /**
  141882. * Texture of the SpriteMap.
  141883. */
  141884. spriteSheet: Texture;
  141885. /**
  141886. * The parameters to initialize the SpriteMap with.
  141887. */
  141888. options: ISpriteMapOptions;
  141889. }
  141890. /**
  141891. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141892. */
  141893. export class SpriteMap implements ISpriteMap {
  141894. /** The Name of the spriteMap */
  141895. name: string;
  141896. /** The JSON file with the frame and meta data */
  141897. atlasJSON: ISpriteJSONAtlas;
  141898. /** The systems Sprite Sheet Texture */
  141899. spriteSheet: Texture;
  141900. /** Arguments passed with the Constructor */
  141901. options: ISpriteMapOptions;
  141902. /** Public Sprite Storage array, parsed from atlasJSON */
  141903. sprites: Array<ISpriteJSONSprite>;
  141904. /** Returns the Number of Sprites in the System */
  141905. get spriteCount(): number;
  141906. /** Returns the Position of Output Plane*/
  141907. get position(): Vector3;
  141908. /** Returns the Position of Output Plane*/
  141909. set position(v: Vector3);
  141910. /** Returns the Rotation of Output Plane*/
  141911. get rotation(): Vector3;
  141912. /** Returns the Rotation of Output Plane*/
  141913. set rotation(v: Vector3);
  141914. /** Sets the AnimationMap*/
  141915. get animationMap(): RawTexture;
  141916. /** Sets the AnimationMap*/
  141917. set animationMap(v: RawTexture);
  141918. /** Scene that the SpriteMap was created in */
  141919. private _scene;
  141920. /** Texture Buffer of Float32 that holds tile frame data*/
  141921. private _frameMap;
  141922. /** Texture Buffers of Float32 that holds tileMap data*/
  141923. private _tileMaps;
  141924. /** Texture Buffer of Float32 that holds Animation Data*/
  141925. private _animationMap;
  141926. /** Custom ShaderMaterial Central to the System*/
  141927. private _material;
  141928. /** Custom ShaderMaterial Central to the System*/
  141929. private _output;
  141930. /** Systems Time Ticker*/
  141931. private _time;
  141932. /**
  141933. * Creates a new SpriteMap
  141934. * @param name defines the SpriteMaps Name
  141935. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141936. * @param spriteSheet is the Texture that the Sprites are on.
  141937. * @param options a basic deployment configuration
  141938. * @param scene The Scene that the map is deployed on
  141939. */
  141940. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141941. /**
  141942. * Returns tileID location
  141943. * @returns Vector2 the cell position ID
  141944. */
  141945. getTileID(): Vector2;
  141946. /**
  141947. * Gets the UV location of the mouse over the SpriteMap.
  141948. * @returns Vector2 the UV position of the mouse interaction
  141949. */
  141950. getMousePosition(): Vector2;
  141951. /**
  141952. * Creates the "frame" texture Buffer
  141953. * -------------------------------------
  141954. * Structure of frames
  141955. * "filename": "Falling-Water-2.png",
  141956. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141957. * "rotated": true,
  141958. * "trimmed": true,
  141959. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141960. * "sourceSize": {"w":32,"h":32}
  141961. * @returns RawTexture of the frameMap
  141962. */
  141963. private _createFrameBuffer;
  141964. /**
  141965. * Creates the tileMap texture Buffer
  141966. * @param buffer normally and array of numbers, or a false to generate from scratch
  141967. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  141968. * @returns RawTexture of the tileMap
  141969. */
  141970. private _createTileBuffer;
  141971. /**
  141972. * Modifies the data of the tileMaps
  141973. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  141974. * @param pos is the iVector2 Coordinates of the Tile
  141975. * @param tile The SpriteIndex of the new Tile
  141976. */
  141977. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  141978. /**
  141979. * Creates the animationMap texture Buffer
  141980. * @param buffer normally and array of numbers, or a false to generate from scratch
  141981. * @returns RawTexture of the animationMap
  141982. */
  141983. private _createTileAnimationBuffer;
  141984. /**
  141985. * Modifies the data of the animationMap
  141986. * @param cellID is the Index of the Sprite
  141987. * @param _frame is the target Animation frame
  141988. * @param toCell is the Target Index of the next frame of the animation
  141989. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  141990. * @param speed is a global scalar of the time variable on the map.
  141991. */
  141992. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  141993. /**
  141994. * Exports the .tilemaps file
  141995. */
  141996. saveTileMaps(): void;
  141997. /**
  141998. * Imports the .tilemaps file
  141999. * @param url of the .tilemaps file
  142000. */
  142001. loadTileMaps(url: string): void;
  142002. /**
  142003. * Release associated resources
  142004. */
  142005. dispose(): void;
  142006. }
  142007. }
  142008. declare module BABYLON {
  142009. /**
  142010. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142011. * @see http://doc.babylonjs.com/babylon101/sprites
  142012. */
  142013. export class SpritePackedManager extends SpriteManager {
  142014. /** defines the packed manager's name */
  142015. name: string;
  142016. /**
  142017. * Creates a new sprite manager from a packed sprite sheet
  142018. * @param name defines the manager's name
  142019. * @param imgUrl defines the sprite sheet url
  142020. * @param capacity defines the maximum allowed number of sprites
  142021. * @param scene defines the hosting scene
  142022. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142023. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142024. * @param samplingMode defines the smapling mode to use with spritesheet
  142025. * @param fromPacked set to true; do not alter
  142026. */
  142027. constructor(
  142028. /** defines the packed manager's name */
  142029. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142030. }
  142031. }
  142032. declare module BABYLON {
  142033. /**
  142034. * Defines the list of states available for a task inside a AssetsManager
  142035. */
  142036. export enum AssetTaskState {
  142037. /**
  142038. * Initialization
  142039. */
  142040. INIT = 0,
  142041. /**
  142042. * Running
  142043. */
  142044. RUNNING = 1,
  142045. /**
  142046. * Done
  142047. */
  142048. DONE = 2,
  142049. /**
  142050. * Error
  142051. */
  142052. ERROR = 3
  142053. }
  142054. /**
  142055. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142056. */
  142057. export abstract class AbstractAssetTask {
  142058. /**
  142059. * Task name
  142060. */ name: string;
  142061. /**
  142062. * Callback called when the task is successful
  142063. */
  142064. onSuccess: (task: any) => void;
  142065. /**
  142066. * Callback called when the task is not successful
  142067. */
  142068. onError: (task: any, message?: string, exception?: any) => void;
  142069. /**
  142070. * Creates a new AssetsManager
  142071. * @param name defines the name of the task
  142072. */
  142073. constructor(
  142074. /**
  142075. * Task name
  142076. */ name: string);
  142077. private _isCompleted;
  142078. private _taskState;
  142079. private _errorObject;
  142080. /**
  142081. * Get if the task is completed
  142082. */
  142083. get isCompleted(): boolean;
  142084. /**
  142085. * Gets the current state of the task
  142086. */
  142087. get taskState(): AssetTaskState;
  142088. /**
  142089. * Gets the current error object (if task is in error)
  142090. */
  142091. get errorObject(): {
  142092. message?: string;
  142093. exception?: any;
  142094. };
  142095. /**
  142096. * Internal only
  142097. * @hidden
  142098. */
  142099. _setErrorObject(message?: string, exception?: any): void;
  142100. /**
  142101. * Execute the current task
  142102. * @param scene defines the scene where you want your assets to be loaded
  142103. * @param onSuccess is a callback called when the task is successfully executed
  142104. * @param onError is a callback called if an error occurs
  142105. */
  142106. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142107. /**
  142108. * Execute the current task
  142109. * @param scene defines the scene where you want your assets to be loaded
  142110. * @param onSuccess is a callback called when the task is successfully executed
  142111. * @param onError is a callback called if an error occurs
  142112. */
  142113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142114. /**
  142115. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142116. * This can be used with failed tasks that have the reason for failure fixed.
  142117. */
  142118. reset(): void;
  142119. private onErrorCallback;
  142120. private onDoneCallback;
  142121. }
  142122. /**
  142123. * Define the interface used by progress events raised during assets loading
  142124. */
  142125. export interface IAssetsProgressEvent {
  142126. /**
  142127. * Defines the number of remaining tasks to process
  142128. */
  142129. remainingCount: number;
  142130. /**
  142131. * Defines the total number of tasks
  142132. */
  142133. totalCount: number;
  142134. /**
  142135. * Defines the task that was just processed
  142136. */
  142137. task: AbstractAssetTask;
  142138. }
  142139. /**
  142140. * Class used to share progress information about assets loading
  142141. */
  142142. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142143. /**
  142144. * Defines the number of remaining tasks to process
  142145. */
  142146. remainingCount: number;
  142147. /**
  142148. * Defines the total number of tasks
  142149. */
  142150. totalCount: number;
  142151. /**
  142152. * Defines the task that was just processed
  142153. */
  142154. task: AbstractAssetTask;
  142155. /**
  142156. * Creates a AssetsProgressEvent
  142157. * @param remainingCount defines the number of remaining tasks to process
  142158. * @param totalCount defines the total number of tasks
  142159. * @param task defines the task that was just processed
  142160. */
  142161. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142162. }
  142163. /**
  142164. * Define a task used by AssetsManager to load meshes
  142165. */
  142166. export class MeshAssetTask extends AbstractAssetTask {
  142167. /**
  142168. * Defines the name of the task
  142169. */
  142170. name: string;
  142171. /**
  142172. * Defines the list of mesh's names you want to load
  142173. */
  142174. meshesNames: any;
  142175. /**
  142176. * Defines the root url to use as a base to load your meshes and associated resources
  142177. */
  142178. rootUrl: string;
  142179. /**
  142180. * Defines the filename of the scene to load from
  142181. */
  142182. sceneFilename: string;
  142183. /**
  142184. * Gets the list of loaded meshes
  142185. */
  142186. loadedMeshes: Array<AbstractMesh>;
  142187. /**
  142188. * Gets the list of loaded particle systems
  142189. */
  142190. loadedParticleSystems: Array<IParticleSystem>;
  142191. /**
  142192. * Gets the list of loaded skeletons
  142193. */
  142194. loadedSkeletons: Array<Skeleton>;
  142195. /**
  142196. * Gets the list of loaded animation groups
  142197. */
  142198. loadedAnimationGroups: Array<AnimationGroup>;
  142199. /**
  142200. * Callback called when the task is successful
  142201. */
  142202. onSuccess: (task: MeshAssetTask) => void;
  142203. /**
  142204. * Callback called when the task is successful
  142205. */
  142206. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142207. /**
  142208. * Creates a new MeshAssetTask
  142209. * @param name defines the name of the task
  142210. * @param meshesNames defines the list of mesh's names you want to load
  142211. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142212. * @param sceneFilename defines the filename of the scene to load from
  142213. */
  142214. constructor(
  142215. /**
  142216. * Defines the name of the task
  142217. */
  142218. name: string,
  142219. /**
  142220. * Defines the list of mesh's names you want to load
  142221. */
  142222. meshesNames: any,
  142223. /**
  142224. * Defines the root url to use as a base to load your meshes and associated resources
  142225. */
  142226. rootUrl: string,
  142227. /**
  142228. * Defines the filename of the scene to load from
  142229. */
  142230. sceneFilename: string);
  142231. /**
  142232. * Execute the current task
  142233. * @param scene defines the scene where you want your assets to be loaded
  142234. * @param onSuccess is a callback called when the task is successfully executed
  142235. * @param onError is a callback called if an error occurs
  142236. */
  142237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142238. }
  142239. /**
  142240. * Define a task used by AssetsManager to load text content
  142241. */
  142242. export class TextFileAssetTask extends AbstractAssetTask {
  142243. /**
  142244. * Defines the name of the task
  142245. */
  142246. name: string;
  142247. /**
  142248. * Defines the location of the file to load
  142249. */
  142250. url: string;
  142251. /**
  142252. * Gets the loaded text string
  142253. */
  142254. text: string;
  142255. /**
  142256. * Callback called when the task is successful
  142257. */
  142258. onSuccess: (task: TextFileAssetTask) => void;
  142259. /**
  142260. * Callback called when the task is successful
  142261. */
  142262. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142263. /**
  142264. * Creates a new TextFileAssetTask object
  142265. * @param name defines the name of the task
  142266. * @param url defines the location of the file to load
  142267. */
  142268. constructor(
  142269. /**
  142270. * Defines the name of the task
  142271. */
  142272. name: string,
  142273. /**
  142274. * Defines the location of the file to load
  142275. */
  142276. url: string);
  142277. /**
  142278. * Execute the current task
  142279. * @param scene defines the scene where you want your assets to be loaded
  142280. * @param onSuccess is a callback called when the task is successfully executed
  142281. * @param onError is a callback called if an error occurs
  142282. */
  142283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142284. }
  142285. /**
  142286. * Define a task used by AssetsManager to load binary data
  142287. */
  142288. export class BinaryFileAssetTask extends AbstractAssetTask {
  142289. /**
  142290. * Defines the name of the task
  142291. */
  142292. name: string;
  142293. /**
  142294. * Defines the location of the file to load
  142295. */
  142296. url: string;
  142297. /**
  142298. * Gets the lodaded data (as an array buffer)
  142299. */
  142300. data: ArrayBuffer;
  142301. /**
  142302. * Callback called when the task is successful
  142303. */
  142304. onSuccess: (task: BinaryFileAssetTask) => void;
  142305. /**
  142306. * Callback called when the task is successful
  142307. */
  142308. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142309. /**
  142310. * Creates a new BinaryFileAssetTask object
  142311. * @param name defines the name of the new task
  142312. * @param url defines the location of the file to load
  142313. */
  142314. constructor(
  142315. /**
  142316. * Defines the name of the task
  142317. */
  142318. name: string,
  142319. /**
  142320. * Defines the location of the file to load
  142321. */
  142322. url: string);
  142323. /**
  142324. * Execute the current task
  142325. * @param scene defines the scene where you want your assets to be loaded
  142326. * @param onSuccess is a callback called when the task is successfully executed
  142327. * @param onError is a callback called if an error occurs
  142328. */
  142329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142330. }
  142331. /**
  142332. * Define a task used by AssetsManager to load images
  142333. */
  142334. export class ImageAssetTask extends AbstractAssetTask {
  142335. /**
  142336. * Defines the name of the task
  142337. */
  142338. name: string;
  142339. /**
  142340. * Defines the location of the image to load
  142341. */
  142342. url: string;
  142343. /**
  142344. * Gets the loaded images
  142345. */
  142346. image: HTMLImageElement;
  142347. /**
  142348. * Callback called when the task is successful
  142349. */
  142350. onSuccess: (task: ImageAssetTask) => void;
  142351. /**
  142352. * Callback called when the task is successful
  142353. */
  142354. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142355. /**
  142356. * Creates a new ImageAssetTask
  142357. * @param name defines the name of the task
  142358. * @param url defines the location of the image to load
  142359. */
  142360. constructor(
  142361. /**
  142362. * Defines the name of the task
  142363. */
  142364. name: string,
  142365. /**
  142366. * Defines the location of the image to load
  142367. */
  142368. url: string);
  142369. /**
  142370. * Execute the current task
  142371. * @param scene defines the scene where you want your assets to be loaded
  142372. * @param onSuccess is a callback called when the task is successfully executed
  142373. * @param onError is a callback called if an error occurs
  142374. */
  142375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142376. }
  142377. /**
  142378. * Defines the interface used by texture loading tasks
  142379. */
  142380. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142381. /**
  142382. * Gets the loaded texture
  142383. */
  142384. texture: TEX;
  142385. }
  142386. /**
  142387. * Define a task used by AssetsManager to load 2D textures
  142388. */
  142389. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142390. /**
  142391. * Defines the name of the task
  142392. */
  142393. name: string;
  142394. /**
  142395. * Defines the location of the file to load
  142396. */
  142397. url: string;
  142398. /**
  142399. * Defines if mipmap should not be generated (default is false)
  142400. */
  142401. noMipmap?: boolean | undefined;
  142402. /**
  142403. * Defines if texture must be inverted on Y axis (default is true)
  142404. */
  142405. invertY: boolean;
  142406. /**
  142407. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142408. */
  142409. samplingMode: number;
  142410. /**
  142411. * Gets the loaded texture
  142412. */
  142413. texture: Texture;
  142414. /**
  142415. * Callback called when the task is successful
  142416. */
  142417. onSuccess: (task: TextureAssetTask) => void;
  142418. /**
  142419. * Callback called when the task is successful
  142420. */
  142421. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142422. /**
  142423. * Creates a new TextureAssetTask object
  142424. * @param name defines the name of the task
  142425. * @param url defines the location of the file to load
  142426. * @param noMipmap defines if mipmap should not be generated (default is false)
  142427. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142428. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142429. */
  142430. constructor(
  142431. /**
  142432. * Defines the name of the task
  142433. */
  142434. name: string,
  142435. /**
  142436. * Defines the location of the file to load
  142437. */
  142438. url: string,
  142439. /**
  142440. * Defines if mipmap should not be generated (default is false)
  142441. */
  142442. noMipmap?: boolean | undefined,
  142443. /**
  142444. * Defines if texture must be inverted on Y axis (default is true)
  142445. */
  142446. invertY?: boolean,
  142447. /**
  142448. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142449. */
  142450. samplingMode?: number);
  142451. /**
  142452. * Execute the current task
  142453. * @param scene defines the scene where you want your assets to be loaded
  142454. * @param onSuccess is a callback called when the task is successfully executed
  142455. * @param onError is a callback called if an error occurs
  142456. */
  142457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142458. }
  142459. /**
  142460. * Define a task used by AssetsManager to load cube textures
  142461. */
  142462. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142463. /**
  142464. * Defines the name of the task
  142465. */
  142466. name: string;
  142467. /**
  142468. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142469. */
  142470. url: string;
  142471. /**
  142472. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142473. */
  142474. extensions?: string[] | undefined;
  142475. /**
  142476. * Defines if mipmaps should not be generated (default is false)
  142477. */
  142478. noMipmap?: boolean | undefined;
  142479. /**
  142480. * Defines the explicit list of files (undefined by default)
  142481. */
  142482. files?: string[] | undefined;
  142483. /**
  142484. * Gets the loaded texture
  142485. */
  142486. texture: CubeTexture;
  142487. /**
  142488. * Callback called when the task is successful
  142489. */
  142490. onSuccess: (task: CubeTextureAssetTask) => void;
  142491. /**
  142492. * Callback called when the task is successful
  142493. */
  142494. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142495. /**
  142496. * Creates a new CubeTextureAssetTask
  142497. * @param name defines the name of the task
  142498. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142499. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142500. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142501. * @param files defines the explicit list of files (undefined by default)
  142502. */
  142503. constructor(
  142504. /**
  142505. * Defines the name of the task
  142506. */
  142507. name: string,
  142508. /**
  142509. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142510. */
  142511. url: string,
  142512. /**
  142513. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142514. */
  142515. extensions?: string[] | undefined,
  142516. /**
  142517. * Defines if mipmaps should not be generated (default is false)
  142518. */
  142519. noMipmap?: boolean | undefined,
  142520. /**
  142521. * Defines the explicit list of files (undefined by default)
  142522. */
  142523. files?: string[] | undefined);
  142524. /**
  142525. * Execute the current task
  142526. * @param scene defines the scene where you want your assets to be loaded
  142527. * @param onSuccess is a callback called when the task is successfully executed
  142528. * @param onError is a callback called if an error occurs
  142529. */
  142530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142531. }
  142532. /**
  142533. * Define a task used by AssetsManager to load HDR cube textures
  142534. */
  142535. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142536. /**
  142537. * Defines the name of the task
  142538. */
  142539. name: string;
  142540. /**
  142541. * Defines the location of the file to load
  142542. */
  142543. url: string;
  142544. /**
  142545. * Defines the desired size (the more it increases the longer the generation will be)
  142546. */
  142547. size: number;
  142548. /**
  142549. * Defines if mipmaps should not be generated (default is false)
  142550. */
  142551. noMipmap: boolean;
  142552. /**
  142553. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142554. */
  142555. generateHarmonics: boolean;
  142556. /**
  142557. * 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)
  142558. */
  142559. gammaSpace: boolean;
  142560. /**
  142561. * Internal Use Only
  142562. */
  142563. reserved: boolean;
  142564. /**
  142565. * Gets the loaded texture
  142566. */
  142567. texture: HDRCubeTexture;
  142568. /**
  142569. * Callback called when the task is successful
  142570. */
  142571. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142572. /**
  142573. * Callback called when the task is successful
  142574. */
  142575. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142576. /**
  142577. * Creates a new HDRCubeTextureAssetTask object
  142578. * @param name defines the name of the task
  142579. * @param url defines the location of the file to load
  142580. * @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.
  142581. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142582. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142583. * @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)
  142584. * @param reserved Internal use only
  142585. */
  142586. constructor(
  142587. /**
  142588. * Defines the name of the task
  142589. */
  142590. name: string,
  142591. /**
  142592. * Defines the location of the file to load
  142593. */
  142594. url: string,
  142595. /**
  142596. * Defines the desired size (the more it increases the longer the generation will be)
  142597. */
  142598. size: number,
  142599. /**
  142600. * Defines if mipmaps should not be generated (default is false)
  142601. */
  142602. noMipmap?: boolean,
  142603. /**
  142604. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142605. */
  142606. generateHarmonics?: boolean,
  142607. /**
  142608. * 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)
  142609. */
  142610. gammaSpace?: boolean,
  142611. /**
  142612. * Internal Use Only
  142613. */
  142614. reserved?: boolean);
  142615. /**
  142616. * Execute the current task
  142617. * @param scene defines the scene where you want your assets to be loaded
  142618. * @param onSuccess is a callback called when the task is successfully executed
  142619. * @param onError is a callback called if an error occurs
  142620. */
  142621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142622. }
  142623. /**
  142624. * Define a task used by AssetsManager to load Equirectangular cube textures
  142625. */
  142626. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142627. /**
  142628. * Defines the name of the task
  142629. */
  142630. name: string;
  142631. /**
  142632. * Defines the location of the file to load
  142633. */
  142634. url: string;
  142635. /**
  142636. * Defines the desired size (the more it increases the longer the generation will be)
  142637. */
  142638. size: number;
  142639. /**
  142640. * Defines if mipmaps should not be generated (default is false)
  142641. */
  142642. noMipmap: boolean;
  142643. /**
  142644. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142645. * but the standard material would require them in Gamma space) (default is true)
  142646. */
  142647. gammaSpace: boolean;
  142648. /**
  142649. * Gets the loaded texture
  142650. */
  142651. texture: EquiRectangularCubeTexture;
  142652. /**
  142653. * Callback called when the task is successful
  142654. */
  142655. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142656. /**
  142657. * Callback called when the task is successful
  142658. */
  142659. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142660. /**
  142661. * Creates a new EquiRectangularCubeTextureAssetTask object
  142662. * @param name defines the name of the task
  142663. * @param url defines the location of the file to load
  142664. * @param size defines the desired size (the more it increases the longer the generation will be)
  142665. * If the size is omitted this implies you are using a preprocessed cubemap.
  142666. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142667. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142668. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142669. * (default is true)
  142670. */
  142671. constructor(
  142672. /**
  142673. * Defines the name of the task
  142674. */
  142675. name: string,
  142676. /**
  142677. * Defines the location of the file to load
  142678. */
  142679. url: string,
  142680. /**
  142681. * Defines the desired size (the more it increases the longer the generation will be)
  142682. */
  142683. size: number,
  142684. /**
  142685. * Defines if mipmaps should not be generated (default is false)
  142686. */
  142687. noMipmap?: boolean,
  142688. /**
  142689. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142690. * but the standard material would require them in Gamma space) (default is true)
  142691. */
  142692. gammaSpace?: boolean);
  142693. /**
  142694. * Execute the current task
  142695. * @param scene defines the scene where you want your assets to be loaded
  142696. * @param onSuccess is a callback called when the task is successfully executed
  142697. * @param onError is a callback called if an error occurs
  142698. */
  142699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142700. }
  142701. /**
  142702. * This class can be used to easily import assets into a scene
  142703. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142704. */
  142705. export class AssetsManager {
  142706. private _scene;
  142707. private _isLoading;
  142708. protected _tasks: AbstractAssetTask[];
  142709. protected _waitingTasksCount: number;
  142710. protected _totalTasksCount: number;
  142711. /**
  142712. * Callback called when all tasks are processed
  142713. */
  142714. onFinish: (tasks: AbstractAssetTask[]) => void;
  142715. /**
  142716. * Callback called when a task is successful
  142717. */
  142718. onTaskSuccess: (task: AbstractAssetTask) => void;
  142719. /**
  142720. * Callback called when a task had an error
  142721. */
  142722. onTaskError: (task: AbstractAssetTask) => void;
  142723. /**
  142724. * Callback called when a task is done (whatever the result is)
  142725. */
  142726. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142727. /**
  142728. * Observable called when all tasks are processed
  142729. */
  142730. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142731. /**
  142732. * Observable called when a task had an error
  142733. */
  142734. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142735. /**
  142736. * Observable called when all tasks were executed
  142737. */
  142738. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142739. /**
  142740. * Observable called when a task is done (whatever the result is)
  142741. */
  142742. onProgressObservable: Observable<IAssetsProgressEvent>;
  142743. /**
  142744. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142746. */
  142747. useDefaultLoadingScreen: boolean;
  142748. /**
  142749. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142750. * when all assets have been downloaded.
  142751. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142752. */
  142753. autoHideLoadingUI: boolean;
  142754. /**
  142755. * Creates a new AssetsManager
  142756. * @param scene defines the scene to work on
  142757. */
  142758. constructor(scene: Scene);
  142759. /**
  142760. * Add a MeshAssetTask to the list of active tasks
  142761. * @param taskName defines the name of the new task
  142762. * @param meshesNames defines the name of meshes to load
  142763. * @param rootUrl defines the root url to use to locate files
  142764. * @param sceneFilename defines the filename of the scene file
  142765. * @returns a new MeshAssetTask object
  142766. */
  142767. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142768. /**
  142769. * Add a TextFileAssetTask to the list of active tasks
  142770. * @param taskName defines the name of the new task
  142771. * @param url defines the url of the file to load
  142772. * @returns a new TextFileAssetTask object
  142773. */
  142774. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142775. /**
  142776. * Add a BinaryFileAssetTask to the list of active tasks
  142777. * @param taskName defines the name of the new task
  142778. * @param url defines the url of the file to load
  142779. * @returns a new BinaryFileAssetTask object
  142780. */
  142781. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142782. /**
  142783. * Add a ImageAssetTask to the list of active tasks
  142784. * @param taskName defines the name of the new task
  142785. * @param url defines the url of the file to load
  142786. * @returns a new ImageAssetTask object
  142787. */
  142788. addImageTask(taskName: string, url: string): ImageAssetTask;
  142789. /**
  142790. * Add a TextureAssetTask to the list of active tasks
  142791. * @param taskName defines the name of the new task
  142792. * @param url defines the url of the file to load
  142793. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142794. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142796. * @returns a new TextureAssetTask object
  142797. */
  142798. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142799. /**
  142800. * Add a CubeTextureAssetTask to the list of active tasks
  142801. * @param taskName defines the name of the new task
  142802. * @param url defines the url of the file to load
  142803. * @param extensions defines the extension to use to load the cube map (can be null)
  142804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142805. * @param files defines the list of files to load (can be null)
  142806. * @returns a new CubeTextureAssetTask object
  142807. */
  142808. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142809. /**
  142810. *
  142811. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142812. * @param taskName defines the name of the new task
  142813. * @param url defines the url of the file to load
  142814. * @param size defines the size you want for the cubemap (can be null)
  142815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142816. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142817. * @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)
  142818. * @param reserved Internal use only
  142819. * @returns a new HDRCubeTextureAssetTask object
  142820. */
  142821. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142822. /**
  142823. *
  142824. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142825. * @param taskName defines the name of the new task
  142826. * @param url defines the url of the file to load
  142827. * @param size defines the size you want for the cubemap (can be null)
  142828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142829. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142830. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142831. * @returns a new EquiRectangularCubeTextureAssetTask object
  142832. */
  142833. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142834. /**
  142835. * Remove a task from the assets manager.
  142836. * @param task the task to remove
  142837. */
  142838. removeTask(task: AbstractAssetTask): void;
  142839. private _decreaseWaitingTasksCount;
  142840. private _runTask;
  142841. /**
  142842. * Reset the AssetsManager and remove all tasks
  142843. * @return the current instance of the AssetsManager
  142844. */
  142845. reset(): AssetsManager;
  142846. /**
  142847. * Start the loading process
  142848. * @return the current instance of the AssetsManager
  142849. */
  142850. load(): AssetsManager;
  142851. /**
  142852. * Start the loading process as an async operation
  142853. * @return a promise returning the list of failed tasks
  142854. */
  142855. loadAsync(): Promise<void>;
  142856. }
  142857. }
  142858. declare module BABYLON {
  142859. /**
  142860. * Wrapper class for promise with external resolve and reject.
  142861. */
  142862. export class Deferred<T> {
  142863. /**
  142864. * The promise associated with this deferred object.
  142865. */
  142866. readonly promise: Promise<T>;
  142867. private _resolve;
  142868. private _reject;
  142869. /**
  142870. * The resolve method of the promise associated with this deferred object.
  142871. */
  142872. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142873. /**
  142874. * The reject method of the promise associated with this deferred object.
  142875. */
  142876. get reject(): (reason?: any) => void;
  142877. /**
  142878. * Constructor for this deferred object.
  142879. */
  142880. constructor();
  142881. }
  142882. }
  142883. declare module BABYLON {
  142884. /**
  142885. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142886. */
  142887. export class MeshExploder {
  142888. private _centerMesh;
  142889. private _meshes;
  142890. private _meshesOrigins;
  142891. private _toCenterVectors;
  142892. private _scaledDirection;
  142893. private _newPosition;
  142894. private _centerPosition;
  142895. /**
  142896. * Explodes meshes from a center mesh.
  142897. * @param meshes The meshes to explode.
  142898. * @param centerMesh The mesh to be center of explosion.
  142899. */
  142900. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142901. private _setCenterMesh;
  142902. /**
  142903. * Get class name
  142904. * @returns "MeshExploder"
  142905. */
  142906. getClassName(): string;
  142907. /**
  142908. * "Exploded meshes"
  142909. * @returns Array of meshes with the centerMesh at index 0.
  142910. */
  142911. getMeshes(): Array<Mesh>;
  142912. /**
  142913. * Explodes meshes giving a specific direction
  142914. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142915. */
  142916. explode(direction?: number): void;
  142917. }
  142918. }
  142919. declare module BABYLON {
  142920. /**
  142921. * Class used to help managing file picking and drag'n'drop
  142922. */
  142923. export class FilesInput {
  142924. /**
  142925. * List of files ready to be loaded
  142926. */
  142927. static get FilesToLoad(): {
  142928. [key: string]: File;
  142929. };
  142930. /**
  142931. * Callback called when a file is processed
  142932. */
  142933. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142934. private _engine;
  142935. private _currentScene;
  142936. private _sceneLoadedCallback;
  142937. private _progressCallback;
  142938. private _additionalRenderLoopLogicCallback;
  142939. private _textureLoadingCallback;
  142940. private _startingProcessingFilesCallback;
  142941. private _onReloadCallback;
  142942. private _errorCallback;
  142943. private _elementToMonitor;
  142944. private _sceneFileToLoad;
  142945. private _filesToLoad;
  142946. /**
  142947. * Creates a new FilesInput
  142948. * @param engine defines the rendering engine
  142949. * @param scene defines the hosting scene
  142950. * @param sceneLoadedCallback callback called when scene is loaded
  142951. * @param progressCallback callback called to track progress
  142952. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142953. * @param textureLoadingCallback callback called when a texture is loading
  142954. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142955. * @param onReloadCallback callback called when a reload is requested
  142956. * @param errorCallback callback call if an error occurs
  142957. */
  142958. 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);
  142959. private _dragEnterHandler;
  142960. private _dragOverHandler;
  142961. private _dropHandler;
  142962. /**
  142963. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142964. * @param elementToMonitor defines the DOM element to track
  142965. */
  142966. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  142967. /**
  142968. * Release all associated resources
  142969. */
  142970. dispose(): void;
  142971. private renderFunction;
  142972. private drag;
  142973. private drop;
  142974. private _traverseFolder;
  142975. private _processFiles;
  142976. /**
  142977. * Load files from a drop event
  142978. * @param event defines the drop event to use as source
  142979. */
  142980. loadFiles(event: any): void;
  142981. private _processReload;
  142982. /**
  142983. * Reload the current scene from the loaded files
  142984. */
  142985. reload(): void;
  142986. }
  142987. }
  142988. declare module BABYLON {
  142989. /**
  142990. * Defines the root class used to create scene optimization to use with SceneOptimizer
  142991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142992. */
  142993. export class SceneOptimization {
  142994. /**
  142995. * Defines the priority of this optimization (0 by default which means first in the list)
  142996. */
  142997. priority: number;
  142998. /**
  142999. * Gets a string describing the action executed by the current optimization
  143000. * @returns description string
  143001. */
  143002. getDescription(): string;
  143003. /**
  143004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143005. * @param scene defines the current scene where to apply this optimization
  143006. * @param optimizer defines the current optimizer
  143007. * @returns true if everything that can be done was applied
  143008. */
  143009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143010. /**
  143011. * Creates the SceneOptimization object
  143012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143013. * @param desc defines the description associated with the optimization
  143014. */
  143015. constructor(
  143016. /**
  143017. * Defines the priority of this optimization (0 by default which means first in the list)
  143018. */
  143019. priority?: number);
  143020. }
  143021. /**
  143022. * Defines an optimization used to reduce the size of render target textures
  143023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143024. */
  143025. export class TextureOptimization extends SceneOptimization {
  143026. /**
  143027. * Defines the priority of this optimization (0 by default which means first in the list)
  143028. */
  143029. priority: number;
  143030. /**
  143031. * 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
  143032. */
  143033. maximumSize: number;
  143034. /**
  143035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143036. */
  143037. step: number;
  143038. /**
  143039. * Gets a string describing the action executed by the current optimization
  143040. * @returns description string
  143041. */
  143042. getDescription(): string;
  143043. /**
  143044. * Creates the TextureOptimization object
  143045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143046. * @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
  143047. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143048. */
  143049. constructor(
  143050. /**
  143051. * Defines the priority of this optimization (0 by default which means first in the list)
  143052. */
  143053. priority?: number,
  143054. /**
  143055. * 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
  143056. */
  143057. maximumSize?: number,
  143058. /**
  143059. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143060. */
  143061. step?: number);
  143062. /**
  143063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143064. * @param scene defines the current scene where to apply this optimization
  143065. * @param optimizer defines the current optimizer
  143066. * @returns true if everything that can be done was applied
  143067. */
  143068. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143069. }
  143070. /**
  143071. * Defines an optimization used to increase or decrease the rendering resolution
  143072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143073. */
  143074. export class HardwareScalingOptimization extends SceneOptimization {
  143075. /**
  143076. * Defines the priority of this optimization (0 by default which means first in the list)
  143077. */
  143078. priority: number;
  143079. /**
  143080. * Defines the maximum scale to use (2 by default)
  143081. */
  143082. maximumScale: number;
  143083. /**
  143084. * Defines the step to use between two passes (0.5 by default)
  143085. */
  143086. step: number;
  143087. private _currentScale;
  143088. private _directionOffset;
  143089. /**
  143090. * Gets a string describing the action executed by the current optimization
  143091. * @return description string
  143092. */
  143093. getDescription(): string;
  143094. /**
  143095. * Creates the HardwareScalingOptimization object
  143096. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143097. * @param maximumScale defines the maximum scale to use (2 by default)
  143098. * @param step defines the step to use between two passes (0.5 by default)
  143099. */
  143100. constructor(
  143101. /**
  143102. * Defines the priority of this optimization (0 by default which means first in the list)
  143103. */
  143104. priority?: number,
  143105. /**
  143106. * Defines the maximum scale to use (2 by default)
  143107. */
  143108. maximumScale?: number,
  143109. /**
  143110. * Defines the step to use between two passes (0.5 by default)
  143111. */
  143112. step?: number);
  143113. /**
  143114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143115. * @param scene defines the current scene where to apply this optimization
  143116. * @param optimizer defines the current optimizer
  143117. * @returns true if everything that can be done was applied
  143118. */
  143119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143120. }
  143121. /**
  143122. * Defines an optimization used to remove shadows
  143123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143124. */
  143125. export class ShadowsOptimization extends SceneOptimization {
  143126. /**
  143127. * Gets a string describing the action executed by the current optimization
  143128. * @return description string
  143129. */
  143130. getDescription(): string;
  143131. /**
  143132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143133. * @param scene defines the current scene where to apply this optimization
  143134. * @param optimizer defines the current optimizer
  143135. * @returns true if everything that can be done was applied
  143136. */
  143137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143138. }
  143139. /**
  143140. * Defines an optimization used to turn post-processes off
  143141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143142. */
  143143. export class PostProcessesOptimization extends SceneOptimization {
  143144. /**
  143145. * Gets a string describing the action executed by the current optimization
  143146. * @return description string
  143147. */
  143148. getDescription(): string;
  143149. /**
  143150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143151. * @param scene defines the current scene where to apply this optimization
  143152. * @param optimizer defines the current optimizer
  143153. * @returns true if everything that can be done was applied
  143154. */
  143155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143156. }
  143157. /**
  143158. * Defines an optimization used to turn lens flares off
  143159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143160. */
  143161. export class LensFlaresOptimization extends SceneOptimization {
  143162. /**
  143163. * Gets a string describing the action executed by the current optimization
  143164. * @return description string
  143165. */
  143166. getDescription(): string;
  143167. /**
  143168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143169. * @param scene defines the current scene where to apply this optimization
  143170. * @param optimizer defines the current optimizer
  143171. * @returns true if everything that can be done was applied
  143172. */
  143173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143174. }
  143175. /**
  143176. * Defines an optimization based on user defined callback.
  143177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143178. */
  143179. export class CustomOptimization extends SceneOptimization {
  143180. /**
  143181. * Callback called to apply the custom optimization.
  143182. */
  143183. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143184. /**
  143185. * Callback called to get custom description
  143186. */
  143187. onGetDescription: () => string;
  143188. /**
  143189. * Gets a string describing the action executed by the current optimization
  143190. * @returns description string
  143191. */
  143192. getDescription(): string;
  143193. /**
  143194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143195. * @param scene defines the current scene where to apply this optimization
  143196. * @param optimizer defines the current optimizer
  143197. * @returns true if everything that can be done was applied
  143198. */
  143199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143200. }
  143201. /**
  143202. * Defines an optimization used to turn particles off
  143203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143204. */
  143205. export class ParticlesOptimization extends SceneOptimization {
  143206. /**
  143207. * Gets a string describing the action executed by the current optimization
  143208. * @return description string
  143209. */
  143210. getDescription(): string;
  143211. /**
  143212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143213. * @param scene defines the current scene where to apply this optimization
  143214. * @param optimizer defines the current optimizer
  143215. * @returns true if everything that can be done was applied
  143216. */
  143217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143218. }
  143219. /**
  143220. * Defines an optimization used to turn render targets off
  143221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143222. */
  143223. export class RenderTargetsOptimization extends SceneOptimization {
  143224. /**
  143225. * Gets a string describing the action executed by the current optimization
  143226. * @return description string
  143227. */
  143228. getDescription(): string;
  143229. /**
  143230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143231. * @param scene defines the current scene where to apply this optimization
  143232. * @param optimizer defines the current optimizer
  143233. * @returns true if everything that can be done was applied
  143234. */
  143235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143236. }
  143237. /**
  143238. * Defines an optimization used to merge meshes with compatible materials
  143239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143240. */
  143241. export class MergeMeshesOptimization extends SceneOptimization {
  143242. private static _UpdateSelectionTree;
  143243. /**
  143244. * Gets or sets a boolean which defines if optimization octree has to be updated
  143245. */
  143246. static get UpdateSelectionTree(): boolean;
  143247. /**
  143248. * Gets or sets a boolean which defines if optimization octree has to be updated
  143249. */
  143250. static set UpdateSelectionTree(value: boolean);
  143251. /**
  143252. * Gets a string describing the action executed by the current optimization
  143253. * @return description string
  143254. */
  143255. getDescription(): string;
  143256. private _canBeMerged;
  143257. /**
  143258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143259. * @param scene defines the current scene where to apply this optimization
  143260. * @param optimizer defines the current optimizer
  143261. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143262. * @returns true if everything that can be done was applied
  143263. */
  143264. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143265. }
  143266. /**
  143267. * Defines a list of options used by SceneOptimizer
  143268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143269. */
  143270. export class SceneOptimizerOptions {
  143271. /**
  143272. * Defines the target frame rate to reach (60 by default)
  143273. */
  143274. targetFrameRate: number;
  143275. /**
  143276. * Defines the interval between two checkes (2000ms by default)
  143277. */
  143278. trackerDuration: number;
  143279. /**
  143280. * Gets the list of optimizations to apply
  143281. */
  143282. optimizations: SceneOptimization[];
  143283. /**
  143284. * Creates a new list of options used by SceneOptimizer
  143285. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143286. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143287. */
  143288. constructor(
  143289. /**
  143290. * Defines the target frame rate to reach (60 by default)
  143291. */
  143292. targetFrameRate?: number,
  143293. /**
  143294. * Defines the interval between two checkes (2000ms by default)
  143295. */
  143296. trackerDuration?: number);
  143297. /**
  143298. * Add a new optimization
  143299. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143300. * @returns the current SceneOptimizerOptions
  143301. */
  143302. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143303. /**
  143304. * Add a new custom optimization
  143305. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143306. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143307. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143308. * @returns the current SceneOptimizerOptions
  143309. */
  143310. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143311. /**
  143312. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143313. * @param targetFrameRate defines the target frame rate (60 by default)
  143314. * @returns a SceneOptimizerOptions object
  143315. */
  143316. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143317. /**
  143318. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143319. * @param targetFrameRate defines the target frame rate (60 by default)
  143320. * @returns a SceneOptimizerOptions object
  143321. */
  143322. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143323. /**
  143324. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143325. * @param targetFrameRate defines the target frame rate (60 by default)
  143326. * @returns a SceneOptimizerOptions object
  143327. */
  143328. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143329. }
  143330. /**
  143331. * Class used to run optimizations in order to reach a target frame rate
  143332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143333. */
  143334. export class SceneOptimizer implements IDisposable {
  143335. private _isRunning;
  143336. private _options;
  143337. private _scene;
  143338. private _currentPriorityLevel;
  143339. private _targetFrameRate;
  143340. private _trackerDuration;
  143341. private _currentFrameRate;
  143342. private _sceneDisposeObserver;
  143343. private _improvementMode;
  143344. /**
  143345. * Defines an observable called when the optimizer reaches the target frame rate
  143346. */
  143347. onSuccessObservable: Observable<SceneOptimizer>;
  143348. /**
  143349. * Defines an observable called when the optimizer enables an optimization
  143350. */
  143351. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143352. /**
  143353. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143354. */
  143355. onFailureObservable: Observable<SceneOptimizer>;
  143356. /**
  143357. * Gets a boolean indicating if the optimizer is in improvement mode
  143358. */
  143359. get isInImprovementMode(): boolean;
  143360. /**
  143361. * Gets the current priority level (0 at start)
  143362. */
  143363. get currentPriorityLevel(): number;
  143364. /**
  143365. * Gets the current frame rate checked by the SceneOptimizer
  143366. */
  143367. get currentFrameRate(): number;
  143368. /**
  143369. * Gets or sets the current target frame rate (60 by default)
  143370. */
  143371. get targetFrameRate(): number;
  143372. /**
  143373. * Gets or sets the current target frame rate (60 by default)
  143374. */
  143375. set targetFrameRate(value: number);
  143376. /**
  143377. * Gets or sets the current interval between two checks (every 2000ms by default)
  143378. */
  143379. get trackerDuration(): number;
  143380. /**
  143381. * Gets or sets the current interval between two checks (every 2000ms by default)
  143382. */
  143383. set trackerDuration(value: number);
  143384. /**
  143385. * Gets the list of active optimizations
  143386. */
  143387. get optimizations(): SceneOptimization[];
  143388. /**
  143389. * Creates a new SceneOptimizer
  143390. * @param scene defines the scene to work on
  143391. * @param options defines the options to use with the SceneOptimizer
  143392. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143393. * @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)
  143394. */
  143395. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143396. /**
  143397. * Stops the current optimizer
  143398. */
  143399. stop(): void;
  143400. /**
  143401. * Reset the optimizer to initial step (current priority level = 0)
  143402. */
  143403. reset(): void;
  143404. /**
  143405. * Start the optimizer. By default it will try to reach a specific framerate
  143406. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143407. */
  143408. start(): void;
  143409. private _checkCurrentState;
  143410. /**
  143411. * Release all resources
  143412. */
  143413. dispose(): void;
  143414. /**
  143415. * Helper function to create a SceneOptimizer with one single line of code
  143416. * @param scene defines the scene to work on
  143417. * @param options defines the options to use with the SceneOptimizer
  143418. * @param onSuccess defines a callback to call on success
  143419. * @param onFailure defines a callback to call on failure
  143420. * @returns the new SceneOptimizer object
  143421. */
  143422. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143423. }
  143424. }
  143425. declare module BABYLON {
  143426. /**
  143427. * Class used to serialize a scene into a string
  143428. */
  143429. export class SceneSerializer {
  143430. /**
  143431. * Clear cache used by a previous serialization
  143432. */
  143433. static ClearCache(): void;
  143434. /**
  143435. * Serialize a scene into a JSON compatible object
  143436. * @param scene defines the scene to serialize
  143437. * @returns a JSON compatible object
  143438. */
  143439. static Serialize(scene: Scene): any;
  143440. /**
  143441. * Serialize a mesh into a JSON compatible object
  143442. * @param toSerialize defines the mesh to serialize
  143443. * @param withParents defines if parents must be serialized as well
  143444. * @param withChildren defines if children must be serialized as well
  143445. * @returns a JSON compatible object
  143446. */
  143447. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143448. }
  143449. }
  143450. declare module BABYLON {
  143451. /**
  143452. * Class used to host texture specific utilities
  143453. */
  143454. export class TextureTools {
  143455. /**
  143456. * Uses the GPU to create a copy texture rescaled at a given size
  143457. * @param texture Texture to copy from
  143458. * @param width defines the desired width
  143459. * @param height defines the desired height
  143460. * @param useBilinearMode defines if bilinear mode has to be used
  143461. * @return the generated texture
  143462. */
  143463. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143464. }
  143465. }
  143466. declare module BABYLON {
  143467. /**
  143468. * This represents the different options available for the video capture.
  143469. */
  143470. export interface VideoRecorderOptions {
  143471. /** Defines the mime type of the video. */
  143472. mimeType: string;
  143473. /** Defines the FPS the video should be recorded at. */
  143474. fps: number;
  143475. /** Defines the chunk size for the recording data. */
  143476. recordChunckSize: number;
  143477. /** The audio tracks to attach to the recording. */
  143478. audioTracks?: MediaStreamTrack[];
  143479. }
  143480. /**
  143481. * This can help with recording videos from BabylonJS.
  143482. * This is based on the available WebRTC functionalities of the browser.
  143483. *
  143484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143485. */
  143486. export class VideoRecorder {
  143487. private static readonly _defaultOptions;
  143488. /**
  143489. * Returns whether or not the VideoRecorder is available in your browser.
  143490. * @param engine Defines the Babylon Engine.
  143491. * @returns true if supported otherwise false.
  143492. */
  143493. static IsSupported(engine: Engine): boolean;
  143494. private readonly _options;
  143495. private _canvas;
  143496. private _mediaRecorder;
  143497. private _recordedChunks;
  143498. private _fileName;
  143499. private _resolve;
  143500. private _reject;
  143501. /**
  143502. * True when a recording is already in progress.
  143503. */
  143504. get isRecording(): boolean;
  143505. /**
  143506. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143507. * @param engine Defines the BabylonJS Engine you wish to record.
  143508. * @param options Defines options that can be used to customize the capture.
  143509. */
  143510. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143511. /**
  143512. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143513. */
  143514. stopRecording(): void;
  143515. /**
  143516. * Starts recording the canvas for a max duration specified in parameters.
  143517. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143518. * If null no automatic download will start and you can rely on the promise to get the data back.
  143519. * @param maxDuration Defines the maximum recording time in seconds.
  143520. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143521. * @return A promise callback at the end of the recording with the video data in Blob.
  143522. */
  143523. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143524. /**
  143525. * Releases internal resources used during the recording.
  143526. */
  143527. dispose(): void;
  143528. private _handleDataAvailable;
  143529. private _handleError;
  143530. private _handleStop;
  143531. }
  143532. }
  143533. declare module BABYLON {
  143534. /**
  143535. * Class containing a set of static utilities functions for screenshots
  143536. */
  143537. export class ScreenshotTools {
  143538. /**
  143539. * Captures a screenshot of the current rendering
  143540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143541. * @param engine defines the rendering engine
  143542. * @param camera defines the source camera
  143543. * @param size This parameter can be set to a single number or to an object with the
  143544. * following (optional) properties: precision, width, height. If a single number is passed,
  143545. * it will be used for both width and height. If an object is passed, the screenshot size
  143546. * will be derived from the parameters. The precision property is a multiplier allowing
  143547. * rendering at a higher or lower resolution
  143548. * @param successCallback defines the callback receives a single parameter which contains the
  143549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143550. * src parameter of an <img> to display it
  143551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143552. * Check your browser for supported MIME types
  143553. */
  143554. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143555. /**
  143556. * Captures a screenshot of the current rendering
  143557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143558. * @param engine defines the rendering engine
  143559. * @param camera defines the source camera
  143560. * @param size This parameter can be set to a single number or to an object with the
  143561. * following (optional) properties: precision, width, height. If a single number is passed,
  143562. * it will be used for both width and height. If an object is passed, the screenshot size
  143563. * will be derived from the parameters. The precision property is a multiplier allowing
  143564. * rendering at a higher or lower resolution
  143565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143566. * Check your browser for supported MIME types
  143567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143568. * to the src parameter of an <img> to display it
  143569. */
  143570. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143571. /**
  143572. * Generates an image screenshot from the specified camera.
  143573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143574. * @param engine The engine to use for rendering
  143575. * @param camera The camera to use for rendering
  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 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 The MIME type of the screenshot image (default: image/png).
  143585. * Check your browser for supported MIME types
  143586. * @param samples Texture samples (default: 1)
  143587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143588. * @param fileName A name for for the downloaded file.
  143589. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143590. */
  143591. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143592. /**
  143593. * Generates an image screenshot from the specified camera.
  143594. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143595. * @param engine The engine to use for rendering
  143596. * @param camera The camera to use for rendering
  143597. * @param size This parameter can be set to a single number or to an object with the
  143598. * following (optional) properties: precision, width, height. If a single number is passed,
  143599. * it will be used for both width and height. If an object is passed, the screenshot size
  143600. * will be derived from the parameters. The precision property is a multiplier allowing
  143601. * rendering at a higher or lower resolution
  143602. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143603. * Check your browser for supported MIME types
  143604. * @param samples Texture samples (default: 1)
  143605. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143606. * @param fileName A name for for the downloaded file.
  143607. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143608. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143609. * to the src parameter of an <img> to display it
  143610. */
  143611. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143612. /**
  143613. * Gets height and width for screenshot size
  143614. * @private
  143615. */
  143616. private static _getScreenshotSize;
  143617. }
  143618. }
  143619. declare module BABYLON {
  143620. /**
  143621. * Interface for a data buffer
  143622. */
  143623. export interface IDataBuffer {
  143624. /**
  143625. * Reads bytes from the data buffer.
  143626. * @param byteOffset The byte offset to read
  143627. * @param byteLength The byte length to read
  143628. * @returns A promise that resolves when the bytes are read
  143629. */
  143630. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143631. /**
  143632. * The byte length of the buffer.
  143633. */
  143634. readonly byteLength: number;
  143635. }
  143636. /**
  143637. * Utility class for reading from a data buffer
  143638. */
  143639. export class DataReader {
  143640. /**
  143641. * The data buffer associated with this data reader.
  143642. */
  143643. readonly buffer: IDataBuffer;
  143644. /**
  143645. * The current byte offset from the beginning of the data buffer.
  143646. */
  143647. byteOffset: number;
  143648. private _dataView;
  143649. private _dataByteOffset;
  143650. /**
  143651. * Constructor
  143652. * @param buffer The buffer to read
  143653. */
  143654. constructor(buffer: IDataBuffer);
  143655. /**
  143656. * Loads the given byte length.
  143657. * @param byteLength The byte length to load
  143658. * @returns A promise that resolves when the load is complete
  143659. */
  143660. loadAsync(byteLength: number): Promise<void>;
  143661. /**
  143662. * Read a unsigned 32-bit integer from the currently loaded data range.
  143663. * @returns The 32-bit integer read
  143664. */
  143665. readUint32(): number;
  143666. /**
  143667. * Read a byte array from the currently loaded data range.
  143668. * @param byteLength The byte length to read
  143669. * @returns The byte array read
  143670. */
  143671. readUint8Array(byteLength: number): Uint8Array;
  143672. /**
  143673. * Read a string from the currently loaded data range.
  143674. * @param byteLength The byte length to read
  143675. * @returns The string read
  143676. */
  143677. readString(byteLength: number): string;
  143678. /**
  143679. * Skips the given byte length the currently loaded data range.
  143680. * @param byteLength The byte length to skip
  143681. */
  143682. skipBytes(byteLength: number): void;
  143683. }
  143684. }
  143685. declare module BABYLON {
  143686. /**
  143687. * Class for storing data to local storage if available or in-memory storage otherwise
  143688. */
  143689. export class DataStorage {
  143690. private static _Storage;
  143691. private static _GetStorage;
  143692. /**
  143693. * Reads a string from the data storage
  143694. * @param key The key to read
  143695. * @param defaultValue The value if the key doesn't exist
  143696. * @returns The string value
  143697. */
  143698. static ReadString(key: string, defaultValue: string): string;
  143699. /**
  143700. * Writes a string to the data storage
  143701. * @param key The key to write
  143702. * @param value The value to write
  143703. */
  143704. static WriteString(key: string, value: string): void;
  143705. /**
  143706. * Reads a boolean from the data storage
  143707. * @param key The key to read
  143708. * @param defaultValue The value if the key doesn't exist
  143709. * @returns The boolean value
  143710. */
  143711. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143712. /**
  143713. * Writes a boolean to the data storage
  143714. * @param key The key to write
  143715. * @param value The value to write
  143716. */
  143717. static WriteBoolean(key: string, value: boolean): void;
  143718. /**
  143719. * Reads a number from the data storage
  143720. * @param key The key to read
  143721. * @param defaultValue The value if the key doesn't exist
  143722. * @returns The number value
  143723. */
  143724. static ReadNumber(key: string, defaultValue: number): number;
  143725. /**
  143726. * Writes a number to the data storage
  143727. * @param key The key to write
  143728. * @param value The value to write
  143729. */
  143730. static WriteNumber(key: string, value: number): void;
  143731. }
  143732. }
  143733. declare module BABYLON {
  143734. /**
  143735. * Options used for hit testing
  143736. */
  143737. export interface IWebXRLegacyHitTestOptions {
  143738. /**
  143739. * Only test when user interacted with the scene. Default - hit test every frame
  143740. */
  143741. testOnPointerDownOnly?: boolean;
  143742. /**
  143743. * The node to use to transform the local results to world coordinates
  143744. */
  143745. worldParentNode?: TransformNode;
  143746. }
  143747. /**
  143748. * Interface defining the babylon result of raycasting/hit-test
  143749. */
  143750. export interface IWebXRLegacyHitResult {
  143751. /**
  143752. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143753. */
  143754. transformationMatrix: Matrix;
  143755. /**
  143756. * The native hit test result
  143757. */
  143758. xrHitResult: XRHitResult | XRHitTestResult;
  143759. }
  143760. /**
  143761. * The currently-working hit-test module.
  143762. * Hit test (or Ray-casting) is used to interact with the real world.
  143763. * For further information read here - https://github.com/immersive-web/hit-test
  143764. */
  143765. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143766. /**
  143767. * options to use when constructing this feature
  143768. */
  143769. readonly options: IWebXRLegacyHitTestOptions;
  143770. private _direction;
  143771. private _mat;
  143772. private _onSelectEnabled;
  143773. private _origin;
  143774. /**
  143775. * The module's name
  143776. */
  143777. static readonly Name: string;
  143778. /**
  143779. * The (Babylon) version of this module.
  143780. * This is an integer representing the implementation version.
  143781. * This number does not correspond to the WebXR specs version
  143782. */
  143783. static readonly Version: number;
  143784. /**
  143785. * Populated with the last native XR Hit Results
  143786. */
  143787. lastNativeXRHitResults: XRHitResult[];
  143788. /**
  143789. * Triggered when new babylon (transformed) hit test results are available
  143790. */
  143791. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143792. /**
  143793. * Creates a new instance of the (legacy version) hit test feature
  143794. * @param _xrSessionManager an instance of WebXRSessionManager
  143795. * @param options options to use when constructing this feature
  143796. */
  143797. constructor(_xrSessionManager: WebXRSessionManager,
  143798. /**
  143799. * options to use when constructing this feature
  143800. */
  143801. options?: IWebXRLegacyHitTestOptions);
  143802. /**
  143803. * execute a hit test with an XR Ray
  143804. *
  143805. * @param xrSession a native xrSession that will execute this hit test
  143806. * @param xrRay the ray (position and direction) to use for ray-casting
  143807. * @param referenceSpace native XR reference space to use for the hit-test
  143808. * @param filter filter function that will filter the results
  143809. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143810. */
  143811. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143812. /**
  143813. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143814. * @param event the (select) event to use to select with
  143815. * @param referenceSpace the reference space to use for this hit test
  143816. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143817. */
  143818. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143819. /**
  143820. * attach this feature
  143821. * Will usually be called by the features manager
  143822. *
  143823. * @returns true if successful.
  143824. */
  143825. attach(): boolean;
  143826. /**
  143827. * detach this feature.
  143828. * Will usually be called by the features manager
  143829. *
  143830. * @returns true if successful.
  143831. */
  143832. detach(): boolean;
  143833. /**
  143834. * Dispose this feature and all of the resources attached
  143835. */
  143836. dispose(): void;
  143837. protected _onXRFrame(frame: XRFrame): void;
  143838. private _onHitTestResults;
  143839. private _onSelect;
  143840. }
  143841. }
  143842. declare module BABYLON {
  143843. /**
  143844. * Options used in the plane detector module
  143845. */
  143846. export interface IWebXRPlaneDetectorOptions {
  143847. /**
  143848. * The node to use to transform the local results to world coordinates
  143849. */
  143850. worldParentNode?: TransformNode;
  143851. }
  143852. /**
  143853. * A babylon interface for a WebXR plane.
  143854. * A Plane is actually a polygon, built from N points in space
  143855. *
  143856. * Supported in chrome 79, not supported in canary 81 ATM
  143857. */
  143858. export interface IWebXRPlane {
  143859. /**
  143860. * a babylon-assigned ID for this polygon
  143861. */
  143862. id: number;
  143863. /**
  143864. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143865. */
  143866. polygonDefinition: Array<Vector3>;
  143867. /**
  143868. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143869. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143870. */
  143871. transformationMatrix: Matrix;
  143872. /**
  143873. * the native xr-plane object
  143874. */
  143875. xrPlane: XRPlane;
  143876. }
  143877. /**
  143878. * The plane detector is used to detect planes in the real world when in AR
  143879. * For more information see https://github.com/immersive-web/real-world-geometry/
  143880. */
  143881. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143882. private _options;
  143883. private _detectedPlanes;
  143884. private _enabled;
  143885. private _lastFrameDetected;
  143886. /**
  143887. * The module's name
  143888. */
  143889. static readonly Name: string;
  143890. /**
  143891. * The (Babylon) version of this module.
  143892. * This is an integer representing the implementation version.
  143893. * This number does not correspond to the WebXR specs version
  143894. */
  143895. static readonly Version: number;
  143896. /**
  143897. * Observers registered here will be executed when a new plane was added to the session
  143898. */
  143899. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143900. /**
  143901. * Observers registered here will be executed when a plane is no longer detected in the session
  143902. */
  143903. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143904. /**
  143905. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143906. * This can execute N times every frame
  143907. */
  143908. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143909. /**
  143910. * construct a new Plane Detector
  143911. * @param _xrSessionManager an instance of xr Session manager
  143912. * @param _options configuration to use when constructing this feature
  143913. */
  143914. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143915. /**
  143916. * Dispose this feature and all of the resources attached
  143917. */
  143918. dispose(): void;
  143919. protected _onXRFrame(frame: XRFrame): void;
  143920. private _init;
  143921. private _updatePlaneWithXRPlane;
  143922. /**
  143923. * avoiding using Array.find for global support.
  143924. * @param xrPlane the plane to find in the array
  143925. */
  143926. private findIndexInPlaneArray;
  143927. }
  143928. }
  143929. declare module BABYLON {
  143930. /**
  143931. * Configuration options of the anchor system
  143932. */
  143933. export interface IWebXRAnchorSystemOptions {
  143934. /**
  143935. * Should a new anchor be added every time a select event is triggered
  143936. */
  143937. addAnchorOnSelect?: boolean;
  143938. /**
  143939. * should the anchor system use plane detection.
  143940. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143941. */
  143942. usePlaneDetection?: boolean;
  143943. /**
  143944. * a node that will be used to convert local to world coordinates
  143945. */
  143946. worldParentNode?: TransformNode;
  143947. }
  143948. /**
  143949. * A babylon container for an XR Anchor
  143950. */
  143951. export interface IWebXRAnchor {
  143952. /**
  143953. * A babylon-assigned ID for this anchor
  143954. */
  143955. id: number;
  143956. /**
  143957. * Transformation matrix to apply to an object attached to this anchor
  143958. */
  143959. transformationMatrix: Matrix;
  143960. /**
  143961. * The native anchor object
  143962. */
  143963. xrAnchor: XRAnchor;
  143964. }
  143965. /**
  143966. * An implementation of the anchor system of WebXR.
  143967. * Note that the current documented implementation is not available in any browser. Future implementations
  143968. * will use the frame to create an anchor and not the session or a detected plane
  143969. * For further information see https://github.com/immersive-web/anchors/
  143970. */
  143971. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  143972. private _options;
  143973. private _enabled;
  143974. private _hitTestModule;
  143975. private _lastFrameDetected;
  143976. private _onSelect;
  143977. private _planeDetector;
  143978. private _trackedAnchors;
  143979. /**
  143980. * The module's name
  143981. */
  143982. static readonly Name: string;
  143983. /**
  143984. * The (Babylon) version of this module.
  143985. * This is an integer representing the implementation version.
  143986. * This number does not correspond to the WebXR specs version
  143987. */
  143988. static readonly Version: number;
  143989. /**
  143990. * Observers registered here will be executed when a new anchor was added to the session
  143991. */
  143992. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  143993. /**
  143994. * Observers registered here will be executed when an anchor was removed from the session
  143995. */
  143996. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  143997. /**
  143998. * Observers registered here will be executed when an existing anchor updates
  143999. * This can execute N times every frame
  144000. */
  144001. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144002. /**
  144003. * constructs a new anchor system
  144004. * @param _xrSessionManager an instance of WebXRSessionManager
  144005. * @param _options configuration object for this feature
  144006. */
  144007. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144008. /**
  144009. * Add anchor at a specific XR point.
  144010. *
  144011. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144012. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144013. * @returns a promise the fulfills when the anchor was created
  144014. */
  144015. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144016. /**
  144017. * attach this feature
  144018. * Will usually be called by the features manager
  144019. *
  144020. * @returns true if successful.
  144021. */
  144022. attach(): boolean;
  144023. /**
  144024. * detach this feature.
  144025. * Will usually be called by the features manager
  144026. *
  144027. * @returns true if successful.
  144028. */
  144029. detach(): boolean;
  144030. /**
  144031. * Dispose this feature and all of the resources attached
  144032. */
  144033. dispose(): void;
  144034. /**
  144035. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144036. * @param hitTestModule the hit-test module to use.
  144037. */
  144038. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144039. /**
  144040. * set the plane detector to use in order to create anchors from frames
  144041. * @param planeDetector the plane-detector module to use
  144042. * @param enable enable plane-anchors. default is true
  144043. */
  144044. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144045. protected _onXRFrame(frame: XRFrame): void;
  144046. /**
  144047. * avoiding using Array.find for global support.
  144048. * @param xrAnchor the plane to find in the array
  144049. */
  144050. private _findIndexInAnchorArray;
  144051. private _updateAnchorWithXRFrame;
  144052. }
  144053. }
  144054. declare module BABYLON {
  144055. /**
  144056. * Options interface for the background remover plugin
  144057. */
  144058. export interface IWebXRBackgroundRemoverOptions {
  144059. /**
  144060. * Further background meshes to disable when entering AR
  144061. */
  144062. backgroundMeshes?: AbstractMesh[];
  144063. /**
  144064. * flags to configure the removal of the environment helper.
  144065. * If not set, the entire background will be removed. If set, flags should be set as well.
  144066. */
  144067. environmentHelperRemovalFlags?: {
  144068. /**
  144069. * Should the skybox be removed (default false)
  144070. */
  144071. skyBox?: boolean;
  144072. /**
  144073. * Should the ground be removed (default false)
  144074. */
  144075. ground?: boolean;
  144076. };
  144077. /**
  144078. * don't disable the environment helper
  144079. */
  144080. ignoreEnvironmentHelper?: boolean;
  144081. }
  144082. /**
  144083. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144084. */
  144085. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144086. /**
  144087. * read-only options to be used in this module
  144088. */
  144089. readonly options: IWebXRBackgroundRemoverOptions;
  144090. /**
  144091. * The module's name
  144092. */
  144093. static readonly Name: string;
  144094. /**
  144095. * The (Babylon) version of this module.
  144096. * This is an integer representing the implementation version.
  144097. * This number does not correspond to the WebXR specs version
  144098. */
  144099. static readonly Version: number;
  144100. /**
  144101. * registered observers will be triggered when the background state changes
  144102. */
  144103. onBackgroundStateChangedObservable: Observable<boolean>;
  144104. /**
  144105. * constructs a new background remover module
  144106. * @param _xrSessionManager the session manager for this module
  144107. * @param options read-only options to be used in this module
  144108. */
  144109. constructor(_xrSessionManager: WebXRSessionManager,
  144110. /**
  144111. * read-only options to be used in this module
  144112. */
  144113. options?: IWebXRBackgroundRemoverOptions);
  144114. /**
  144115. * attach this feature
  144116. * Will usually be called by the features manager
  144117. *
  144118. * @returns true if successful.
  144119. */
  144120. attach(): boolean;
  144121. /**
  144122. * detach this feature.
  144123. * Will usually be called by the features manager
  144124. *
  144125. * @returns true if successful.
  144126. */
  144127. detach(): boolean;
  144128. /**
  144129. * Dispose this feature and all of the resources attached
  144130. */
  144131. dispose(): void;
  144132. protected _onXRFrame(_xrFrame: XRFrame): void;
  144133. private _setBackgroundState;
  144134. }
  144135. }
  144136. declare module BABYLON {
  144137. /**
  144138. * Options for the controller physics feature
  144139. */
  144140. export class IWebXRControllerPhysicsOptions {
  144141. /**
  144142. * Should the headset get its own impostor
  144143. */
  144144. enableHeadsetImpostor?: boolean;
  144145. /**
  144146. * Optional parameters for the headset impostor
  144147. */
  144148. headsetImpostorParams?: {
  144149. /**
  144150. * The type of impostor to create. Default is sphere
  144151. */
  144152. impostorType: number;
  144153. /**
  144154. * the size of the impostor. Defaults to 10cm
  144155. */
  144156. impostorSize?: number | {
  144157. width: number;
  144158. height: number;
  144159. depth: number;
  144160. };
  144161. /**
  144162. * Friction definitions
  144163. */
  144164. friction?: number;
  144165. /**
  144166. * Restitution
  144167. */
  144168. restitution?: number;
  144169. };
  144170. /**
  144171. * The physics properties of the future impostors
  144172. */
  144173. physicsProperties?: {
  144174. /**
  144175. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144176. * Note that this requires a physics engine that supports mesh impostors!
  144177. */
  144178. useControllerMesh?: boolean;
  144179. /**
  144180. * The type of impostor to create. Default is sphere
  144181. */
  144182. impostorType?: number;
  144183. /**
  144184. * the size of the impostor. Defaults to 10cm
  144185. */
  144186. impostorSize?: number | {
  144187. width: number;
  144188. height: number;
  144189. depth: number;
  144190. };
  144191. /**
  144192. * Friction definitions
  144193. */
  144194. friction?: number;
  144195. /**
  144196. * Restitution
  144197. */
  144198. restitution?: number;
  144199. };
  144200. /**
  144201. * the xr input to use with this pointer selection
  144202. */
  144203. xrInput: WebXRInput;
  144204. }
  144205. /**
  144206. * Add physics impostor to your webxr controllers,
  144207. * including naive calculation of their linear and angular velocity
  144208. */
  144209. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144210. private readonly _options;
  144211. private _attachController;
  144212. private _controllers;
  144213. private _debugMode;
  144214. private _delta;
  144215. private _headsetImpostor?;
  144216. private _headsetMesh?;
  144217. private _lastTimestamp;
  144218. private _tmpQuaternion;
  144219. private _tmpVector;
  144220. /**
  144221. * The module's name
  144222. */
  144223. static readonly Name: string;
  144224. /**
  144225. * The (Babylon) version of this module.
  144226. * This is an integer representing the implementation version.
  144227. * This number does not correspond to the webxr specs version
  144228. */
  144229. static readonly Version: number;
  144230. /**
  144231. * Construct a new Controller Physics Feature
  144232. * @param _xrSessionManager the corresponding xr session manager
  144233. * @param _options options to create this feature with
  144234. */
  144235. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144236. /**
  144237. * @hidden
  144238. * enable debugging - will show console outputs and the impostor mesh
  144239. */
  144240. _enablePhysicsDebug(): void;
  144241. /**
  144242. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144243. * @param xrController the controller to add
  144244. */
  144245. addController(xrController: WebXRInputSource): void;
  144246. /**
  144247. * attach this feature
  144248. * Will usually be called by the features manager
  144249. *
  144250. * @returns true if successful.
  144251. */
  144252. attach(): boolean;
  144253. /**
  144254. * detach this feature.
  144255. * Will usually be called by the features manager
  144256. *
  144257. * @returns true if successful.
  144258. */
  144259. detach(): boolean;
  144260. /**
  144261. * Get the headset impostor, if enabled
  144262. * @returns the impostor
  144263. */
  144264. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144265. /**
  144266. * Get the physics impostor of a specific controller.
  144267. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144268. * @param controller the controller or the controller id of which to get the impostor
  144269. * @returns the impostor or null
  144270. */
  144271. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144272. /**
  144273. * Update the physics properties provided in the constructor
  144274. * @param newProperties the new properties object
  144275. */
  144276. setPhysicsProperties(newProperties: {
  144277. impostorType?: number;
  144278. impostorSize?: number | {
  144279. width: number;
  144280. height: number;
  144281. depth: number;
  144282. };
  144283. friction?: number;
  144284. restitution?: number;
  144285. }): void;
  144286. protected _onXRFrame(_xrFrame: any): void;
  144287. private _detachController;
  144288. }
  144289. }
  144290. declare module BABYLON {
  144291. /**
  144292. * Options used for hit testing (version 2)
  144293. */
  144294. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144295. /**
  144296. * Do not create a permanent hit test. Will usually be used when only
  144297. * transient inputs are needed.
  144298. */
  144299. disablePermanentHitTest?: boolean;
  144300. /**
  144301. * Enable transient (for example touch-based) hit test inspections
  144302. */
  144303. enableTransientHitTest?: boolean;
  144304. /**
  144305. * Offset ray for the permanent hit test
  144306. */
  144307. offsetRay?: Vector3;
  144308. /**
  144309. * Offset ray for the transient hit test
  144310. */
  144311. transientOffsetRay?: Vector3;
  144312. /**
  144313. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144314. */
  144315. useReferenceSpace?: boolean;
  144316. }
  144317. /**
  144318. * Interface defining the babylon result of hit-test
  144319. */
  144320. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144321. /**
  144322. * The input source that generated this hit test (if transient)
  144323. */
  144324. inputSource?: XRInputSource;
  144325. /**
  144326. * Is this a transient hit test
  144327. */
  144328. isTransient?: boolean;
  144329. /**
  144330. * Position of the hit test result
  144331. */
  144332. position: Vector3;
  144333. /**
  144334. * Rotation of the hit test result
  144335. */
  144336. rotationQuaternion: Quaternion;
  144337. }
  144338. /**
  144339. * The currently-working hit-test module.
  144340. * Hit test (or Ray-casting) is used to interact with the real world.
  144341. * For further information read here - https://github.com/immersive-web/hit-test
  144342. *
  144343. * Tested on chrome (mobile) 80.
  144344. */
  144345. export class WebXRHitTest extends WebXRAbstractFeature {
  144346. /**
  144347. * options to use when constructing this feature
  144348. */
  144349. readonly options: IWebXRHitTestOptions;
  144350. private _tmpMat;
  144351. private _tmpPos;
  144352. private _tmpQuat;
  144353. private _transientXrHitTestSource;
  144354. private _xrHitTestSource;
  144355. private initHitTestSource;
  144356. /**
  144357. * The module's name
  144358. */
  144359. static readonly Name: string;
  144360. /**
  144361. * The (Babylon) version of this module.
  144362. * This is an integer representing the implementation version.
  144363. * This number does not correspond to the WebXR specs version
  144364. */
  144365. static readonly Version: number;
  144366. /**
  144367. * When set to true, each hit test will have its own position/rotation objects
  144368. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144369. * the developers will clone them or copy them as they see fit.
  144370. */
  144371. autoCloneTransformation: boolean;
  144372. /**
  144373. * Populated with the last native XR Hit Results
  144374. */
  144375. lastNativeXRHitResults: XRHitResult[];
  144376. /**
  144377. * Triggered when new babylon (transformed) hit test results are available
  144378. */
  144379. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144380. /**
  144381. * Use this to temporarily pause hit test checks.
  144382. */
  144383. paused: boolean;
  144384. /**
  144385. * Creates a new instance of the hit test feature
  144386. * @param _xrSessionManager an instance of WebXRSessionManager
  144387. * @param options options to use when constructing this feature
  144388. */
  144389. constructor(_xrSessionManager: WebXRSessionManager,
  144390. /**
  144391. * options to use when constructing this feature
  144392. */
  144393. options?: IWebXRHitTestOptions);
  144394. /**
  144395. * attach this feature
  144396. * Will usually be called by the features manager
  144397. *
  144398. * @returns true if successful.
  144399. */
  144400. attach(): boolean;
  144401. /**
  144402. * detach this feature.
  144403. * Will usually be called by the features manager
  144404. *
  144405. * @returns true if successful.
  144406. */
  144407. detach(): boolean;
  144408. /**
  144409. * Dispose this feature and all of the resources attached
  144410. */
  144411. dispose(): void;
  144412. protected _onXRFrame(frame: XRFrame): void;
  144413. private _processWebXRHitTestResult;
  144414. }
  144415. }
  144416. declare module BABYLON {
  144417. /**
  144418. * The motion controller class for all microsoft mixed reality controllers
  144419. */
  144420. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144421. protected readonly _mapping: {
  144422. defaultButton: {
  144423. valueNodeName: string;
  144424. unpressedNodeName: string;
  144425. pressedNodeName: string;
  144426. };
  144427. defaultAxis: {
  144428. valueNodeName: string;
  144429. minNodeName: string;
  144430. maxNodeName: string;
  144431. };
  144432. buttons: {
  144433. "xr-standard-trigger": {
  144434. rootNodeName: string;
  144435. componentProperty: string;
  144436. states: string[];
  144437. };
  144438. "xr-standard-squeeze": {
  144439. rootNodeName: string;
  144440. componentProperty: string;
  144441. states: string[];
  144442. };
  144443. "xr-standard-touchpad": {
  144444. rootNodeName: string;
  144445. labelAnchorNodeName: string;
  144446. touchPointNodeName: string;
  144447. };
  144448. "xr-standard-thumbstick": {
  144449. rootNodeName: string;
  144450. componentProperty: string;
  144451. states: string[];
  144452. };
  144453. };
  144454. axes: {
  144455. "xr-standard-touchpad": {
  144456. "x-axis": {
  144457. rootNodeName: string;
  144458. };
  144459. "y-axis": {
  144460. rootNodeName: string;
  144461. };
  144462. };
  144463. "xr-standard-thumbstick": {
  144464. "x-axis": {
  144465. rootNodeName: string;
  144466. };
  144467. "y-axis": {
  144468. rootNodeName: string;
  144469. };
  144470. };
  144471. };
  144472. };
  144473. /**
  144474. * The base url used to load the left and right controller models
  144475. */
  144476. static MODEL_BASE_URL: string;
  144477. /**
  144478. * The name of the left controller model file
  144479. */
  144480. static MODEL_LEFT_FILENAME: string;
  144481. /**
  144482. * The name of the right controller model file
  144483. */
  144484. static MODEL_RIGHT_FILENAME: string;
  144485. profileId: string;
  144486. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144487. protected _getFilenameAndPath(): {
  144488. filename: string;
  144489. path: string;
  144490. };
  144491. protected _getModelLoadingConstraints(): boolean;
  144492. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144493. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144494. protected _updateModel(): void;
  144495. }
  144496. }
  144497. declare module BABYLON {
  144498. /**
  144499. * The motion controller class for oculus touch (quest, rift).
  144500. * This class supports legacy mapping as well the standard xr mapping
  144501. */
  144502. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144503. private _forceLegacyControllers;
  144504. private _modelRootNode;
  144505. /**
  144506. * The base url used to load the left and right controller models
  144507. */
  144508. static MODEL_BASE_URL: string;
  144509. /**
  144510. * The name of the left controller model file
  144511. */
  144512. static MODEL_LEFT_FILENAME: string;
  144513. /**
  144514. * The name of the right controller model file
  144515. */
  144516. static MODEL_RIGHT_FILENAME: string;
  144517. /**
  144518. * Base Url for the Quest controller model.
  144519. */
  144520. static QUEST_MODEL_BASE_URL: string;
  144521. profileId: string;
  144522. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144523. protected _getFilenameAndPath(): {
  144524. filename: string;
  144525. path: string;
  144526. };
  144527. protected _getModelLoadingConstraints(): boolean;
  144528. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144529. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144530. protected _updateModel(): void;
  144531. /**
  144532. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144533. * between the touch and touch 2.
  144534. */
  144535. private _isQuest;
  144536. }
  144537. }
  144538. declare module BABYLON {
  144539. /**
  144540. * The motion controller class for the standard HTC-Vive controllers
  144541. */
  144542. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144543. private _modelRootNode;
  144544. /**
  144545. * The base url used to load the left and right controller models
  144546. */
  144547. static MODEL_BASE_URL: string;
  144548. /**
  144549. * File name for the controller model.
  144550. */
  144551. static MODEL_FILENAME: string;
  144552. profileId: string;
  144553. /**
  144554. * Create a new Vive motion controller object
  144555. * @param scene the scene to use to create this controller
  144556. * @param gamepadObject the corresponding gamepad object
  144557. * @param handness the handness of the controller
  144558. */
  144559. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144560. protected _getFilenameAndPath(): {
  144561. filename: string;
  144562. path: string;
  144563. };
  144564. protected _getModelLoadingConstraints(): boolean;
  144565. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144566. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144567. protected _updateModel(): void;
  144568. }
  144569. }
  144570. declare module BABYLON {
  144571. /**
  144572. * A cursor which tracks a point on a path
  144573. */
  144574. export class PathCursor {
  144575. private path;
  144576. /**
  144577. * Stores path cursor callbacks for when an onchange event is triggered
  144578. */
  144579. private _onchange;
  144580. /**
  144581. * The value of the path cursor
  144582. */
  144583. value: number;
  144584. /**
  144585. * The animation array of the path cursor
  144586. */
  144587. animations: Animation[];
  144588. /**
  144589. * Initializes the path cursor
  144590. * @param path The path to track
  144591. */
  144592. constructor(path: Path2);
  144593. /**
  144594. * Gets the cursor point on the path
  144595. * @returns A point on the path cursor at the cursor location
  144596. */
  144597. getPoint(): Vector3;
  144598. /**
  144599. * Moves the cursor ahead by the step amount
  144600. * @param step The amount to move the cursor forward
  144601. * @returns This path cursor
  144602. */
  144603. moveAhead(step?: number): PathCursor;
  144604. /**
  144605. * Moves the cursor behind by the step amount
  144606. * @param step The amount to move the cursor back
  144607. * @returns This path cursor
  144608. */
  144609. moveBack(step?: number): PathCursor;
  144610. /**
  144611. * Moves the cursor by the step amount
  144612. * If the step amount is greater than one, an exception is thrown
  144613. * @param step The amount to move the cursor
  144614. * @returns This path cursor
  144615. */
  144616. move(step: number): PathCursor;
  144617. /**
  144618. * Ensures that the value is limited between zero and one
  144619. * @returns This path cursor
  144620. */
  144621. private ensureLimits;
  144622. /**
  144623. * Runs onchange callbacks on change (used by the animation engine)
  144624. * @returns This path cursor
  144625. */
  144626. private raiseOnChange;
  144627. /**
  144628. * Executes a function on change
  144629. * @param f A path cursor onchange callback
  144630. * @returns This path cursor
  144631. */
  144632. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144633. }
  144634. }
  144635. declare module BABYLON {
  144636. /** @hidden */
  144637. export var blurPixelShader: {
  144638. name: string;
  144639. shader: string;
  144640. };
  144641. }
  144642. declare module BABYLON {
  144643. /** @hidden */
  144644. export var pointCloudVertexDeclaration: {
  144645. name: string;
  144646. shader: string;
  144647. };
  144648. }
  144649. // Mixins
  144650. interface Window {
  144651. mozIndexedDB: IDBFactory;
  144652. webkitIndexedDB: IDBFactory;
  144653. msIndexedDB: IDBFactory;
  144654. webkitURL: typeof URL;
  144655. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144656. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144657. WebGLRenderingContext: WebGLRenderingContext;
  144658. MSGesture: MSGesture;
  144659. CANNON: any;
  144660. AudioContext: AudioContext;
  144661. webkitAudioContext: AudioContext;
  144662. PointerEvent: any;
  144663. Math: Math;
  144664. Uint8Array: Uint8ArrayConstructor;
  144665. Float32Array: Float32ArrayConstructor;
  144666. mozURL: typeof URL;
  144667. msURL: typeof URL;
  144668. VRFrameData: any; // WebVR, from specs 1.1
  144669. DracoDecoderModule: any;
  144670. setImmediate(handler: (...args: any[]) => void): number;
  144671. }
  144672. interface HTMLCanvasElement {
  144673. requestPointerLock(): void;
  144674. msRequestPointerLock?(): void;
  144675. mozRequestPointerLock?(): void;
  144676. webkitRequestPointerLock?(): void;
  144677. /** Track wether a record is in progress */
  144678. isRecording: boolean;
  144679. /** Capture Stream method defined by some browsers */
  144680. captureStream(fps?: number): MediaStream;
  144681. }
  144682. interface CanvasRenderingContext2D {
  144683. msImageSmoothingEnabled: boolean;
  144684. }
  144685. interface MouseEvent {
  144686. mozMovementX: number;
  144687. mozMovementY: number;
  144688. webkitMovementX: number;
  144689. webkitMovementY: number;
  144690. msMovementX: number;
  144691. msMovementY: number;
  144692. }
  144693. interface Navigator {
  144694. mozGetVRDevices: (any: any) => any;
  144695. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144696. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144697. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144698. webkitGetGamepads(): Gamepad[];
  144699. msGetGamepads(): Gamepad[];
  144700. webkitGamepads(): Gamepad[];
  144701. }
  144702. interface HTMLVideoElement {
  144703. mozSrcObject: any;
  144704. }
  144705. interface Math {
  144706. fround(x: number): number;
  144707. imul(a: number, b: number): number;
  144708. }
  144709. interface WebGLRenderingContext {
  144710. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144711. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144712. vertexAttribDivisor(index: number, divisor: number): void;
  144713. createVertexArray(): any;
  144714. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144715. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144716. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144717. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144718. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144719. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144720. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144721. // Queries
  144722. createQuery(): WebGLQuery;
  144723. deleteQuery(query: WebGLQuery): void;
  144724. beginQuery(target: number, query: WebGLQuery): void;
  144725. endQuery(target: number): void;
  144726. getQueryParameter(query: WebGLQuery, pname: number): any;
  144727. getQuery(target: number, pname: number): any;
  144728. MAX_SAMPLES: number;
  144729. RGBA8: number;
  144730. READ_FRAMEBUFFER: number;
  144731. DRAW_FRAMEBUFFER: number;
  144732. UNIFORM_BUFFER: number;
  144733. HALF_FLOAT_OES: number;
  144734. RGBA16F: number;
  144735. RGBA32F: number;
  144736. R32F: number;
  144737. RG32F: number;
  144738. RGB32F: number;
  144739. R16F: number;
  144740. RG16F: number;
  144741. RGB16F: number;
  144742. RED: number;
  144743. RG: number;
  144744. R8: number;
  144745. RG8: number;
  144746. UNSIGNED_INT_24_8: number;
  144747. DEPTH24_STENCIL8: number;
  144748. MIN: number;
  144749. MAX: number;
  144750. /* Multiple Render Targets */
  144751. drawBuffers(buffers: number[]): void;
  144752. readBuffer(src: number): void;
  144753. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144754. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144755. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144756. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144757. // Occlusion Query
  144758. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144759. ANY_SAMPLES_PASSED: number;
  144760. QUERY_RESULT_AVAILABLE: number;
  144761. QUERY_RESULT: number;
  144762. }
  144763. interface WebGLProgram {
  144764. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144765. }
  144766. interface EXT_disjoint_timer_query {
  144767. QUERY_COUNTER_BITS_EXT: number;
  144768. TIME_ELAPSED_EXT: number;
  144769. TIMESTAMP_EXT: number;
  144770. GPU_DISJOINT_EXT: number;
  144771. QUERY_RESULT_EXT: number;
  144772. QUERY_RESULT_AVAILABLE_EXT: number;
  144773. queryCounterEXT(query: WebGLQuery, target: number): void;
  144774. createQueryEXT(): WebGLQuery;
  144775. beginQueryEXT(target: number, query: WebGLQuery): void;
  144776. endQueryEXT(target: number): void;
  144777. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144778. deleteQueryEXT(query: WebGLQuery): void;
  144779. }
  144780. interface WebGLUniformLocation {
  144781. _currentState: any;
  144782. }
  144783. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144784. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144785. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144786. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144787. interface WebGLRenderingContext {
  144788. readonly RASTERIZER_DISCARD: number;
  144789. readonly DEPTH_COMPONENT24: number;
  144790. readonly TEXTURE_3D: number;
  144791. readonly TEXTURE_2D_ARRAY: number;
  144792. readonly TEXTURE_COMPARE_FUNC: number;
  144793. readonly TEXTURE_COMPARE_MODE: number;
  144794. readonly COMPARE_REF_TO_TEXTURE: number;
  144795. readonly TEXTURE_WRAP_R: number;
  144796. readonly HALF_FLOAT: number;
  144797. readonly RGB8: number;
  144798. readonly RED_INTEGER: number;
  144799. readonly RG_INTEGER: number;
  144800. readonly RGB_INTEGER: number;
  144801. readonly RGBA_INTEGER: number;
  144802. readonly R8_SNORM: number;
  144803. readonly RG8_SNORM: number;
  144804. readonly RGB8_SNORM: number;
  144805. readonly RGBA8_SNORM: number;
  144806. readonly R8I: number;
  144807. readonly RG8I: number;
  144808. readonly RGB8I: number;
  144809. readonly RGBA8I: number;
  144810. readonly R8UI: number;
  144811. readonly RG8UI: number;
  144812. readonly RGB8UI: number;
  144813. readonly RGBA8UI: number;
  144814. readonly R16I: number;
  144815. readonly RG16I: number;
  144816. readonly RGB16I: number;
  144817. readonly RGBA16I: number;
  144818. readonly R16UI: number;
  144819. readonly RG16UI: number;
  144820. readonly RGB16UI: number;
  144821. readonly RGBA16UI: number;
  144822. readonly R32I: number;
  144823. readonly RG32I: number;
  144824. readonly RGB32I: number;
  144825. readonly RGBA32I: number;
  144826. readonly R32UI: number;
  144827. readonly RG32UI: number;
  144828. readonly RGB32UI: number;
  144829. readonly RGBA32UI: number;
  144830. readonly RGB10_A2UI: number;
  144831. readonly R11F_G11F_B10F: number;
  144832. readonly RGB9_E5: number;
  144833. readonly RGB10_A2: number;
  144834. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144835. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144836. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144837. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144838. readonly DEPTH_COMPONENT32F: number;
  144839. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144840. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144841. 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;
  144842. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144843. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144844. readonly TRANSFORM_FEEDBACK: number;
  144845. readonly INTERLEAVED_ATTRIBS: number;
  144846. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144847. createTransformFeedback(): WebGLTransformFeedback;
  144848. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144849. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144850. beginTransformFeedback(primitiveMode: number): void;
  144851. endTransformFeedback(): void;
  144852. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144853. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144854. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144855. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144856. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144857. }
  144858. interface ImageBitmap {
  144859. readonly width: number;
  144860. readonly height: number;
  144861. close(): void;
  144862. }
  144863. interface WebGLQuery extends WebGLObject {
  144864. }
  144865. declare var WebGLQuery: {
  144866. prototype: WebGLQuery;
  144867. new(): WebGLQuery;
  144868. };
  144869. interface WebGLSampler extends WebGLObject {
  144870. }
  144871. declare var WebGLSampler: {
  144872. prototype: WebGLSampler;
  144873. new(): WebGLSampler;
  144874. };
  144875. interface WebGLSync extends WebGLObject {
  144876. }
  144877. declare var WebGLSync: {
  144878. prototype: WebGLSync;
  144879. new(): WebGLSync;
  144880. };
  144881. interface WebGLTransformFeedback extends WebGLObject {
  144882. }
  144883. declare var WebGLTransformFeedback: {
  144884. prototype: WebGLTransformFeedback;
  144885. new(): WebGLTransformFeedback;
  144886. };
  144887. interface WebGLVertexArrayObject extends WebGLObject {
  144888. }
  144889. declare var WebGLVertexArrayObject: {
  144890. prototype: WebGLVertexArrayObject;
  144891. new(): WebGLVertexArrayObject;
  144892. };
  144893. // Type definitions for WebVR API
  144894. // Project: https://w3c.github.io/webvr/
  144895. // Definitions by: six a <https://github.com/lostfictions>
  144896. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144897. interface VRDisplay extends EventTarget {
  144898. /**
  144899. * Dictionary of capabilities describing the VRDisplay.
  144900. */
  144901. readonly capabilities: VRDisplayCapabilities;
  144902. /**
  144903. * z-depth defining the far plane of the eye view frustum
  144904. * enables mapping of values in the render target depth
  144905. * attachment to scene coordinates. Initially set to 10000.0.
  144906. */
  144907. depthFar: number;
  144908. /**
  144909. * z-depth defining the near plane of the eye view frustum
  144910. * enables mapping of values in the render target depth
  144911. * attachment to scene coordinates. Initially set to 0.01.
  144912. */
  144913. depthNear: number;
  144914. /**
  144915. * An identifier for this distinct VRDisplay. Used as an
  144916. * association point in the Gamepad API.
  144917. */
  144918. readonly displayId: number;
  144919. /**
  144920. * A display name, a user-readable name identifying it.
  144921. */
  144922. readonly displayName: string;
  144923. readonly isConnected: boolean;
  144924. readonly isPresenting: boolean;
  144925. /**
  144926. * If this VRDisplay supports room-scale experiences, the optional
  144927. * stage attribute contains details on the room-scale parameters.
  144928. */
  144929. readonly stageParameters: VRStageParameters | null;
  144930. /**
  144931. * Passing the value returned by `requestAnimationFrame` to
  144932. * `cancelAnimationFrame` will unregister the callback.
  144933. * @param handle Define the hanle of the request to cancel
  144934. */
  144935. cancelAnimationFrame(handle: number): void;
  144936. /**
  144937. * Stops presenting to the VRDisplay.
  144938. * @returns a promise to know when it stopped
  144939. */
  144940. exitPresent(): Promise<void>;
  144941. /**
  144942. * Return the current VREyeParameters for the given eye.
  144943. * @param whichEye Define the eye we want the parameter for
  144944. * @returns the eye parameters
  144945. */
  144946. getEyeParameters(whichEye: string): VREyeParameters;
  144947. /**
  144948. * Populates the passed VRFrameData with the information required to render
  144949. * the current frame.
  144950. * @param frameData Define the data structure to populate
  144951. * @returns true if ok otherwise false
  144952. */
  144953. getFrameData(frameData: VRFrameData): boolean;
  144954. /**
  144955. * Get the layers currently being presented.
  144956. * @returns the list of VR layers
  144957. */
  144958. getLayers(): VRLayer[];
  144959. /**
  144960. * Return a VRPose containing the future predicted pose of the VRDisplay
  144961. * when the current frame will be presented. The value returned will not
  144962. * change until JavaScript has returned control to the browser.
  144963. *
  144964. * The VRPose will contain the position, orientation, velocity,
  144965. * and acceleration of each of these properties.
  144966. * @returns the pose object
  144967. */
  144968. getPose(): VRPose;
  144969. /**
  144970. * Return the current instantaneous pose of the VRDisplay, with no
  144971. * prediction applied.
  144972. * @returns the current instantaneous pose
  144973. */
  144974. getImmediatePose(): VRPose;
  144975. /**
  144976. * The callback passed to `requestAnimationFrame` will be called
  144977. * any time a new frame should be rendered. When the VRDisplay is
  144978. * presenting the callback will be called at the native refresh
  144979. * rate of the HMD. When not presenting this function acts
  144980. * identically to how window.requestAnimationFrame acts. Content should
  144981. * make no assumptions of frame rate or vsync behavior as the HMD runs
  144982. * asynchronously from other displays and at differing refresh rates.
  144983. * @param callback Define the eaction to run next frame
  144984. * @returns the request handle it
  144985. */
  144986. requestAnimationFrame(callback: FrameRequestCallback): number;
  144987. /**
  144988. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  144989. * Repeat calls while already presenting will update the VRLayers being displayed.
  144990. * @param layers Define the list of layer to present
  144991. * @returns a promise to know when the request has been fulfilled
  144992. */
  144993. requestPresent(layers: VRLayer[]): Promise<void>;
  144994. /**
  144995. * Reset the pose for this display, treating its current position and
  144996. * orientation as the "origin/zero" values. VRPose.position,
  144997. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  144998. * updated when calling resetPose(). This should be called in only
  144999. * sitting-space experiences.
  145000. */
  145001. resetPose(): void;
  145002. /**
  145003. * The VRLayer provided to the VRDisplay will be captured and presented
  145004. * in the HMD. Calling this function has the same effect on the source
  145005. * canvas as any other operation that uses its source image, and canvases
  145006. * created without preserveDrawingBuffer set to true will be cleared.
  145007. * @param pose Define the pose to submit
  145008. */
  145009. submitFrame(pose?: VRPose): void;
  145010. }
  145011. declare var VRDisplay: {
  145012. prototype: VRDisplay;
  145013. new(): VRDisplay;
  145014. };
  145015. interface VRLayer {
  145016. leftBounds?: number[] | Float32Array | null;
  145017. rightBounds?: number[] | Float32Array | null;
  145018. source?: HTMLCanvasElement | null;
  145019. }
  145020. interface VRDisplayCapabilities {
  145021. readonly canPresent: boolean;
  145022. readonly hasExternalDisplay: boolean;
  145023. readonly hasOrientation: boolean;
  145024. readonly hasPosition: boolean;
  145025. readonly maxLayers: number;
  145026. }
  145027. interface VREyeParameters {
  145028. /** @deprecated */
  145029. readonly fieldOfView: VRFieldOfView;
  145030. readonly offset: Float32Array;
  145031. readonly renderHeight: number;
  145032. readonly renderWidth: number;
  145033. }
  145034. interface VRFieldOfView {
  145035. readonly downDegrees: number;
  145036. readonly leftDegrees: number;
  145037. readonly rightDegrees: number;
  145038. readonly upDegrees: number;
  145039. }
  145040. interface VRFrameData {
  145041. readonly leftProjectionMatrix: Float32Array;
  145042. readonly leftViewMatrix: Float32Array;
  145043. readonly pose: VRPose;
  145044. readonly rightProjectionMatrix: Float32Array;
  145045. readonly rightViewMatrix: Float32Array;
  145046. readonly timestamp: number;
  145047. }
  145048. interface VRPose {
  145049. readonly angularAcceleration: Float32Array | null;
  145050. readonly angularVelocity: Float32Array | null;
  145051. readonly linearAcceleration: Float32Array | null;
  145052. readonly linearVelocity: Float32Array | null;
  145053. readonly orientation: Float32Array | null;
  145054. readonly position: Float32Array | null;
  145055. readonly timestamp: number;
  145056. }
  145057. interface VRStageParameters {
  145058. sittingToStandingTransform?: Float32Array;
  145059. sizeX?: number;
  145060. sizeY?: number;
  145061. }
  145062. interface Navigator {
  145063. getVRDisplays(): Promise<VRDisplay[]>;
  145064. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145065. }
  145066. interface Window {
  145067. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145068. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145069. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145070. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145071. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145072. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145073. }
  145074. interface Gamepad {
  145075. readonly displayId: number;
  145076. }
  145077. type XRSessionMode =
  145078. | "inline"
  145079. | "immersive-vr"
  145080. | "immersive-ar";
  145081. type XRReferenceSpaceType =
  145082. | "viewer"
  145083. | "local"
  145084. | "local-floor"
  145085. | "bounded-floor"
  145086. | "unbounded";
  145087. type XREnvironmentBlendMode =
  145088. | "opaque"
  145089. | "additive"
  145090. | "alpha-blend";
  145091. type XRVisibilityState =
  145092. | "visible"
  145093. | "visible-blurred"
  145094. | "hidden";
  145095. type XRHandedness =
  145096. | "none"
  145097. | "left"
  145098. | "right";
  145099. type XRTargetRayMode =
  145100. | "gaze"
  145101. | "tracked-pointer"
  145102. | "screen";
  145103. type XREye =
  145104. | "none"
  145105. | "left"
  145106. | "right";
  145107. interface XRSpace extends EventTarget {
  145108. }
  145109. interface XRRenderState {
  145110. depthNear?: number;
  145111. depthFar?: number;
  145112. inlineVerticalFieldOfView?: number;
  145113. baseLayer?: XRWebGLLayer;
  145114. }
  145115. interface XRInputSource {
  145116. handedness: XRHandedness;
  145117. targetRayMode: XRTargetRayMode;
  145118. targetRaySpace: XRSpace;
  145119. gripSpace: XRSpace | undefined;
  145120. gamepad: Gamepad | undefined;
  145121. profiles: Array<string>;
  145122. }
  145123. interface XRSessionInit {
  145124. optionalFeatures?: XRReferenceSpaceType[];
  145125. requiredFeatures?: XRReferenceSpaceType[];
  145126. }
  145127. interface XRSession extends XRAnchorCreator {
  145128. addEventListener: Function;
  145129. removeEventListener: Function;
  145130. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145131. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145132. requestAnimationFrame: Function;
  145133. end(): Promise<void>;
  145134. renderState: XRRenderState;
  145135. inputSources: Array<XRInputSource>;
  145136. // hit test
  145137. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145138. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145139. // legacy AR hit test
  145140. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145141. // legacy plane detection
  145142. updateWorldTrackingState(options: {
  145143. planeDetectionState?: { enabled: boolean; }
  145144. }): void;
  145145. }
  145146. interface XRReferenceSpace extends XRSpace {
  145147. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145148. onreset: any;
  145149. }
  145150. type XRPlaneSet = Set<XRPlane>;
  145151. type XRAnchorSet = Set<XRAnchor>;
  145152. interface XRFrame {
  145153. session: XRSession;
  145154. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145155. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145156. // AR
  145157. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145158. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145159. // Anchors
  145160. trackedAnchors?: XRAnchorSet;
  145161. // Planes
  145162. worldInformation: {
  145163. detectedPlanes?: XRPlaneSet;
  145164. };
  145165. }
  145166. interface XRViewerPose extends XRPose {
  145167. views: Array<XRView>;
  145168. }
  145169. interface XRPose {
  145170. transform: XRRigidTransform;
  145171. emulatedPosition: boolean;
  145172. }
  145173. interface XRWebGLLayerOptions {
  145174. antialias?: boolean;
  145175. depth?: boolean;
  145176. stencil?: boolean;
  145177. alpha?: boolean;
  145178. multiview?: boolean;
  145179. framebufferScaleFactor?: number;
  145180. }
  145181. declare var XRWebGLLayer: {
  145182. prototype: XRWebGLLayer;
  145183. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145184. };
  145185. interface XRWebGLLayer {
  145186. framebuffer: WebGLFramebuffer;
  145187. framebufferWidth: number;
  145188. framebufferHeight: number;
  145189. getViewport: Function;
  145190. }
  145191. declare class XRRigidTransform {
  145192. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145193. position: DOMPointReadOnly;
  145194. orientation: DOMPointReadOnly;
  145195. matrix: Float32Array;
  145196. inverse: XRRigidTransform;
  145197. }
  145198. interface XRView {
  145199. eye: XREye;
  145200. projectionMatrix: Float32Array;
  145201. transform: XRRigidTransform;
  145202. }
  145203. interface XRInputSourceChangeEvent {
  145204. session: XRSession;
  145205. removed: Array<XRInputSource>;
  145206. added: Array<XRInputSource>;
  145207. }
  145208. interface XRInputSourceEvent extends Event {
  145209. readonly frame: XRFrame;
  145210. readonly inputSource: XRInputSource;
  145211. }
  145212. // Experimental(er) features
  145213. declare class XRRay {
  145214. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145215. origin: DOMPointReadOnly;
  145216. direction: DOMPointReadOnly;
  145217. matrix: Float32Array;
  145218. }
  145219. declare enum XRHitTestTrackableType {
  145220. "point",
  145221. "plane"
  145222. }
  145223. interface XRHitResult {
  145224. hitMatrix: Float32Array;
  145225. }
  145226. interface XRTransientInputHitTestResult {
  145227. readonly inputSource: XRInputSource;
  145228. readonly results: Array<XRHitTestResult>;
  145229. }
  145230. interface XRHitTestResult {
  145231. getPose(baseSpace: XRSpace): XRPose | undefined;
  145232. }
  145233. interface XRHitTestSource {
  145234. cancel(): void;
  145235. }
  145236. interface XRTransientInputHitTestSource {
  145237. cancel(): void;
  145238. }
  145239. interface XRHitTestOptionsInit {
  145240. space: XRSpace;
  145241. entityTypes?: Array<XRHitTestTrackableType>;
  145242. offsetRay?: XRRay;
  145243. }
  145244. interface XRTransientInputHitTestOptionsInit {
  145245. profile: string;
  145246. entityTypes?: Array<XRHitTestTrackableType>;
  145247. offsetRay?: XRRay;
  145248. }
  145249. interface XRAnchor {
  145250. // remove?
  145251. id?: string;
  145252. anchorSpace: XRSpace;
  145253. lastChangedTime: number;
  145254. detach(): void;
  145255. }
  145256. interface XRPlane extends XRAnchorCreator {
  145257. orientation: "Horizontal" | "Vertical";
  145258. planeSpace: XRSpace;
  145259. polygon: Array<DOMPointReadOnly>;
  145260. lastChangedTime: number;
  145261. }
  145262. interface XRAnchorCreator {
  145263. // AR Anchors
  145264. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145265. }